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

Unified Diff: chrome/renderer/resources/extensions/app_window_custom_bindings.js

Issue 11369039: Add setBounds method and browsertest for get/set bounds to app window API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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;
+ });
+});
+

Powered by Google App Engine
This is Rietveld 408576698