Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1852)

Unified Diff: chrome/browser/chromeos/extensions/input_method_api.cc

Issue 973213003: Adds extension events for custom dictionary load/change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Remove extra braces. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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(
bshe 2015/03/09 13:16:39 I am not familiar with the code. But could this fu
Peter Wen 2015/03/09 14:56:08 Thanks for the heads up. Shu, thoughts? I changed
- new chromeos::ExtensionInputMethodEventRouter(context_));
- EventRouter::Get(context_)->UnregisterObserver(this);
bshe 2015/03/09 13:16:39 Looks like you removed the UnregisterObserver step
Peter Wen 2015/03/09 14:56:08 Done.
+ 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> >

Powered by Google App Engine
This is Rietveld 408576698