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

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

Issue 2166193002: Handle ctrl + shift + left click on links in PDF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Handle ctrl + shift + left click on links in PDF. Created 4 years, 5 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
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..1509066acf2d7f15c6127479476e5ddb7e8579e5 100644
--- a/chrome/browser/resources/pdf/navigator.js
+++ b/chrome/browser/resources/pdf/navigator.js
@@ -11,21 +11,35 @@
* @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. C++ counterpart of
+ * the enum is in ui/base/window_open_disposition.h. This enum represents
+ * the only values that are passed from Plugin.
+ * @enum {number}
+ */
+Navigator.WindowOpenDisposition = {
+ CURRENT_TAB: 1,
+ NEW_FOREGROUND_TAB: 3,
+ NEW_BACKGROUND_TAB: 4,
+ NEW_WINDOW: 6,
+ SAVE_TO_DISK: 7
+};
+
Navigator.prototype = {
/**
* @private
@@ -35,7 +49,7 @@ Navigator.prototype = {
* @param {boolean} newTab Whether to perform the navigation in a new tab or
Lei Zhang 2016/07/25 22:10:02 Doc is out of date.
jaepark 2016/07/25 23:24:13 Done.
* in the current tab.
*/
- navigate: function(url, newTab) {
+ navigate: function(url, disposition) {
if (url.length == 0)
return;
@@ -58,11 +72,27 @@ Navigator.prototype = {
if (!this.isValidUrl_(url))
return;
- if (newTab) {
- this.navigateInNewBackgroundTabCallback_(url);
- } else {
- this.paramsParser_.getViewportFromUrlParams(
- url, this.onViewportReceived_.bind(this));
+ switch (disposition) {
+ case Navigator.WindowOpenDisposition.CURRENT_TAB:
+ this.paramsParser_.getViewportFromUrlParams(
+ url, this.onViewportReceived_.bind(this));
+ break;
+ case Navigator.WindowOpenDisposition.NEW_BACKGROUND_TAB:
+ this.navigateInNewTabCallback_(url, false);
+ break;
+ case Navigator.WindowOpenDisposition.NEW_FOREGROUND_TAB:
+ this.navigateInNewTabCallback_(url, true);
+ break;
+ case Navigator.WindowOpenDisposition.NEW_WINDOW:
+ // TODO (jaepark): It should navigate in a new window when
Lei Zhang 2016/07/25 22:10:02 no space after "TODO"
jaepark 2016/07/25 23:24:13 Done.
+ // shift + left clicking link in PDFs. See http://crbug.com/628057.
+ break;
Lei Zhang 2016/07/25 22:10:02 Previously these fell through to SAVE_TO_DISK, whi
jaepark 2016/07/25 23:24:13 Done.
+ case Navigator.WindowOpenDisposition.SAVE_TO_DISK:
+ // TODO (jaepark) : Alt + left clicking link in PDFs should
+ // donwload the link.
+ break;
+ default:
+ break;
}
},

Powered by Google App Engine
This is Rietveld 408576698