Chromium Code Reviews| Index: chrome/browser/resources/pdf/navigator.js |
| diff --git a/chrome/browser/resources/pdf/navigator.js b/chrome/browser/resources/pdf/navigator.js |
| index 93445413df9c719c54a42ca9b065facee1c13b78..439720cbab45f1be5bbb926d60d9a639ea1645c5 100644 |
| --- a/chrome/browser/resources/pdf/navigator.js |
| +++ b/chrome/browser/resources/pdf/navigator.js |
| @@ -11,21 +11,32 @@ |
| * @param {Object} paramsParser The object for URL parsing. |
| * @param {Function} navigateInCurrentTabCallback The Callback function that |
| * gets called when navigation happens in the current tab. |
| - * @param {Function} navigateInNewBackgroundTabCallback The Callback function |
| - * that gets called when navigation happens in the new background tab. |
| + * @param {Function} navigateInNewTabCallback The Callback function |
| + * that gets called when navigation happens in the new tab. |
| */ |
| function Navigator(originalUrl, |
| viewport, |
| paramsParser, |
| navigateInCurrentTabCallback, |
| - navigateInNewBackgroundTabCallback) { |
| + navigateInNewTabCallback) { |
| this.originalUrl_ = originalUrl; |
| this.viewport_ = viewport; |
| this.paramsParser_ = paramsParser; |
| this.navigateInCurrentTabCallback_ = navigateInCurrentTabCallback; |
| - this.navigateInNewBackgroundTabCallback_ = navigateInNewBackgroundTabCallback; |
| + this.navigateInNewTabCallback_ = navigateInNewTabCallback; |
| } |
| +/** |
| + * Represents options when navigating to a new url. |
|
Lei Zhang
2016/07/21 05:34:28
You still need a comment to mention where the C++
jaepark
2016/07/21 22:34:33
Done.
|
| + * @enum {number} |
| + */ |
| +Navigator.NavigateOption = { |
| + OPEN_IN_CURRENT_TAB: 0, |
| + OPEN_IN_NEW_BACKGROUND_TAB: 1, |
| + OPEN_IN_NEW_FOREGROUND_TAB: 2, |
| + OPEN_IN_NEW_WINDOW: 3 |
| +}; |
| + |
| Navigator.prototype = { |
| /** |
| * @private |
| @@ -35,7 +46,7 @@ Navigator.prototype = { |
| * @param {boolean} newTab Whether to perform the navigation in a new tab or |
| * in the current tab. |
| */ |
| - navigate: function(url, newTab) { |
| + navigate: function(url, navigateOption) { |
| if (url.length == 0) |
| return; |
| @@ -58,11 +69,23 @@ Navigator.prototype = { |
| if (!this.isValidUrl_(url)) |
| return; |
| - if (newTab) { |
| - this.navigateInNewBackgroundTabCallback_(url); |
| - } else { |
| - this.paramsParser_.getViewportFromUrlParams( |
| - url, this.onViewportReceived_.bind(this)); |
| + var NavigateOption = Navigator.NavigateOption; |
| + switch (navigateOption) { |
| + case NavigateOption.OPEN_IN_CURRENT_TAB: |
| + case NavigateOption.OPEN_IN_NEW_WINDOW: |
| + // TODO (jaepark): It should navigate in a new window when |
| + // shift + left clicking link in PDFs. See http://crbug.com/628057. |
| + this.paramsParser_.getViewportFromUrlParams( |
| + url, this.onViewportReceived_.bind(this)); |
| + break; |
| + case NavigateOption.OPEN_IN_NEW_BACKGROUND_TAB: |
| + this.navigateInNewTabCallback_(url, false); |
| + break; |
| + case NavigateOption.OPEN_IN_NEW_FOREGROUND_TAB: |
| + this.navigateInNewTabCallback_(url, true); |
| + break; |
| + default: |
| + break; |
| } |
| }, |