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

Side by Side Diff: chrome/browser/devtools/devtools_window.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 "chrome/browser/devtools/devtools_window.h" 5 #include "chrome/browser/devtools/devtools_window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 << "(" << key_code << "," << modifiers << ")"; 267 << "(" << key_code << "," << modifiers << ")";
268 continue; 268 continue;
269 } 269 }
270 whitelisted_keys_.insert(CombineKeyCodeAndModifiers(key_code, modifiers)); 270 whitelisted_keys_.insert(CombineKeyCodeAndModifiers(key_code, modifiers));
271 } 271 }
272 } 272 }
273 273
274 bool DevToolsEventForwarder::ForwardEvent( 274 bool DevToolsEventForwarder::ForwardEvent(
275 const content::NativeWebKeyboardEvent& event) { 275 const content::NativeWebKeyboardEvent& event) {
276 std::string event_type; 276 std::string event_type;
277 switch (event.type) { 277 switch (event.type()) {
278 case WebInputEvent::KeyDown: 278 case WebInputEvent::KeyDown:
279 case WebInputEvent::RawKeyDown: 279 case WebInputEvent::RawKeyDown:
280 event_type = kKeyDownEventName; 280 event_type = kKeyDownEventName;
281 break; 281 break;
282 case WebInputEvent::KeyUp: 282 case WebInputEvent::KeyUp:
283 event_type = kKeyUpEventName; 283 event_type = kKeyUpEventName;
284 break; 284 break;
285 default: 285 default:
286 return false; 286 return false;
287 } 287 }
288 288
289 int key_code = ui::LocatedToNonLocatedKeyboardCode( 289 int key_code = ui::LocatedToNonLocatedKeyboardCode(
290 static_cast<ui::KeyboardCode>(event.windowsKeyCode)); 290 static_cast<ui::KeyboardCode>(event.windowsKeyCode));
291 int modifiers = event.modifiers & (WebInputEvent::ShiftKey | 291 int modifiers =
292 WebInputEvent::ControlKey | 292 event.modifiers() & (WebInputEvent::ShiftKey | WebInputEvent::ControlKey |
293 WebInputEvent::AltKey | 293 WebInputEvent::AltKey | WebInputEvent::MetaKey);
294 WebInputEvent::MetaKey);
295 int key = CombineKeyCodeAndModifiers(key_code, modifiers); 294 int key = CombineKeyCodeAndModifiers(key_code, modifiers);
296 if (whitelisted_keys_.find(key) == whitelisted_keys_.end()) 295 if (whitelisted_keys_.find(key) == whitelisted_keys_.end())
297 return false; 296 return false;
298 297
299 base::DictionaryValue event_data; 298 base::DictionaryValue event_data;
300 event_data.SetString("type", event_type); 299 event_data.SetString("type", event_type);
301 event_data.SetString("key", ui::KeycodeConverter::DomKeyToKeyString( 300 event_data.SetString("key", ui::KeycodeConverter::DomKeyToKeyString(
302 static_cast<ui::DomKey>(event.domKey))); 301 static_cast<ui::DomKey>(event.domKey)));
303 event_data.SetString("code", ui::KeycodeConverter::DomCodeToCodeString( 302 event_data.SetString("code", ui::KeycodeConverter::DomCodeToCodeString(
304 static_cast<ui::DomCode>(event.domCode))); 303 static_cast<ui::DomCode>(event.domCode)));
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 1118
1120 void DevToolsWindow::RunFileChooser(content::RenderFrameHost* render_frame_host, 1119 void DevToolsWindow::RunFileChooser(content::RenderFrameHost* render_frame_host,
1121 const content::FileChooserParams& params) { 1120 const content::FileChooserParams& params) {
1122 FileSelectHelper::RunFileChooser(render_frame_host, params); 1121 FileSelectHelper::RunFileChooser(render_frame_host, params);
1123 } 1122 }
1124 1123
1125 bool DevToolsWindow::PreHandleGestureEvent( 1124 bool DevToolsWindow::PreHandleGestureEvent(
1126 WebContents* source, 1125 WebContents* source,
1127 const blink::WebGestureEvent& event) { 1126 const blink::WebGestureEvent& event) {
1128 // Disable pinch zooming. 1127 // Disable pinch zooming.
1129 return event.type == blink::WebGestureEvent::GesturePinchBegin || 1128 return event.type() == blink::WebGestureEvent::GesturePinchBegin ||
1130 event.type == blink::WebGestureEvent::GesturePinchUpdate || 1129 event.type() == blink::WebGestureEvent::GesturePinchUpdate ||
1131 event.type == blink::WebGestureEvent::GesturePinchEnd; 1130 event.type() == blink::WebGestureEvent::GesturePinchEnd;
1132 } 1131 }
1133 1132
1134 void DevToolsWindow::ShowCertificateViewerInDevTools( 1133 void DevToolsWindow::ShowCertificateViewerInDevTools(
1135 content::WebContents* web_contents, 1134 content::WebContents* web_contents,
1136 scoped_refptr<net::X509Certificate> certificate) { 1135 scoped_refptr<net::X509Certificate> certificate) {
1137 ShowCertificateViewer(certificate); 1136 ShowCertificateViewer(certificate);
1138 } 1137 }
1139 1138
1140 void DevToolsWindow::ActivateWindow() { 1139 void DevToolsWindow::ActivateWindow() {
1141 if (life_stage_ != kLoadCompleted) 1140 if (life_stage_ != kLoadCompleted)
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) { 1390 bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) {
1392 // Only route reload via front-end if the agent is attached. 1391 // Only route reload via front-end if the agent is attached.
1393 WebContents* wc = GetInspectedWebContents(); 1392 WebContents* wc = GetInspectedWebContents();
1394 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING) 1393 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING)
1395 return false; 1394 return false;
1396 base::FundamentalValue bypass_cache_value(bypass_cache); 1395 base::FundamentalValue bypass_cache_value(bypass_cache);
1397 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage", 1396 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage",
1398 &bypass_cache_value, nullptr, nullptr); 1397 &bypass_cache_value, nullptr, nullptr);
1399 return true; 1398 return true;
1400 } 1399 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/ui/webui_login_view.cc ('k') | chrome/browser/extensions/extension_view_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698