summaryrefslogtreecommitdiffstats
path: root/pdf/out_of_process_instance.cc
diff options
context:
space:
mode:
authorraymes <raymes@chromium.org>2015-01-12 21:02:46 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-13 05:03:42 +0000
commitd914d7d0903eda0b9ae77c5d0adb7a6a61c95e13 (patch)
tree17920fea9da172eece41a2a5a06f350e3cf95e4e /pdf/out_of_process_instance.cc
parent317e773e3499fe6a19871b5498a5c6164d972316 (diff)
downloadchromium_src-d914d7d0903eda0b9ae77c5d0adb7a6a61c95e13.zip
chromium_src-d914d7d0903eda0b9ae77c5d0adb7a6a61c95e13.tar.gz
chromium_src-d914d7d0903eda0b9ae77c5d0adb7a6a61c95e13.tar.bz2
Add print and getSelectedText functions to the OOP PDF scripting API
These are needed by some internal users (see the bug for more details). A test is added for selectAll/getSelectedText. BUG=415858 Review URL: https://codereview.chromium.org/843463002 Cr-Commit-Position: refs/heads/master@{#311218}
Diffstat (limited to 'pdf/out_of_process_instance.cc')
-rw-r--r--pdf/out_of_process_instance.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc
index a7c5340..4e76e32 100644
--- a/pdf/out_of_process_instance.cc
+++ b/pdf/out_of_process_instance.cc
@@ -127,6 +127,11 @@ const char kJSRotateClockwiseType[] = "rotateClockwise";
const char kJSRotateCounterclockwiseType[] = "rotateCounterclockwise";
// Select all text in the document (Page -> Plugin)
const char kJSSelectAllType[] = "selectAll";
+// Get the selected text in the document (Page -> Plugin)
+const char kJSGetSelectedTextType[] = "getSelectedText";
+// Reply with selected text (Plugin -> Page)
+const char kJSGetSelectedTextReplyType[] = "getSelectedTextReply";
+const char kJSSelectedText[] = "selectedText";
const int kFindResultCooldownMs = 100;
@@ -444,6 +449,14 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) {
PostMessage(reply);
} else if (type == kJSStopScrollingType) {
stop_scrolling_ = true;
+ } else if (type == kJSGetSelectedTextType) {
+ std::string selected_text = engine_->GetSelectedText();
+ // Always return unix newlines to JS.
+ base::ReplaceChars(selected_text, "\r", std::string(), &selected_text);
+ pp::VarDictionary reply;
+ reply.Set(pp::Var(kType), pp::Var(kJSGetSelectedTextReplyType));
+ reply.Set(pp::Var(kJSSelectedText), selected_text);
+ PostMessage(reply);
} else {
NOTREACHED();
}