Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(459)

Side by Side Diff: chrome/browser/resources/file_manager/js/suggest_apps_dialog.js

Issue 23494024: [Files.app] Pass the access token to the widget by the 'initialize' message (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/file_manager/js/cws_container_client.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 196
197 /** 197 /**
198 * @override 198 * @override
199 */ 199 */
200 SuggestAppsDialog.prototype.onInputFocus = function() { 200 SuggestAppsDialog.prototype.onInputFocus = function() {
201 this.webviewContainer_.select(); 201 this.webviewContainer_.select();
202 }; 202 };
203 203
204 /** 204 /**
205 * Injects headers into the passed request. 205 * Injects headers into the passed request.
206 * TODO(yoshiki): Removes this method after the CWS widget supports the access
207 * token in 'initialization' message.
206 * 208 *
207 * @param {Event} e Request event. 209 * @param {Event} e Request event.
208 * @return {{requestHeaders: HttpHeaders}} Modified headers. 210 * @return {{requestHeaders: HttpHeaders}} Modified headers.
209 * @private 211 * @private
210 */ 212 */
211 SuggestAppsDialog.prototype.authorizeRequest_ = function(e) { 213 SuggestAppsDialog.prototype.authorizeRequest_ = function(e) {
212 e.requestHeaders.push({ 214 e.requestHeaders.push({
213 name: 'Authorization', 215 name: 'Authorization',
214 value: 'Bearer ' + this.accessToken_ 216 value: 'Bearer ' + this.accessToken_
215 }); 217 });
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 cr.ui.dialogs.BaseDialog.prototype.showWithTitle.apply( 272 cr.ui.dialogs.BaseDialog.prototype.showWithTitle.apply(
271 this, [title, '', function() {}, null, null]); 273 this, [title, '', function() {}, null, null]);
272 274
273 this.webviewContainer_.innerHTML = 275 this.webviewContainer_.innerHTML =
274 '<webview id="cws-widget" partition="persist:cwswidgets"></webview>'; 276 '<webview id="cws-widget" partition="persist:cwswidgets"></webview>';
275 this.webviewContainer_.classList.remove('loaded'); 277 this.webviewContainer_.classList.remove('loaded');
276 this.webviewContainer_.style.width = SPINNER_WIDTH + 'px'; 278 this.webviewContainer_.style.width = SPINNER_WIDTH + 'px';
277 this.webviewContainer_.style.height = SPINNER_HEIGHT + 'px'; 279 this.webviewContainer_.style.height = SPINNER_HEIGHT + 'px';
278 280
279 this.webview_ = this.container_.querySelector('#cws-widget'); 281 this.webview_ = this.container_.querySelector('#cws-widget');
282
283 // TODO(yoshiki): Removes the 'Authentication' header after the CWS widget
284 // supports the access token in 'initialization' message.
280 this.webview_.request.onBeforeSendHeaders.addListener( 285 this.webview_.request.onBeforeSendHeaders.addListener(
281 this.authorizeRequest_.bind(this), 286 this.authorizeRequest_.bind(this),
282 {urls: [this.widgetOrigin_ + '/*']}, 287 {urls: [this.widgetOrigin_ + '/*']},
283 ['blocking', 'requestHeaders']); 288 ['blocking', 'requestHeaders']);
284 289
285 this.spinnerWrapper_.hidden = false; 290 this.spinnerWrapper_.hidden = false;
286 291
287 this.webviewClient_ = new CWSContainerClient( 292 this.webviewClient_ = new CWSContainerClient(
288 this.webview_, 293 this.webview_,
289 extension, mime, 294 extension, mime,
290 WEBVIEW_WIDTH, WEBVIEW_HEIGHT, 295 WEBVIEW_WIDTH, WEBVIEW_HEIGHT,
291 this.widgetUrl_, this.widgetOrigin_); 296 this.widgetUrl_, this.widgetOrigin_,
297 this.accessToken_);
292 this.webviewClient_.addEventListener(CWSContainerClient.Events.LOADED, 298 this.webviewClient_.addEventListener(CWSContainerClient.Events.LOADED,
293 this.onWidgetLoaded_.bind(this)); 299 this.onWidgetLoaded_.bind(this));
294 this.webviewClient_.addEventListener(CWSContainerClient.Events.LOAD_FAILED, 300 this.webviewClient_.addEventListener(CWSContainerClient.Events.LOAD_FAILED,
295 this.onWidgetLoadFailed_.bind(this)); 301 this.onWidgetLoadFailed_.bind(this));
296 this.webviewClient_.addEventListener( 302 this.webviewClient_.addEventListener(
297 CWSContainerClient.Events.REQUEST_INSTALL, 303 CWSContainerClient.Events.REQUEST_INSTALL,
298 this.onInstallRequest_.bind(this)); 304 this.onInstallRequest_.bind(this));
299 this.webviewClient_.load(); 305 this.webviewClient_.load();
300 }.bind(this)); 306 }.bind(this));
301 }; 307 };
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/file_manager/js/cws_container_client.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698