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 /** | 7 /** |
| 8 * @return {number} Width of a scrollbar in pixels | 8 * @return {number} Width of a scrollbar in pixels |
| 9 */ | 9 */ |
| 10 function getScrollbarWidth() { | 10 function getScrollbarWidth() { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 // the zoom. onZoomChange() is called before setZoomComplete() callback | 149 // the zoom. onZoomChange() is called before setZoomComplete() callback |
| 150 // when we initiate the zoom. | 150 // when we initiate the zoom. |
| 151 if ((zoomDelta > MIN_ZOOM_DELTA) && !this.setZoomInProgress_) | 151 if ((zoomDelta > MIN_ZOOM_DELTA) && !this.setZoomInProgress_) |
| 152 this.viewport_.setZoom(zoomChangeInfo.newZoomFactor); | 152 this.viewport_.setZoom(zoomChangeInfo.newZoomFactor); |
| 153 }.bind(this)); | 153 }.bind(this)); |
| 154 } | 154 } |
| 155 | 155 |
| 156 // Parse open pdf parameters. | 156 // Parse open pdf parameters. |
| 157 this.paramsParser_ = new OpenPDFParamsParser(); | 157 this.paramsParser_ = new OpenPDFParamsParser(); |
| 158 this.navigator_ = new Navigator(this.streamDetails_.originalUrl, | 158 this.navigator_ = new Navigator(this.streamDetails_.originalUrl, |
| 159 this.viewport_, this.paramsParser_); | 159 this.viewport_, this.paramsParser_, this.onNavigateInCurrentTab_, |
| 160 this.onNavigateInNewTab_); | |
| 160 } | 161 } |
| 161 | 162 |
| 162 PDFViewer.prototype = { | 163 PDFViewer.prototype = { |
| 163 /** | 164 /** |
| 164 * @private | 165 * @private |
| 165 * Handle key events. These may come from the user directly or via the | 166 * Handle key events. These may come from the user directly or via the |
| 166 * scripting API. | 167 * scripting API. |
| 167 * @param {KeyboardEvent} e the event to handle. | 168 * @param {KeyboardEvent} e the event to handle. |
| 168 */ | 169 */ |
| 169 handleKeyEvent_: function(e) { | 170 handleKeyEvent_: function(e) { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 */ | 365 */ |
| 365 onPasswordSubmitted_: function(event) { | 366 onPasswordSubmitted_: function(event) { |
| 366 this.plugin_.postMessage({ | 367 this.plugin_.postMessage({ |
| 367 type: 'getPasswordComplete', | 368 type: 'getPasswordComplete', |
| 368 password: event.detail.password | 369 password: event.detail.password |
| 369 }); | 370 }); |
| 370 }, | 371 }, |
| 371 | 372 |
| 372 /** | 373 /** |
| 373 * @private | 374 * @private |
| 375 * Called when navigation happens in the current tab. | |
| 376 * @param {string} url The url to be opened in the current tab. | |
| 377 */ | |
| 378 onNavigateInCurrentTab_: function(url) { | |
| 379 window.location.href = url; | |
| 380 }, | |
|
raymes
2015/02/01 23:50:38
These don't need to be functions hanging off of PD
Deepak
2015/02/02 04:00:12
Done.
| |
| 381 | |
| 382 /** | |
| 383 * @private | |
| 384 * Called when navigation happens in the new tab. | |
| 385 * @param {string} url The url to be opened in the new tab. | |
| 386 */ | |
| 387 onNavigateInNewTab_: function(url) { | |
| 388 if (chrome.tabs) | |
|
raymes
2015/02/01 23:50:38
We used to have a comment here, it disapeared!
Deepak
2015/02/02 04:00:12
Done.
| |
| 389 chrome.tabs.create({ url: url}); | |
| 390 else | |
| 391 window.open(url); | |
| 392 }, | |
| 393 | |
| 394 /** | |
| 395 * @private | |
| 374 * An event handler for handling message events received from the plugin. | 396 * An event handler for handling message events received from the plugin. |
| 375 * @param {MessageObject} message a message event. | 397 * @param {MessageObject} message a message event. |
| 376 */ | 398 */ |
| 377 handlePluginMessage_: function(message) { | 399 handlePluginMessage_: function(message) { |
| 378 switch (message.data.type.toString()) { | 400 switch (message.data.type.toString()) { |
| 379 case 'documentDimensions': | 401 case 'documentDimensions': |
| 380 this.documentDimensions_ = message.data; | 402 this.documentDimensions_ = message.data; |
| 381 this.viewport_.setDocumentDimensions(this.documentDimensions_); | 403 this.viewport_.setDocumentDimensions(this.documentDimensions_); |
| 382 // If we received the document dimensions, the password was good so we | 404 // If we received the document dimensions, the password was good so we |
| 383 // can dismiss the password screen. | 405 // can dismiss the password screen. |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 694 * Each bookmark is an Object containing a: | 716 * Each bookmark is an Object containing a: |
| 695 * - title | 717 * - title |
| 696 * - page (optional) | 718 * - page (optional) |
| 697 * - array of children (themselves bookmarks) | 719 * - array of children (themselves bookmarks) |
| 698 * @type {Array} the top-level bookmarks of the PDF. | 720 * @type {Array} the top-level bookmarks of the PDF. |
| 699 */ | 721 */ |
| 700 get bookmarks() { | 722 get bookmarks() { |
| 701 return this.bookmarks_; | 723 return this.bookmarks_; |
| 702 } | 724 } |
| 703 }; | 725 }; |
| OLD | NEW |