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 runtimeNatives = requireNative('runtime'); | 8 var runtimeNatives = requireNative('runtime'); |
9 var Binding = require('binding').Binding; | 9 var Binding = require('binding').Binding; |
10 var Event = require('event_bindings').Event; | 10 var Event = require('event_bindings').Event; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 forEach(currentWindowInternal, function(key, value) { | 206 forEach(currentWindowInternal, function(key, value) { |
207 // Do not add internal functions that should not appear in the AppWindow | 207 // Do not add internal functions that should not appear in the AppWindow |
208 // interface. They are called by Bounds mutators. | 208 // interface. They are called by Bounds mutators. |
209 if (key !== kSetBoundsFunction && key !== kSetSizeConstraintsFunction) | 209 if (key !== kSetBoundsFunction && key !== kSetSizeConstraintsFunction) |
210 AppWindow.prototype[key] = value; | 210 AppWindow.prototype[key] = value; |
211 }); | 211 }); |
212 AppWindow.prototype.moveTo = $Function.bind(window.moveTo, window); | 212 AppWindow.prototype.moveTo = $Function.bind(window.moveTo, window); |
213 AppWindow.prototype.resizeTo = $Function.bind(window.resizeTo, window); | 213 AppWindow.prototype.resizeTo = $Function.bind(window.resizeTo, window); |
214 AppWindow.prototype.contentWindow = window; | 214 AppWindow.prototype.contentWindow = window; |
215 AppWindow.prototype.onClosed = new Event(); | 215 AppWindow.prototype.onClosed = new Event(); |
| 216 AppWindow.prototype.onWindowFirstShown = new Event(); |
216 AppWindow.prototype.close = function() { | 217 AppWindow.prototype.close = function() { |
217 this.contentWindow.close(); | 218 this.contentWindow.close(); |
218 }; | 219 }; |
219 AppWindow.prototype.getBounds = function() { | 220 AppWindow.prototype.getBounds = function() { |
220 // This is to maintain backcompatibility with a bug on Windows and | 221 // This is to maintain backcompatibility with a bug on Windows and |
221 // ChromeOS, which returns the position of the window but the size of | 222 // ChromeOS, which returns the position of the window but the size of |
222 // the content. | 223 // the content. |
223 var innerBounds = appWindowData.innerBounds; | 224 var innerBounds = appWindowData.innerBounds; |
224 var outerBounds = appWindowData.outerBounds; | 225 var outerBounds = appWindowData.outerBounds; |
225 return { left: outerBounds.left, top: outerBounds.top, | 226 return { left: outerBounds.left, top: outerBounds.top, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 dispatchEventIfExists(currentWindow, "onMinimized"); | 334 dispatchEventIfExists(currentWindow, "onMinimized"); |
334 if (!oldData.maximized && update.maximized) | 335 if (!oldData.maximized && update.maximized) |
335 dispatchEventIfExists(currentWindow, "onMaximized"); | 336 dispatchEventIfExists(currentWindow, "onMaximized"); |
336 | 337 |
337 if ((oldData.fullscreen && !update.fullscreen) || | 338 if ((oldData.fullscreen && !update.fullscreen) || |
338 (oldData.minimized && !update.minimized) || | 339 (oldData.minimized && !update.minimized) || |
339 (oldData.maximized && !update.maximized)) | 340 (oldData.maximized && !update.maximized)) |
340 dispatchEventIfExists(currentWindow, "onRestored"); | 341 dispatchEventIfExists(currentWindow, "onRestored"); |
341 }; | 342 }; |
342 | 343 |
| 344 function onAppWindowFirstShown() { |
| 345 if (!currentAppWindow) |
| 346 return; |
| 347 |
| 348 dispatchEventIfExists(currentAppWindow, "onWindowFirstShown"); |
| 349 } |
| 350 |
343 function onAppWindowClosed() { | 351 function onAppWindowClosed() { |
344 if (!currentAppWindow) | 352 if (!currentAppWindow) |
345 return; | 353 return; |
346 dispatchEventIfExists(currentAppWindow, "onClosed"); | 354 dispatchEventIfExists(currentAppWindow, "onClosed"); |
347 } | 355 } |
348 | 356 |
349 function updateBounds(boundsType, bounds) { | 357 function updateBounds(boundsType, bounds) { |
350 if (!currentWindowInternal) | 358 if (!currentWindowInternal) |
351 return; | 359 return; |
352 | 360 |
(...skipping 11 matching lines...) Expand all Loading... |
364 if (value === null) | 372 if (value === null) |
365 constraints[key] = 0; | 373 constraints[key] = 0; |
366 }); | 374 }); |
367 | 375 |
368 currentWindowInternal.setSizeConstraints(boundsType, constraints); | 376 currentWindowInternal.setSizeConstraints(boundsType, constraints); |
369 } | 377 } |
370 | 378 |
371 exports.binding = appWindow.generate(); | 379 exports.binding = appWindow.generate(); |
372 exports.onAppWindowClosed = onAppWindowClosed; | 380 exports.onAppWindowClosed = onAppWindowClosed; |
373 exports.updateAppWindowProperties = updateAppWindowProperties; | 381 exports.updateAppWindowProperties = updateAppWindowProperties; |
| 382 exports.appWindowFirstShown = onAppWindowFirstShown; |
OLD | NEW |