summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordeepak.m1 <deepak.m1@samsung.com>2014-10-02 23:13:19 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-03 06:14:35 +0000
commit2faaced431869fd80ba281d230d0bc4bcfec32fb (patch)
tree21d068409b14396df116880171f90a24dca8ed0d
parent737f39b697dd822d1d117df19b7a0270a1707e69 (diff)
downloadchromium_src-2faaced431869fd80ba281d230d0bc4bcfec32fb.zip
chromium_src-2faaced431869fd80ba281d230d0bc4bcfec32fb.tar.gz
chromium_src-2faaced431869fd80ba281d230d0bc4bcfec32fb.tar.bz2
Handle the keyboard event for ctrl+a inside pdf.js instead of out_of_process_pdf.cc
This moves the logic to handle the ctrl+a keyboard event into the pdf.js container page, sending a message to the plugin to select all the text. This ensures that the event is handled, even if the plugin element doesn't have focus in the document. BUG=419986 Review URL: https://codereview.chromium.org/615853003 Cr-Commit-Position: refs/heads/master@{#297998}
-rw-r--r--chrome/browser/resources/pdf/pdf.js7
-rw-r--r--pdf/out_of_process_instance.cc14
2 files changed, 11 insertions, 10 deletions
diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js
index 0616c8d..2b22e60 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -218,6 +218,13 @@ PDFViewer.prototype = {
this.viewport.position = position;
}
return;
+ case 65: // a key.
+ if (e.ctrlKey || e.metaKey) {
+ this.plugin_.postMessage({
+ type: 'selectAll',
+ });
+ }
+ return;
case 83: // s key.
if (e.ctrlKey || e.metaKey) {
// Simulate a click on the button so that the <a download ...>
diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc
index a385bb3..d627dc2 100644
--- a/pdf/out_of_process_instance.cc
+++ b/pdf/out_of_process_instance.cc
@@ -127,6 +127,8 @@ const char kJSEmailBody[] = "body";
// Rotation (Page -> Plugin)
const char kJSRotateClockwiseType[] = "rotateClockwise";
const char kJSRotateCounterclockwiseType[] = "rotateCounterclockwise";
+// Select all text in the document (Page -> Plugin)
+const char kJSSelectAllType[] = "selectAll";
const int kFindResultCooldownMs = 100;
@@ -381,6 +383,8 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) {
RotateClockwise();
} else if (type == kJSRotateCounterclockwiseType) {
RotateCounterclockwise();
+ } else if (type == kJSSelectAllType) {
+ engine_->SelectAll();
} else if (type == kJSResetPrintPreviewModeType &&
dict.Get(pp::Var(kJSPrintPreviewUrl)).is_string() &&
dict.Get(pp::Var(kJSPrintPreviewGrayscale)).is_bool() &&
@@ -488,16 +492,6 @@ bool OutOfProcessInstance::HandleInputEvent(
// TODO(raymes): Implement this scroll behavior in JS:
// When click+dragging, scroll the document correctly.
- if (event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN &&
- event.GetModifiers() & kDefaultKeyModifier) {
- pp::KeyboardInputEvent keyboard_event(event);
- switch (keyboard_event.GetKeyCode()) {
- case 'A':
- engine_->SelectAll();
- return true;
- }
- }
-
// Return true for unhandled clicks so the plugin takes focus.
return (event.GetType() == PP_INPUTEVENT_TYPE_MOUSEDOWN);
}