~abreu-alexandre/webbrowser-app/rtm-intent-support

« back to all changes in this revision

Viewing changes to src/app/webcontainer/webapp-container.qml

  • Committer: CI Train Bot
  • Author(s): Alexandre Abreu
  • Date: 2015-01-21 14:23:30 UTC
  • mfrom: (780.1.1 rtm-14.09)
  • Revision ID: ci-train-bot@canonical.com-20150121142330-2dhjj2s9dsax2z5t
Backport fix to make sure that we properly consider the local webapp name that could be imported by a webapp-properties file for things like UA overrides. Fixes: #1408064
Approved by: Olivier Tilloy

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
    title: getWindowTitle()
52
52
 
53
53
    function getWindowTitle() {
54
 
        var webappViewTitle = webappViewLoader.item ? webappViewLoader.item.title : ""
55
 
        if (typeof(webappName) === 'string' && webappName.length !== 0) {
56
 
            return webappName
 
54
        var webappViewTitle =
 
55
                webappViewLoader.item
 
56
                ? webappViewLoader.item.title : ""
 
57
        var name = getWebappName()
 
58
        if (typeof(name) === 'string' && name.length !== 0) {
 
59
            return name
57
60
        } else if (webappViewTitle) {
58
61
            // TRANSLATORS: %1 refers to the current page’s title
59
62
            return i18n.tr("%1 - Ubuntu Web Browser").arg(webappViewTitle)
100
103
        }
101
104
    }
102
105
 
 
106
    function getWebappName() {
 
107
        /**
 
108
          Any webapp name coming from the command line takes over.
 
109
          A webapp can also be defined by a specific drop-in webapp-properties.json
 
110
          file that can bundle a few specific 'properties' (as the name implies)
 
111
          instead of having them listed in the command line.
 
112
          */
 
113
        if (webappName)
 
114
            return webappName
 
115
        return webappModelSearchPath && webappModel.providesSingleInlineWebapp()
 
116
            ? webappModel.getSingleInlineWebappName()
 
117
            : ""
 
118
    }
 
119
 
103
120
    function getLocalUserAgentOverrideIfAny() {
104
121
        if (localUserAgentOverride.length !== 0)
105
122
            return localUserAgentOverride
106
123
 
107
 
        if (webappName && webappModel.exists(webappName))
108
 
            return webappModel.userAgentOverrideFor(webappName)
 
124
        var name = getWebappName()
 
125
        if (name && webappModel.exists(name))
 
126
            return webappModel.userAgentOverrideFor(name)
109
127
 
110
128
        return ""
111
129
    }
115
133
        searchPath: root.webappModelSearchPath
116
134
 
117
135
        onModelContentChanged: {
118
 
            if (root.webappName && root.url.length === 0) {
119
 
                var idx = webappModel.getWebappIndex(root.webappName)
120
 
                root.url = webappModel.data(idx, UnityWebApps.UnityWebappsAppModel.Homepage)
 
136
            var name = getWebappName()
 
137
            if (name && root.url.length === 0) {
 
138
                var idx = webappModel.getWebappIndex(name)
 
139
                root.url = webappModel.data(
 
140
                            idx, UnityWebApps.UnityWebappsAppModel.Homepage)
121
141
            }
122
142
        }
123
143
    }