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

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

Issue 1883703002: Revert "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/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/common/extensions/api/input_ime.h" 9 #include "chrome/common/extensions/api/input_ime.h"
10 #include "content/public/browser/notification_registrar.h" 10 #include "content/public/browser/notification_registrar.h"
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 extensions::InputImeEventRouterFactory::GetInstance()->RemoveProfile( 395 extensions::InputImeEventRouterFactory::GetInstance()->RemoveProfile(
396 content::Source<Profile>(source).ptr()); 396 content::Source<Profile>(source).ptr());
397 } 397 }
398 } 398 }
399 399
400 InputImeAPI::~InputImeAPI() { 400 InputImeAPI::~InputImeAPI() {
401 EventRouter::Get(browser_context_)->UnregisterObserver(this); 401 EventRouter::Get(browser_context_)->UnregisterObserver(this);
402 registrar_.RemoveAll(); 402 registrar_.RemoveAll();
403 } 403 }
404 404
405 void InputImeAPI::OnListenerAdded(const EventListenerInfo& details) {
406 if (!details.browser_context)
407 return;
408 InputImeEventRouter* event_router =
409 GetInputImeEventRouter(Profile::FromBrowserContext(
410 Profile::FromBrowserContext(details.browser_context)));
411 InputMethodEngineBase* engine =
412 event_router ? event_router->GetActiveEngine(details.extension_id)
413 : nullptr;
414
415 // Notifies the IME extension for IME ready with onActivate/onFocus events.
416 if (engine)
417 engine->Enable(engine->GetActiveComponentId());
418 }
419
420 static base::LazyInstance<BrowserContextKeyedAPIFactory<InputImeAPI> > 405 static base::LazyInstance<BrowserContextKeyedAPIFactory<InputImeAPI> >
421 g_factory = LAZY_INSTANCE_INITIALIZER; 406 g_factory = LAZY_INSTANCE_INITIALIZER;
422 407
423 // static 408 // static
424 BrowserContextKeyedAPIFactory<InputImeAPI>* InputImeAPI::GetFactoryInstance() { 409 BrowserContextKeyedAPIFactory<InputImeAPI>* InputImeAPI::GetFactoryInstance() {
425 return g_factory.Pointer(); 410 return g_factory.Pointer();
426 } 411 }
427 412
428 InputImeEventRouter* GetInputImeEventRouter(Profile* profile) { 413 InputImeEventRouter* GetInputImeEventRouter(Profile* profile) {
429 if (!profile) 414 if (!profile)
430 return nullptr; 415 return nullptr;
431 if (profile->HasOffTheRecordProfile()) 416 if (profile->HasOffTheRecordProfile())
432 profile = profile->GetOffTheRecordProfile(); 417 profile = profile->GetOffTheRecordProfile();
433 return extensions::InputImeEventRouterFactory::GetInstance()->GetRouter( 418 return extensions::InputImeEventRouterFactory::GetInstance()->GetRouter(
434 profile); 419 profile);
435 } 420 }
436 421
437 } // namespace extensions 422 } // 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