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

Side by Side Diff: chrome/browser/resources/pdf/pdf.js

Issue 2127383002: Open hyperlinks in PDF in a new tab when middle mouse clicking. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Open hyperlinks in PDF in a new tab when middle mouse clicking. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * @return {number} Width of a scrollbar in pixels 8 * @return {number} Width of a scrollbar in pixels
9 */ 9 */
10 function getScrollbarWidth() { 10 function getScrollbarWidth() {
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 this.toolbar_.docLength = 597 this.toolbar_.docLength =
598 this.documentDimensions_.pageDimensions.length; 598 this.documentDimensions_.pageDimensions.length;
599 } 599 }
600 break; 600 break;
601 case 'email': 601 case 'email':
602 var href = 'mailto:' + message.data.to + '?cc=' + message.data.cc + 602 var href = 'mailto:' + message.data.to + '?cc=' + message.data.cc +
603 '&bcc=' + message.data.bcc + '&subject=' + message.data.subject + 603 '&bcc=' + message.data.bcc + '&subject=' + message.data.subject +
604 '&body=' + message.data.body; 604 '&body=' + message.data.body;
605 window.location.href = href; 605 window.location.href = href;
606 break; 606 break;
607 case 'getLinkPositionReply':
608 var visiblePage = this.viewport_.getMostVisiblePage();
609 var visiblePageDimensions =
610 this.viewport_.getPageScreenRect(visiblePage);
611
612 var linkExists = false;
613 var viewportCoordinateX;
614 var viewportCoordinateY;
615 if (message.data.x !== undefined && message.data.y !== undefined) {
616 linkExists = true;
617 viewportCoordinateX = message.data.x + visiblePageDimensions.x;
618 viewportCoordinateY = message.data.y + visiblePageDimensions.y +
619 PDFViewer.MATERIAL_TOOLBAR_HEIGHT;
620 }
621
622 this.sendScriptingMessage_({
623 type: 'getLinkPositionReply',
624 linkExists: linkExists,
625 x: viewportCoordinateX,
626 y: viewportCoordinateY
627 });
628 break;
607 case 'getPassword': 629 case 'getPassword':
608 // If the password screen isn't up, put it up. Otherwise we're 630 // If the password screen isn't up, put it up. Otherwise we're
609 // responding to an incorrect password so deny it. 631 // responding to an incorrect password so deny it.
610 if (!this.passwordScreen_.active) 632 if (!this.passwordScreen_.active)
611 this.passwordScreen_.active = true; 633 this.passwordScreen_.active = true;
612 else 634 else
613 this.passwordScreen_.deny(); 635 this.passwordScreen_.deny();
614 break; 636 break;
615 case 'getSelectedTextReply': 637 case 'getSelectedTextReply':
616 this.sendScriptingMessage_(message.data); 638 this.sendScriptingMessage_(message.data);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 return; 794 return;
773 795
774 // Delay scripting messages from users of the scripting API until the 796 // Delay scripting messages from users of the scripting API until the
775 // document is loaded. This simplifies use of the APIs. 797 // document is loaded. This simplifies use of the APIs.
776 if (this.loadState_ != LoadState.SUCCESS) { 798 if (this.loadState_ != LoadState.SUCCESS) {
777 this.delayedScriptingMessages_.push(message); 799 this.delayedScriptingMessages_.push(message);
778 return; 800 return;
779 } 801 }
780 802
781 switch (message.data.type.toString()) { 803 switch (message.data.type.toString()) {
804 case 'getLinkPosition':
782 case 'getSelectedText': 805 case 'getSelectedText':
783 case 'print': 806 case 'print':
784 case 'selectAll': 807 case 'selectAll':
785 this.plugin_.postMessage(message.data); 808 this.plugin_.postMessage(message.data);
786 break; 809 break;
787 } 810 }
788 }, 811 },
789 812
790 /** 813 /**
791 * @private 814 * @private
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 * Each bookmark is an Object containing a: 897 * Each bookmark is an Object containing a:
875 * - title 898 * - title
876 * - page (optional) 899 * - page (optional)
877 * - array of children (themselves bookmarks) 900 * - array of children (themselves bookmarks)
878 * @type {Array} the top-level bookmarks of the PDF. 901 * @type {Array} the top-level bookmarks of the PDF.
879 */ 902 */
880 get bookmarks() { 903 get bookmarks() {
881 return this.bookmarks_; 904 return this.bookmarks_;
882 } 905 }
883 }; 906 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698