| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/extension_input_api.h" | 5 #include "chrome/browser/extensions/extension_input_api.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "app/keyboard_code_conversion.h" | |
| 10 #include "base/values.h" | 9 #include "base/values.h" |
| 11 #include "chrome/browser/browser_window.h" | 10 #include "chrome/browser/browser_window.h" |
| 12 #include "chrome/browser/extensions/extension_tabs_module.h" | 11 #include "chrome/browser/extensions/extension_tabs_module.h" |
| 13 #include "chrome/browser/renderer_host/render_view_host.h" | 12 #include "chrome/browser/renderer_host/render_view_host.h" |
| 14 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/views/frame/browser_view.h" | 14 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 16 #include "chrome/common/native_web_keyboard_event.h" | 15 #include "chrome/common/native_web_keyboard_event.h" |
| 17 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" | 16 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" |
| 17 #include "ui/base/keycodes/keyboard_code_conversion.h" |
| 18 #include "views/event.h" | 18 #include "views/event.h" |
| 19 #include "views/widget/root_view.h" | 19 #include "views/widget/root_view.h" |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // Keys. | 23 // Keys. |
| 24 const char kType[] = "type"; | 24 const char kType[] = "type"; |
| 25 const char kKeyIdentifier[] = "keyIdentifier"; | 25 const char kKeyIdentifier[] = "keyIdentifier"; |
| 26 const char kAlt[] = "altKey"; | 26 const char kAlt[] = "altKey"; |
| 27 const char kCtrl[] = "ctrlKey"; | 27 const char kCtrl[] = "ctrlKey"; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 std::string type_name; | 76 std::string type_name; |
| 77 EXTENSION_FUNCTION_VALIDATE(args->GetString(kType, &type_name)); | 77 EXTENSION_FUNCTION_VALIDATE(args->GetString(kType, &type_name)); |
| 78 views::Event::EventType type = GetTypeFromString(type_name); | 78 views::Event::EventType type = GetTypeFromString(type_name); |
| 79 if (type == views::Event::ET_UNKNOWN) { | 79 if (type == views::Event::ET_UNKNOWN) { |
| 80 error_ = kUnknownEventTypeError; | 80 error_ = kUnknownEventTypeError; |
| 81 return false; | 81 return false; |
| 82 } | 82 } |
| 83 | 83 |
| 84 std::string identifier; | 84 std::string identifier; |
| 85 EXTENSION_FUNCTION_VALIDATE(args->GetString(kKeyIdentifier, &identifier)); | 85 EXTENSION_FUNCTION_VALIDATE(args->GetString(kKeyIdentifier, &identifier)); |
| 86 app::KeyboardCode code = app::KeyCodeFromKeyIdentifier(identifier); | 86 ui::KeyboardCode code = ui::KeyCodeFromKeyIdentifier(identifier); |
| 87 if (code == app::VKEY_UNKNOWN) { | 87 if (code == ui::VKEY_UNKNOWN) { |
| 88 error_ = kUnknownOrUnsupportedKeyIdentiferError; | 88 error_ = kUnknownOrUnsupportedKeyIdentiferError; |
| 89 return false; | 89 return false; |
| 90 } | 90 } |
| 91 | 91 |
| 92 int flags = 0; | 92 int flags = 0; |
| 93 bool alt = false; | 93 bool alt = false; |
| 94 if (args->GetBoolean(kAlt, &alt)) | 94 if (args->GetBoolean(kAlt, &alt)) |
| 95 flags |= alt ? WebKit::WebInputEvent::AltKey : 0; | 95 flags |= alt ? WebKit::WebInputEvent::AltKey : 0; |
| 96 bool ctrl = false; | 96 bool ctrl = false; |
| 97 if (args->GetBoolean(kCtrl, &ctrl)) | 97 if (args->GetBoolean(kCtrl, &ctrl)) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 110 } | 110 } |
| 111 | 111 |
| 112 views::KeyEvent event(type, code, flags, 0, 0); | 112 views::KeyEvent event(type, code, flags, 0, 0); |
| 113 if (!root_view->ProcessKeyEvent(event)) { | 113 if (!root_view->ProcessKeyEvent(event)) { |
| 114 error_ = kKeyEventUnprocessedError; | 114 error_ = kKeyEventUnprocessedError; |
| 115 return false; | 115 return false; |
| 116 } | 116 } |
| 117 | 117 |
| 118 return true; | 118 return true; |
| 119 } | 119 } |
| OLD | NEW |