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

Side by Side Diff: chrome/browser/devtools/devtools_window.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 "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 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 1099
1101 void DevToolsWindow::RunFileChooser(content::RenderFrameHost* render_frame_host, 1100 void DevToolsWindow::RunFileChooser(content::RenderFrameHost* render_frame_host,
1102 const content::FileChooserParams& params) { 1101 const content::FileChooserParams& params) {
1103 FileSelectHelper::RunFileChooser(render_frame_host, params); 1102 FileSelectHelper::RunFileChooser(render_frame_host, params);
1104 } 1103 }
1105 1104
1106 bool DevToolsWindow::PreHandleGestureEvent( 1105 bool DevToolsWindow::PreHandleGestureEvent(
1107 WebContents* source, 1106 WebContents* source,
1108 const blink::WebGestureEvent& event) { 1107 const blink::WebGestureEvent& event) {
1109 // Disable pinch zooming. 1108 // Disable pinch zooming.
1110 return event.type == blink::WebGestureEvent::GesturePinchBegin || 1109 return event.type() == blink::WebGestureEvent::GesturePinchBegin ||
1111 event.type == blink::WebGestureEvent::GesturePinchUpdate || 1110 event.type() == blink::WebGestureEvent::GesturePinchUpdate ||
1112 event.type == blink::WebGestureEvent::GesturePinchEnd; 1111 event.type() == blink::WebGestureEvent::GesturePinchEnd;
1113 } 1112 }
1114 1113
1115 void DevToolsWindow::ShowCertificateViewerInDevTools( 1114 void DevToolsWindow::ShowCertificateViewerInDevTools(
1116 content::WebContents* web_contents, 1115 content::WebContents* web_contents,
1117 scoped_refptr<net::X509Certificate> certificate) { 1116 scoped_refptr<net::X509Certificate> certificate) {
1118 ShowCertificateViewer(certificate); 1117 ShowCertificateViewer(certificate);
1119 } 1118 }
1120 1119
1121 void DevToolsWindow::ActivateWindow() { 1120 void DevToolsWindow::ActivateWindow() {
1122 if (life_stage_ != kLoadCompleted) 1121 if (life_stage_ != kLoadCompleted)
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) { 1381 bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) {
1383 // Only route reload via front-end if the agent is attached. 1382 // Only route reload via front-end if the agent is attached.
1384 WebContents* wc = GetInspectedWebContents(); 1383 WebContents* wc = GetInspectedWebContents();
1385 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING) 1384 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING)
1386 return false; 1385 return false;
1387 base::FundamentalValue bypass_cache_value(bypass_cache); 1386 base::FundamentalValue bypass_cache_value(bypass_cache);
1388 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage", 1387 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage",
1389 &bypass_cache_value, nullptr, nullptr); 1388 &bypass_cache_value, nullptr, nullptr);
1390 return true; 1389 return true;
1391 } 1390 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698