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'; |
Jamie
2015/01/23 22:37:24
As discussed, this currently doesn't work due to c
kelvinp
2015/01/23 23:39:58
Should we wait for the apps team before making thi
Jamie
2015/01/24 00:46:35
I decided to go ahead and implement the workaround
| |
113 }, | 113 chrome.app.window.create(url, { |
114 /** @param {AppWindow=} appWindow */ | 114 'width': 800, 'height': 600, |
115 function(appWindow) { | 115 'frame': 'none', |
116 if (!appWindow) { | 116 'id': String(remoting.V2AppLauncher.nextWindowId_++), |
117 reject(new Error(chrome.runtime.lastError.message)); | 117 'state': state |
118 } else { | 118 }, |
119 resolve(appWindow.id); | 119 /** @param {AppWindow=} appWindow */ |
120 } | 120 function(appWindow) { |
121 }); | 121 if (!appWindow) { |
122 reject(new Error(chrome.runtime.lastError.message)); | |
123 } else { | |
124 resolve(appWindow.id); | |
125 } | |
126 }); | |
127 }; | |
128 chrome.storage.local.get(START_FULLSCREEN, onValues); | |
122 }); | 129 }); |
123 }; | 130 }; |
124 | 131 |
125 remoting.V2AppLauncher.prototype.close = function(id) { | 132 remoting.V2AppLauncher.prototype.close = function(id) { |
126 var appWindow = chrome.app.window.get(id); | 133 var appWindow = chrome.app.window.get(id); |
127 if (!appWindow) { | 134 if (!appWindow) { |
128 return Promise.reject(new Error(chrome.runtime.lastError.message)); | 135 return Promise.reject(new Error(chrome.runtime.lastError.message)); |
129 } | 136 } |
130 appWindow.close(); | 137 appWindow.close(); |
131 return Promise.resolve(); | 138 return Promise.resolve(); |
132 }; | 139 }; |
OLD | NEW |