Commit 203a1880 authored by scheib's avatar scheib Committed by Commit bot

Sandbox windows not provided to chrome.app.window.create.

Documented in developer console, avoiding raising an exception, and
on developer documentation page sample.

BUG=154662

Review URL: https://codereview.chromium.org/1107163002

Cr-Commit-Position: refs/heads/master@{#327421}
parent 184754be
......@@ -178,14 +178,11 @@ one for the main app window that isn't sandboxed,
and one for the sandboxed page:
</p>
<p class="warning">
<p class="note">
NOTE:
<a href="https://code.google.com/p/chromium/issues/detail?id=154662">issue 154662</a>
is a bug when using sandbox pages to create windows.
The effect is that an error "Uncaught TypeError: Cannot call method
'initializeAppWindow' of undefined" is output to the developer console
and that the app.window.create call does not call the callback function
with a window object. However, the sandbox page is created as a new window.
A sandboxed window will not have access to the chrome.app APIs. If a
callback is provided to app.window.create it will be run, but will not have
the sandboxed window provided to it.
</p>
<pre data-filename="background.js">
......
......@@ -140,10 +140,21 @@ appWindow.registerCustomHook(function(bindingsAPI) {
}
// Initialize appWindowData in the newly created JS context
view.chrome.app.window.initializeAppWindow(windowParams);
if (view.chrome.app) {
view.chrome.app.window.initializeAppWindow(windowParams);
} else {
var sandbox_window_message = 'Creating sandboxed window, it doesn\'t ' +
'have access to the chrome.app API.';
if (callback) {
sandbox_window_message = sandbox_window_message +
' The chrome.app.window.create callback will be called, but ' +
'there will be no object provided for the sandboxed window.';
}
console.warn(sandbox_window_message);
}
if (callback) {
if (!view) {
if (!view || !view.chrome.app /* sandboxed window */) {
callback(undefined);
return;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment