OLD | NEW |
---|---|
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 Loading... | |
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(); | |
Lei Zhang
2016/07/08 18:02:35
Can you add a comment to say this translate page c
jaepark
2016/07/08 20:58:16
I used viewportCoordinateX and viewportCoordinateY
| |
609 var visiblePageDimensions = | |
610 this.viewport_.getPageScreenRect(visiblePage); | |
611 this.sendScriptingMessage_({ | |
612 type: 'getLinkPositionReply', | |
613 x: message.data.x + visiblePageDimensions.x, | |
Lei Zhang
2016/07/08 18:02:35
What if the plugin fails to find the link? Is x eq
jaepark
2016/07/08 20:58:16
I added linkExists field to check.
| |
614 y: message.data.y + visiblePageDimensions.y + | |
615 PDFViewer.MATERIAL_TOOLBAR_HEIGHT | |
616 }); | |
617 break; | |
607 case 'getPassword': | 618 case 'getPassword': |
608 // If the password screen isn't up, put it up. Otherwise we're | 619 // If the password screen isn't up, put it up. Otherwise we're |
609 // responding to an incorrect password so deny it. | 620 // responding to an incorrect password so deny it. |
610 if (!this.passwordScreen_.active) | 621 if (!this.passwordScreen_.active) |
611 this.passwordScreen_.active = true; | 622 this.passwordScreen_.active = true; |
612 else | 623 else |
613 this.passwordScreen_.deny(); | 624 this.passwordScreen_.deny(); |
614 break; | 625 break; |
615 case 'getSelectedTextReply': | 626 case 'getSelectedTextReply': |
616 this.sendScriptingMessage_(message.data); | 627 this.sendScriptingMessage_(message.data); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
772 return; | 783 return; |
773 | 784 |
774 // Delay scripting messages from users of the scripting API until the | 785 // Delay scripting messages from users of the scripting API until the |
775 // document is loaded. This simplifies use of the APIs. | 786 // document is loaded. This simplifies use of the APIs. |
776 if (this.loadState_ != LoadState.SUCCESS) { | 787 if (this.loadState_ != LoadState.SUCCESS) { |
777 this.delayedScriptingMessages_.push(message); | 788 this.delayedScriptingMessages_.push(message); |
778 return; | 789 return; |
779 } | 790 } |
780 | 791 |
781 switch (message.data.type.toString()) { | 792 switch (message.data.type.toString()) { |
793 case 'getLinkPosition': | |
782 case 'getSelectedText': | 794 case 'getSelectedText': |
783 case 'print': | 795 case 'print': |
784 case 'selectAll': | 796 case 'selectAll': |
785 this.plugin_.postMessage(message.data); | 797 this.plugin_.postMessage(message.data); |
786 break; | 798 break; |
787 } | 799 } |
788 }, | 800 }, |
789 | 801 |
790 /** | 802 /** |
791 * @private | 803 * @private |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
874 * Each bookmark is an Object containing a: | 886 * Each bookmark is an Object containing a: |
875 * - title | 887 * - title |
876 * - page (optional) | 888 * - page (optional) |
877 * - array of children (themselves bookmarks) | 889 * - array of children (themselves bookmarks) |
878 * @type {Array} the top-level bookmarks of the PDF. | 890 * @type {Array} the top-level bookmarks of the PDF. |
879 */ | 891 */ |
880 get bookmarks() { | 892 get bookmarks() { |
881 return this.bookmarks_; | 893 return this.bookmarks_; |
882 } | 894 } |
883 }; | 895 }; |
OLD | NEW |