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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 * @type {RegExp} | 75 * @type {RegExp} |
76 * @const | 76 * @const |
77 */ | 77 */ |
78 var REGEXP_LOCALHOST_MATCH = /^https?:\/\/localhost(?:\:\d{1,5})?$/; | 78 var REGEXP_LOCALHOST_MATCH = /^https?:\/\/localhost(?:\:\d{1,5})?$/; |
79 | 79 |
80 /** | 80 /** |
81 * Creates dialog in DOM tree. | 81 * Creates dialog in DOM tree. |
82 * | 82 * |
83 * @param {HTMLElement} parentNode Node to be parent for this dialog. | 83 * @param {HTMLElement} parentNode Node to be parent for this dialog. |
84 * @constructor | 84 * @constructor |
85 * @extends {cr.ui.dialogs.BaseDialog} | 85 * @extends {FileManagerDialogBase} |
86 */ | 86 */ |
87 function SuggestAppsDialog(parentNode) { | 87 function SuggestAppsDialog(parentNode) { |
88 cr.ui.dialogs.BaseDialog.call(this, parentNode); | 88 FileManagerDialogBase.call(this, parentNode); |
89 | 89 |
90 this.frame_.id = 'suggest-app-dialog'; | 90 this.frame_.id = 'suggest-app-dialog'; |
91 | 91 |
92 this.spinnerWrapper_ = this.document_.createElement('div'); | 92 this.spinnerWrapper_ = this.document_.createElement('div'); |
93 this.spinnerWrapper_.className = 'spinner-container'; | 93 this.spinnerWrapper_.className = 'spinner-container'; |
94 this.spinnerWrapper_.style.width = SPINNER_WIDTH + 'px'; | 94 this.spinnerWrapper_.style.width = SPINNER_WIDTH + 'px'; |
95 this.spinnerWrapper_.style.height = SPINNER_HEIGHT + 'px'; | 95 this.spinnerWrapper_.style.height = SPINNER_HEIGHT + 'px'; |
96 this.spinnerWrapper_.hidden = true; | 96 this.spinnerWrapper_.hidden = true; |
97 this.frame_.appendChild(this.spinnerWrapper_); | 97 this.frame_.appendChild(this.spinnerWrapper_); |
98 | 98 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 this.mime_ = null; | 147 this.mime_ = null; |
148 this.installingItemId_ = null; | 148 this.installingItemId_ = null; |
149 this.state_ = SuggestAppsDialog.State.UNINITIALIZED; | 149 this.state_ = SuggestAppsDialog.State.UNINITIALIZED; |
150 | 150 |
151 this.initializationTask_ = new AsyncUtil.Group(); | 151 this.initializationTask_ = new AsyncUtil.Group(); |
152 this.initializationTask_.add(this.retrieveAuthorizeToken_.bind(this)); | 152 this.initializationTask_.add(this.retrieveAuthorizeToken_.bind(this)); |
153 this.initializationTask_.run(); | 153 this.initializationTask_.run(); |
154 } | 154 } |
155 | 155 |
156 SuggestAppsDialog.prototype = { | 156 SuggestAppsDialog.prototype = { |
157 __proto__: cr.ui.dialogs.BaseDialog.prototype | 157 __proto__: FileManagerDialogBase.prototype |
158 }; | 158 }; |
159 | 159 |
160 /** | 160 /** |
161 * @enum {string} | 161 * @enum {string} |
162 * @const | 162 * @const |
163 */ | 163 */ |
164 SuggestAppsDialog.State = { | 164 SuggestAppsDialog.State = { |
165 UNINITIALIZED: 'SuggestAppsDialog.State.UNINITIALIZED', | 165 UNINITIALIZED: 'SuggestAppsDialog.State.UNINITIALIZED', |
166 INITIALIZING: 'SuggestAppsDialog.State.INITIALIZING', | 166 INITIALIZING: 'SuggestAppsDialog.State.INITIALIZING', |
167 INITIALIZE_FAILED_CLOSING: | 167 INITIALIZE_FAILED_CLOSING: |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 this.onHide_(); | 260 this.onHide_(); |
261 return; | 261 return; |
262 } | 262 } |
263 | 263 |
264 var title = str('SUGGEST_DIALOG_TITLE'); | 264 var title = str('SUGGEST_DIALOG_TITLE'); |
265 | 265 |
266 // TODO(yoshiki): Remove this before ShareDialog launches. | 266 // TODO(yoshiki): Remove this before ShareDialog launches. |
267 if (this.urlOverrided_) | 267 if (this.urlOverrided_) |
268 title += ' [OVERRIDED]'; | 268 title += ' [OVERRIDED]'; |
269 | 269 |
270 cr.ui.dialogs.BaseDialog.prototype.showWithTitle.apply( | 270 var show = |
271 this, [title, '', function() {}, null, null]); | 271 FileManagerDialogBase.prototype.showTitleOnlyDialog.call(this, title); |
| 272 if (!show) { |
| 273 console.error('SuggestAppsDialog can\'t be shown'); |
| 274 this.state_ = SuggestAppsDialog.State.UNINITIALIZED; |
| 275 this.onHide(); |
| 276 return; |
| 277 } |
272 | 278 |
273 this.webviewContainer_.innerHTML = | 279 this.webviewContainer_.innerHTML = |
274 '<webview id="cws-widget" partition="persist:cwswidgets"></webview>'; | 280 '<webview id="cws-widget" partition="persist:cwswidgets"></webview>'; |
275 this.webviewContainer_.classList.remove('loaded'); | 281 this.webviewContainer_.classList.remove('loaded'); |
276 this.webviewContainer_.style.width = SPINNER_WIDTH + 'px'; | 282 this.webviewContainer_.style.width = SPINNER_WIDTH + 'px'; |
277 this.webviewContainer_.style.height = SPINNER_HEIGHT + 'px'; | 283 this.webviewContainer_.style.height = SPINNER_HEIGHT + 'px'; |
278 | 284 |
279 this.webview_ = this.container_.querySelector('#cws-widget'); | 285 this.webview_ = this.container_.querySelector('#cws-widget'); |
280 | 286 |
281 // TODO(yoshiki): Removes the 'Authentication' header after the CWS widget | 287 // TODO(yoshiki): Removes the 'Authentication' header after the CWS widget |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 | 423 |
418 if (this.webviewClient_) { | 424 if (this.webviewClient_) { |
419 this.webviewClient_.dispose(); | 425 this.webviewClient_.dispose(); |
420 this.webviewClient_ = null; | 426 this.webviewClient_ = null; |
421 } | 427 } |
422 | 428 |
423 this.webviewContainer_.innerHTML = ''; | 429 this.webviewContainer_.innerHTML = ''; |
424 this.extension_ = null; | 430 this.extension_ = null; |
425 this.mime_ = null; | 431 this.mime_ = null; |
426 | 432 |
427 cr.ui.dialogs.BaseDialog.prototype.hide.call( | 433 FileManagerDialogBase.prototype.hide.call( |
428 this, | 434 this, |
429 this.onHide_.bind(this, opt_originalOnHide)); | 435 this.onHide_.bind(this, opt_originalOnHide)); |
430 }; | 436 }; |
431 | 437 |
432 /** | 438 /** |
433 * @param {function()=} opt_originalOnHide Original onHide function passed to | 439 * @param {function()=} opt_originalOnHide Original onHide function passed to |
434 * SuggestAppsDialog.hide(). | 440 * SuggestAppsDialog.hide(). |
435 * @private | 441 * @private |
436 */ | 442 */ |
437 SuggestAppsDialog.prototype.onHide_ = function(opt_originalOnHide) { | 443 SuggestAppsDialog.prototype.onHide_ = function(opt_originalOnHide) { |
(...skipping 16 matching lines...) Expand all Loading... |
454 result = SuggestAppsDialog.Result.USER_CANCELL; | 460 result = SuggestAppsDialog.Result.USER_CANCELL; |
455 break; | 461 break; |
456 default: | 462 default: |
457 result = SuggestAppsDialog.Result.USER_CANCELL; | 463 result = SuggestAppsDialog.Result.USER_CANCELL; |
458 console.error('Invalid state.'); | 464 console.error('Invalid state.'); |
459 } | 465 } |
460 this.state_ = SuggestAppsDialog.State.UNINITIALIZED; | 466 this.state_ = SuggestAppsDialog.State.UNINITIALIZED; |
461 | 467 |
462 this.onDialogClosed_(result); | 468 this.onDialogClosed_(result); |
463 }; | 469 }; |
OLD | NEW |