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

Side by Side Diff: chrome/browser/extensions/api/input_ime/input_ime_api.cc

Issue 1870783003: Notifies the IME extension for IME ready with onActivate/onFocus events at start. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/extensions/api/input_ime/input_ime_api.h" 5 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "chrome/common/extensions/api/input_ime.h" 8 #include "chrome/common/extensions/api/input_ime.h"
9 #include "extensions/browser/extension_registry.h" 9 #include "extensions/browser/extension_registry.h"
10 10
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context_)); 367 extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context_));
368 368
369 EventRouter* event_router = EventRouter::Get(browser_context_); 369 EventRouter* event_router = EventRouter::Get(browser_context_);
370 event_router->RegisterObserver(this, input_ime::OnFocus::kEventName); 370 event_router->RegisterObserver(this, input_ime::OnFocus::kEventName);
371 } 371 }
372 372
373 InputImeAPI::~InputImeAPI() { 373 InputImeAPI::~InputImeAPI() {
374 EventRouter::Get(browser_context_)->UnregisterObserver(this); 374 EventRouter::Get(browser_context_)->UnregisterObserver(this);
375 } 375 }
376 376
377 void InputImeAPI::OnListenerAdded(const EventListenerInfo& details) {
378 if (!details.browser_context)
379 return;
380 InputImeEventRouter* event_router =
381 GetInputImeEventRouter(Profile::FromBrowserContext(
382 Profile::FromBrowserContext(details.browser_context)));
383 InputMethodEngineBase* engine =
384 event_router ? event_router->GetActiveEngine(details.extension_id)
385 : nullptr;
386
387 // Notifies the IME extension for IME ready with onActivate/onFocus events.
388 if (engine)
389 engine->Enable(engine->GetActiveComponentId());
390 }
391
377 static base::LazyInstance<BrowserContextKeyedAPIFactory<InputImeAPI> > 392 static base::LazyInstance<BrowserContextKeyedAPIFactory<InputImeAPI> >
378 g_factory = LAZY_INSTANCE_INITIALIZER; 393 g_factory = LAZY_INSTANCE_INITIALIZER;
379 394
380 // static 395 // static
381 BrowserContextKeyedAPIFactory<InputImeAPI>* InputImeAPI::GetFactoryInstance() { 396 BrowserContextKeyedAPIFactory<InputImeAPI>* InputImeAPI::GetFactoryInstance() {
382 return g_factory.Pointer(); 397 return g_factory.Pointer();
383 } 398 }
384 399
385 InputImeEventRouter* GetInputImeEventRouter(Profile* profile) { 400 InputImeEventRouter* GetInputImeEventRouter(Profile* profile) {
386 if (!profile) 401 if (!profile)
387 return nullptr; 402 return nullptr;
388 if (profile->HasOffTheRecordProfile()) 403 if (profile->HasOffTheRecordProfile())
389 profile = profile->GetOffTheRecordProfile(); 404 profile = profile->GetOffTheRecordProfile();
390 return extensions::InputImeEventRouterFactory::GetInstance()->GetRouter( 405 return extensions::InputImeEventRouterFactory::GetInstance()->GetRouter(
391 profile); 406 profile);
392 } 407 }
393 408
394 } // namespace extensions 409 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698