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

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

Issue 11571014: Lazy load chrome.* APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments/TODOs Created 7 years, 10 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 | Annotate | Revision Log
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 bindings for the app_window API. 5 // Custom bindings for the app_window API.
6 6
7 var bindings = new (require('schema_binding_generator').Bindings)('app.window');
8
7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 9 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
10 var chrome = requireNative('chrome').GetChrome();
8 var sendRequest = require('sendRequest').sendRequest; 11 var sendRequest = require('sendRequest').sendRequest;
9 var appWindowNatives = requireNative('app_window'); 12 var appWindowNatives = requireNative('app_window');
10 var forEach = require('utils').forEach; 13 var forEach = require('utils').forEach;
11 var GetView = appWindowNatives.GetView; 14 var GetView = appWindowNatives.GetView;
12 var OnContextReady = appWindowNatives.OnContextReady; 15 var OnContextReady = appWindowNatives.OnContextReady;
13 16
14 chromeHidden.registerCustomHook('app.window', function(bindingsAPI) { 17 bindings.registerCustomHook(function(bindingsAPI) {
15 var apiFunctions = bindingsAPI.apiFunctions; 18 var apiFunctions = bindingsAPI.apiFunctions;
19
16 apiFunctions.setCustomCallback('create', 20 apiFunctions.setCustomCallback('create',
17 function(name, request, windowParams) { 21 function(name, request, windowParams) {
18 var view = null; 22 var view = null;
19 if (windowParams.viewId) 23 if (windowParams.viewId)
20 view = GetView(windowParams.viewId, windowParams.injectTitlebar); 24 view = GetView(windowParams.viewId, windowParams.injectTitlebar);
21 25
22 if (!view) { 26 if (!view) {
23 // No route to created window. If given a callback, trigger it with an 27 // No route to created window. If given a callback, trigger it with an
24 // undefined object. 28 // undefined object.
25 if (request.callback) { 29 if (request.callback) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 78
75 chromeHidden.OnAppWindowClosed = function() { 79 chromeHidden.OnAppWindowClosed = function() {
76 if (!chromeHidden.currentAppWindow) 80 if (!chromeHidden.currentAppWindow)
77 return; 81 return;
78 chromeHidden.currentAppWindow.onClosed.dispatch(); 82 chromeHidden.currentAppWindow.onClosed.dispatch();
79 }; 83 };
80 84
81 // This is an internal function, but needs to be bound with setHandleRequest 85 // This is an internal function, but needs to be bound with setHandleRequest
82 // because it is called from a different JS context. 86 // because it is called from a different JS context.
83 apiFunctions.setHandleRequest('initializeAppWindow', function(params) { 87 apiFunctions.setHandleRequest('initializeAppWindow', function(params) {
88 // TODO(cduvall): Fix dependencies.
89 chrome.app.currentWindowInternal;
90
84 var AppWindow = function() {}; 91 var AppWindow = function() {};
85 forEach(chromeHidden.internalAPIs.app.currentWindowInternal, function(fn) { 92 forEach(chromeHidden.internalAPIs.app.currentWindowInternal, function(fn) {
86 AppWindow.prototype[fn] = 93 AppWindow.prototype[fn] =
87 chromeHidden.internalAPIs.app.currentWindowInternal[fn]; 94 chromeHidden.internalAPIs.app.currentWindowInternal[fn];
88 }); 95 });
89 AppWindow.prototype.moveTo = window.moveTo.bind(window); 96 AppWindow.prototype.moveTo = window.moveTo.bind(window);
90 AppWindow.prototype.resizeTo = window.resizeTo.bind(window); 97 AppWindow.prototype.resizeTo = window.resizeTo.bind(window);
91 AppWindow.prototype.contentWindow = window; 98 AppWindow.prototype.contentWindow = window;
92 AppWindow.prototype.onClosed = new chrome.Event; 99 AppWindow.prototype.onClosed = new chrome.Event;
93 AppWindow.prototype.close = function() { 100 AppWindow.prototype.close = function() {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 148
142 if (!oldData.minimized && update.minimized) 149 if (!oldData.minimized && update.minimized)
143 currentWindow["onMinimized"].dispatch(); 150 currentWindow["onMinimized"].dispatch();
144 if (!oldData.maximized && update.maximized) 151 if (!oldData.maximized && update.maximized)
145 currentWindow["onMaximized"].dispatch(); 152 currentWindow["onMaximized"].dispatch();
146 153
147 if ((oldData.minimized && !update.minimized) || 154 if ((oldData.minimized && !update.minimized) ||
148 (oldData.maximized && !update.maximized)) 155 (oldData.maximized && !update.maximized))
149 currentWindow["onRestored"].dispatch(); 156 currentWindow["onRestored"].dispatch();
150 }; 157 };
158
159 exports.bindings = bindings.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698