OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * SuggestAppsDialog contains a list box to select an app to be opened the file | 8 * SuggestAppsDialog contains a list box to select an app to be opened the file |
9 * with. This dialog should be used as action picker for file operations. | 9 * with. This dialog should be used as action picker for file operations. |
10 */ | 10 */ |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 }; | 217 }; |
218 | 218 |
219 /** | 219 /** |
220 * Retrieves the authorize token. This method should be called in | 220 * Retrieves the authorize token. This method should be called in |
221 * initialization of the dialog. | 221 * initialization of the dialog. |
222 * | 222 * |
223 * @param {function()} callback Called when the token is retrieved. | 223 * @param {function()} callback Called when the token is retrieved. |
224 * @private | 224 * @private |
225 */ | 225 */ |
226 SuggestAppsDialog.prototype.retrieveAuthorizeToken_ = function(callback) { | 226 SuggestAppsDialog.prototype.retrieveAuthorizeToken_ = function(callback) { |
227 // TODO(yoshiki): Share the access token with ShareDialog. | |
228 if (this.accessToken_) { | 227 if (this.accessToken_) { |
229 callback(); | 228 callback(); |
230 return; | 229 return; |
231 } | 230 } |
232 | 231 |
233 // Fetch or update the access token. | 232 // Fetch or update the access token. |
234 chrome.fileBrowserPrivate.requestAccessToken( | 233 chrome.fileBrowserPrivate.requestWebStoreAccessToken( |
235 false, // force_refresh | 234 function(accessToken) { |
hidehiko
2013/09/04 05:45:08
I think you'd need error handling here.
yoshiki
2013/09/04 06:14:58
I added the handling in show() below.
| |
236 function(inAccessToken) { | 235 this.accessToken_ = accessToken; |
237 this.accessToken_ = inAccessToken; | |
238 callback(); | 236 callback(); |
239 }.bind(this)); | 237 }.bind(this)); |
240 }; | 238 }; |
241 | 239 |
242 /** | 240 /** |
243 * Shows dialog. | 241 * Shows dialog. |
244 * | 242 * |
245 * @param {string} extension Extension of the file. | 243 * @param {string} extension Extension of the file. |
246 * @param {string} mime Mime of the file. | 244 * @param {string} mime Mime of the file. |
247 * @param {function(boolean)} onDialogClosed Called when the dialog is closed. | 245 * @param {function(boolean)} onDialogClosed Called when the dialog is closed. |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
454 result = SuggestAppsDialog.Result.USER_CANCELL; | 452 result = SuggestAppsDialog.Result.USER_CANCELL; |
455 break; | 453 break; |
456 default: | 454 default: |
457 result = SuggestAppsDialog.Result.USER_CANCELL; | 455 result = SuggestAppsDialog.Result.USER_CANCELL; |
458 console.error('Invalid state.'); | 456 console.error('Invalid state.'); |
459 } | 457 } |
460 this.state_ = SuggestAppsDialog.State.UNINITIALIZED; | 458 this.state_ = SuggestAppsDialog.State.UNINITIALIZED; |
461 | 459 |
462 this.onDialogClosed_(result); | 460 this.onDialogClosed_(result); |
463 }; | 461 }; |
OLD | NEW |