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)); |
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |