Chromium Code Reviews| Index: chrome/browser/resources/uber/uber_utils.js |
| diff --git a/chrome/browser/resources/uber/uber_utils.js b/chrome/browser/resources/uber/uber_utils.js |
| index 49d4b54fe9439dd45aa039cb034c72c8938ca977..6259e823097358ae10d4c1027c0dd52c1d900949 100644 |
| --- a/chrome/browser/resources/uber/uber_utils.js |
| +++ b/chrome/browser/resources/uber/uber_utils.js |
| @@ -12,19 +12,32 @@ cr.define('uber', function() { |
| * Invokes a method on the parent window (UberPage). This is a convenience |
| * method for API calls into the uber page. |
| * @param {String} method The name of the method to invoke. |
| - * @param {Object} params Optional property bag of parameters to pass to the |
| - * invoked method. |
| + * @param {Object} opt_params Optional property bag of parameters to pass to |
| + * the invoked method. |
| * @private |
| */ |
| - function invokeMethodOnParent(method, params) { |
| - if (!window.parent) |
| + function invokeMethodOnParent(method, opt_params) { |
| + if (window.location == window.parent.location) |
|
Dan Beam
2012/01/20 00:59:02
wouldn't it be better if we assert(window.location
Evan Stade
2012/01/20 03:27:07
ignoring instead of asserting so you can load chro
|
| return; |
| - var data = {method: method, params: params}; |
| - window.parent.postMessage(data, 'chrome://chrome'); |
| + invokeMethodOnWindow(window.parent, method, opt_params, 'chrome://chrome'); |
| }; |
|
Dan Beam
2012/01/20 00:59:02
remove ;
Evan Stade
2012/01/20 03:27:07
Done.
|
| + /** |
| + * Invokes a method on the target window. |
| + * @param {String} method The name of the method to invoke. |
| + * @param {Object} opt_params Optional property bag of parameters to pass toi |
|
Dan Beam
2012/01/20 00:59:02
toi -> to
Evan Stade
2012/01/20 03:27:07
Done.
|
| + * the invoked method. |
| + * @param {String} opt_url The origin of the target window. |
| + * @private |
| + */ |
| + function invokeMethodOnWindow(targetWindow, method, opt_params, opt_url) { |
| + var data = {method: method, params: opt_params}; |
| + targetWindow.postMessage(data, opt_url ? opt_url : '*'); |
| + } |
| + |
| return { |
| - invokeMethodOnParent: invokeMethodOnParent |
| + invokeMethodOnParent: invokeMethodOnParent, |
| + invokeMethodOnWindow: invokeMethodOnWindow |
|
Dan Beam
2012/01/20 00:59:02
add ,
Evan Stade
2012/01/20 03:27:07
Done.
|
| } |
|
Dan Beam
2012/01/20 00:59:02
add ;
Evan Stade
2012/01/20 03:27:07
Done.
|
| }); |