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

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: Created 4 years 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 array[i] = vector[i].c_str(); 312 array[i] = vector[i].c_str();
313 return array; 313 return array;
314 } 314 }
315 315
316 // Returns true if this is a "system reserved" key which should not be sent to 316 // Returns true if this is a "system reserved" key which should not be sent to
317 // a plugin. Some poorly behaving plugins (like Flash) incorrectly report that 317 // a plugin. Some poorly behaving plugins (like Flash) incorrectly report that
318 // they handle all keys sent to them. This can prevent keystrokes from working 318 // they handle all keys sent to them. This can prevent keystrokes from working
319 // for things like screen brightness and volume control. 319 // for things like screen brightness and volume control.
320 bool IsReservedSystemInputEvent(const blink::WebInputEvent& event) { 320 bool IsReservedSystemInputEvent(const blink::WebInputEvent& event) {
321 #if defined(OS_CHROMEOS) 321 #if defined(OS_CHROMEOS)
322 if (event.type != WebInputEvent::KeyDown && 322 if (event.type() != WebInputEvent::KeyDown &&
323 event.type != WebInputEvent::KeyUp) 323 event.type() != WebInputEvent::KeyUp)
324 return false; 324 return false;
325 const blink::WebKeyboardEvent& key_event = 325 const blink::WebKeyboardEvent& key_event =
326 static_cast<const blink::WebKeyboardEvent&>(event); 326 static_cast<const blink::WebKeyboardEvent&>(event);
327 switch (key_event.windowsKeyCode) { 327 switch (key_event.windowsKeyCode) {
328 case ui::VKEY_BRIGHTNESS_DOWN: 328 case ui::VKEY_BRIGHTNESS_DOWN:
329 case ui::VKEY_BRIGHTNESS_UP: 329 case ui::VKEY_BRIGHTNESS_UP:
330 case ui::VKEY_KBD_BRIGHTNESS_DOWN: 330 case ui::VKEY_KBD_BRIGHTNESS_DOWN:
331 case ui::VKEY_KBD_BRIGHTNESS_UP: 331 case ui::VKEY_KBD_BRIGHTNESS_UP:
332 case ui::VKEY_VOLUME_MUTE: 332 case ui::VKEY_VOLUME_MUTE:
333 case ui::VKEY_VOLUME_DOWN: 333 case ui::VKEY_VOLUME_DOWN:
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 ConvertDIPToViewport(&caret); 1113 ConvertDIPToViewport(&caret);
1114 return caret; 1114 return caret;
1115 } 1115 }
1116 1116
1117 bool PepperPluginInstanceImpl::HandleInputEvent( 1117 bool PepperPluginInstanceImpl::HandleInputEvent(
1118 const blink::WebInputEvent& event, 1118 const blink::WebInputEvent& event,
1119 WebCursorInfo* cursor_info) { 1119 WebCursorInfo* cursor_info) {
1120 TRACE_EVENT0("ppapi", "PepperPluginInstanceImpl::HandleInputEvent"); 1120 TRACE_EVENT0("ppapi", "PepperPluginInstanceImpl::HandleInputEvent");
1121 1121
1122 if (!has_been_clicked_ && is_flash_plugin_ && 1122 if (!has_been_clicked_ && is_flash_plugin_ &&
1123 event.type == blink::WebInputEvent::MouseDown && 1123 event.type() == blink::WebInputEvent::MouseDown &&
1124 (event.modifiers & blink::WebInputEvent::LeftButtonDown)) { 1124 (event.modifiers() & blink::WebInputEvent::LeftButtonDown)) {
1125 has_been_clicked_ = true; 1125 has_been_clicked_ = true;
1126 blink::WebRect bounds = container()->element().boundsInViewport(); 1126 blink::WebRect bounds = container()->element().boundsInViewport();
1127 render_frame()->GetRenderWidget()->convertViewportToWindow(&bounds); 1127 render_frame()->GetRenderWidget()->convertViewportToWindow(&bounds);
1128 RecordFlashClickSizeMetric(bounds.width, bounds.height); 1128 RecordFlashClickSizeMetric(bounds.width, bounds.height);
1129 } 1129 }
1130 1130
1131 if (throttler_ && throttler_->ConsumeInputEvent(event)) 1131 if (throttler_ && throttler_->ConsumeInputEvent(event))
1132 return true; 1132 return true;
1133 1133
1134 if (!render_frame_) 1134 if (!render_frame_)
1135 return false; 1135 return false;
1136 if (WebInputEvent::isMouseEventType(event.type)) { 1136 if (WebInputEvent::isMouseEventType(event.type())) {
1137 render_frame_->PepperDidReceiveMouseEvent(this); 1137 render_frame_->PepperDidReceiveMouseEvent(this);
1138 } 1138 }
1139 1139
1140 // Don't dispatch input events to crashed plugins. 1140 // Don't dispatch input events to crashed plugins.
1141 if (module()->is_crashed()) 1141 if (module()->is_crashed())
1142 return false; 1142 return false;
1143 1143
1144 // Don't send reserved system key events to plugins. 1144 // Don't send reserved system key events to plugins.
1145 if (IsReservedSystemInputEvent(event)) 1145 if (IsReservedSystemInputEvent(event))
1146 return false; 1146 return false;
(...skipping 2309 matching lines...) Expand 10 before | Expand all | Expand 10 after
3456 const cc::TextureMailbox& mailbox) const { 3456 const cc::TextureMailbox& mailbox) const {
3457 auto it = 3457 auto it =
3458 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(), 3458 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(),
3459 [&mailbox](const TextureMailboxRefCount& ref_count) { 3459 [&mailbox](const TextureMailboxRefCount& ref_count) {
3460 return ref_count.first.mailbox() == mailbox.mailbox(); 3460 return ref_count.first.mailbox() == mailbox.mailbox();
3461 }); 3461 });
3462 return it != texture_ref_counts_.end(); 3462 return it != texture_ref_counts_.end();
3463 } 3463 }
3464 3464
3465 } // namespace content 3465 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698