| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/extensions/api/input/input.h" | 5 #include "chrome/browser/extensions/api/input/input.h" |
| 6 | 6 |
| 7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 49 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 50 keyboard::switches::kEnableSwipeSelection)) { | 50 keyboard::switches::kEnableSwipeSelection)) { |
| 51 return false; | 51 return false; |
| 52 } | 52 } |
| 53 | 53 |
| 54 int swipe_direction; | 54 int swipe_direction; |
| 55 int modifier_flags; | 55 int modifier_flags; |
| 56 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &swipe_direction)); | 56 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &swipe_direction)); |
| 57 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &modifier_flags)); | 57 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &modifier_flags)); |
| 58 | 58 |
| 59 return keyboard::MoveCursor(swipe_direction, modifier_flags, | 59 return keyboard::MoveCursor( |
| 60 ash::Shell::GetPrimaryRootWindow()); | 60 swipe_direction, |
| 61 modifier_flags, |
| 62 ash::Shell::GetPrimaryRootWindow()->GetDispatcher()); |
| 61 #endif | 63 #endif |
| 62 error_ = kNotYetImplementedError; | 64 error_ = kNotYetImplementedError; |
| 63 return false; | 65 return false; |
| 64 } | 66 } |
| 65 | 67 |
| 66 bool VirtualKeyboardPrivateSendKeyEventFunction::RunImpl() { | 68 bool VirtualKeyboardPrivateSendKeyEventFunction::RunImpl() { |
| 67 #if defined(USE_ASH) | 69 #if defined(USE_ASH) |
| 68 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 70 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 69 | 71 |
| 70 base::Value* options_value = NULL; | 72 base::Value* options_value = NULL; |
| 71 base::DictionaryValue* params = NULL; | 73 base::DictionaryValue* params = NULL; |
| 72 std::string type; | 74 std::string type; |
| 73 int char_value; | 75 int char_value; |
| 74 int key_code; | 76 int key_code; |
| 75 bool shift_modifier; | 77 bool shift_modifier; |
| 76 | 78 |
| 77 EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &options_value)); | 79 EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &options_value)); |
| 78 EXTENSION_FUNCTION_VALIDATE(options_value->GetAsDictionary(¶ms)); | 80 EXTENSION_FUNCTION_VALIDATE(options_value->GetAsDictionary(¶ms)); |
| 79 EXTENSION_FUNCTION_VALIDATE(params->GetString("type", &type)); | 81 EXTENSION_FUNCTION_VALIDATE(params->GetString("type", &type)); |
| 80 EXTENSION_FUNCTION_VALIDATE(params->GetInteger("charValue", &char_value)); | 82 EXTENSION_FUNCTION_VALIDATE(params->GetInteger("charValue", &char_value)); |
| 81 EXTENSION_FUNCTION_VALIDATE(params->GetInteger("keyCode", &key_code)); | 83 EXTENSION_FUNCTION_VALIDATE(params->GetInteger("keyCode", &key_code)); |
| 82 EXTENSION_FUNCTION_VALIDATE(params->GetBoolean("shiftKey", &shift_modifier)); | 84 EXTENSION_FUNCTION_VALIDATE(params->GetBoolean("shiftKey", &shift_modifier)); |
| 83 | 85 |
| 84 return keyboard::SendKeyEvent(type, | 86 return keyboard::SendKeyEvent( |
| 85 char_value, | 87 type, |
| 86 key_code, | 88 char_value, |
| 87 shift_modifier, | 89 key_code, |
| 88 ash::Shell::GetPrimaryRootWindow()); | 90 shift_modifier, |
| 91 ash::Shell::GetPrimaryRootWindow()->GetDispatcher()); |
| 89 #endif | 92 #endif |
| 90 error_ = kNotYetImplementedError; | 93 error_ = kNotYetImplementedError; |
| 91 return false; | 94 return false; |
| 92 } | 95 } |
| 93 | 96 |
| 94 bool VirtualKeyboardPrivateHideKeyboardFunction::RunImpl() { | 97 bool VirtualKeyboardPrivateHideKeyboardFunction::RunImpl() { |
| 95 #if defined(USE_ASH) | 98 #if defined(USE_ASH) |
| 96 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 99 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 97 | 100 |
| 98 UMA_HISTOGRAM_ENUMERATION( | 101 UMA_HISTOGRAM_ENUMERATION( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 119 | 122 |
| 120 static base::LazyInstance<ProfileKeyedAPIFactory<InputAPI> > | 123 static base::LazyInstance<ProfileKeyedAPIFactory<InputAPI> > |
| 121 g_factory = LAZY_INSTANCE_INITIALIZER; | 124 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 122 | 125 |
| 123 // static | 126 // static |
| 124 ProfileKeyedAPIFactory<InputAPI>* InputAPI::GetFactoryInstance() { | 127 ProfileKeyedAPIFactory<InputAPI>* InputAPI::GetFactoryInstance() { |
| 125 return &g_factory.Get(); | 128 return &g_factory.Get(); |
| 126 } | 129 } |
| 127 | 130 |
| 128 } // namespace extensions | 131 } // namespace extensions |
| OLD | NEW |