84
84
return webview.webappName && typeof(webview.webappName) === 'string' && webview.webappName.length != 0
87
function haveValidUrlPatterns() {
88
return webappUrlPatterns && webappUrlPatterns.length !== 0
87
91
function navigationRequestedDelegate(request) {
88
92
if (!request.isMainFrame) {
89
93
request.action = WebView.AcceptRequest
93
var action = WebView.AcceptRequest
97
// Pass-through if we are not running as a named webapp (--webapp='Gmail')
98
// or if we dont have a list of url patterns specified to filter the
100
if ( ! haveValidUrlPatterns() && ! isRunningAsANamedWebapp()) {
101
request.action = WebView.AcceptRequest
105
var action = WebView.IgnoreRequest
94
106
var url = request.url.toString()
96
108
// The list of url patterns defined by the webapp takes precedence over command line
97
109
if (isRunningAsANamedWebapp()) {
98
if (unityWebapps.model.exists(webview.webappName) &&
99
!unityWebapps.model.doesUrlMatchesWebapp(webview.webappName, url)) {
100
action = WebView.IgnoreRequest
110
if (unityWebapps.model.exists(unityWebapps.name) &&
111
unityWebapps.model.doesUrlMatchesWebapp(unityWebapps.name, url)) {
112
request.action = WebView.AcceptRequest
102
} else if (webview.webappUrlPatterns && webview.webappUrlPatterns.length !== 0) {
103
action = WebView.IgnoreRequest
104
for (var i = 0; i < webview.webappUrlPatterns.length; ++i) {
105
var pattern = webview.webappUrlPatterns[i]
117
// We still take the possible additional patterns specified in the command line
118
// (the in the case of finer grained ones specifically for the container and not
119
// as an 'install source' for the webapp).
120
if (webappUrlPatterns && webappUrlPatterns.length !== 0) {
121
for (var i = 0; i < webappUrlPatterns.length; ++i) {
122
var pattern = webappUrlPatterns[i]
106
123
if (url.match(pattern)) {
107
124
action = WebView.AcceptRequest