summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormrunal.kapade@intel.com <mrunal.kapade@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-02 05:56:00 +0000
committermrunal.kapade@intel.com <mrunal.kapade@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-02 05:56:00 +0000
commit2372952cef5c0420c3b994cc26c0819214dc620d (patch)
tree0927b0a4708a7759db52dcc625e7049ca1ca9832
parentb3c3fde3c66f9502e97f0c30c91ab4304c40c5b8 (diff)
downloadchromium_src-2372952cef5c0420c3b994cc26c0819214dc620d.zip
chromium_src-2372952cef5c0420c3b994cc26c0819214dc620d.tar.gz
chromium_src-2372952cef5c0420c3b994cc26c0819214dc620d.tar.bz2
Remove the dependency of Extension API from tts_chromeos
Moving the extension api dependency from TtsPlatformImplChromeOs to TtsExtensionEngine through TtsEngineDelegate. This is part of an effort to move TTS to content. BUG=347045 Review URL: https://codereview.chromium.org/434083003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287160 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/speech/extension_api/tts_engine_extension_api.cc24
-rw-r--r--chrome/browser/speech/extension_api/tts_engine_extension_api.h1
-rw-r--r--chrome/browser/speech/tts_chromeos.cc30
-rw-r--r--chrome/browser/speech/tts_controller.h7
-rw-r--r--chrome/browser/speech/tts_controller_impl.cc4
-rw-r--r--chrome/browser/speech/tts_controller_impl.h1
6 files changed, 46 insertions, 21 deletions
diff --git a/chrome/browser/speech/extension_api/tts_engine_extension_api.cc b/chrome/browser/speech/extension_api/tts_engine_extension_api.cc
index c7f514a..5f06106 100644
--- a/chrome/browser/speech/extension_api/tts_engine_extension_api.cc
+++ b/chrome/browser/speech/extension_api/tts_engine_extension_api.cc
@@ -8,11 +8,15 @@
#include "base/json/json_writer.h"
#include "base/values.h"
+#include "chrome/browser/extensions/component_loader.h"
+#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/speech/extension_api/tts_engine_extension_observer.h"
#include "chrome/browser/speech/extension_api/tts_extension_api.h"
#include "chrome/browser/speech/extension_api/tts_extension_api_constants.h"
#include "chrome/browser/speech/tts_controller.h"
#include "chrome/common/extensions/api/speech/tts_engine_manifest_handler.h"
+#include "chrome/common/extensions/extension_constants.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/common/console_message_level.h"
@@ -210,6 +214,26 @@ void TtsExtensionEngine::Resume(Utterance* utterance) {
WarnIfMissingPauseOrResumeListener(profile, event_router, id);
}
+bool TtsExtensionEngine::LoadBuiltInTtsExtension(Profile* profile) {
+#if defined(OS_CHROMEOS)
+ // Check to see if the engine was previously loaded.
+ if (TtsEngineExtensionObserver::GetInstance(profile)->SawExtensionLoad(
+ extension_misc::kSpeechSynthesisExtensionId, true)) {
+ return false;
+ }
+
+ // Load the component extension into this profile.
+ ExtensionService* extension_service =
+ extensions::ExtensionSystem::Get(profile)->extension_service();
+ DCHECK(extension_service);
+ extension_service->component_loader()
+ ->AddChromeOsSpeechSynthesisExtension();
+ return true;
+#else
+ return false;
+#endif
+}
+
bool ExtensionTtsEngineSendTtsEventFunction::RunSync() {
int utterance_id;
EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &utterance_id));
diff --git a/chrome/browser/speech/extension_api/tts_engine_extension_api.h b/chrome/browser/speech/extension_api/tts_engine_extension_api.h
index a2df681..4d9310c 100644
--- a/chrome/browser/speech/extension_api/tts_engine_extension_api.h
+++ b/chrome/browser/speech/extension_api/tts_engine_extension_api.h
@@ -40,6 +40,7 @@ class TtsExtensionEngine : public TtsEngineDelegate {
virtual void Stop(Utterance* utterance) OVERRIDE;
virtual void Pause(Utterance* utterance) OVERRIDE;
virtual void Resume(Utterance* utterance) OVERRIDE;
+ virtual bool LoadBuiltInTtsExtension(Profile* profile) OVERRIDE;
};
// Hidden/internal extension function used to allow TTS engine extensions
diff --git a/chrome/browser/speech/tts_chromeos.cc b/chrome/browser/speech/tts_chromeos.cc
index ad52238..1e74195 100644
--- a/chrome/browser/speech/tts_chromeos.cc
+++ b/chrome/browser/speech/tts_chromeos.cc
@@ -2,20 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/extensions/component_loader.h"
-#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/speech/extension_api/tts_engine_extension_observer.h"
#include "chrome/browser/speech/tts_platform.h"
-#include "chrome/common/extensions/extension_constants.h"
-#include "extensions/browser/extension_system.h"
// Chrome OS doesn't have native TTS, instead it includes a built-in
// component extension that provides speech synthesis. This class includes
// an implementation of LoadBuiltInTtsExtension and dummy implementations of
// everything else.
-class TtsPlatformImplChromeOs
- : public TtsPlatformImpl {
+
+class Profile;
+
+class TtsPlatformImplChromeOs : public TtsPlatformImpl {
public:
// TtsPlatformImpl overrides:
virtual bool PlatformImplAvailable() OVERRIDE {
@@ -23,19 +19,11 @@ class TtsPlatformImplChromeOs
}
virtual bool LoadBuiltInTtsExtension(Profile* profile) OVERRIDE {
- // Check to see if the engine was previously loaded.
- if (TtsEngineExtensionObserver::GetInstance(profile)->SawExtensionLoad(
- extension_misc::kSpeechSynthesisExtensionId, true)) {
- return false;
- }
-
- // Load the component extension into this profile.
- ExtensionService* extension_service =
- extensions::ExtensionSystem::Get(profile)->extension_service();
- DCHECK(extension_service);
- extension_service->component_loader()
- ->AddChromeOsSpeechSynthesisExtension();
- return true;
+ TtsEngineDelegate* tts_engine_delegate =
+ TtsController::GetInstance()->GetTtsEngineDelegate();
+ if (tts_engine_delegate)
+ return tts_engine_delegate->LoadBuiltInTtsExtension(profile);
+ return false;
}
virtual bool Speak(
diff --git a/chrome/browser/speech/tts_controller.h b/chrome/browser/speech/tts_controller.h
index 54e4740..441b05f 100644
--- a/chrome/browser/speech/tts_controller.h
+++ b/chrome/browser/speech/tts_controller.h
@@ -98,6 +98,9 @@ class TtsEngineDelegate {
// Resume speaking this utterance.
virtual void Resume(Utterance* utterance) = 0;
+
+ // Load the built-in component extension for ChromeOS.
+ virtual bool LoadBuiltInTtsExtension(Profile* profile) = 0;
};
// Class that wants to receive events on utterances.
@@ -321,6 +324,10 @@ class TtsController {
// extensions.
virtual void SetTtsEngineDelegate(TtsEngineDelegate* delegate) = 0;
+ // Get the delegate that processes TTS requests with user-installed
+ // extensions.
+ virtual TtsEngineDelegate* GetTtsEngineDelegate() = 0;
+
// For unit testing.
virtual void SetPlatformImpl(TtsPlatformImpl* platform_impl) = 0;
virtual int QueueSize() = 0;
diff --git a/chrome/browser/speech/tts_controller_impl.cc b/chrome/browser/speech/tts_controller_impl.cc
index c9e18e469..84df7cd 100644
--- a/chrome/browser/speech/tts_controller_impl.cc
+++ b/chrome/browser/speech/tts_controller_impl.cc
@@ -457,3 +457,7 @@ void TtsControllerImpl::SetTtsEngineDelegate(
TtsEngineDelegate* delegate) {
tts_engine_delegate_ = delegate;
}
+
+TtsEngineDelegate* TtsControllerImpl::GetTtsEngineDelegate() {
+ return tts_engine_delegate_;
+}
diff --git a/chrome/browser/speech/tts_controller_impl.h b/chrome/browser/speech/tts_controller_impl.h
index 2049a32..1135cb5 100644
--- a/chrome/browser/speech/tts_controller_impl.h
+++ b/chrome/browser/speech/tts_controller_impl.h
@@ -42,6 +42,7 @@ class TtsControllerImpl : public TtsController {
virtual void RemoveVoicesChangedDelegate(
VoicesChangedDelegate* delegate) OVERRIDE;
virtual void SetTtsEngineDelegate(TtsEngineDelegate* delegate) OVERRIDE;
+ virtual TtsEngineDelegate* GetTtsEngineDelegate() OVERRIDE;
virtual void SetPlatformImpl(TtsPlatformImpl* platform_impl) OVERRIDE;
virtual int QueueSize() OVERRIDE;