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/extensions/component_loader.h" | |
6 #include "chrome/browser/extensions/extension_service.h" | |
7 #include "chrome/browser/profiles/profile.h" | |
8 #include "chrome/browser/speech/extension_api/tts_engine_extension_observer.h" | |
9 #include "chrome/browser/speech/tts_platform.h" | 5 #include "chrome/browser/speech/tts_platform.h" |
10 #include "chrome/common/extensions/extension_constants.h" | |
11 #include "extensions/browser/extension_system.h" | |
12 | 6 |
13 // Chrome OS doesn't have native TTS, instead it includes a built-in | 7 // Chrome OS doesn't have native TTS, instead it includes a built-in |
14 // component extension that provides speech synthesis. This class includes | 8 // component extension that provides speech synthesis. This class includes |
15 // an implementation of LoadBuiltInTtsExtension and dummy implementations of | 9 // an implementation of LoadBuiltInTtsExtension and dummy implementations of |
16 // everything else. | 10 // everything else. |
17 class TtsPlatformImplChromeOs | 11 |
18 : public TtsPlatformImpl { | 12 class Profile; |
| 13 |
| 14 class TtsPlatformImplChromeOs : public TtsPlatformImpl { |
19 public: | 15 public: |
20 // TtsPlatformImpl overrides: | 16 // TtsPlatformImpl overrides: |
21 virtual bool PlatformImplAvailable() OVERRIDE { | 17 virtual bool PlatformImplAvailable() OVERRIDE { |
22 return false; | 18 return false; |
23 } | 19 } |
24 | 20 |
25 virtual bool LoadBuiltInTtsExtension(Profile* profile) OVERRIDE { | 21 virtual bool LoadBuiltInTtsExtension(Profile* profile) OVERRIDE { |
26 // Check to see if the engine was previously loaded. | 22 TtsEngineDelegate* tts_engine_delegate = |
27 if (TtsEngineExtensionObserver::GetInstance(profile)->SawExtensionLoad( | 23 TtsController::GetInstance()->GetTtsEngineDelegate(); |
28 extension_misc::kSpeechSynthesisExtensionId, true)) { | 24 if (tts_engine_delegate) |
29 return false; | 25 return tts_engine_delegate->LoadBuiltInTtsExtension(profile); |
30 } | 26 return false; |
31 | |
32 // Load the component extension into this profile. | |
33 ExtensionService* extension_service = | |
34 extensions::ExtensionSystem::Get(profile)->extension_service(); | |
35 DCHECK(extension_service); | |
36 extension_service->component_loader() | |
37 ->AddChromeOsSpeechSynthesisExtension(); | |
38 return true; | |
39 } | 27 } |
40 | 28 |
41 virtual bool Speak( | 29 virtual bool Speak( |
42 int utterance_id, | 30 int utterance_id, |
43 const std::string& utterance, | 31 const std::string& utterance, |
44 const std::string& lang, | 32 const std::string& lang, |
45 const VoiceData& voice, | 33 const VoiceData& voice, |
46 const UtteranceContinuousParameters& params) OVERRIDE { | 34 const UtteranceContinuousParameters& params) OVERRIDE { |
47 return false; | 35 return false; |
48 } | 36 } |
(...skipping 28 matching lines...) Expand all Loading... |
77 // static | 65 // static |
78 TtsPlatformImpl* TtsPlatformImpl::GetInstance() { | 66 TtsPlatformImpl* TtsPlatformImpl::GetInstance() { |
79 return TtsPlatformImplChromeOs::GetInstance(); | 67 return TtsPlatformImplChromeOs::GetInstance(); |
80 } | 68 } |
81 | 69 |
82 // static | 70 // static |
83 TtsPlatformImplChromeOs* | 71 TtsPlatformImplChromeOs* |
84 TtsPlatformImplChromeOs::GetInstance() { | 72 TtsPlatformImplChromeOs::GetInstance() { |
85 return Singleton<TtsPlatformImplChromeOs>::get(); | 73 return Singleton<TtsPlatformImplChromeOs>::get(); |
86 } | 74 } |
OLD | NEW |