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 Binding = require('binding').Binding; | 7 var Binding = require('binding').Binding; |
8 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | 8 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
9 var chrome = requireNative('chrome').GetChrome(); | 9 var chrome = requireNative('chrome').GetChrome(); |
10 var sendRequest = require('sendRequest').sendRequest; | 10 var sendRequest = require('sendRequest').sendRequest; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 } | 67 } |
68 }); | 68 }); |
69 | 69 |
70 apiFunctions.setHandleRequest('current', function() { | 70 apiFunctions.setHandleRequest('current', function() { |
71 if (!chromeHidden.currentAppWindow) { | 71 if (!chromeHidden.currentAppWindow) { |
72 console.error('chrome.app.window.current() is null -- window not ' + | 72 console.error('chrome.app.window.current() is null -- window not ' + |
73 'created with chrome.app.window.create()'); | 73 'created with chrome.app.window.create()'); |
74 return null; | 74 return null; |
75 } | 75 } |
76 return chromeHidden.currentAppWindow; | 76 return chromeHidden.currentAppWindow; |
77 }); | 77 }, false); |
78 | 78 |
79 chromeHidden.OnAppWindowClosed = function() { | 79 chromeHidden.OnAppWindowClosed = function() { |
80 if (!chromeHidden.currentAppWindow) | 80 if (!chromeHidden.currentAppWindow) |
81 return; | 81 return; |
82 chromeHidden.currentAppWindow.onClosed.dispatch(); | 82 chromeHidden.currentAppWindow.onClosed.dispatch(); |
83 }; | 83 }; |
84 | 84 |
85 // This is an internal function, but needs to be bound with setHandleRequest | 85 // This is an internal function, but needs to be bound with setHandleRequest |
86 // because it is called from a different JS context. | 86 // because it is called from a different JS context. |
87 apiFunctions.setHandleRequest('initializeAppWindow', function(params) { | 87 apiFunctions.setHandleRequest('initializeAppWindow', function(params) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 | 120 |
121 chromeHidden.appWindowData = { | 121 chromeHidden.appWindowData = { |
122 id: params.id || '', | 122 id: params.id || '', |
123 bounds: { left: params.bounds.left, top: params.bounds.top, | 123 bounds: { left: params.bounds.left, top: params.bounds.top, |
124 width: params.bounds.width, height: params.bounds.height }, | 124 width: params.bounds.width, height: params.bounds.height }, |
125 fullscreen: false, | 125 fullscreen: false, |
126 minimized: false, | 126 minimized: false, |
127 maximized: false | 127 maximized: false |
128 }; | 128 }; |
129 chromeHidden.currentAppWindow = new AppWindow; | 129 chromeHidden.currentAppWindow = new AppWindow; |
130 }); | 130 }, true); |
Matt Perry
2013/03/15 17:51:07
I don't see where this one calls sendRequest.
| |
131 }); | 131 }); |
132 | 132 |
133 function boundsEqual(bounds1, bounds2) { | 133 function boundsEqual(bounds1, bounds2) { |
134 if (!bounds1 || !bounds2) | 134 if (!bounds1 || !bounds2) |
135 return false; | 135 return false; |
136 return (bounds1.left == bounds2.left && bounds1.top == bounds2.top && | 136 return (bounds1.left == bounds2.left && bounds1.top == bounds2.top && |
137 bounds1.width == bounds2.width && bounds1.height == bounds2.height); | 137 bounds1.width == bounds2.width && bounds1.height == bounds2.height); |
138 } | 138 } |
139 | 139 |
140 chromeHidden.updateAppWindowProperties = function(update) { | 140 chromeHidden.updateAppWindowProperties = function(update) { |
(...skipping 15 matching lines...) Expand all Loading... | |
156 if (!oldData.maximized && update.maximized) | 156 if (!oldData.maximized && update.maximized) |
157 currentWindow["onMaximized"].dispatch(); | 157 currentWindow["onMaximized"].dispatch(); |
158 | 158 |
159 if ((oldData.fullscreen && !update.fullscreen) || | 159 if ((oldData.fullscreen && !update.fullscreen) || |
160 (oldData.minimized && !update.minimized) || | 160 (oldData.minimized && !update.minimized) || |
161 (oldData.maximized && !update.maximized)) | 161 (oldData.maximized && !update.maximized)) |
162 currentWindow["onRestored"].dispatch(); | 162 currentWindow["onRestored"].dispatch(); |
163 }; | 163 }; |
164 | 164 |
165 exports.binding = appWindow.generate(); | 165 exports.binding = appWindow.generate(); |
OLD | NEW |