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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 }); | 186 }); |
187 }); | 187 }); |
188 | 188 |
189 apiFunctions.setHandleRequest('get', function(id) { | 189 apiFunctions.setHandleRequest('get', function(id) { |
190 var windows = $Array.filter(chrome.app.window.getAll(), function(win) { | 190 var windows = $Array.filter(chrome.app.window.getAll(), function(win) { |
191 return win.id == id; | 191 return win.id == id; |
192 }); | 192 }); |
193 return windows.length > 0 ? windows[0] : null; | 193 return windows.length > 0 ? windows[0] : null; |
194 }); | 194 }); |
195 | 195 |
| 196 apiFunctions.setHandleRequest('canSetVisibleOnAllWorkspaces', function() { |
| 197 return /Mac/.test(navigator.platform) || /Linux/.test(navigator.userAgent); |
| 198 }); |
| 199 |
196 // This is an internal function, but needs to be bound into a closure | 200 // This is an internal function, but needs to be bound into a closure |
197 // so the correct JS context is used for global variables such as | 201 // so the correct JS context is used for global variables such as |
198 // currentWindowInternal, appWindowData, etc. | 202 // currentWindowInternal, appWindowData, etc. |
199 apiFunctions.setHandleRequest('initializeAppWindow', function(params) { | 203 apiFunctions.setHandleRequest('initializeAppWindow', function(params) { |
200 currentWindowInternal = | 204 currentWindowInternal = |
201 Binding.create('app.currentWindowInternal').generate(); | 205 Binding.create('app.currentWindowInternal').generate(); |
202 var AppWindow = function() { | 206 var AppWindow = function() { |
203 this.innerBounds = new Bounds('innerBounds'); | 207 this.innerBounds = new Bounds('innerBounds'); |
204 this.outerBounds = new Bounds('outerBounds'); | 208 this.outerBounds = new Bounds('outerBounds'); |
205 }; | 209 }; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 constraints[key] = 0; | 396 constraints[key] = 0; |
393 }); | 397 }); |
394 | 398 |
395 currentWindowInternal.setSizeConstraints(boundsType, constraints); | 399 currentWindowInternal.setSizeConstraints(boundsType, constraints); |
396 } | 400 } |
397 | 401 |
398 exports.binding = appWindow.generate(); | 402 exports.binding = appWindow.generate(); |
399 exports.onAppWindowClosed = onAppWindowClosed; | 403 exports.onAppWindowClosed = onAppWindowClosed; |
400 exports.updateAppWindowProperties = updateAppWindowProperties; | 404 exports.updateAppWindowProperties = updateAppWindowProperties; |
401 exports.appWindowShownForTests = onAppWindowShownForTests; | 405 exports.appWindowShownForTests = onAppWindowShownForTests; |
OLD | NEW |