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

Side by Side Diff: content/renderer/pepper/pepper_plugin_instance_impl.cc

Issue 2573073003: Collapse the API surface on WebInputEvent via accessor functions. (Closed)
Patch Set: Fix nits Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bit_cast.h" 10 #include "base/bit_cast.h"
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 array[i] = vector[i].c_str(); 313 array[i] = vector[i].c_str();
314 return array; 314 return array;
315 } 315 }
316 316
317 // Returns true if this is a "system reserved" key which should not be sent to 317 // Returns true if this is a "system reserved" key which should not be sent to
318 // a plugin. Some poorly behaving plugins (like Flash) incorrectly report that 318 // a plugin. Some poorly behaving plugins (like Flash) incorrectly report that
319 // they handle all keys sent to them. This can prevent keystrokes from working 319 // they handle all keys sent to them. This can prevent keystrokes from working
320 // for things like screen brightness and volume control. 320 // for things like screen brightness and volume control.
321 bool IsReservedSystemInputEvent(const blink::WebInputEvent& event) { 321 bool IsReservedSystemInputEvent(const blink::WebInputEvent& event) {
322 #if defined(OS_CHROMEOS) 322 #if defined(OS_CHROMEOS)
323 if (event.type != WebInputEvent::KeyDown && 323 if (event.type() != WebInputEvent::KeyDown &&
324 event.type != WebInputEvent::KeyUp) 324 event.type() != WebInputEvent::KeyUp)
325 return false; 325 return false;
326 const blink::WebKeyboardEvent& key_event = 326 const blink::WebKeyboardEvent& key_event =
327 static_cast<const blink::WebKeyboardEvent&>(event); 327 static_cast<const blink::WebKeyboardEvent&>(event);
328 switch (key_event.windowsKeyCode) { 328 switch (key_event.windowsKeyCode) {
329 case ui::VKEY_BRIGHTNESS_DOWN: 329 case ui::VKEY_BRIGHTNESS_DOWN:
330 case ui::VKEY_BRIGHTNESS_UP: 330 case ui::VKEY_BRIGHTNESS_UP:
331 case ui::VKEY_KBD_BRIGHTNESS_DOWN: 331 case ui::VKEY_KBD_BRIGHTNESS_DOWN:
332 case ui::VKEY_KBD_BRIGHTNESS_UP: 332 case ui::VKEY_KBD_BRIGHTNESS_UP:
333 case ui::VKEY_VOLUME_MUTE: 333 case ui::VKEY_VOLUME_MUTE:
334 case ui::VKEY_VOLUME_DOWN: 334 case ui::VKEY_VOLUME_DOWN:
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 ConvertDIPToViewport(&caret); 1114 ConvertDIPToViewport(&caret);
1115 return caret; 1115 return caret;
1116 } 1116 }
1117 1117
1118 bool PepperPluginInstanceImpl::HandleInputEvent( 1118 bool PepperPluginInstanceImpl::HandleInputEvent(
1119 const blink::WebInputEvent& event, 1119 const blink::WebInputEvent& event,
1120 WebCursorInfo* cursor_info) { 1120 WebCursorInfo* cursor_info) {
1121 TRACE_EVENT0("ppapi", "PepperPluginInstanceImpl::HandleInputEvent"); 1121 TRACE_EVENT0("ppapi", "PepperPluginInstanceImpl::HandleInputEvent");
1122 1122
1123 if (!has_been_clicked_ && is_flash_plugin_ && 1123 if (!has_been_clicked_ && is_flash_plugin_ &&
1124 event.type == blink::WebInputEvent::MouseDown && 1124 event.type() == blink::WebInputEvent::MouseDown &&
1125 (event.modifiers & blink::WebInputEvent::LeftButtonDown)) { 1125 (event.modifiers() & blink::WebInputEvent::LeftButtonDown)) {
1126 has_been_clicked_ = true; 1126 has_been_clicked_ = true;
1127 blink::WebRect bounds = container()->element().boundsInViewport(); 1127 blink::WebRect bounds = container()->element().boundsInViewport();
1128 render_frame()->GetRenderWidget()->convertViewportToWindow(&bounds); 1128 render_frame()->GetRenderWidget()->convertViewportToWindow(&bounds);
1129 RecordFlashClickSizeMetric(bounds.width, bounds.height); 1129 RecordFlashClickSizeMetric(bounds.width, bounds.height);
1130 } 1130 }
1131 1131
1132 if (throttler_ && throttler_->ConsumeInputEvent(event)) 1132 if (throttler_ && throttler_->ConsumeInputEvent(event))
1133 return true; 1133 return true;
1134 1134
1135 if (!render_frame_) 1135 if (!render_frame_)
1136 return false; 1136 return false;
1137 if (WebInputEvent::isMouseEventType(event.type)) { 1137 if (WebInputEvent::isMouseEventType(event.type())) {
1138 render_frame_->PepperDidReceiveMouseEvent(this); 1138 render_frame_->PepperDidReceiveMouseEvent(this);
1139 } 1139 }
1140 1140
1141 // Don't dispatch input events to crashed plugins. 1141 // Don't dispatch input events to crashed plugins.
1142 if (module()->is_crashed()) 1142 if (module()->is_crashed())
1143 return false; 1143 return false;
1144 1144
1145 // Don't send reserved system key events to plugins. 1145 // Don't send reserved system key events to plugins.
1146 if (IsReservedSystemInputEvent(event)) 1146 if (IsReservedSystemInputEvent(event))
1147 return false; 1147 return false;
(...skipping 2317 matching lines...) Expand 10 before | Expand all | Expand 10 after
3465 const cc::TextureMailbox& mailbox) const { 3465 const cc::TextureMailbox& mailbox) const {
3466 auto it = 3466 auto it =
3467 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(), 3467 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(),
3468 [&mailbox](const TextureMailboxRefCount& ref_count) { 3468 [&mailbox](const TextureMailboxRefCount& ref_count) {
3469 return ref_count.first.mailbox() == mailbox.mailbox(); 3469 return ref_count.first.mailbox() == mailbox.mailbox();
3470 }); 3470 });
3471 return it != texture_ref_counts_.end(); 3471 return it != texture_ref_counts_.end();
3472 } 3472 }
3473 3473
3474 } // namespace content 3474 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/event_conversion_unittest.cc ('k') | content/renderer/pepper/plugin_instance_throttler_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698