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 "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/profiles/incognito_helpers.h" | 10 #include "chrome/browser/profiles/incognito_helpers.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" | 12 #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" |
13 #include "chrome/browser/speech/tts_controller.h" | 13 #include "chrome/browser/speech/tts_controller.h" |
14 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 14 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
15 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" | 15 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
16 #include "components/keyed_service/core/keyed_service.h" | 16 #include "components/keyed_service/core/keyed_service.h" |
17 #include "extensions/browser/event_router.h" | 17 #include "extensions/browser/event_router.h" |
18 #include "extensions/browser/event_router_factory.h" | 18 #include "extensions/browser/event_router_factory.h" |
19 | 19 |
20 // Factory to load one instance of TtsExtensionLoaderChromeOs per profile. | 20 // Factory to load one instance of TtsExtensionLoaderChromeOs per profile. |
21 class TtsEngineExtensionObserverFactory | 21 class TtsEngineExtensionObserverFactory |
22 : public BrowserContextKeyedServiceFactory { | 22 : public BrowserContextKeyedServiceFactory { |
23 public: | 23 public: |
24 static TtsEngineExtensionObserver* GetForProfile(Profile* profile) { | 24 static TtsEngineExtensionObserver* GetForProfile(Profile* profile) { |
25 return static_cast<TtsEngineExtensionObserver*>( | 25 return static_cast<TtsEngineExtensionObserver*>( |
26 GetInstance()->GetServiceForBrowserContext(profile, true)); | 26 GetInstance()->GetServiceForBrowserContext(profile, true)); |
27 } | 27 } |
28 | 28 |
29 static TtsEngineExtensionObserverFactory* GetInstance() { | 29 static TtsEngineExtensionObserverFactory* GetInstance() { |
30 return Singleton<TtsEngineExtensionObserverFactory>::get(); | 30 return base::Singleton<TtsEngineExtensionObserverFactory>::get(); |
31 } | 31 } |
32 | 32 |
33 private: | 33 private: |
34 friend struct DefaultSingletonTraits<TtsEngineExtensionObserverFactory>; | 34 friend struct base::DefaultSingletonTraits<TtsEngineExtensionObserverFactory>; |
35 | 35 |
36 TtsEngineExtensionObserverFactory() | 36 TtsEngineExtensionObserverFactory() |
37 : BrowserContextKeyedServiceFactory( | 37 : BrowserContextKeyedServiceFactory( |
38 "TtsEngineExtensionObserver", | 38 "TtsEngineExtensionObserver", |
39 BrowserContextDependencyManager::GetInstance()) { | 39 BrowserContextDependencyManager::GetInstance()) { |
40 DependsOn(extensions::EventRouterFactory::GetInstance()); | 40 DependsOn(extensions::EventRouterFactory::GetInstance()); |
41 } | 41 } |
42 | 42 |
43 ~TtsEngineExtensionObserverFactory() override {} | 43 ~TtsEngineExtensionObserverFactory() override {} |
44 | 44 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 void TtsEngineExtensionObserver::OnExtensionUnloaded( | 119 void TtsEngineExtensionObserver::OnExtensionUnloaded( |
120 content::BrowserContext* browser_context, | 120 content::BrowserContext* browser_context, |
121 const extensions::Extension* extension, | 121 const extensions::Extension* extension, |
122 extensions::UnloadedExtensionInfo::Reason reason) { | 122 extensions::UnloadedExtensionInfo::Reason reason) { |
123 if (engine_extension_ids_.find(extension->id()) != | 123 if (engine_extension_ids_.find(extension->id()) != |
124 engine_extension_ids_.end()) { | 124 engine_extension_ids_.end()) { |
125 engine_extension_ids_.erase(extension->id()); | 125 engine_extension_ids_.erase(extension->id()); |
126 TtsController::GetInstance()->VoicesChanged(); | 126 TtsController::GetInstance()->VoicesChanged(); |
127 } | 127 } |
128 } | 128 } |
OLD | NEW |