| 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/extensions/extension_system_factory.h" | 10 #include "chrome/browser/extensions/extension_system_factory.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 TtsEngineExtensionObserverFactory() | 37 TtsEngineExtensionObserverFactory() |
| 38 : BrowserContextKeyedServiceFactory( | 38 : BrowserContextKeyedServiceFactory( |
| 39 "TtsEngineExtensionObserver", | 39 "TtsEngineExtensionObserver", |
| 40 BrowserContextDependencyManager::GetInstance()) { | 40 BrowserContextDependencyManager::GetInstance()) { |
| 41 DependsOn(extensions::ExtensionSystemFactory::GetInstance()); | 41 DependsOn(extensions::ExtensionSystemFactory::GetInstance()); |
| 42 } | 42 } |
| 43 | 43 |
| 44 virtual ~TtsEngineExtensionObserverFactory() {} | 44 virtual ~TtsEngineExtensionObserverFactory() {} |
| 45 | 45 |
| 46 virtual content::BrowserContext* GetBrowserContextToUse( | 46 virtual content::BrowserContext* GetBrowserContextToUse( |
| 47 content::BrowserContext* context) const OVERRIDE { | 47 content::BrowserContext* context) const override { |
| 48 // If given an incognito profile (including the Chrome OS login | 48 // If given an incognito profile (including the Chrome OS login |
| 49 // profile), share the service with the original profile. | 49 // profile), share the service with the original profile. |
| 50 return chrome::GetBrowserContextRedirectedInIncognito(context); | 50 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 51 } | 51 } |
| 52 | 52 |
| 53 virtual KeyedService* BuildServiceInstanceFor( | 53 virtual KeyedService* BuildServiceInstanceFor( |
| 54 content::BrowserContext* profile) const OVERRIDE { | 54 content::BrowserContext* profile) const override { |
| 55 return new TtsEngineExtensionObserver(static_cast<Profile*>(profile)); | 55 return new TtsEngineExtensionObserver(static_cast<Profile*>(profile)); |
| 56 } | 56 } |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 TtsEngineExtensionObserver* TtsEngineExtensionObserver::GetInstance( | 59 TtsEngineExtensionObserver* TtsEngineExtensionObserver::GetInstance( |
| 60 Profile* profile) { | 60 Profile* profile) { |
| 61 return TtsEngineExtensionObserverFactory::GetInstance()->GetForProfile( | 61 return TtsEngineExtensionObserverFactory::GetInstance()->GetForProfile( |
| 62 profile); | 62 profile); |
| 63 } | 63 } |
| 64 | 64 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 void TtsEngineExtensionObserver::OnExtensionUnloaded( | 124 void TtsEngineExtensionObserver::OnExtensionUnloaded( |
| 125 content::BrowserContext* browser_context, | 125 content::BrowserContext* browser_context, |
| 126 const extensions::Extension* extension, | 126 const extensions::Extension* extension, |
| 127 extensions::UnloadedExtensionInfo::Reason reason) { | 127 extensions::UnloadedExtensionInfo::Reason reason) { |
| 128 if (engine_extension_ids_.find(extension->id()) != | 128 if (engine_extension_ids_.find(extension->id()) != |
| 129 engine_extension_ids_.end()) { | 129 engine_extension_ids_.end()) { |
| 130 engine_extension_ids_.erase(extension->id()); | 130 engine_extension_ids_.erase(extension->id()); |
| 131 TtsController::GetInstance()->VoicesChanged(); | 131 TtsController::GetInstance()->VoicesChanged(); |
| 132 } | 132 } |
| 133 } | 133 } |
| OLD | NEW |