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 a2a5af1634e42cecf22de1b76a4fe45db3d19b11..7fed21b8b62050b19b9fde35e0d08e0e24cd1124 100644 |
--- a/chrome/renderer/resources/extensions/app_window_custom_bindings.js |
+++ b/chrome/renderer/resources/extensions/app_window_custom_bindings.js |
@@ -4,14 +4,13 @@ |
// Custom binding for the app_window API. |
+var appWindowNatives = requireNative('app_window_natives'); |
var Binding = require('binding').Binding; |
var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
var chrome = requireNative('chrome').GetChrome(); |
-var sendRequest = require('sendRequest').sendRequest; |
-var appWindowNatives = requireNative('app_window'); |
+var Event = require('event_bindings').Event; |
var forEach = require('utils').forEach; |
-var GetView = appWindowNatives.GetView; |
-var OnContextReady = appWindowNatives.OnContextReady; |
+var sendRequest = require('sendRequest').sendRequest; |
var appWindow = Binding.create('app.window'); |
appWindow.registerCustomHook(function(bindingsAPI) { |
@@ -20,8 +19,10 @@ appWindow.registerCustomHook(function(bindingsAPI) { |
apiFunctions.setCustomCallback('create', |
function(name, request, windowParams) { |
var view = null; |
- if (windowParams.viewId) |
- view = GetView(windowParams.viewId, windowParams.injectTitlebar); |
+ if (windowParams.viewId) { |
+ view = appWindowNatives.GetView( |
+ windowParams.viewId, windowParams.injectTitlebar); |
+ } |
if (!view) { |
// No route to created window. If given a callback, trigger it with an |
@@ -54,7 +55,8 @@ appWindow.registerCustomHook(function(bindingsAPI) { |
return; |
} |
- var willCallback = OnContextReady(windowParams.viewId, function(success) { |
+ var willCallback = appWindowNatives.OnContextReady(windowParams.viewId, |
+ function(success) { |
if (success) { |
callback(view.chrome.app.window.current()); |
} else { |
@@ -76,12 +78,6 @@ appWindow.registerCustomHook(function(bindingsAPI) { |
return chromeHidden.currentAppWindow; |
}); |
- chromeHidden.OnAppWindowClosed = function() { |
- if (!chromeHidden.currentAppWindow) |
- return; |
- chromeHidden.currentAppWindow.onClosed.dispatch(); |
- }; |
- |
// This is an internal function, but needs to be bound with setHandleRequest |
// because it is called from a different JS context. |
apiFunctions.setHandleRequest('initializeAppWindow', function(params) { |
@@ -95,7 +91,7 @@ appWindow.registerCustomHook(function(bindingsAPI) { |
AppWindow.prototype.moveTo = window.moveTo.bind(window); |
AppWindow.prototype.resizeTo = window.resizeTo.bind(window); |
AppWindow.prototype.contentWindow = window; |
- AppWindow.prototype.onClosed = new chrome.Event; |
+ AppWindow.prototype.onClosed = new Event(); |
AppWindow.prototype.close = function() { |
this.contentWindow.close(); |
}; |
@@ -137,7 +133,7 @@ function boundsEqual(bounds1, bounds2) { |
bounds1.width == bounds2.width && bounds1.height == bounds2.height); |
} |
-chromeHidden.updateAppWindowProperties = function(update) { |
+function updateAppWindowProperties(update) { |
if (!chromeHidden.appWindowData) |
return; |
var oldData = chromeHidden.appWindowData; |
@@ -162,4 +158,13 @@ chromeHidden.updateAppWindowProperties = function(update) { |
currentWindow["onRestored"].dispatch(); |
}; |
+// Called by c/r/e/extension_helper.cc. |
+function onAppWindowClosed() { |
+ if (!chromeHidden.currentAppWindow) |
+ return; |
+ chromeHidden.currentAppWindow.onClosed.dispatch(); |
+} |
+ |
exports.binding = appWindow.generate(); |
+exports.onAppWindowClosed = onAppWindowClosed; |
+exports.updateAppWindowProperties = updateAppWindowProperties; |