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 | |
200 // This is an internal function, but needs to be bound into a closure | 196 // This is an internal function, but needs to be bound into a closure |
201 // so the correct JS context is used for global variables such as | 197 // so the correct JS context is used for global variables such as |
202 // currentWindowInternal, appWindowData, etc. | 198 // currentWindowInternal, appWindowData, etc. |
203 apiFunctions.setHandleRequest('initializeAppWindow', function(params) { | 199 apiFunctions.setHandleRequest('initializeAppWindow', function(params) { |
204 currentWindowInternal = | 200 currentWindowInternal = |
205 Binding.create('app.currentWindowInternal').generate(); | 201 Binding.create('app.currentWindowInternal').generate(); |
206 var AppWindow = function() { | 202 var AppWindow = function() { |
207 this.innerBounds = new Bounds('innerBounds'); | 203 this.innerBounds = new Bounds('innerBounds'); |
208 this.outerBounds = new Bounds('outerBounds'); | 204 this.outerBounds = new Bounds('outerBounds'); |
209 }; | 205 }; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 constraints[key] = 0; | 392 constraints[key] = 0; |
397 }); | 393 }); |
398 | 394 |
399 currentWindowInternal.setSizeConstraints(boundsType, constraints); | 395 currentWindowInternal.setSizeConstraints(boundsType, constraints); |
400 } | 396 } |
401 | 397 |
402 exports.binding = appWindow.generate(); | 398 exports.binding = appWindow.generate(); |
403 exports.onAppWindowClosed = onAppWindowClosed; | 399 exports.onAppWindowClosed = onAppWindowClosed; |
404 exports.updateAppWindowProperties = updateAppWindowProperties; | 400 exports.updateAppWindowProperties = updateAppWindowProperties; |
405 exports.appWindowShownForTests = onAppWindowShownForTests; | 401 exports.appWindowShownForTests = onAppWindowShownForTests; |
OLD | NEW |