Chromium Code Reviews| Index: chrome/browser/resources/pdf/pdf.js |
| diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js |
| index 0de26003e2a5426058c48c347605d2e51777fadf..d20afee162fd449b09642915d6c78e16e1e78740 100644 |
| --- a/chrome/browser/resources/pdf/pdf.js |
| +++ b/chrome/browser/resources/pdf/pdf.js |
| @@ -141,6 +141,7 @@ function PDFViewer(streamDetails) { |
| // Parse open pdf parameters. |
| this.paramsParser_ = new OpenPDFParamsParser(); |
| + this.navigatePDF_ = new NavigationPDF(); |
|
raymes
2015/01/20 02:58:29
this.navigator_ = new Navigator(this.viewport_, th
Deepak
2015/01/20 07:08:37
we should not pass these here as information in th
|
| } |
| PDFViewer.prototype = { |
| @@ -347,64 +348,6 @@ PDFViewer.prototype = { |
| /** |
| * @private |
| - * Helper function to navigate to given URL. This might involve navigating |
| - * within the PDF page or opening a new url (in the same tab or a new tab). |
| - * @param {string} url The URL to navigate to. |
| - * @param {boolean} newTab Whether to perform the navigation in a new tab or |
| - * in the current tab. |
| - */ |
| - navigate_: function(url, newTab) { |
| - if (url.length == 0) |
| - return; |
| - var originalUrl = this.streamDetails_.originalUrl; |
| - // If |urlFragment| starts with '#', then it's for the same URL with a |
| - // different URL fragment. |
| - if (url.charAt(0) == '#') { |
| - // if '#' is already present in |originalUrl| then remove old fragment |
| - // and add new url fragment. |
| - var hashIndex = originalUrl.search('#'); |
| - if (hashIndex != -1) |
| - url = originalUrl.substring(0, hashIndex) + url; |
| - else |
| - url = originalUrl + url; |
| - } |
| - |
| - var inputURL = url; |
| - // If there's no scheme, add http. |
| - if (inputURL.indexOf('://') == -1 && inputURL.indexOf('mailto:') == -1) |
| - inputURL = 'http://' + inputURL; |
| - |
| - // Make sure inputURL starts with a valid scheme. |
| - if (inputURL.indexOf('http://') != 0 && |
| - inputURL.indexOf('https://') != 0 && |
| - inputURL.indexOf('ftp://') != 0 && |
| - inputURL.indexOf('file://') != 0 && |
| - inputURL.indexOf('mailto:') != 0) { |
| - return; |
| - } |
| - // Make sure inputURL is not only a scheme. |
| - if (inputURL == 'http://' || |
| - inputURL == 'https://' || |
| - inputURL == 'ftp://' || |
| - inputURL == 'file://' || |
| - inputURL == 'mailto:') { |
| - return; |
| - } |
| - |
| - if (newTab) { |
| - chrome.tabs.create({ url: inputURL }); |
| - } else { |
| - var pageNumber = |
| - this.paramsParser_.getViewportFromUrlParams(inputURL).page; |
| - if (pageNumber != undefined) |
| - this.viewport_.goToPage(pageNumber); |
| - else |
| - window.location.href = inputURL; |
| - } |
| - }, |
| - |
| - /** |
| - * @private |
| * An event handler for handling message events received from the plugin. |
| * @param {MessageObject} message a message event. |
| */ |
| @@ -450,7 +393,8 @@ PDFViewer.prototype = { |
| case 'navigate': |
| if (this.isPrintPreview_) |
| break; |
| - this.navigate_(message.data.url, message.data.newTab); |
| + this.navigatePDF_.navigate(message.data.url, message.data.newTab, |
| + this.streamDetails_.originalUrl); |
| break; |
| case 'setNamedDestinations': |
| this.paramsParser_.namedDestinations = message.data.namedDestinations; |