Chromium Code Reviews| 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 bindings for the app_window API. | 5 // Custom bindings for the app_window API. |
| 6 | 6 |
| 7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | 7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
| 8 var sendRequest = require('sendRequest').sendRequest; | 8 var sendRequest = require('sendRequest').sendRequest; |
| 9 var appWindowNatives = requireNative('app_window'); | 9 var appWindowNatives = requireNative('app_window'); |
| 10 var forEach = require('utils').forEach; | |
| 10 var GetView = appWindowNatives.GetView; | 11 var GetView = appWindowNatives.GetView; |
| 11 | 12 |
| 12 chromeHidden.registerCustomHook('app.window', function(bindingsAPI) { | 13 chromeHidden.registerCustomHook('app.window', function(bindingsAPI) { |
| 13 var apiFunctions = bindingsAPI.apiFunctions; | 14 var apiFunctions = bindingsAPI.apiFunctions; |
| 14 apiFunctions.setCustomCallback('create', function(name, request, viewId) { | 15 apiFunctions.setCustomCallback('create', function(name, request, viewId) { |
| 15 var view = null; | 16 var view = null; |
| 16 if (viewId) | 17 if (viewId) |
| 17 view = GetView(viewId); | 18 view = GetView(viewId); |
| 18 if (request.callback) { | 19 if (request.callback) { |
| 19 request.callback(view); | 20 request.callback(view.chrome.app.window.current()); |
| 20 delete request.callback; | 21 delete request.callback; |
| 21 } | 22 } |
| 22 }) | 23 }) |
| 23 apiFunctions.setHandleRequest('moveTo', function(x, y) { | 24 var AppWindow = function() {}; |
| 24 window.moveTo(x, y); | 25 forEach(chromeHidden.internalAPIs.app.currentWindowInternal, function(fn) { |
| 25 }) | 26 AppWindow.prototype[fn] = |
| 26 apiFunctions.setHandleRequest('resizeTo', function(width, height) { | 27 chromeHidden.internalAPIs.app.currentWindowInternal[fn]; |
| 27 window.resizeTo(width, height); | 28 }); |
| 29 AppWindow.prototype.moveTo = window.moveTo.bind(window); | |
| 30 AppWindow.prototype.resizeTo = window.resizeTo.bind(window); | |
| 31 AppWindow.prototype.dom = window; | |
|
Aaron Boodman
2012/09/06 04:53:29
Nit: Not actually the 'dom', but the windows globa
jeremya
2012/09/06 16:31:20
Perhaps I should rename it to 'global'?
| |
| 32 apiFunctions.setHandleRequest('current', function() { | |
| 33 return new AppWindow; | |
| 28 }) | 34 }) |
| 29 }); | 35 }); |
| OLD | NEW |