| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/speech/extension_api/tts_engine_extension_observer.h" | 5 #include "chrome/browser/speech/extension_api/tts_engine_extension_observer.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "base/profiler/scoped_profile.h" | 9 #include "base/profiler/scoped_profile.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 private: | 35 private: |
| 36 friend struct DefaultSingletonTraits<TtsEngineExtensionObserverFactory>; | 36 friend struct DefaultSingletonTraits<TtsEngineExtensionObserverFactory>; |
| 37 | 37 |
| 38 TtsEngineExtensionObserverFactory() | 38 TtsEngineExtensionObserverFactory() |
| 39 : BrowserContextKeyedServiceFactory( | 39 : BrowserContextKeyedServiceFactory( |
| 40 "TtsEngineExtensionObserver", | 40 "TtsEngineExtensionObserver", |
| 41 BrowserContextDependencyManager::GetInstance()) { | 41 BrowserContextDependencyManager::GetInstance()) { |
| 42 DependsOn(extensions::ExtensionSystemFactory::GetInstance()); | 42 DependsOn(extensions::ExtensionSystemFactory::GetInstance()); |
| 43 } | 43 } |
| 44 | 44 |
| 45 virtual ~TtsEngineExtensionObserverFactory() {} | 45 ~TtsEngineExtensionObserverFactory() override {} |
| 46 | 46 |
| 47 virtual content::BrowserContext* GetBrowserContextToUse( | 47 content::BrowserContext* GetBrowserContextToUse( |
| 48 content::BrowserContext* context) const override { | 48 content::BrowserContext* context) const override { |
| 49 // If given an incognito profile (including the Chrome OS login | 49 // If given an incognito profile (including the Chrome OS login |
| 50 // profile), share the service with the original profile. | 50 // profile), share the service with the original profile. |
| 51 return chrome::GetBrowserContextRedirectedInIncognito(context); | 51 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 52 } | 52 } |
| 53 | 53 |
| 54 virtual KeyedService* BuildServiceInstanceFor( | 54 KeyedService* BuildServiceInstanceFor( |
| 55 content::BrowserContext* profile) const override { | 55 content::BrowserContext* profile) const override { |
| 56 return new TtsEngineExtensionObserver(static_cast<Profile*>(profile)); | 56 return new TtsEngineExtensionObserver(static_cast<Profile*>(profile)); |
| 57 } | 57 } |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 TtsEngineExtensionObserver* TtsEngineExtensionObserver::GetInstance( | 60 TtsEngineExtensionObserver* TtsEngineExtensionObserver::GetInstance( |
| 61 Profile* profile) { | 61 Profile* profile) { |
| 62 return TtsEngineExtensionObserverFactory::GetInstance()->GetForProfile( | 62 return TtsEngineExtensionObserverFactory::GetInstance()->GetForProfile( |
| 63 profile); | 63 profile); |
| 64 } | 64 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 void TtsEngineExtensionObserver::OnExtensionUnloaded( | 130 void TtsEngineExtensionObserver::OnExtensionUnloaded( |
| 131 content::BrowserContext* browser_context, | 131 content::BrowserContext* browser_context, |
| 132 const extensions::Extension* extension, | 132 const extensions::Extension* extension, |
| 133 extensions::UnloadedExtensionInfo::Reason reason) { | 133 extensions::UnloadedExtensionInfo::Reason reason) { |
| 134 if (engine_extension_ids_.find(extension->id()) != | 134 if (engine_extension_ids_.find(extension->id()) != |
| 135 engine_extension_ids_.end()) { | 135 engine_extension_ids_.end()) { |
| 136 engine_extension_ids_.erase(extension->id()); | 136 engine_extension_ids_.erase(extension->id()); |
| 137 TtsController::GetInstance()->VoicesChanged(); | 137 TtsController::GetInstance()->VoicesChanged(); |
| 138 } | 138 } |
| 139 } | 139 } |
| OLD | NEW |