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

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

Issue 11442074: Lazy initialization for ExtensionInputMethodEventRouter (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years 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 0b965e5256fc3fcc19d4ff5d5adb7902666e45e1..4e16ba3558287f9da024e2d7dd7139469df1d03b 100644
--- a/chrome/browser/chromeos/extensions/input_method_api.cc
+++ b/chrome/browser/chromeos/extensions/input_method_api.cc
@@ -5,10 +5,11 @@
#include "chrome/browser/chromeos/extensions/input_method_api.h"
#include "base/values.h"
+#include "chrome/browser/chromeos/extensions/input_method_api_factory.h"
#include "chrome/browser/chromeos/extensions/input_method_event_router.h"
#include "chrome/browser/chromeos/input_method/input_method_configuration.h"
#include "chrome/browser/chromeos/input_method/input_method_manager.h"
-#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
@@ -26,8 +27,7 @@ bool GetInputMethodFunction::RunImpl() {
return false;
#else
chromeos::ExtensionInputMethodEventRouter* router =
- extensions::ExtensionSystem::Get(profile_)->extension_service()->
- input_method_event_router();
+ InputMethodAPI::Get(profile_)->input_method_event_router();
chromeos::input_method::InputMethodManager* manager =
chromeos::input_method::GetInputMethodManager();
const std::string input_method =
@@ -37,4 +37,37 @@ bool GetInputMethodFunction::RunImpl() {
#endif
}
+InputMethodAPI::InputMethodAPI(Profile* profile)
+ : profile_(profile) {
+ ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
+ this, event_names::kOnInputMethodChanged);
+}
+
+InputMethodAPI::~InputMethodAPI() {
+}
+
+// static
+InputMethodAPI* InputMethodAPI::Get(Profile* profile) {
+ return InputMethodAPIFactory::GetForProfile(profile);
+}
+
+chromeos::ExtensionInputMethodEventRouter*
+ InputMethodAPI::input_method_event_router() {
+ if (!input_method_event_router_) {
+ input_method_event_router_.reset(
+ new chromeos::ExtensionInputMethodEventRouter());
+ }
+ return input_method_event_router_.get();
+}
+
+void InputMethodAPI::Shutdown() {
+ ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this);
+}
+
+void InputMethodAPI::OnListenerAdded(
+ const extensions::EventListenerInfo& details) {
+ input_method_event_router();
+ ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this);
+}
+
} // namespace extensions
« no previous file with comments | « chrome/browser/chromeos/extensions/input_method_api.h ('k') | chrome/browser/chromeos/extensions/input_method_api_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698