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

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: android compilation Created 7 years, 9 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 binding for the app_window API.
6 6
7 var Binding = require('binding').Binding;
7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 8 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
9 var chrome = requireNative('chrome').GetChrome();
8 var sendRequest = require('sendRequest').sendRequest; 10 var sendRequest = require('sendRequest').sendRequest;
9 var appWindowNatives = requireNative('app_window'); 11 var appWindowNatives = requireNative('app_window');
10 var forEach = require('utils').forEach; 12 var forEach = require('utils').forEach;
11 var GetView = appWindowNatives.GetView; 13 var GetView = appWindowNatives.GetView;
12 var OnContextReady = appWindowNatives.OnContextReady; 14 var OnContextReady = appWindowNatives.OnContextReady;
13 15
14 chromeHidden.registerCustomHook('app.window', function(bindingsAPI) { 16 var appWindow = Binding.create('app.window');
17 appWindow.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 var currentWindowInternal =
89 Binding.create('app.currentWindowInternal').generate();
84 var AppWindow = function() {}; 90 var AppWindow = function() {};
85 forEach(chromeHidden.internalAPIs.app.currentWindowInternal, function(fn) { 91 forEach(currentWindowInternal, function(fn) {
86 AppWindow.prototype[fn] = 92 AppWindow.prototype[fn] =
87 chromeHidden.internalAPIs.app.currentWindowInternal[fn]; 93 currentWindowInternal[fn];
88 }); 94 });
89 AppWindow.prototype.moveTo = window.moveTo.bind(window); 95 AppWindow.prototype.moveTo = window.moveTo.bind(window);
90 AppWindow.prototype.resizeTo = window.resizeTo.bind(window); 96 AppWindow.prototype.resizeTo = window.resizeTo.bind(window);
91 AppWindow.prototype.contentWindow = window; 97 AppWindow.prototype.contentWindow = window;
92 AppWindow.prototype.onClosed = new chrome.Event; 98 AppWindow.prototype.onClosed = new chrome.Event;
93 AppWindow.prototype.close = function() { 99 AppWindow.prototype.close = function() {
94 this.contentWindow.close(); 100 this.contentWindow.close();
95 }; 101 };
96 AppWindow.prototype.getBounds = function() { 102 AppWindow.prototype.getBounds = function() {
97 var bounds = chromeHidden.appWindowData.bounds; 103 var bounds = chromeHidden.appWindowData.bounds;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 if (!oldData.minimized && update.minimized) 154 if (!oldData.minimized && update.minimized)
149 currentWindow["onMinimized"].dispatch(); 155 currentWindow["onMinimized"].dispatch();
150 if (!oldData.maximized && update.maximized) 156 if (!oldData.maximized && update.maximized)
151 currentWindow["onMaximized"].dispatch(); 157 currentWindow["onMaximized"].dispatch();
152 158
153 if ((oldData.fullscreen && !update.fullscreen) || 159 if ((oldData.fullscreen && !update.fullscreen) ||
154 (oldData.minimized && !update.minimized) || 160 (oldData.minimized && !update.minimized) ||
155 (oldData.maximized && !update.maximized)) 161 (oldData.maximized && !update.maximized))
156 currentWindow["onRestored"].dispatch(); 162 currentWindow["onRestored"].dispatch();
157 }; 163 };
164
165 exports.binding = appWindow.generate();
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/app_runtime_custom_bindings.js ('k') | chrome/renderer/resources/extensions/binding.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698