Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Unified Diff: chrome/browser/resources/pdf/navigator.js

Issue 838723003: Testcases for nameddests and navigate for PDF (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing nit. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/pdf/pdf.js » ('j') | chrome/test/data/pdf/navigator_test.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
}
}
};
« no previous file with comments | « no previous file | chrome/browser/resources/pdf/pdf.js » ('j') | chrome/test/data/pdf/navigator_test.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698