OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 * @param {WebView} webView Web View tag. | 8 * @param {WebView} webView Web View tag. |
9 * @param {string} ext File extension. | 9 * @param {string} ext File extension. |
10 * @param {string} mime File mime type. | 10 * @param {string} mime File mime type. |
11 * @param {number} width Width of the CWS widget. | 11 * @param {number} width Width of the CWS widget. |
12 * @param {number} height Height of the CWS widget. | 12 * @param {number} height Height of the CWS widget. |
13 * @param {string} url Share Url for an entry. | 13 * @param {string} url Share Url for an entry. |
14 * @param {string} target Target (scheme + host + port) of the widget. | 14 * @param {string} target Target (scheme + host + port) of the widget. |
| 15 * @param {string} token Access token to access CWS. |
15 * @constructor | 16 * @constructor |
16 */ | 17 */ |
17 function CWSContainerClient(webView, ext, mime, width, height, url, target) { | 18 function CWSContainerClient( |
| 19 webView, ext, mime, width, height, url, target, token) { |
18 this.webView_ = webView; | 20 this.webView_ = webView; |
19 this.ext_ = ext; | 21 this.ext_ = ext; |
20 this.mime_ = mime; | 22 this.mime_ = mime; |
21 this.width_ = width; | 23 this.width_ = width; |
22 this.height_ = height; | 24 this.height_ = height; |
23 this.url_ = url; | 25 this.url_ = url; |
24 this.target_ = target; | 26 this.target_ = target; |
| 27 this.token_ = token; |
25 | 28 |
26 this.loaded_ = false; | 29 this.loaded_ = false; |
27 this.loading_ = false; | 30 this.loading_ = false; |
28 | 31 |
29 this.onMessageBound_ = this.onMessage_.bind(this); | 32 this.onMessageBound_ = this.onMessage_.bind(this); |
30 this.onLoadStopBound_ = this.onLoadStop_.bind(this); | 33 this.onLoadStopBound_ = this.onLoadStop_.bind(this); |
31 this.onLoadAbortBound_ = this.onLoadAbort_.bind(this); | 34 this.onLoadAbortBound_ = this.onLoadAbort_.bind(this); |
32 } | 35 } |
33 | 36 |
34 CWSContainerClient.prototype = { | 37 CWSContainerClient.prototype = { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 * @private | 183 * @private |
181 */ | 184 */ |
182 CWSContainerClient.prototype.postInitializeMessage_ = function() { | 185 CWSContainerClient.prototype.postInitializeMessage_ = function() { |
183 var message = { | 186 var message = { |
184 message: 'initialize', | 187 message: 'initialize', |
185 hl: util.getCurrentLocaleOrDefault(), | 188 hl: util.getCurrentLocaleOrDefault(), |
186 widgth: this.width_, | 189 widgth: this.width_, |
187 height: this.height_, | 190 height: this.height_, |
188 file_extension: this.ext_, | 191 file_extension: this.ext_, |
189 mime_type: this.mime_, | 192 mime_type: this.mime_, |
| 193 access_token: this.token_, |
190 v: 1 | 194 v: 1 |
191 }; | 195 }; |
192 | 196 |
193 this.postMessage_(message); | 197 this.postMessage_(message); |
194 }; | 198 }; |
195 | 199 |
196 /** | 200 /** |
197 * Send a message to the widget. This method shouldn't be called directly, | 201 * Send a message to the widget. This method shouldn't be called directly, |
198 * should from more specified posting function (eg. postXyzMessage_()). | 202 * should from more specified posting function (eg. postXyzMessage_()). |
199 * | 203 * |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 'loadabort', this.onLoadAbortBound_); | 236 'loadabort', this.onLoadAbortBound_); |
233 this.webView_.stop(); | 237 this.webView_.stop(); |
234 }; | 238 }; |
235 | 239 |
236 /** | 240 /** |
237 * Cleans the dialog by removing all handlers. | 241 * Cleans the dialog by removing all handlers. |
238 */ | 242 */ |
239 CWSContainerClient.prototype.dispose = function() { | 243 CWSContainerClient.prototype.dispose = function() { |
240 this.abort(); | 244 this.abort(); |
241 }; | 245 }; |
242 | |
OLD | NEW |