| 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/speech/tts_extension_loader_chromeos.h" | 5 #include "chrome/browser/speech/tts_extension_loader_chromeos.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/component_loader.h" | 9 #include "chrome/browser/extensions/component_loader.h" |
| 10 #include "chrome/browser/extensions/event_router.h" | 10 #include "chrome/browser/extensions/event_router.h" |
| 11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/extensions/extension_system.h" | 12 #include "chrome/browser/extensions/extension_system.h" |
| 13 #include "chrome/browser/profiles/incognito_helpers.h" | 13 #include "chrome/browser/profiles/incognito_helpers.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" | 15 #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" |
| 16 #include "chrome/browser/speech/tts_controller.h" | 16 #include "chrome/browser/speech/tts_controller.h" |
| 17 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
| 18 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 18 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
| 19 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 19 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
| 20 #include "components/browser_context_keyed_service/browser_context_keyed_service
_factory.h" | 20 #include "components/browser_context_keyed_service/browser_context_keyed_service
_factory.h" |
| 21 #include "grit/browser_resources.h" | 21 #include "grit/browser_resources.h" |
| 22 | 22 |
| 23 // Factory to load one instance of TtsExtensionLoaderChromeOs per profile. | 23 // Factory to load one instance of TtsExtensionLoaderChromeOs per profile. |
| 24 class TtsExtensionLoaderChromeOsFactory : public ProfileKeyedServiceFactory { | 24 class TtsExtensionLoaderChromeOsFactory : public BrowserContextKeyedServiceFacto
ry { |
| 25 public: | 25 public: |
| 26 static TtsExtensionLoaderChromeOs* GetForProfile(Profile* profile) { | 26 static TtsExtensionLoaderChromeOs* GetForProfile(Profile* profile) { |
| 27 return static_cast<TtsExtensionLoaderChromeOs*>( | 27 return static_cast<TtsExtensionLoaderChromeOs*>( |
| 28 GetInstance()->GetServiceForProfile(profile, true)); | 28 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 29 } | 29 } |
| 30 | 30 |
| 31 static TtsExtensionLoaderChromeOsFactory* GetInstance() { | 31 static TtsExtensionLoaderChromeOsFactory* GetInstance() { |
| 32 return Singleton<TtsExtensionLoaderChromeOsFactory>::get(); | 32 return Singleton<TtsExtensionLoaderChromeOsFactory>::get(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 friend struct DefaultSingletonTraits<TtsExtensionLoaderChromeOsFactory>; | 36 friend struct DefaultSingletonTraits<TtsExtensionLoaderChromeOsFactory>; |
| 37 | 37 |
| 38 TtsExtensionLoaderChromeOsFactory() : ProfileKeyedServiceFactory( | 38 TtsExtensionLoaderChromeOsFactory() : BrowserContextKeyedServiceFactory( |
| 39 "TtsExtensionLoaderChromeOs", | 39 "TtsExtensionLoaderChromeOs", |
| 40 ProfileDependencyManager::GetInstance()) | 40 BrowserContextDependencyManager::GetInstance()) |
| 41 {} | 41 {} |
| 42 | 42 |
| 43 virtual ~TtsExtensionLoaderChromeOsFactory() {} | 43 virtual ~TtsExtensionLoaderChromeOsFactory() {} |
| 44 | 44 |
| 45 virtual content::BrowserContext* GetBrowserContextToUse( | 45 virtual content::BrowserContext* GetBrowserContextToUse( |
| 46 content::BrowserContext* context) const OVERRIDE{ | 46 content::BrowserContext* context) const OVERRIDE{ |
| 47 // If given an incognito profile (including the Chrome OS login | 47 // If given an incognito profile (including the Chrome OS login |
| 48 // profile), share the service with the original profile. | 48 // profile), share the service with the original profile. |
| 49 return chrome::GetBrowserContextRedirectedInIncognito(context); | 49 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 50 } | 50 } |
| 51 | 51 |
| 52 virtual ProfileKeyedService* BuildServiceInstanceFor( | 52 virtual BrowserContextKeyedService* BuildServiceInstanceFor( |
| 53 content::BrowserContext* profile) const OVERRIDE { | 53 content::BrowserContext* profile) const OVERRIDE { |
| 54 return new TtsExtensionLoaderChromeOs(static_cast<Profile*>(profile)); | 54 return new TtsExtensionLoaderChromeOs(static_cast<Profile*>(profile)); |
| 55 } | 55 } |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 TtsExtensionLoaderChromeOs* | 58 TtsExtensionLoaderChromeOs* |
| 59 TtsExtensionLoaderChromeOs::GetInstance(Profile* profile) { | 59 TtsExtensionLoaderChromeOs::GetInstance(Profile* profile) { |
| 60 return TtsExtensionLoaderChromeOsFactory::GetInstance() | 60 return TtsExtensionLoaderChromeOsFactory::GetInstance() |
| 61 ->GetForProfile(profile); | 61 ->GetForProfile(profile); |
| 62 } | 62 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 if (!IsTtsLoadedInThisProfile()) | 117 if (!IsTtsLoadedInThisProfile()) |
| 118 return; | 118 return; |
| 119 | 119 |
| 120 if (tts_state_ == TTS_LOADING) { | 120 if (tts_state_ == TTS_LOADING) { |
| 121 LOG(INFO) << "TTS component extension loaded, retrying queued utterances."; | 121 LOG(INFO) << "TTS component extension loaded, retrying queued utterances."; |
| 122 tts_state_ = TTS_LOADED; | 122 tts_state_ = TTS_LOADED; |
| 123 TtsController::GetInstance()->RetrySpeakingQueuedUtterances(); | 123 TtsController::GetInstance()->RetrySpeakingQueuedUtterances(); |
| 124 } | 124 } |
| 125 } | 125 } |
| OLD | NEW |