| OLD | NEW |
| 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 <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 } | 409 } |
| 410 | 410 |
| 411 void InputImeAPI::Observe(int type, | 411 void InputImeAPI::Observe(int type, |
| 412 const content::NotificationSource& source, | 412 const content::NotificationSource& source, |
| 413 const content::NotificationDetails& details) { | 413 const content::NotificationDetails& details) { |
| 414 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 414 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
| 415 extensions::InputImeEventRouterFactory::GetInstance()->RemoveProfile( | 415 extensions::InputImeEventRouterFactory::GetInstance()->RemoveProfile( |
| 416 content::Source<Profile>(source).ptr()); | 416 content::Source<Profile>(source).ptr()); |
| 417 } | 417 } |
| 418 | 418 |
| 419 InputImeAPI::~InputImeAPI() { | 419 InputImeAPI::~InputImeAPI() = default; |
| 420 |
| 421 void InputImeAPI::Shutdown() { |
| 420 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 422 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
| 421 registrar_.RemoveAll(); | 423 registrar_.RemoveAll(); |
| 422 } | 424 } |
| 423 | 425 |
| 424 static base::LazyInstance< | 426 static base::LazyInstance< |
| 425 BrowserContextKeyedAPIFactory<InputImeAPI>>::DestructorAtExit g_factory = | 427 BrowserContextKeyedAPIFactory<InputImeAPI>>::DestructorAtExit g_factory = |
| 426 LAZY_INSTANCE_INITIALIZER; | 428 LAZY_INSTANCE_INITIALIZER; |
| 427 | 429 |
| 428 // static | 430 // static |
| 429 BrowserContextKeyedAPIFactory<InputImeAPI>* InputImeAPI::GetFactoryInstance() { | 431 BrowserContextKeyedAPIFactory<InputImeAPI>* InputImeAPI::GetFactoryInstance() { |
| 430 return g_factory.Pointer(); | 432 return g_factory.Pointer(); |
| 431 } | 433 } |
| 432 | 434 |
| 433 InputImeEventRouter* GetInputImeEventRouter(Profile* profile) { | 435 InputImeEventRouter* GetInputImeEventRouter(Profile* profile) { |
| 434 if (!profile) | 436 if (!profile) |
| 435 return nullptr; | 437 return nullptr; |
| 436 if (profile->HasOffTheRecordProfile()) | 438 if (profile->HasOffTheRecordProfile()) |
| 437 profile = profile->GetOffTheRecordProfile(); | 439 profile = profile->GetOffTheRecordProfile(); |
| 438 return extensions::InputImeEventRouterFactory::GetInstance()->GetRouter( | 440 return extensions::InputImeEventRouterFactory::GetInstance()->GetRouter( |
| 439 profile); | 441 profile); |
| 440 } | 442 } |
| 441 | 443 |
| 442 } // namespace extensions | 444 } // namespace extensions |
| OLD | NEW |