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