Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * AppLauncher is an interface that allows the client code to launch and close | 7 * AppLauncher is an interface that allows the client code to launch and close |
| 8 * the app without knowing the implementation difference between a v1 app and | 8 * the app without knowing the implementation difference between a v1 app and |
| 9 * a v2 app. | 9 * a v2 app. |
| 10 * | 10 * |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 * @param {function(*=):void} resolve | 54 * @param {function(*=):void} resolve |
| 55 * @param {function(*=):void} reject | 55 * @param {function(*=):void} reject |
| 56 */ | 56 */ |
| 57 return new Promise(function(resolve, reject) { | 57 return new Promise(function(resolve, reject) { |
| 58 chrome.tabs.create({ url: url, selected: true }, | 58 chrome.tabs.create({ url: url, selected: true }, |
| 59 /** @param {chrome.Tab} tab The created tab. */ | 59 /** @param {chrome.Tab} tab The created tab. */ |
| 60 function(tab) { | 60 function(tab) { |
| 61 if (!tab) { | 61 if (!tab) { |
| 62 reject(new Error(chrome.runtime.lastError.message)); | 62 reject(new Error(chrome.runtime.lastError.message)); |
| 63 } else { | 63 } else { |
| 64 resolve(tab.id); | 64 resolve(String(tab.id)); |
|
kelvinp
2014/08/13 00:08:48
tab.id is a number. Casting to string for API con
Jamie
2014/08/13 01:44:52
If both v1 and v2 represent a window/tab using a n
kelvinp
2014/08/13 23:44:09
The window Id returns in v2 is a string. I have r
| |
| 65 } | 65 } |
| 66 }); | 66 }); |
| 67 }); | 67 }); |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 remoting.V1AppLauncher.prototype.close = function(id) { | 70 remoting.V1AppLauncher.prototype.close = function(id) { |
| 71 /** | 71 /** |
| 72 * @param {function(*=):void} resolve | 72 * @param {function(*=):void} resolve |
| 73 * @param {function(*=):void} reject | 73 * @param {function(*=):void} reject |
| 74 */ | 74 */ |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 'width': 800, | 109 'width': 800, |
| 110 'height': 600, | 110 'height': 600, |
| 111 'frame': 'none', | 111 'frame': 'none', |
| 112 'id': String(remoting.V2AppLauncher.nextWindowId_++) | 112 'id': String(remoting.V2AppLauncher.nextWindowId_++) |
| 113 }, | 113 }, |
| 114 /** @param {AppWindow} appWindow */ | 114 /** @param {AppWindow} appWindow */ |
| 115 function(appWindow) { | 115 function(appWindow) { |
| 116 if (!appWindow) { | 116 if (!appWindow) { |
| 117 reject(new Error(chrome.runtime.lastError.message)); | 117 reject(new Error(chrome.runtime.lastError.message)); |
| 118 } else { | 118 } else { |
| 119 resolve(appWindow.id); | 119 resolve(String(appWindow.id)); |
| 120 } | 120 } |
| 121 }); | 121 }); |
| 122 }); | 122 }); |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 remoting.V2AppLauncher.prototype.close = function(id) { | 125 remoting.V2AppLauncher.prototype.close = function(id) { |
| 126 var appWindow = chrome.app.window.get(id); | 126 var appWindow = chrome.app.window.get(id); |
| 127 if (!appWindow) { | 127 if (!appWindow) { |
| 128 return Promise.reject(new Error(chrome.runtime.lastError.message)); | 128 return Promise.reject(new Error(chrome.runtime.lastError.message)); |
| 129 } | 129 } |
| 130 appWindow.close(); | 130 appWindow.close(); |
| 131 return Promise.resolve(); | 131 return Promise.resolve(); |
| 132 }; | 132 }; |
| OLD | NEW |