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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 // We should not change zoom level when we are responsible for initiating | 130 // We should not change zoom level when we are responsible for initiating |
| 131 // the zoom. onZoomChange() is called before setZoomComplete() callback | 131 // the zoom. onZoomChange() is called before setZoomComplete() callback |
| 132 // when we initiate the zoom. | 132 // when we initiate the zoom. |
| 133 if ((zoomDelta > MIN_ZOOM_DELTA) && !this.setZoomInProgress_) | 133 if ((zoomDelta > MIN_ZOOM_DELTA) && !this.setZoomInProgress_) |
| 134 this.viewport_.setZoom(zoomChangeInfo.newZoomFactor); | 134 this.viewport_.setZoom(zoomChangeInfo.newZoomFactor); |
| 135 }.bind(this)); | 135 }.bind(this)); |
| 136 } | 136 } |
| 137 | 137 |
| 138 // Parse open pdf parameters. | 138 // Parse open pdf parameters. |
| 139 var paramsParser = new OpenPDFParamsParser(this.streamDetails_.originalUrl); | 139 var paramsParser = new OpenPDFParamsParser(this.streamDetails_.originalUrl); |
| 140 this.urlParams_ = paramsParser.urlParams; | 140 this.urlParams_ = paramsParser.urlParams; |
|
raymes
2015/01/11 23:08:41
Let's move these two lines of code into handleURLP
Deepak
2015/01/12 09:21:43
I agree, we don't need these 2 variables here.
| |
| 141 // This will have name of all the nameddest from the loaded PDF. | |
| 142 this.namedDestinations_ = {}; | |
|
raymes
2015/01/11 23:08:41
Rather than storing these here, maybe we can just
Deepak
2015/01/12 09:21:43
Done.
| |
| 141 } | 143 } |
| 142 | 144 |
| 143 PDFViewer.prototype = { | 145 PDFViewer.prototype = { |
| 144 /** | 146 /** |
| 145 * @private | 147 * @private |
| 146 * Handle key events. These may come from the user directly or via the | 148 * Handle key events. These may come from the user directly or via the |
| 147 * scripting API. | 149 * scripting API. |
| 148 * @param {KeyboardEvent} e the event to handle. | 150 * @param {KeyboardEvent} e the event to handle. |
| 149 */ | 151 */ |
| 150 handleKeyEvent_: function(e) { | 152 handleKeyEvent_: function(e) { |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 // responding to an incorrect password so deny it. | 375 // responding to an incorrect password so deny it. |
| 374 if (!this.passwordScreen_.active) | 376 if (!this.passwordScreen_.active) |
| 375 this.passwordScreen_.active = true; | 377 this.passwordScreen_.active = true; |
| 376 else | 378 else |
| 377 this.passwordScreen_.deny(); | 379 this.passwordScreen_.deny(); |
| 378 break; | 380 break; |
| 379 case 'goToPage': | 381 case 'goToPage': |
| 380 this.viewport_.goToPage(message.data.page); | 382 this.viewport_.goToPage(message.data.page); |
| 381 break; | 383 break; |
| 382 case 'loadProgress': | 384 case 'loadProgress': |
| 385 this.namedDestinations_ = message.data.namedDestinations; | |
|
raymes
2015/01/11 23:08:41
Let's add a new message type for named destination
Deepak
2015/01/12 09:21:43
Done.
I have added a message and sending that when
| |
| 383 this.updateProgress_(message.data.progress); | 386 this.updateProgress_(message.data.progress); |
| 384 break; | 387 break; |
| 385 case 'navigate': | 388 case 'navigate': |
| 386 if (message.data.newTab) | 389 if (message.data.newTab) { |
| 387 window.open(message.data.url); | 390 chrome.tabs.create({ url: message.data.url }); |
| 388 else | 391 } else { |
| 389 window.location.href = message.data.url; | 392 var hashIndex = message.data.url.search('#'); |
| 393 if (hashIndex != -1) { | |
| 394 var urlString = message.data.url.substring(hashIndex + 1); | |
| 395 if (this.namedDestinations_[urlString] != undefined) | |
| 396 this.viewport_.goToPage(this.namedDestinations_[urlString]); | |
| 397 } else { | |
| 398 chrome.tabs.update(this.streamDetails_.tabId, | |
|
raymes
2015/01/11 23:08:41
We don't need to use the chrome.tabs API here - th
Deepak
2015/01/12 09:21:43
window.location.href = message.data.url; is OK,
Bu
| |
| 399 { url: message.data.url }); | |
| 400 } | |
| 401 } | |
|
raymes
2015/01/11 23:08:41
Let's move all of this code into a new function. T
Deepak
2015/01/12 09:21:43
Done.
| |
| 390 break; | 402 break; |
| 391 case 'setScrollPosition': | 403 case 'setScrollPosition': |
| 392 var position = this.viewport_.position; | 404 var position = this.viewport_.position; |
| 393 if (message.data.x != undefined) | 405 if (message.data.x != undefined) |
| 394 position.x = message.data.x; | 406 position.x = message.data.x; |
| 395 if (message.data.y != undefined) | 407 if (message.data.y != undefined) |
| 396 position.y = message.data.y; | 408 position.y = message.data.y; |
| 397 this.viewport_.position = position; | 409 this.viewport_.position = position; |
| 398 break; | 410 break; |
| 399 case 'setTranslatedStrings': | 411 case 'setTranslatedStrings': |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 601 this.streamDetails_.tabId != -1); | 613 this.streamDetails_.tabId != -1); |
| 602 }, | 614 }, |
| 603 | 615 |
| 604 /** | 616 /** |
| 605 * @type {Viewport} the viewport of the PDF viewer. | 617 * @type {Viewport} the viewport of the PDF viewer. |
| 606 */ | 618 */ |
| 607 get viewport() { | 619 get viewport() { |
| 608 return this.viewport_; | 620 return this.viewport_; |
| 609 } | 621 } |
| 610 }; | 622 }; |
| OLD | NEW |