Index: chrome/browser/chromeos/extensions/input_method_api.cc |
diff --git a/chrome/browser/chromeos/extensions/input_method_api.cc b/chrome/browser/chromeos/extensions/input_method_api.cc |
index ce70b3642b55a32b673897124fcff817d1e3551c..07679468a43356f6efd19b082ab25d8904a1e789 100644 |
--- a/chrome/browser/chromeos/extensions/input_method_api.cc |
+++ b/chrome/browser/chromeos/extensions/input_method_api.cc |
@@ -20,6 +20,7 @@ |
#include "chrome/browser/spellchecker/spellcheck_factory.h" |
#include "chrome/browser/spellchecker/spellcheck_service.h" |
#include "chrome/browser/sync/profile_sync_service_factory.h" |
+#include "chrome/common/extensions/api/input_method_private.h" |
#include "chromeos/chromeos_switches.h" |
#include "components/browser_sync/browser/profile_sync_service.h" |
#include "extensions/browser/extension_function_registry.h" |
@@ -29,6 +30,12 @@ |
#include "ui/base/ime/chromeos/input_method_manager.h" |
#include "ui/keyboard/keyboard_util.h" |
+namespace OnChanged = extensions::api::input_method_private::OnChanged; |
+namespace OnDictionaryChanged = |
+ extensions::api::input_method_private::OnDictionaryChanged; |
+namespace OnDictionaryLoaded = |
+ extensions::api::input_method_private::OnDictionaryLoaded; |
+ |
namespace { |
// Prefix, which is used by XKB. |
@@ -38,7 +45,8 @@ const char kXkbPrefix[] = "xkb:"; |
namespace extensions { |
-ExtensionFunction::ResponseAction GetInputMethodConfigFunction::Run() { |
+ExtensionFunction::ResponseAction |
+InputMethodPrivateGetInputMethodConfigFunction::Run() { |
#if !defined(OS_CHROMEOS) |
EXTENSION_FUNCTION_VALIDATE(false); |
#else |
@@ -51,7 +59,8 @@ ExtensionFunction::ResponseAction GetInputMethodConfigFunction::Run() { |
#endif |
} |
-ExtensionFunction::ResponseAction GetCurrentInputMethodFunction::Run() { |
+ExtensionFunction::ResponseAction |
+InputMethodPrivateGetCurrentInputMethodFunction::Run() { |
#if !defined(OS_CHROMEOS) |
EXTENSION_FUNCTION_VALIDATE(false); |
#else |
@@ -62,7 +71,8 @@ ExtensionFunction::ResponseAction GetCurrentInputMethodFunction::Run() { |
#endif |
} |
-ExtensionFunction::ResponseAction SetCurrentInputMethodFunction::Run() { |
+ExtensionFunction::ResponseAction |
+InputMethodPrivateSetCurrentInputMethodFunction::Run() { |
#if !defined(OS_CHROMEOS) |
EXTENSION_FUNCTION_VALIDATE(false); |
#else |
@@ -83,7 +93,8 @@ ExtensionFunction::ResponseAction SetCurrentInputMethodFunction::Run() { |
#endif |
} |
-ExtensionFunction::ResponseAction GetInputMethodsFunction::Run() { |
+ExtensionFunction::ResponseAction |
+InputMethodPrivateGetInputMethodsFunction::Run() { |
#if !defined(OS_CHROMEOS) |
EXTENSION_FUNCTION_VALIDATE(false); |
#else |
@@ -108,7 +119,8 @@ ExtensionFunction::ResponseAction GetInputMethodsFunction::Run() { |
#endif |
} |
-ExtensionFunction::ResponseAction FetchAllDictionaryWordsFunction::Run() { |
+ExtensionFunction::ResponseAction |
+InputMethodPrivateFetchAllDictionaryWordsFunction::Run() { |
#if !defined(OS_CHROMEOS) |
EXTENSION_FUNCTION_VALIDATE(false); |
#else |
@@ -131,7 +143,8 @@ ExtensionFunction::ResponseAction FetchAllDictionaryWordsFunction::Run() { |
#endif |
} |
-ExtensionFunction::ResponseAction AddWordToDictionaryFunction::Run() { |
+ExtensionFunction::ResponseAction |
+InputMethodPrivateAddWordToDictionaryFunction::Run() { |
#if !defined(OS_CHROMEOS) |
EXTENSION_FUNCTION_VALIDATE(false); |
#else |
@@ -159,7 +172,8 @@ ExtensionFunction::ResponseAction AddWordToDictionaryFunction::Run() { |
#endif |
} |
-ExtensionFunction::ResponseAction GetEncryptSyncEnabledFunction::Run() { |
+ExtensionFunction::ResponseAction |
+InputMethodPrivateGetEncryptSyncEnabledFunction::Run() { |
#if !defined(OS_CHROMEOS) |
EXTENSION_FUNCTION_VALIDATE(false); |
#else |
@@ -174,32 +188,8 @@ ExtensionFunction::ResponseAction GetEncryptSyncEnabledFunction::Run() { |
#endif |
} |
-// static |
-const char InputMethodAPI::kOnDictionaryChanged[] = |
- "inputMethodPrivate.onDictionaryChanged"; |
- |
-// static |
-const char InputMethodAPI::kOnDictionaryLoaded[] = |
- "inputMethodPrivate.onDictionaryLoaded"; |
- |
-// static |
-const char InputMethodAPI::kOnInputMethodChanged[] = |
- "inputMethodPrivate.onChanged"; |
- |
InputMethodAPI::InputMethodAPI(content::BrowserContext* context) |
: context_(context) { |
- EventRouter::Get(context_)->RegisterObserver(this, kOnInputMethodChanged); |
- EventRouter::Get(context_)->RegisterObserver(this, kOnDictionaryChanged); |
- EventRouter::Get(context_)->RegisterObserver(this, kOnDictionaryLoaded); |
- ExtensionFunctionRegistry* registry = |
- ExtensionFunctionRegistry::GetInstance(); |
- registry->RegisterFunction<GetInputMethodConfigFunction>(); |
- registry->RegisterFunction<GetCurrentInputMethodFunction>(); |
- registry->RegisterFunction<SetCurrentInputMethodFunction>(); |
- registry->RegisterFunction<GetInputMethodsFunction>(); |
- registry->RegisterFunction<FetchAllDictionaryWordsFunction>(); |
- registry->RegisterFunction<AddWordToDictionaryFunction>(); |
- registry->RegisterFunction<GetEncryptSyncEnabledFunction>(); |
} |
InputMethodAPI::~InputMethodAPI() { |
@@ -220,18 +210,17 @@ void InputMethodAPI::Shutdown() { |
void InputMethodAPI::OnListenerAdded( |
const extensions::EventListenerInfo& details) { |
- if (details.event_name == kOnInputMethodChanged) { |
- if (!input_method_event_router_.get()) { |
- input_method_event_router_.reset( |
- new chromeos::ExtensionInputMethodEventRouter(context_)); |
- } |
- } else if (details.event_name == kOnDictionaryChanged || |
- details.event_name == kOnDictionaryLoaded) { |
+ if (details.event_name == OnChanged::kEventName && |
+ !input_method_event_router_.get()) { |
+ input_method_event_router_.reset( |
+ new chromeos::ExtensionInputMethodEventRouter(context_)); |
+ } else if (details.event_name == OnDictionaryChanged::kEventName || |
+ details.event_name == OnDictionaryLoaded::kEventName) { |
if (!dictionary_event_router_.get()) { |
dictionary_event_router_.reset( |
new chromeos::ExtensionDictionaryEventRouter(context_)); |
} |
- if (details.event_name == kOnDictionaryLoaded) { |
+ if (details.event_name == OnDictionaryLoaded::kEventName) { |
dictionary_event_router_->DispatchLoadedEventIfLoaded(); |
} |
} |