Chromium Code Reviews| 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 <include src="../../../../ui/webui/resources/js/util.js"> | 7 <include src="../../../../ui/webui/resources/js/util.js"> |
| 8 <include src="pdf_scripting_api.js"> | 8 <include src="pdf_scripting_api.js"> |
| 9 <include src="viewport.js"> | 9 <include src="viewport.js"> |
| 10 | 10 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 * Notify the plugin to print. | 258 * Notify the plugin to print. |
| 259 */ | 259 */ |
| 260 print_: function() { | 260 print_: function() { |
| 261 this.plugin_.postMessage({ | 261 this.plugin_.postMessage({ |
| 262 type: 'print', | 262 type: 'print', |
| 263 }); | 263 }); |
| 264 }, | 264 }, |
| 265 | 265 |
| 266 /** | 266 /** |
| 267 * @private | 267 * @private |
| 268 * Handle open PDF parameters. | |
|
raymes
2014/08/18 00:39:34
nit: Maybe we can elaborate on the comment saying
Nikhil
2014/08/18 04:53:32
Done.
| |
| 269 */ | |
| 270 handleOpenPDFParams_: function() { | |
| 271 var originalUrl = this.streamDetails.originalUrl; | |
| 272 var hasParams = originalUrl.search('#'); | |
| 273 if (hasParams == -1) | |
| 274 return; | |
| 275 | |
| 276 var paramTokens = originalUrl.substring(hasParams + 1).split('&'); | |
| 277 var paramsDictionary = {}; | |
| 278 for (var i = 0; i < paramTokens.length; ++i) { | |
| 279 var keyValueSplit = paramTokens[i].split('='); | |
| 280 if (keyValueSplit.length != 2) | |
| 281 continue; | |
| 282 paramsDictionary[keyValueSplit[0]] = keyValueSplit[1]; | |
| 283 } | |
| 284 | |
| 285 // Order is important as later actions can override the effects | |
| 286 // of previous actions. | |
| 287 if ('page' in paramsDictionary) { | |
| 288 // value is 1-based. | |
| 289 this.viewport_.goToPage(paramsDictionary['page'] - 1); | |
| 290 } | |
| 291 }, | |
| 292 | |
| 293 /** | |
| 294 * @private | |
| 268 * Update the loading progress of the document in response to a progress | 295 * Update the loading progress of the document in response to a progress |
| 269 * message being received from the plugin. | 296 * message being received from the plugin. |
| 270 * @param {number} progress the progress as a percentage. | 297 * @param {number} progress the progress as a percentage. |
| 271 */ | 298 */ |
| 272 updateProgress_: function(progress) { | 299 updateProgress_: function(progress) { |
| 273 this.progressBar_.progress = progress; | 300 this.progressBar_.progress = progress; |
| 274 if (progress == -1) { | 301 if (progress == -1) { |
| 275 // Document load failed. | 302 // Document load failed. |
| 276 this.errorScreen_.style.visibility = 'visible'; | 303 this.errorScreen_.style.visibility = 'visible'; |
| 277 this.sizer_.style.display = 'none'; | 304 this.sizer_.style.display = 'none'; |
| 278 this.toolbar_.style.visibility = 'hidden'; | 305 this.toolbar_.style.visibility = 'hidden'; |
| 279 if (this.passwordScreen_.active) { | 306 if (this.passwordScreen_.active) { |
| 280 this.passwordScreen_.deny(); | 307 this.passwordScreen_.deny(); |
| 281 this.passwordScreen_.active = false; | 308 this.passwordScreen_.active = false; |
| 282 } | 309 } |
| 283 } else if (progress == 100) { | 310 } else if (progress == 100) { |
| 284 // Document load complete. | 311 // Document load complete. |
| 312 this.handleOpenPDFParams_(); | |
|
Nikhil
2014/08/16 10:24:01
Is there a way to check whether we are in PrintPre
Nikhil
2014/08/17 16:53:45
Maybe I can introduce isPrintPreview() here? Simil
raymes
2014/08/18 00:39:34
I think it should be ok not to do any check here.
Nikhil
2014/08/18 04:53:32
Acknowledged.
| |
| 285 this.loaded = true; | 313 this.loaded = true; |
| 286 var loadEvent = new Event('pdfload'); | 314 var loadEvent = new Event('pdfload'); |
| 287 window.dispatchEvent(loadEvent); | 315 window.dispatchEvent(loadEvent); |
| 288 this.sendScriptingMessage_({ | 316 this.sendScriptingMessage_({ |
| 289 type: 'documentLoaded' | 317 type: 'documentLoaded' |
| 290 }); | 318 }); |
| 291 if (this.lastViewportPosition_) | 319 if (this.lastViewportPosition_) |
| 292 this.viewport_.position = this.lastViewportPosition_; | 320 this.viewport_.position = this.lastViewportPosition_; |
| 293 } | 321 } |
| 294 }, | 322 }, |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 | 567 |
| 540 /** | 568 /** |
| 541 * @type {Viewport} the viewport of the PDF viewer. | 569 * @type {Viewport} the viewport of the PDF viewer. |
| 542 */ | 570 */ |
| 543 get viewport() { | 571 get viewport() { |
| 544 return this.viewport_; | 572 return this.viewport_; |
| 545 } | 573 } |
| 546 }; | 574 }; |
| 547 | 575 |
| 548 var viewer = new PDFViewer(); | 576 var viewer = new PDFViewer(); |
| OLD | NEW |