| 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 22e9f44fdb26686786015cdc0ac6c2ed5b4b7ef4..8dc478e48f5370e0e0ad53c2a336247ffb7884d8 100644
|
| --- a/chrome/browser/chromeos/extensions/input_method_api.cc
|
| +++ b/chrome/browser/chromeos/extensions/input_method_api.cc
|
| @@ -7,6 +7,7 @@
|
| #include "base/command_line.h"
|
| #include "base/lazy_instance.h"
|
| #include "base/values.h"
|
| +#include "chrome/browser/chromeos/extensions/dictionary_event_router.h"
|
| #include "chrome/browser/chromeos/extensions/input_method_event_router.h"
|
| #include "chrome/browser/chromeos/input_method/input_method_util.h"
|
| #include "chrome/browser/extensions/api/input_ime/input_ime_api.h"
|
| @@ -157,12 +158,22 @@ ExtensionFunction::ResponseAction AddWordToDictionaryFunction::Run() {
|
| }
|
|
|
| // 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>();
|
| @@ -193,10 +204,18 @@ void InputMethodAPI::Shutdown() {
|
|
|
| void InputMethodAPI::OnListenerAdded(
|
| const extensions::EventListenerInfo& details) {
|
| - DCHECK(!input_method_event_router_.get());
|
| - input_method_event_router_.reset(
|
| - new chromeos::ExtensionInputMethodEventRouter(context_));
|
| - EventRouter::Get(context_)->UnregisterObserver(this);
|
| + 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 (!dictionary_event_router_.get()) {
|
| + dictionary_event_router_.reset(
|
| + new chromeos::ExtensionDictionaryEventRouter(context_));
|
| + }
|
| + }
|
| }
|
|
|
| static base::LazyInstance<BrowserContextKeyedAPIFactory<InputMethodAPI> >
|
|
|