Commit 4823999b authored by yoshiki@chromium.org's avatar yoshiki@chromium.org

[Files.app] Pass the access token to the widget by the 'initialize' message

CWS widget team requested to pass the access token by the 'initialize' message.

BUG=none
TEST=manual
R=hirono@chromium.org

Review URL: https://codereview.chromium.org/23494024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221646 0039d316-1c4b-4281-b951-d872f2087c98
parent 22326044
...@@ -12,9 +12,11 @@ ...@@ -12,9 +12,11 @@
* @param {number} height Height of the CWS widget. * @param {number} height Height of the CWS widget.
* @param {string} url Share Url for an entry. * @param {string} url Share Url for an entry.
* @param {string} target Target (scheme + host + port) of the widget. * @param {string} target Target (scheme + host + port) of the widget.
* @param {string} token Access token to access CWS.
* @constructor * @constructor
*/ */
function CWSContainerClient(webView, ext, mime, width, height, url, target) { function CWSContainerClient(
webView, ext, mime, width, height, url, target, token) {
this.webView_ = webView; this.webView_ = webView;
this.ext_ = ext; this.ext_ = ext;
this.mime_ = mime; this.mime_ = mime;
...@@ -22,6 +24,7 @@ function CWSContainerClient(webView, ext, mime, width, height, url, target) { ...@@ -22,6 +24,7 @@ function CWSContainerClient(webView, ext, mime, width, height, url, target) {
this.height_ = height; this.height_ = height;
this.url_ = url; this.url_ = url;
this.target_ = target; this.target_ = target;
this.token_ = token;
this.loaded_ = false; this.loaded_ = false;
this.loading_ = false; this.loading_ = false;
...@@ -187,6 +190,7 @@ CWSContainerClient.prototype.postInitializeMessage_ = function() { ...@@ -187,6 +190,7 @@ CWSContainerClient.prototype.postInitializeMessage_ = function() {
height: this.height_, height: this.height_,
file_extension: this.ext_, file_extension: this.ext_,
mime_type: this.mime_, mime_type: this.mime_,
access_token: this.token_,
v: 1 v: 1
}; };
...@@ -239,4 +243,3 @@ CWSContainerClient.prototype.abort = function() { ...@@ -239,4 +243,3 @@ CWSContainerClient.prototype.abort = function() {
CWSContainerClient.prototype.dispose = function() { CWSContainerClient.prototype.dispose = function() {
this.abort(); this.abort();
}; };
...@@ -203,6 +203,8 @@ SuggestAppsDialog.prototype.onInputFocus = function() { ...@@ -203,6 +203,8 @@ SuggestAppsDialog.prototype.onInputFocus = function() {
/** /**
* Injects headers into the passed request. * Injects headers into the passed request.
* TODO(yoshiki): Removes this method after the CWS widget supports the access
* token in 'initialization' message.
* *
* @param {Event} e Request event. * @param {Event} e Request event.
* @return {{requestHeaders: HttpHeaders}} Modified headers. * @return {{requestHeaders: HttpHeaders}} Modified headers.
...@@ -277,6 +279,9 @@ SuggestAppsDialog.prototype.show = function(extension, mime, onDialogClosed) { ...@@ -277,6 +279,9 @@ SuggestAppsDialog.prototype.show = function(extension, mime, onDialogClosed) {
this.webviewContainer_.style.height = SPINNER_HEIGHT + 'px'; this.webviewContainer_.style.height = SPINNER_HEIGHT + 'px';
this.webview_ = this.container_.querySelector('#cws-widget'); this.webview_ = this.container_.querySelector('#cws-widget');
// TODO(yoshiki): Removes the 'Authentication' header after the CWS widget
// supports the access token in 'initialization' message.
this.webview_.request.onBeforeSendHeaders.addListener( this.webview_.request.onBeforeSendHeaders.addListener(
this.authorizeRequest_.bind(this), this.authorizeRequest_.bind(this),
{urls: [this.widgetOrigin_ + '/*']}, {urls: [this.widgetOrigin_ + '/*']},
...@@ -288,7 +293,8 @@ SuggestAppsDialog.prototype.show = function(extension, mime, onDialogClosed) { ...@@ -288,7 +293,8 @@ SuggestAppsDialog.prototype.show = function(extension, mime, onDialogClosed) {
this.webview_, this.webview_,
extension, mime, extension, mime,
WEBVIEW_WIDTH, WEBVIEW_HEIGHT, WEBVIEW_WIDTH, WEBVIEW_HEIGHT,
this.widgetUrl_, this.widgetOrigin_); this.widgetUrl_, this.widgetOrigin_,
this.accessToken_);
this.webviewClient_.addEventListener(CWSContainerClient.Events.LOADED, this.webviewClient_.addEventListener(CWSContainerClient.Events.LOADED,
this.onWidgetLoaded_.bind(this)); this.onWidgetLoaded_.bind(this));
this.webviewClient_.addEventListener(CWSContainerClient.Events.LOAD_FAILED, this.webviewClient_.addEventListener(CWSContainerClient.Events.LOAD_FAILED,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment