OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Custom binding for the app_window API. | 5 // Custom binding for the app_window API. |
6 | 6 |
7 var appWindowNatives = requireNative('app_window_natives'); | 7 var appWindowNatives = requireNative('app_window_natives'); |
8 var runtimeNatives = requireNative('runtime'); | 8 var runtimeNatives = requireNative('runtime'); |
9 var Binding = require('binding').Binding; | 9 var Binding = require('binding').Binding; |
10 var Event = require('event_bindings').Event; | 10 var Event = require('event_bindings').Event; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 if (windowParams.existingWindow) { | 134 if (windowParams.existingWindow) { |
135 // Not creating a new window, but activating an existing one, so trigger | 135 // Not creating a new window, but activating an existing one, so trigger |
136 // callback with existing window and don't do anything else. | 136 // callback with existing window and don't do anything else. |
137 if (callback) | 137 if (callback) |
138 callback(view.chrome.app.window.current()); | 138 callback(view.chrome.app.window.current()); |
139 return; | 139 return; |
140 } | 140 } |
141 | 141 |
142 // Initialize appWindowData in the newly created JS context | 142 // Initialize appWindowData in the newly created JS context |
143 view.chrome.app.window.initializeAppWindow(windowParams); | 143 if (view.chrome.app) { |
| 144 view.chrome.app.window.initializeAppWindow(windowParams); |
| 145 } else { |
| 146 var sandbox_window_message = 'Creating sandboxed window, it doesn\'t ' + |
| 147 'have access to the chrome.app API.'; |
| 148 if (callback) { |
| 149 sandbox_window_message = sandbox_window_message + |
| 150 ' The chrome.app.window.create callback will be called, but ' + |
| 151 'there will be no object provided for the sandboxed window.'; |
| 152 } |
| 153 console.warn(sandbox_window_message); |
| 154 } |
144 | 155 |
145 if (callback) { | 156 if (callback) { |
146 if (!view) { | 157 if (!view || !view.chrome.app /* sandboxed window */) { |
147 callback(undefined); | 158 callback(undefined); |
148 return; | 159 return; |
149 } | 160 } |
150 | 161 |
151 var willCallback = | 162 var willCallback = |
152 renderViewObserverNatives.OnDocumentElementCreated( | 163 renderViewObserverNatives.OnDocumentElementCreated( |
153 windowParams.viewId, | 164 windowParams.viewId, |
154 function(success) { | 165 function(success) { |
155 if (success) { | 166 if (success) { |
156 callback(view.chrome.app.window.current()); | 167 callback(view.chrome.app.window.current()); |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 constraints[key] = 0; | 401 constraints[key] = 0; |
391 }); | 402 }); |
392 | 403 |
393 currentWindowInternal.setSizeConstraints(boundsType, constraints); | 404 currentWindowInternal.setSizeConstraints(boundsType, constraints); |
394 } | 405 } |
395 | 406 |
396 exports.binding = appWindow.generate(); | 407 exports.binding = appWindow.generate(); |
397 exports.onAppWindowClosed = onAppWindowClosed; | 408 exports.onAppWindowClosed = onAppWindowClosed; |
398 exports.updateAppWindowProperties = updateAppWindowProperties; | 409 exports.updateAppWindowProperties = updateAppWindowProperties; |
399 exports.appWindowShownForTests = onAppWindowShownForTests; | 410 exports.appWindowShownForTests = onAppWindowShownForTests; |
OLD | NEW |