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

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

Issue 843463002: Add print and getSelectedText functions to the OOP PDF scripting API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@postMessage-api
Patch Set: 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 | « chrome/browser/resources/pdf/pdf.js ('k') | chrome/test/data/pdf/basic_plugin_test.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
*/
« no previous file with comments | « chrome/browser/resources/pdf/pdf.js ('k') | chrome/test/data/pdf/basic_plugin_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698