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 /** | 5 /** |
6 * @param {WebView} webView Web View tag. | 6 * @param {WebView} webView Web View tag. |
| 7 * @param {?string} ext File extension. |
| 8 * @param {?string} mime File mime type. |
| 9 * @param {?string} searchQuery Search query. |
7 * @param {number} width Width of the CWS widget. | 10 * @param {number} width Width of the CWS widget. |
8 * @param {number} height Height of the CWS widget. | 11 * @param {number} height Height of the CWS widget. |
9 * @param {string} url Share Url for an entry. | 12 * @param {string} url Share Url for an entry. |
10 * @param {string} target Target (scheme + host + port) of the widget. | 13 * @param {string} target Target (scheme + host + port) of the widget. |
11 * @param {Object<string, *>} options Options to be sent to the dialog host. | |
12 * @constructor | 14 * @constructor |
13 * @extends {cr.EventTarget} | 15 * @extends {cr.EventTarget} |
14 */ | 16 */ |
15 function CWSContainerClient(webView, width, height, url, target, options) { | 17 function CWSContainerClient( |
| 18 webView, ext, mime, searchQuery, width, height, url, target) { |
16 this.webView_ = webView; | 19 this.webView_ = webView; |
| 20 this.ext_ = (ext && ext[0] == '.') ? ext.substr(1) : ext; |
| 21 this.mime_ = mime; |
| 22 this.searchQuery_ = searchQuery; |
17 this.width_ = width; | 23 this.width_ = width; |
18 this.height_ = height; | 24 this.height_ = height; |
19 this.url_ = url; | 25 this.url_ = url; |
20 this.target_ = target; | 26 this.target_ = target; |
21 this.options_ = options; | |
22 | 27 |
23 this.loaded_ = false; | 28 this.loaded_ = false; |
24 this.loading_ = false; | 29 this.loading_ = false; |
25 | 30 |
26 this.onMessageBound_ = this.onMessage_.bind(this); | 31 this.onMessageBound_ = this.onMessage_.bind(this); |
27 this.onLoadStopBound_ = this.onLoadStop_.bind(this); | 32 this.onLoadStopBound_ = this.onLoadStop_.bind(this); |
28 this.onLoadAbortBound_ = this.onLoadAbort_.bind(this); | 33 this.onLoadAbortBound_ = this.onLoadAbort_.bind(this); |
29 } | 34 } |
30 | 35 |
31 CWSContainerClient.prototype = { | 36 CWSContainerClient.prototype = { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 */ | 183 */ |
179 CWSContainerClient.prototype.postInitializeMessage_ = function() { | 184 CWSContainerClient.prototype.postInitializeMessage_ = function() { |
180 var message = { | 185 var message = { |
181 message: 'initialize', | 186 message: 'initialize', |
182 hl: util.getCurrentLocaleOrDefault(), | 187 hl: util.getCurrentLocaleOrDefault(), |
183 width: this.width_, | 188 width: this.width_, |
184 height: this.height_, | 189 height: this.height_, |
185 v: 1 | 190 v: 1 |
186 }; | 191 }; |
187 | 192 |
188 if (this.options_) { | 193 if (this.searchQuery_) { |
189 Object.keys(this.options_).forEach(function(key) { | 194 message['search_query'] = this.searchQuery_; |
190 message[key] = this.options_[key]; | 195 } else { |
191 }.bind(this)); | 196 message['file_extension'] = this.ext_; |
| 197 message['mime_type'] = this.mime_; |
192 } | 198 } |
193 | 199 |
194 this.postMessage_(message); | 200 this.postMessage_(message); |
195 }; | 201 }; |
196 | 202 |
197 /** | 203 /** |
198 * Send a message to the widget. This method shouldn't be called directly, | 204 * Send a message to the widget. This method shouldn't be called directly, |
199 * should from more specified posting function (eg. postXyzMessage_()). | 205 * should from more specified posting function (eg. postXyzMessage_()). |
200 * | 206 * |
201 * @param {Object} message Message object to be posted. | 207 * @param {Object} message Message object to be posted. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 'loadabort', this.onLoadAbortBound_); | 239 'loadabort', this.onLoadAbortBound_); |
234 this.webView_.stop(); | 240 this.webView_.stop(); |
235 }; | 241 }; |
236 | 242 |
237 /** | 243 /** |
238 * Cleans the dialog by removing all handlers. | 244 * Cleans the dialog by removing all handlers. |
239 */ | 245 */ |
240 CWSContainerClient.prototype.dispose = function() { | 246 CWSContainerClient.prototype.dispose = function() { |
241 this.abort(); | 247 this.abort(); |
242 }; | 248 }; |
OLD | NEW |