Index: chrome/browser/resources/pdf/navigator.js |
diff --git a/chrome/browser/resources/pdf/navigator.js b/chrome/browser/resources/pdf/navigator.js |
index b07c98cdb33ce0332840154a06b353fd99e2e61f..334bc99baa88a18591a4fd98d41254fe2727e458 100644 |
--- a/chrome/browser/resources/pdf/navigator.js |
+++ b/chrome/browser/resources/pdf/navigator.js |
@@ -9,14 +9,48 @@ |
* @param {string} originalUrl The original page URL. |
* @param {Object} viewport The viewport info of the page. |
* @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} navigateInNewTabCallback The Callback function that gets |
+ * called when navigation happens in the new tab. |
*/ |
-function Navigator(originalUrl, viewport, paramsParser) { |
+function Navigator(originalUrl, |
+ viewport, |
+ paramsParser, |
+ navigateInCurrentTabCallback, |
+ navigateInNewTabCallback) { |
this.originalUrl_ = originalUrl; |
this.viewport_ = viewport; |
this.paramsParser_ = paramsParser; |
+ this.navigateInCurrentTabCallback_ = navigateInCurrentTabCallback; |
+ this.navigateInNewTabCallback_ = navigateInNewTabCallback; |
} |
Navigator.prototype = { |
+ |
+ /** |
+ * @private |
+ * Called when navigation happens in the current tab. |
+ * @param {string} url The url to be opened in the current tab. |
+ */ |
+ navigateInCurrentTab_: function(url) { |
+ window.location.href = url; |
+ this.navigateInCurrentTabCallback_(); |
+ }, |
+ |
+ /** |
+ * @private |
+ * Called when navigation happens in the new tab. |
+ * @param {string} url The url to be opened in the new tab. |
+ */ |
+ navigateInNewTab_: function(url) { |
raymes
2015/01/30 03:45:03
These functions should be defined inside pdf.js an
Deepak
2015/01/30 04:39:21
Done.
|
+ if (chrome.tabs) |
+ chrome.tabs.create({ url: url}); |
+ else |
+ window.open(url); |
+ this.navigateInNewTabCallback_(); |
+ }, |
+ |
/** |
* @private |
* Function to navigate to the given URL. This might involve navigating |
@@ -62,19 +96,14 @@ Navigator.prototype = { |
} |
if (newTab) { |
- // Prefer the tabs API because it guarantees we can just open a new tab. |
- // window.open doesn't have this guarantee. |
- if (chrome.tabs) |
- chrome.tabs.create({ url: url }); |
- else |
- window.open(url); |
+ this.navigateInNewTab_(url); |
raymes
2015/01/30 03:45:03
this should just call this.navigateInNewTabCallbac
Deepak
2015/01/30 04:39:21
Done.
|
} else { |
var pageNumber = |
this.paramsParser_.getViewportFromUrlParams(url).page; |
if (pageNumber != undefined) |
this.viewport_.goToPage(pageNumber); |
else |
- window.location.href = url; |
+ this.navigateInCurrentTab_(url); |
raymes
2015/01/30 03:45:03
this should just call this.navigateInCurrentTabCal
Deepak
2015/01/30 04:39:21
Done.
|
} |
} |
}; |