Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Side by Side Diff: extensions/renderer/resources/app_window_custom_bindings.js

Issue 1211003006: [Extensions OOPI] Update app window bindings for OOPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/renderer/render_view_observer_natives.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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;
11 var forEach = require('utils').forEach; 11 var forEach = require('utils').forEach;
12 var renderViewObserverNatives = requireNative('renderViewObserverNatives'); 12 var renderFrameObserverNatives = requireNative('renderFrameObserverNatives');
13 13
14 var appWindowData = null; 14 var appWindowData = null;
15 var currentAppWindow = null; 15 var currentAppWindow = null;
16 var currentWindowInternal = null; 16 var currentWindowInternal = null;
17 17
18 var kSetBoundsFunction = 'setBounds'; 18 var kSetBoundsFunction = 'setBounds';
19 var kSetSizeConstraintsFunction = 'setSizeConstraints'; 19 var kSetSizeConstraintsFunction = 'setSizeConstraints';
20 20
21 // Bounds class definition. 21 // Bounds class definition.
22 var Bounds = function(boundsKey) { 22 var Bounds = function(boundsKey) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 var appWindow = Binding.create('app.window'); 112 var appWindow = Binding.create('app.window');
113 appWindow.registerCustomHook(function(bindingsAPI) { 113 appWindow.registerCustomHook(function(bindingsAPI) {
114 var apiFunctions = bindingsAPI.apiFunctions; 114 var apiFunctions = bindingsAPI.apiFunctions;
115 115
116 apiFunctions.setCustomCallback('create', 116 apiFunctions.setCustomCallback('create',
117 function(name, request, callback, windowParams) { 117 function(name, request, callback, windowParams) {
118 var view = null; 118 var view = null;
119 119
120 // When window creation fails, |windowParams| will be undefined. 120 // When window creation fails, |windowParams| will be undefined.
121 if (windowParams && windowParams.viewId) { 121 if (windowParams && windowParams.frameId) {
122 view = appWindowNatives.GetView( 122 view = appWindowNatives.GetFrame(
123 windowParams.viewId, windowParams.injectTitlebar); 123 windowParams.frameId, windowParams.injectTitlebar);
124 } 124 }
125 125
126 if (!view) { 126 if (!view) {
127 // No route to created window. If given a callback, trigger it with an 127 // No route to created window. If given a callback, trigger it with an
128 // undefined object. 128 // undefined object.
129 if (callback) 129 if (callback)
130 callback(); 130 callback();
131 return; 131 return;
132 } 132 }
133 133
(...skipping 19 matching lines...) Expand all
153 console.warn(sandbox_window_message); 153 console.warn(sandbox_window_message);
154 } 154 }
155 155
156 if (callback) { 156 if (callback) {
157 if (!view || !view.chrome.app /* sandboxed window */) { 157 if (!view || !view.chrome.app /* sandboxed window */) {
158 callback(undefined); 158 callback(undefined);
159 return; 159 return;
160 } 160 }
161 161
162 var willCallback = 162 var willCallback =
163 renderViewObserverNatives.OnDocumentElementCreated( 163 renderFrameObserverNatives.OnDocumentElementCreated(
164 windowParams.viewId, 164 windowParams.frameId,
165 function(success) { 165 function(success) {
166 if (success) { 166 if (success) {
167 callback(view.chrome.app.window.current()); 167 callback(view.chrome.app.window.current());
168 } else { 168 } else {
169 callback(undefined); 169 callback(undefined);
170 } 170 }
171 }); 171 });
172 if (!willCallback) { 172 if (!willCallback) {
173 callback(undefined); 173 callback(undefined);
174 } 174 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 constraints[key] = 0; 401 constraints[key] = 0;
402 }); 402 });
403 403
404 currentWindowInternal.setSizeConstraints(boundsType, constraints); 404 currentWindowInternal.setSizeConstraints(boundsType, constraints);
405 } 405 }
406 406
407 exports.binding = appWindow.generate(); 407 exports.binding = appWindow.generate();
408 exports.onAppWindowClosed = onAppWindowClosed; 408 exports.onAppWindowClosed = onAppWindowClosed;
409 exports.updateAppWindowProperties = updateAppWindowProperties; 409 exports.updateAppWindowProperties = updateAppWindowProperties;
410 exports.appWindowShownForTests = onAppWindowShownForTests; 410 exports.appWindowShownForTests = onAppWindowShownForTests;
OLDNEW
« no previous file with comments | « extensions/renderer/render_view_observer_natives.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698