| Index: chrome/renderer/resources/extensions/app_window_custom_bindings.js
|
| diff --git a/chrome/renderer/resources/extensions/app_window_custom_bindings.js b/chrome/renderer/resources/extensions/app_window_custom_bindings.js
|
| index b1ed42f3edbcc392a8021db8aebc02c6c3c0f811..02870bbe85610349a7b44678e0ac6bef92ad27d3 100644
|
| --- a/chrome/renderer/resources/extensions/app_window_custom_bindings.js
|
| +++ b/chrome/renderer/resources/extensions/app_window_custom_bindings.js
|
| @@ -23,7 +23,7 @@ chromeHidden.registerCustomHook('app.window', function(bindingsAPI) {
|
| // No route to created window. If given a callback, trigger it with an
|
| // undefined object.
|
| if (request.callback) {
|
| - request.callback()
|
| + request.callback();
|
| delete request.callback;
|
| }
|
| return;
|
| @@ -69,7 +69,7 @@ chromeHidden.registerCustomHook('app.window', function(bindingsAPI) {
|
| };
|
|
|
| // This is an internal function, but needs to be bound with setHandleRequest
|
| - // because it is called from a different JS context
|
| + // because it is called from a different JS context.
|
| apiFunctions.setHandleRequest('initializeAppWindow', function(params) {
|
| var AppWindow = function() {};
|
| forEach(chromeHidden.internalAPIs.app.currentWindowInternal, function(fn) {
|
| @@ -83,14 +83,47 @@ chromeHidden.registerCustomHook('app.window', function(bindingsAPI) {
|
| AppWindow.prototype.close = function() {
|
| this.contentWindow.close();
|
| };
|
| + AppWindow.prototype.getBounds = function() {
|
| + var bounds = chromeHidden.appWindowData.bounds;
|
| + return { left: bounds.left, top: bounds.top,
|
| + width: bounds.width, height: bounds.height };
|
| + };
|
|
|
| Object.defineProperty(AppWindow.prototype, 'id', {get: function() {
|
| return chromeHidden.appWindowData.id;
|
| }});
|
|
|
| chromeHidden.appWindowData = {
|
| - id: params.id || ''
|
| + id: params.id || '',
|
| + bounds: { left: 0, top: 0, width: 0, height: 0 }
|
| };
|
| chromeHidden.currentAppWindow = new AppWindow;
|
| });
|
| });
|
| +
|
| +chromeHidden.updateAppWindowBounds = function(info) {
|
| + var data = chromeHidden.appWindowData;
|
| + if (!data)
|
| + return;
|
| + data.bounds.left = info.left;
|
| + data.bounds.top = info.top;
|
| + data.bounds.width = info.width;
|
| + data.bounds.height = info.height;
|
| +};
|
| +
|
| +chromeHidden.registerCustomHook('app.currentWindowInternal',
|
| + function(bindingsAPI) {
|
| + var apiFunctions = bindingsAPI.apiFunctions;
|
| + apiFunctions.setUpdateArgumentsPostValidate('setBounds', function(bounds) {
|
| + // Cache the update locally so that getBounds can immediately return the
|
| + // updated value.
|
| + var cachedBounds = chromeHidden.appWindowData.bounds;
|
| + var names = ['left', 'top', 'width', 'height'];
|
| + for (var i = 0; i < names.length; i++) {
|
| + if (typeof(bounds[names[i]]) != 'undefined')
|
| + cachedBounds[names[i]] = bounds[names[i]];
|
| + }
|
| + return arguments;
|
| + });
|
| +});
|
| +
|
|
|