| 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/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/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 TtsExtensionLoaderChromeOsFactory() : BrowserContextKeyedServiceFactory( | 40 TtsExtensionLoaderChromeOsFactory() : BrowserContextKeyedServiceFactory( |
| 41 "TtsExtensionLoaderChromeOs", | 41 "TtsExtensionLoaderChromeOs", |
| 42 BrowserContextDependencyManager::GetInstance()) { | 42 BrowserContextDependencyManager::GetInstance()) { |
| 43 DependsOn(extensions::ExtensionSystemFactory::GetInstance()); | 43 DependsOn(extensions::ExtensionSystemFactory::GetInstance()); |
| 44 } | 44 } |
| 45 | 45 |
| 46 virtual ~TtsExtensionLoaderChromeOsFactory() {} | 46 virtual ~TtsExtensionLoaderChromeOsFactory() {} |
| 47 | 47 |
| 48 virtual content::BrowserContext* GetBrowserContextToUse( | 48 virtual content::BrowserContext* GetBrowserContextToUse( |
| 49 content::BrowserContext* context) const OVERRIDE{ | 49 content::BrowserContext* context) const OVERRIDE { |
| 50 // If given an incognito profile (including the Chrome OS login | 50 // If given an incognito profile (including the Chrome OS login |
| 51 // profile), share the service with the original profile. | 51 // profile), share the service with the original profile. |
| 52 return chrome::GetBrowserContextRedirectedInIncognito(context); | 52 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 53 } | 53 } |
| 54 | 54 |
| 55 virtual KeyedService* BuildServiceInstanceFor( | 55 virtual KeyedService* BuildServiceInstanceFor( |
| 56 content::BrowserContext* profile) const OVERRIDE { | 56 content::BrowserContext* profile) const OVERRIDE { |
| 57 return new TtsExtensionLoaderChromeOs(static_cast<Profile*>(profile)); | 57 return new TtsExtensionLoaderChromeOs(static_cast<Profile*>(profile)); |
| 58 } | 58 } |
| 59 }; | 59 }; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 78 event_router->RegisterObserver(this, tts_engine_events::kOnStop); | 78 event_router->RegisterObserver(this, tts_engine_events::kOnStop); |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool TtsExtensionLoaderChromeOs::LoadTtsExtension() { | 81 bool TtsExtensionLoaderChromeOs::LoadTtsExtension() { |
| 82 if (tts_state_ == TTS_LOADED || tts_state_ == TTS_LOADING) | 82 if (tts_state_ == TTS_LOADED || tts_state_ == TTS_LOADING) |
| 83 return false; | 83 return false; |
| 84 | 84 |
| 85 // Load the component extension into this profile. | 85 // Load the component extension into this profile. |
| 86 VLOG(1) << "Loading TTS component extension."; | 86 VLOG(1) << "Loading TTS component extension."; |
| 87 tts_state_ = TTS_LOADING; | 87 tts_state_ = TTS_LOADING; |
| 88 ExtensionService* extension_service = profile_->GetExtensionService(); | 88 ExtensionService* extension_service = |
| 89 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| 89 DCHECK(extension_service); | 90 DCHECK(extension_service); |
| 90 extension_service->component_loader()->AddChromeOsSpeechSynthesisExtension(); | 91 extension_service->component_loader()->AddChromeOsSpeechSynthesisExtension(); |
| 91 return true; | 92 return true; |
| 92 } | 93 } |
| 93 | 94 |
| 94 void TtsExtensionLoaderChromeOs::Shutdown() { | 95 void TtsExtensionLoaderChromeOs::Shutdown() { |
| 95 extensions::EventRouter::Get(profile_)->UnregisterObserver(this); | 96 extensions::EventRouter::Get(profile_)->UnregisterObserver(this); |
| 96 } | 97 } |
| 97 | 98 |
| 98 bool TtsExtensionLoaderChromeOs::IsTtsLoadedInThisProfile() { | 99 bool TtsExtensionLoaderChromeOs::IsTtsLoadedInThisProfile() { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 120 | 121 |
| 121 if (!IsTtsLoadedInThisProfile()) | 122 if (!IsTtsLoadedInThisProfile()) |
| 122 return; | 123 return; |
| 123 | 124 |
| 124 if (tts_state_ == TTS_LOADING) { | 125 if (tts_state_ == TTS_LOADING) { |
| 125 VLOG(1) << "TTS component extension loaded, retrying queued utterances."; | 126 VLOG(1) << "TTS component extension loaded, retrying queued utterances."; |
| 126 tts_state_ = TTS_LOADED; | 127 tts_state_ = TTS_LOADED; |
| 127 TtsController::GetInstance()->RetrySpeakingQueuedUtterances(); | 128 TtsController::GetInstance()->RetrySpeakingQueuedUtterances(); |
| 128 } | 129 } |
| 129 } | 130 } |
| OLD | NEW |