| 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/extension_input_ime_api.h" | 5 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/chromeos/input_method/input_method_engine.h" | 11 #include "chrome/browser/chromeos/input_method/input_method_engine.h" |
| 12 #include "chrome/browser/extensions/extension_event_router.h" | 12 #include "chrome/browser/extensions/extension_event_router.h" |
| 13 #include "chrome/browser/extensions/extension_input_module_constants.h" | 13 #include "chrome/browser/extensions/extension_input_module_constants.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 | 15 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 GURL()); | 226 GURL()); |
| 227 } | 227 } |
| 228 | 228 |
| 229 virtual void OnKeyEvent(const std::string& engine_id, | 229 virtual void OnKeyEvent(const std::string& engine_id, |
| 230 const InputMethodEngine::KeyboardEvent& event, | 230 const InputMethodEngine::KeyboardEvent& event, |
| 231 chromeos::input_method::KeyEventHandle* key_data) { | 231 chromeos::input_method::KeyEventHandle* key_data) { |
| 232 if (profile_ == NULL || extension_id_.empty()) | 232 if (profile_ == NULL || extension_id_.empty()) |
| 233 return; | 233 return; |
| 234 | 234 |
| 235 std::string request_id = | 235 std::string request_id = |
| 236 ExtensionInputImeEventRouter::GetInstance()->AddRequest(engine_id, | 236 extensions::ExtensionInputImeEventRouter::GetInstance()->AddRequest( |
| 237 key_data); | 237 engine_id, |
| 238 key_data); |
| 238 | 239 |
| 239 DictionaryValue* dict = new DictionaryValue(); | 240 DictionaryValue* dict = new DictionaryValue(); |
| 240 dict->SetString("type", event.type); | 241 dict->SetString("type", event.type); |
| 241 dict->SetString("requestId", request_id); | 242 dict->SetString("requestId", request_id); |
| 242 dict->SetString("key", event.key); | 243 dict->SetString("key", event.key); |
| 243 dict->SetBoolean("altKey", event.alt_key); | 244 dict->SetBoolean("altKey", event.alt_key); |
| 244 dict->SetBoolean("ctrlKey", event.ctrl_key); | 245 dict->SetBoolean("ctrlKey", event.ctrl_key); |
| 245 dict->SetBoolean("shiftKey", event.shift_key); | 246 dict->SetBoolean("shiftKey", event.shift_key); |
| 246 | 247 |
| 247 ListValue args; | 248 ListValue args; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 private: | 307 private: |
| 307 Profile* profile_; | 308 Profile* profile_; |
| 308 std::string extension_id_; | 309 std::string extension_id_; |
| 309 std::string engine_id_; | 310 std::string engine_id_; |
| 310 | 311 |
| 311 DISALLOW_COPY_AND_ASSIGN(ImeObserver); | 312 DISALLOW_COPY_AND_ASSIGN(ImeObserver); |
| 312 }; | 313 }; |
| 313 | 314 |
| 314 } // namespace chromeos | 315 } // namespace chromeos |
| 315 | 316 |
| 317 namespace extensions { |
| 318 |
| 316 ExtensionInputImeEventRouter* | 319 ExtensionInputImeEventRouter* |
| 317 ExtensionInputImeEventRouter::GetInstance() { | 320 ExtensionInputImeEventRouter::GetInstance() { |
| 318 return Singleton<ExtensionInputImeEventRouter>::get(); | 321 return Singleton<ExtensionInputImeEventRouter>::get(); |
| 319 } | 322 } |
| 320 | 323 |
| 321 void ExtensionInputImeEventRouter::Init() {} | 324 void ExtensionInputImeEventRouter::Init() {} |
| 322 | 325 |
| 323 #if defined(OS_CHROMEOS) | 326 #if defined(OS_CHROMEOS) |
| 324 bool ExtensionInputImeEventRouter::RegisterIme( | 327 bool ExtensionInputImeEventRouter::RegisterIme( |
| 325 Profile* profile, | 328 Profile* profile, |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 | 831 |
| 829 bool handled = false; | 832 bool handled = false; |
| 830 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &handled)); | 833 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &handled)); |
| 831 | 834 |
| 832 ExtensionInputImeEventRouter::GetInstance()->OnEventHandled( | 835 ExtensionInputImeEventRouter::GetInstance()->OnEventHandled( |
| 833 extension_id(), request_id_str, handled); | 836 extension_id(), request_id_str, handled); |
| 834 | 837 |
| 835 return true; | 838 return true; |
| 836 } | 839 } |
| 837 #endif | 840 #endif |
| 841 |
| 842 } // namespace extensions |
| OLD | NEW |