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

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 2775553002: Adds the ability for WebContentsDelegate to decide if event should be updated (Closed)
Patch Set: Fix compile Created 3 years, 9 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/browser/renderer_host/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <set> 9 #include <set>
10 #include <tuple> 10 #include <tuple>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "content/common/content_switches_internal.h" 57 #include "content/common/content_switches_internal.h"
58 #include "content/common/cursors/webcursor.h" 58 #include "content/common/cursors/webcursor.h"
59 #include "content/common/drag_messages.h" 59 #include "content/common/drag_messages.h"
60 #include "content/common/frame_messages.h" 60 #include "content/common/frame_messages.h"
61 #include "content/common/host_shared_bitmap_manager.h" 61 #include "content/common/host_shared_bitmap_manager.h"
62 #include "content/common/input_messages.h" 62 #include "content/common/input_messages.h"
63 #include "content/common/resize_params.h" 63 #include "content/common/resize_params.h"
64 #include "content/common/text_input_state.h" 64 #include "content/common/text_input_state.h"
65 #include "content/common/view_messages.h" 65 #include "content/common/view_messages.h"
66 #include "content/public/browser/browser_context.h" 66 #include "content/public/browser/browser_context.h"
67 #include "content/public/browser/keyboard_event_processing_result.h"
67 #include "content/public/browser/native_web_keyboard_event.h" 68 #include "content/public/browser/native_web_keyboard_event.h"
68 #include "content/public/browser/notification_service.h" 69 #include "content/public/browser/notification_service.h"
69 #include "content/public/browser/notification_types.h" 70 #include "content/public/browser/notification_types.h"
70 #include "content/public/browser/render_widget_host_iterator.h" 71 #include "content/public/browser/render_widget_host_iterator.h"
71 #include "content/public/browser/storage_partition.h" 72 #include "content/public/browser/storage_partition.h"
72 #include "content/public/common/content_constants.h" 73 #include "content/public/common/content_constants.h"
73 #include "content/public/common/content_switches.h" 74 #include "content/public/common/content_switches.h"
74 #include "content/public/common/result_codes.h" 75 #include "content/public/common/result_codes.h"
75 #include "content/public/common/web_preferences.h" 76 #include "content/public/common/web_preferences.h"
76 #include "gpu/GLES2/gl2extchromium.h" 77 #include "gpu/GLES2/gl2extchromium.h"
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 } 1160 }
1160 return; 1161 return;
1161 } 1162 }
1162 1163
1163 DispatchInputEventWithLatencyInfo(touch_event, &touch_with_latency.latency); 1164 DispatchInputEventWithLatencyInfo(touch_event, &touch_with_latency.latency);
1164 input_router_->SendTouchEvent(touch_with_latency); 1165 input_router_->SendTouchEvent(touch_with_latency);
1165 } 1166 }
1166 1167
1167 void RenderWidgetHostImpl::ForwardKeyboardEvent( 1168 void RenderWidgetHostImpl::ForwardKeyboardEvent(
1168 const NativeWebKeyboardEvent& key_event) { 1169 const NativeWebKeyboardEvent& key_event) {
1169 ForwardKeyboardEventWithCommands(key_event, nullptr); 1170 ForwardKeyboardEventWithCommands(key_event, nullptr, nullptr);
1170 } 1171 }
1171 1172
1172 void RenderWidgetHostImpl::ForwardKeyboardEventWithCommands( 1173 void RenderWidgetHostImpl::ForwardKeyboardEventWithCommands(
1173 const NativeWebKeyboardEvent& key_event, 1174 const NativeWebKeyboardEvent& key_event,
1174 const std::vector<EditCommand>* commands) { 1175 const std::vector<EditCommand>* commands,
1176 bool* update_event) {
1175 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardKeyboardEvent"); 1177 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardKeyboardEvent");
1176 if (owner_delegate_ && 1178 if (owner_delegate_ &&
1177 !owner_delegate_->MayRenderWidgetForwardKeyboardEvent(key_event)) { 1179 !owner_delegate_->MayRenderWidgetForwardKeyboardEvent(key_event)) {
1178 return; 1180 return;
1179 } 1181 }
1180 1182
1181 if (ShouldDropInputEvents()) 1183 if (ShouldDropInputEvents())
1182 return; 1184 return;
1183 1185
1184 if (!process_->HasConnection()) 1186 if (!process_->HasConnection())
(...skipping 24 matching lines...) Expand all
1209 DCHECK(key_event.type() == WebKeyboardEvent::RawKeyDown || 1211 DCHECK(key_event.type() == WebKeyboardEvent::RawKeyDown ||
1210 key_event.type() == WebKeyboardEvent::KeyDown); 1212 key_event.type() == WebKeyboardEvent::KeyDown);
1211 suppress_events_until_keydown_ = false; 1213 suppress_events_until_keydown_ = false;
1212 } 1214 }
1213 1215
1214 bool is_shortcut = false; 1216 bool is_shortcut = false;
1215 1217
1216 // Only pre-handle the key event if it's not handled by the input method. 1218 // Only pre-handle the key event if it's not handled by the input method.
1217 if (delegate_ && !key_event.skip_in_browser) { 1219 if (delegate_ && !key_event.skip_in_browser) {
1218 // We need to set |suppress_events_until_keydown_| to true if 1220 // We need to set |suppress_events_until_keydown_| to true if
1219 // PreHandleKeyboardEvent() returns true, but |this| may already be 1221 // PreHandleKeyboardEvent() handles the event, but |this| may already be
1220 // destroyed at that time. So set |suppress_events_until_keydown_| true 1222 // destroyed at that time. So set |suppress_events_until_keydown_| true
1221 // here, then revert it afterwards when necessary. 1223 // here, then revert it afterwards when necessary.
1222 if (key_event.type() == WebKeyboardEvent::RawKeyDown) 1224 if (key_event.type() == WebKeyboardEvent::RawKeyDown)
1223 suppress_events_until_keydown_ = true; 1225 suppress_events_until_keydown_ = true;
1224 1226
1225 // Tab switching/closing accelerators aren't sent to the renderer to avoid 1227 // Tab switching/closing accelerators aren't sent to the renderer to avoid
1226 // a hung/malicious renderer from interfering. 1228 // a hung/malicious renderer from interfering.
1227 if (delegate_->PreHandleKeyboardEvent(key_event, &is_shortcut)) 1229 switch (delegate_->PreHandleKeyboardEvent(key_event)) {
1228 return; 1230 case KeyboardEventProcessingResult::HANDLED:
1231 return;
1232 #if defined(USE_AURA)
1233 case KeyboardEventProcessingResult::HANDLED_DONT_UPDATE_EVENT:
1234 if (update_event)
1235 *update_event = false;
1236 return;
1237 #endif
1238 case KeyboardEventProcessingResult::NOT_HANDLED:
1239 break;
1240 case KeyboardEventProcessingResult::NOT_HANDLED_IS_SHORTCUT:
1241 is_shortcut = true;
1242 break;
1243 }
1229 1244
1230 if (key_event.type() == WebKeyboardEvent::RawKeyDown) 1245 if (key_event.type() == WebKeyboardEvent::RawKeyDown)
1231 suppress_events_until_keydown_ = false; 1246 suppress_events_until_keydown_ = false;
1232 } 1247 }
1233 1248
1234 if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event)) 1249 if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event))
1235 return; 1250 return;
1236 ui::LatencyInfo latency_info(ui::SourceEventType::OTHER); 1251 ui::LatencyInfo latency_info(ui::SourceEventType::OTHER);
1237 NativeWebKeyboardEventWithLatencyInfo key_event_with_latency(key_event, 1252 NativeWebKeyboardEventWithLatencyInfo key_event_with_latency(key_event,
1238 latency_info); 1253 latency_info);
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after
2615 // different from the receiver's. 2630 // different from the receiver's.
2616 file_system_file.url = 2631 file_system_file.url =
2617 GURL(storage::GetIsolatedFileSystemRootURIString( 2632 GURL(storage::GetIsolatedFileSystemRootURIString(
2618 file_system_url.origin(), filesystem_id, std::string()) 2633 file_system_url.origin(), filesystem_id, std::string())
2619 .append(register_name)); 2634 .append(register_name));
2620 file_system_file.filesystem_id = filesystem_id; 2635 file_system_file.filesystem_id = filesystem_id;
2621 } 2636 }
2622 } 2637 }
2623 2638
2624 } // namespace content 2639 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698