diff options
author | kalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-03 08:25:45 +0000 |
---|---|---|
committer | kalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-03 08:25:45 +0000 |
commit | c3d03feb760a5bce6cc3728d048991774218a86d (patch) | |
tree | b07102f2387b0c906757148ec8c1edf2295a7f97 | |
parent | f82756922e39b4c93c99d2553ebc94f11fc85026 (diff) | |
download | chromium_src-c3d03feb760a5bce6cc3728d048991774218a86d.zip chromium_src-c3d03feb760a5bce6cc3728d048991774218a86d.tar.gz chromium_src-c3d03feb760a5bce6cc3728d048991774218a86d.tar.bz2 |
Guard against app window events being overridden by apps.
BUG=267631
Review URL: https://chromiumcodereview.appspot.com/22009002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215499 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/renderer/resources/extensions/app_window_custom_bindings.js | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/chrome/renderer/resources/extensions/app_window_custom_bindings.js b/chrome/renderer/resources/extensions/app_window_custom_bindings.js index 944189a..a4d6b2b 100644 --- a/chrome/renderer/resources/extensions/app_window_custom_bindings.js +++ b/chrome/renderer/resources/extensions/app_window_custom_bindings.js @@ -136,6 +136,16 @@ function boundsEqual(bounds1, bounds2) { bounds1.width == bounds2.width && bounds1.height == bounds2.height); } +function dispatchEventIfExists(target, name) { + // Sometimes apps like to put their own properties on the window which + // break our assumptions. + var event = target[name]; + if (event && (typeof event.dispatch == 'function')) + event.dispatch(); + else + console.warn('Could not dispatch ' + name + ', event has been clobbered'); +} + function updateAppWindowProperties(update) { if (!appWindowData) return; @@ -147,25 +157,25 @@ function updateAppWindowProperties(update) { var currentWindow = currentAppWindow; if (!boundsEqual(oldData.bounds, update.bounds)) - currentWindow["onBoundsChanged"].dispatch(); + dispatchEventIfExists(currentWindow, "onBoundsChanged"); if (!oldData.fullscreen && update.fullscreen) - currentWindow["onFullscreened"].dispatch(); + dispatchEventIfExists(currentWindow, "onFullscreened"); if (!oldData.minimized && update.minimized) - currentWindow["onMinimized"].dispatch(); + dispatchEventIfExists(currentWindow, "onMinimized"); if (!oldData.maximized && update.maximized) - currentWindow["onMaximized"].dispatch(); + dispatchEventIfExists(currentWindow, "onMaximized"); if ((oldData.fullscreen && !update.fullscreen) || (oldData.minimized && !update.minimized) || (oldData.maximized && !update.maximized)) - currentWindow["onRestored"].dispatch(); + dispatchEventIfExists(currentWindow, "onRestored"); }; function onAppWindowClosed() { if (!currentAppWindow) return; - currentAppWindow.onClosed.dispatch(); + dispatchEventIfExists(currentAppWindow, "onClosed"); } exports.binding = appWindow.generate(); |