| OLD | NEW |
| 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/extensions/api/input_ime/input_ime_api.h" | 5 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "chrome/common/extensions/api/input_ime.h" | 8 #include "chrome/common/extensions/api/input_ime.h" |
| 9 #include "extensions/browser/extension_registry.h" | 9 #include "extensions/browser/extension_registry.h" |
| 10 | 10 |
| 11 namespace input_ime = extensions::api::input_ime; | 11 namespace input_ime = extensions::api::input_ime; |
| 12 namespace KeyEventHandled = extensions::api::input_ime::KeyEventHandled; | 12 namespace KeyEventHandled = extensions::api::input_ime::KeyEventHandled; |
| 13 using ui::IMEEngineHandlerInterface; | 13 using ui::IMEEngineHandlerInterface; |
| 14 using input_method::InputMethodEngineBase; |
| 14 | 15 |
| 15 namespace ui { | 16 namespace ui { |
| 16 | 17 |
| 17 ImeObserver::ImeObserver(const std::string& extension_id, Profile* profile) | 18 ImeObserver::ImeObserver(const std::string& extension_id, Profile* profile) |
| 18 : extension_id_(extension_id), profile_(profile) {} | 19 : extension_id_(extension_id), profile_(profile) {} |
| 19 | 20 |
| 20 void ImeObserver::OnActivate(const std::string& component_id) { | 21 void ImeObserver::OnActivate(const std::string& component_id) { |
| 21 if (extension_id_.empty() || !HasListener(input_ime::OnActivate::kEventName)) | 22 if (extension_id_.empty() || !HasListener(input_ime::OnActivate::kEventName)) |
| 22 return; | 23 return; |
| 23 | 24 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 54 return; | 55 return; |
| 55 | 56 |
| 56 scoped_ptr<base::ListValue> args(input_ime::OnBlur::Create(context_id)); | 57 scoped_ptr<base::ListValue> args(input_ime::OnBlur::Create(context_id)); |
| 57 | 58 |
| 58 DispatchEventToExtension(extensions::events::INPUT_IME_ON_BLUR, | 59 DispatchEventToExtension(extensions::events::INPUT_IME_ON_BLUR, |
| 59 input_ime::OnBlur::kEventName, std::move(args)); | 60 input_ime::OnBlur::kEventName, std::move(args)); |
| 60 } | 61 } |
| 61 | 62 |
| 62 void ImeObserver::OnKeyEvent( | 63 void ImeObserver::OnKeyEvent( |
| 63 const std::string& component_id, | 64 const std::string& component_id, |
| 64 const IMEEngineHandlerInterface::KeyboardEvent& event, | 65 const InputMethodEngineBase::KeyboardEvent& event, |
| 65 IMEEngineHandlerInterface::KeyEventDoneCallback& key_data) { | 66 IMEEngineHandlerInterface::KeyEventDoneCallback& key_data) { |
| 66 if (extension_id_.empty()) | 67 if (extension_id_.empty()) |
| 67 return; | 68 return; |
| 68 | 69 |
| 69 // If there is no listener for the event, no need to dispatch the event to | 70 // If there is no listener for the event, no need to dispatch the event to |
| 70 // extension. Instead, releases the key event for default system behavior. | 71 // extension. Instead, releases the key event for default system behavior. |
| 71 if (!ShouldForwardKeyEvent()) { | 72 if (!ShouldForwardKeyEvent()) { |
| 72 // Continue processing the key event so that the physical keyboard can | 73 // Continue processing the key event so that the physical keyboard can |
| 73 // still work. | 74 // still work. |
| 74 key_data.Run(false); | 75 key_data.Run(false); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 } | 272 } |
| 272 | 273 |
| 273 InputImeEventRouter* GetInputImeEventRouter(Profile* profile) { | 274 InputImeEventRouter* GetInputImeEventRouter(Profile* profile) { |
| 274 if (profile->HasOffTheRecordProfile()) | 275 if (profile->HasOffTheRecordProfile()) |
| 275 profile = profile->GetOffTheRecordProfile(); | 276 profile = profile->GetOffTheRecordProfile(); |
| 276 return extensions::InputImeEventRouterFactory::GetInstance()->GetRouter( | 277 return extensions::InputImeEventRouterFactory::GetInstance()->GetRouter( |
| 277 profile); | 278 profile); |
| 278 } | 279 } |
| 279 | 280 |
| 280 } // namespace extensions | 281 } // namespace extensions |
| OLD | NEW |