OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Custom binding for the app_window API. | 5 // Custom binding for the app_window API. |
6 | 6 |
7 var appWindowNatives = requireNative('app_window_natives'); | 7 var appWindowNatives = requireNative('app_window_natives'); |
8 var Binding = require('binding').Binding; | 8 var Binding = require('binding').Binding; |
9 var chrome = requireNative('chrome').GetChrome(); | 9 var chrome = requireNative('chrome').GetChrome(); |
10 var Event = require('event_bindings').Event; | 10 var Event = require('event_bindings').Event; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } | 66 } |
67 }); | 67 }); |
68 if (!willCallback) { | 68 if (!willCallback) { |
69 callback(undefined); | 69 callback(undefined); |
70 } | 70 } |
71 } | 71 } |
72 }); | 72 }); |
73 | 73 |
74 apiFunctions.setHandleRequest('current', function() { | 74 apiFunctions.setHandleRequest('current', function() { |
75 if (!currentAppWindow) { | 75 if (!currentAppWindow) { |
76 console.error('chrome.app.window.current() is null -- window not ' + | 76 console.error('The JavaScript context calling ' + |
77 'created with chrome.app.window.create()'); | 77 'chrome.app.window.current() has no associated AppWindow.'); |
78 return null; | 78 return null; |
79 } | 79 } |
80 return currentAppWindow; | 80 return currentAppWindow; |
81 }); | 81 }); |
82 | 82 |
83 // This is an internal function, but needs to be bound with setHandleRequest | 83 // This is an internal function, but needs to be bound with setHandleRequest |
84 // because it is called from a different JS context. | 84 // because it is called from a different JS context. |
85 apiFunctions.setHandleRequest('initializeAppWindow', function(params) { | 85 apiFunctions.setHandleRequest('initializeAppWindow', function(params) { |
86 var currentWindowInternal = | 86 var currentWindowInternal = |
87 Binding.create('app.currentWindowInternal').generate(); | 87 Binding.create('app.currentWindowInternal').generate(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 163 |
164 function onAppWindowClosed() { | 164 function onAppWindowClosed() { |
165 if (!currentAppWindow) | 165 if (!currentAppWindow) |
166 return; | 166 return; |
167 currentAppWindow.onClosed.dispatch(); | 167 currentAppWindow.onClosed.dispatch(); |
168 } | 168 } |
169 | 169 |
170 exports.binding = appWindow.generate(); | 170 exports.binding = appWindow.generate(); |
171 exports.onAppWindowClosed = onAppWindowClosed; | 171 exports.onAppWindowClosed = onAppWindowClosed; |
172 exports.updateAppWindowProperties = updateAppWindowProperties; | 172 exports.updateAppWindowProperties = updateAppWindowProperties; |
OLD | NEW |