~mardy/unity-webapps-qml/lp1427649-rtm

« back to all changes in this revision

Viewing changes to src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp

  • Committer: CI bot
  • Author(s): Alexandre Abreu
  • Date: 2014-05-06 17:26:52 UTC
  • mfrom: (112.1.3 latest)
  • Revision ID: ps-jenkins@lists.canonical.com-20140506172652-i5u40rlivc449gso
Add UA override capabilities to webapps; clean some code and tests, Fixes: 1245465

Show diffs side-by-side

added added

removed removed

Lines of Context:
154
154
        roles[Urls] = "urls";
155
155
        roles[ScriptsContent] = "content";
156
156
        roles[Scripts] = "scripts";
 
157
        roles[Chrome] = "chrome";
 
158
        roles[UserAgentOverride] = "useragent";
157
159
      }
158
160
    return roles;
159
161
}
301
303
    return script;
302
304
}
303
305
 
 
306
QString
 
307
UnityWebappsAppModel::userAgentOverrideFor(const QString & webappName) const
 
308
{
 
309
    if (!exists(webappName))
 
310
        return QString();
 
311
 
 
312
    int idx = getWebappIndex(webappName);
 
313
    if (Q_UNLIKELY(idx == -1))
 
314
    {
 
315
        qDebug() << "Invalid index for a supposedly existing webapp: " << webappName;
 
316
        return QString();
 
317
    }
 
318
 
 
319
    return data(idx, UserAgentOverride).toString();
 
320
}
 
321
 
304
322
QStringList
305
323
UnityWebappsAppModel::getChromeOptionsFor(const QString & webappName) const
306
324
{
488
506
            }
489
507
            return scripts;
490
508
        }
 
509
 
491
510
    case ScriptsContent:
492
511
        return webapp.data.content;
 
512
 
 
513
    case UserAgentOverride:
 
514
        return webapp.data.manifest.userAgentOverride;
493
515
    }
494
516
 
495
517
    return QVariant();