Chromium Code Reviews| Index: chrome/browser/resources/pdf/pdf_scripting_api.js |
| diff --git a/chrome/browser/resources/pdf/pdf_scripting_api.js b/chrome/browser/resources/pdf/pdf_scripting_api.js |
| index 978ef7859b961c3344ca2903f07b00d81738d51d..f14b5934092db254b71ce2b4a01b49d9f36cb6cd 100644 |
| --- a/chrome/browser/resources/pdf/pdf_scripting_api.js |
| +++ b/chrome/browser/resources/pdf/pdf_scripting_api.js |
| @@ -37,6 +37,12 @@ function PDFScriptingAPI(window, plugin) { |
| this.accessibilityCallback_ = null; |
| } |
| break; |
| + case 'getSelectedTextReply': |
| + if (this.selectedTextCallback_) { |
| + this.selectedTextCallback_(event.data.selectedText); |
| + this.selectedTextCallback_ = null; |
| + } |
| + break; |
| } |
| }.bind(this), false); |
| } |
| @@ -125,7 +131,8 @@ PDFScriptingAPI.prototype = { |
| }, |
| /** |
| - * Get accessibility JSON for the document. |
| + * Get accessibility JSON for the document. Must be called after document |
|
Sam McNally
2015/01/08 04:00:59
s/Must/May only/
Fix everywhere.
raymes
2015/01/08 22:23:03
Done.
|
| + * load. |
| * @param {Function} callback a callback to be called with the accessibility |
| * json that has been retrieved. |
| * @param {number} [page] the 0-indexed page number to get accessibility data |
| @@ -148,6 +155,41 @@ PDFScriptingAPI.prototype = { |
| }, |
| /** |
| + * Select all the text in the document. Must be called after document load. |
| + */ |
| + selectAll: function() { |
| + this.sendMessage_({ |
| + type: 'selectAll' |
| + }); |
| + }, |
| + |
| + /** |
| + * Get the selected text in the document. The callback will be called with the |
| + * text that is selected. Must be called after document load. |
| + * @param {Function} callback a callback to be called with the selected text. |
| + * @return {boolean} true if the function is successful, false if there is an |
| + * outstanding request for selected text that has not been answered. |
| + */ |
| + getSelectedText: function(callback) { |
| + if (this.selectedTextCallback_) |
| + return false; |
| + this.selectedTextCallback_ = callback; |
| + this.sendMessage_({ |
| + type: 'getSelectedText' |
| + }); |
| + return true; |
| + }, |
| + |
| + /** |
| + * Print the document. Must be called after document load. |
| + */ |
| + print: function() { |
| + this.sendMessage_({ |
| + type: 'print' |
| + }); |
| + }, |
| + |
| + /** |
| * Send a key event to the extension. |
| * @param {number} keyCode the key code to send to the extension. |
| */ |