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/chromeos/extensions/input_method_api.h" | 5 #include "chrome/browser/chromeos/extensions/input_method_api.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" | 9 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" |
10 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 10 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
11 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" | 11 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" |
12 #include "chromeos/ime/extension_ime_util.h" | 12 #include "chromeos/ime/extension_ime_util.h" |
13 #include "chromeos/ime/input_method_descriptor.h" | 13 #include "chromeos/ime/input_method_descriptor.h" |
14 #include "chromeos/ime/input_method_manager.h" | 14 #include "chromeos/ime/input_method_manager.h" |
15 #include "extensions/browser/extension_function_registry.h" | 15 #include "extensions/browser/extension_function_registry.h" |
16 #include "extensions/browser/extension_system.h" | 16 #include "extensions/browser/extension_system.h" |
17 #include "extensions/common/value_builder.h" | 17 #include "extensions/common/value_builder.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 // Prefix, which is used by XKB. | 21 // Prefix, which is used by XKB. |
22 const char kXkbPrefix[] = "xkb:"; | 22 const char kXkbPrefix[] = "xkb:"; |
23 | 23 |
24 } // namespace | 24 } // namespace |
25 | 25 |
26 namespace extensions { | 26 namespace extensions { |
27 | 27 |
| 28 ExtensionFunction::ResponseAction GetConfigFunction::Run() { |
| 29 #if !defined(OS_CHROMEOS) |
| 30 EXTENSION_FUNCTION_VALIDATE(false); |
| 31 #else |
| 32 bool isExperimental = chromeos::input_method::InputMethodManager:: |
| 33 IsExperimentalImeFeaturesEnabled(); |
| 34 LOG(ERROR) << "-----run to here." << isExperimental; |
| 35 base::DictionaryValue* output = new base::DictionaryValue(); |
| 36 output->SetBoolean("isExperimentalEnabled", isExperimental); |
| 37 return RespondNow(OneArgument(output)); |
| 38 #endif |
| 39 } |
| 40 |
28 ExtensionFunction::ResponseAction GetCurrentInputMethodFunction::Run() { | 41 ExtensionFunction::ResponseAction GetCurrentInputMethodFunction::Run() { |
29 #if !defined(OS_CHROMEOS) | 42 #if !defined(OS_CHROMEOS) |
30 EXTENSION_FUNCTION_VALIDATE(false); | 43 EXTENSION_FUNCTION_VALIDATE(false); |
31 #else | 44 #else |
32 chromeos::input_method::InputMethodManager* manager = | 45 chromeos::input_method::InputMethodManager* manager = |
33 chromeos::input_method::InputMethodManager::Get(); | 46 chromeos::input_method::InputMethodManager::Get(); |
34 return RespondNow(OneArgument(new base::StringValue( | 47 return RespondNow(OneArgument(new base::StringValue( |
35 manager->GetActiveIMEState()->GetCurrentInputMethod().id()))); | 48 manager->GetActiveIMEState()->GetCurrentInputMethod().id()))); |
36 #endif | 49 #endif |
37 } | 50 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 97 |
85 // static | 98 // static |
86 const char InputMethodAPI::kOnInputMethodChanged[] = | 99 const char InputMethodAPI::kOnInputMethodChanged[] = |
87 "inputMethodPrivate.onChanged"; | 100 "inputMethodPrivate.onChanged"; |
88 | 101 |
89 InputMethodAPI::InputMethodAPI(content::BrowserContext* context) | 102 InputMethodAPI::InputMethodAPI(content::BrowserContext* context) |
90 : context_(context) { | 103 : context_(context) { |
91 EventRouter::Get(context_)->RegisterObserver(this, kOnInputMethodChanged); | 104 EventRouter::Get(context_)->RegisterObserver(this, kOnInputMethodChanged); |
92 ExtensionFunctionRegistry* registry = | 105 ExtensionFunctionRegistry* registry = |
93 ExtensionFunctionRegistry::GetInstance(); | 106 ExtensionFunctionRegistry::GetInstance(); |
| 107 registry->RegisterFunction<GetConfigFunction>(); |
94 registry->RegisterFunction<GetCurrentInputMethodFunction>(); | 108 registry->RegisterFunction<GetCurrentInputMethodFunction>(); |
95 registry->RegisterFunction<SetCurrentInputMethodFunction>(); | 109 registry->RegisterFunction<SetCurrentInputMethodFunction>(); |
96 registry->RegisterFunction<GetInputMethodsFunction>(); | 110 registry->RegisterFunction<GetInputMethodsFunction>(); |
97 } | 111 } |
98 | 112 |
99 InputMethodAPI::~InputMethodAPI() { | 113 InputMethodAPI::~InputMethodAPI() { |
100 } | 114 } |
101 | 115 |
102 // static | 116 // static |
103 std::string InputMethodAPI::GetInputMethodForXkb(const std::string& xkb_id) { | 117 std::string InputMethodAPI::GetInputMethodForXkb(const std::string& xkb_id) { |
(...skipping 21 matching lines...) Expand all Loading... |
125 static base::LazyInstance<BrowserContextKeyedAPIFactory<InputMethodAPI> > | 139 static base::LazyInstance<BrowserContextKeyedAPIFactory<InputMethodAPI> > |
126 g_factory = LAZY_INSTANCE_INITIALIZER; | 140 g_factory = LAZY_INSTANCE_INITIALIZER; |
127 | 141 |
128 // static | 142 // static |
129 BrowserContextKeyedAPIFactory<InputMethodAPI>* | 143 BrowserContextKeyedAPIFactory<InputMethodAPI>* |
130 InputMethodAPI::GetFactoryInstance() { | 144 InputMethodAPI::GetFactoryInstance() { |
131 return g_factory.Pointer(); | 145 return g_factory.Pointer(); |
132 } | 146 } |
133 | 147 |
134 } // namespace extensions | 148 } // namespace extensions |
OLD | NEW |