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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 remoting.V2AppLauncher.nextWindowId_ = 0; | 98 remoting.V2AppLauncher.nextWindowId_ = 0; |
99 | 99 |
100 remoting.V2AppLauncher.prototype.launch = function(opt_launchArgs) { | 100 remoting.V2AppLauncher.prototype.launch = function(opt_launchArgs) { |
101 var url = base.urlJoin('main.html', opt_launchArgs); | 101 var url = base.urlJoin('main.html', opt_launchArgs); |
102 | 102 |
103 /** | 103 /** |
104 * @param {function(*=):void} resolve | 104 * @param {function(*=):void} resolve |
105 * @param {function(*=):void} reject | 105 * @param {function(*=):void} reject |
106 */ | 106 */ |
107 return new Promise(function(resolve, reject) { | 107 return new Promise(function(resolve, reject) { |
108 chrome.app.window.create(url, { | 108 var START_FULLSCREEN = 'start-fullscreen'; |
109 'width': 800, | 109 /** @param {Object} values */ |
110 'height': 600, | 110 var onValues = function(values) { |
111 'frame': 'none', | 111 /** @type {string} */ |
112 'id': String(remoting.V2AppLauncher.nextWindowId_++) | 112 var state = values[START_FULLSCREEN] ? 'fullscreen' : 'normal'; |
113 }, | 113 chrome.app.window.create(url, { |
114 /** @param {AppWindow=} appWindow */ | 114 'width': 800, |
115 function(appWindow) { | 115 'height': 600, |
116 if (!appWindow) { | 116 'frame': 'none', |
117 reject(new Error(chrome.runtime.lastError.message)); | 117 'id': String(remoting.V2AppLauncher.nextWindowId_++), |
118 } else { | 118 'state': state |
119 resolve(appWindow.id); | 119 }, |
120 } | 120 /** @param {AppWindow=} appWindow */ |
121 }); | 121 function(appWindow) { |
| 122 if (!appWindow) { |
| 123 reject(new Error(chrome.runtime.lastError.message)); |
| 124 } else { |
| 125 resolve(appWindow.id); |
| 126 } |
| 127 }); |
| 128 }; |
| 129 chrome.storage.local.get(START_FULLSCREEN, onValues); |
122 }); | 130 }); |
123 }; | 131 }; |
124 | 132 |
125 remoting.V2AppLauncher.prototype.close = function(id) { | 133 remoting.V2AppLauncher.prototype.close = function(id) { |
126 var appWindow = chrome.app.window.get(id); | 134 var appWindow = chrome.app.window.get(id); |
127 if (!appWindow) { | 135 if (!appWindow) { |
128 return Promise.reject(new Error(chrome.runtime.lastError.message)); | 136 return Promise.reject(new Error(chrome.runtime.lastError.message)); |
129 } | 137 } |
130 appWindow.close(); | 138 appWindow.close(); |
131 return Promise.resolve(); | 139 return Promise.resolve(); |
132 }; | 140 }; |
OLD | NEW |