diff options
author | chase@chromium.org <chase@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-27 21:05:28 +0000 |
---|---|---|
committer | chase@chromium.org <chase@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-27 21:05:28 +0000 |
commit | 48eb3ceb38aa3b945b1706453c42b2f8f6da2639 (patch) | |
tree | 09ed8339419c090cab98de12b38ef4295de8cae7 /chrome/browser/extensions | |
parent | 16449f376f22c0d07ffb022ed407e827c15b8da0 (diff) | |
download | chromium_src-48eb3ceb38aa3b945b1706453c42b2f8f6da2639.zip chromium_src-48eb3ceb38aa3b945b1706453c42b2f8f6da2639.tar.gz chromium_src-48eb3ceb38aa3b945b1706453c42b2f8f6da2639.tar.bz2 |
Revert 57701 - Reland 3149027.
Review URL: http://codereview.chromium.org/3236004
Broke ChromiumOS browser_tests in ExtensionApiTest.Tts.
TBR=dtseng@chromium.org
Review URL: http://codereview.chromium.org/3224003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57727 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
5 files changed, 12 insertions, 145 deletions
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc index ce0cc58..51cc8fe 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.cc +++ b/chrome/browser/extensions/extension_function_dispatcher.cc @@ -46,7 +46,9 @@ #include "chrome/browser/extensions/extension_sidebar_api.h" #include "chrome/browser/extensions/extension_tabs_module.h" #include "chrome/browser/extensions/extension_test_api.h" +#if defined(OS_CHROMEOS) #include "chrome/browser/extensions/extension_tts_api.h" +#endif #include "chrome/browser/extensions/extensions_quota_service.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/profile.h" @@ -232,10 +234,12 @@ void FactoryRegistry::ResetFunctions() { RegisterFunction<GetFocusedControlFunction>(); RegisterFunction<SetAccessibilityEnabledFunction>(); +#if defined(OS_CHROMEOS) // Text-to-speech. RegisterFunction<ExtensionTtsSpeakFunction>(); RegisterFunction<ExtensionTtsStopSpeakingFunction>(); RegisterFunction<ExtensionTtsIsSpeakingFunction>(); +#endif // Clipboard. RegisterFunction<ExecuteCopyClipboardFunction>(); diff --git a/chrome/browser/extensions/extension_tts_api_gtk.cc b/chrome/browser/extensions/extension_tts_api_gtk.cc deleted file mode 100644 index 6804f92..0000000 --- a/chrome/browser/extensions/extension_tts_api_gtk.cc +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "extension_tts_api.h"
-
-bool ExtensionTtsSpeakFunction::RunImpl() {
- return false;
-}
-
-bool ExtensionTtsStopSpeakingFunction::RunImpl() {
- return false;
-}
-
-bool ExtensionTtsIsSpeakingFunction::RunImpl() {
- return false;
-}
diff --git a/chrome/browser/extensions/extension_tts_api_mac.mm b/chrome/browser/extensions/extension_tts_api_mac.mm deleted file mode 100644 index 98e49e3..0000000 --- a/chrome/browser/extensions/extension_tts_api_mac.mm +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "extension_tts_api.h"
-
-#include <string>
-
-#include "base/values.h"
-#include "chrome/browser/extensions/extension_function.h"
-
-#import <cocoa/cocoa.h>
-
-static NSSpeechSynthesizer* speech_synthesizer_;
-
-void InitializeSpeechSynthesizer() {
- if (!speech_synthesizer_)
- speech_synthesizer_ = [[NSSpeechSynthesizer alloc] init];
-}
-
-bool ExtensionTtsSpeakFunction::RunImpl() {
- InitializeSpeechSynthesizer();
- std::string utterance;
- EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &utterance));
- return
- [speech_synthesizer_ startSpeakingString:
- [NSString stringWithUTF8String: utterance.c_str()]];
-}
-
-bool ExtensionTtsStopSpeakingFunction::RunImpl() {
- InitializeSpeechSynthesizer();
- [speech_synthesizer_ stopSpeaking];
- return true;
-}
-
-bool ExtensionTtsIsSpeakingFunction::RunImpl() {
- InitializeSpeechSynthesizer();
- return [speech_synthesizer_ isSpeaking];
-}
diff --git a/chrome/browser/extensions/extension_tts_api_win.cc b/chrome/browser/extensions/extension_tts_api_win.cc deleted file mode 100644 index 260d047..0000000 --- a/chrome/browser/extensions/extension_tts_api_win.cc +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "extension_tts_api.h"
-
-#include <atlbase.h>
-#include <atlcom.h>
-#include <sapi.h>
-
-#include "base/scoped_comptr_win.h"
-#include "base/singleton.h"
-#include "base/values.h"
-
-class SpeechSynthesizerWrapper {
- public:
- SpeechSynthesizerWrapper() : speech_synthesizer_(NULL),
- paused_(false),
- permanent_failure_(false) {
- InitializeSpeechSynthesizer();
- }
-
- bool InitializeSpeechSynthesizer() {
- if (!SUCCEEDED(CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_SERVER,
- IID_ISpVoice, reinterpret_cast<void**>(&speech_synthesizer_)))) {
- permanent_failure_ = true;
- return false;
- }
-
- if (paused_)
- speech_synthesizer_->Resume();
- return true;
- }
-
- ScopedComPtr<ISpVoice> speech_synthesizer() {
- return speech_synthesizer_;
- }
-
- bool paused() {
- return paused_;
- }
-
- void paused(bool state) {
- paused_ = state;
- }
-
- private:
- ScopedComPtr<ISpVoice> speech_synthesizer_;
- bool paused_;
- // Indicates an error retrieving the SAPI COM interface.
- bool permanent_failure_;
-};
-
-typedef Singleton<SpeechSynthesizerWrapper> SpeechSynthesizerSingleton;
-
-bool ExtensionTtsSpeakFunction::RunImpl() {
- ScopedComPtr<ISpVoice> speech_synthesizer =
- SpeechSynthesizerSingleton::get()->speech_synthesizer();
- if (speech_synthesizer) {
- std::wstring utterance;
- EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &utterance));
- if (SpeechSynthesizerSingleton::get()->paused())
- speech_synthesizer->Resume();
- speech_synthesizer->Speak(
- utterance.c_str(), SPF_ASYNC | SPF_PURGEBEFORESPEAK, NULL);
- return true;
- }
-
- return false;
-}
-
-bool ExtensionTtsStopSpeakingFunction::RunImpl() {
- // We need to keep track of the paused state since SAPI doesn't have a stop
- // method.
- ScopedComPtr<ISpVoice> speech_synthesizer =
- SpeechSynthesizerSingleton::get()->speech_synthesizer();
- if (speech_synthesizer && !SpeechSynthesizerSingleton::get()->paused()) {
- speech_synthesizer->Pause();
- SpeechSynthesizerSingleton::get()->paused(true);
- }
- return true;
-}
-
-bool ExtensionTtsIsSpeakingFunction::RunImpl() {
- return false;
-}
diff --git a/chrome/browser/extensions/extension_tts_apitest.cc b/chrome/browser/extensions/extension_tts_apitest.cc index b1a035b..5acda10 100644 --- a/chrome/browser/extensions/extension_tts_apitest.cc +++ b/chrome/browser/extensions/extension_tts_apitest.cc @@ -7,15 +7,20 @@ #include "chrome/common/chrome_switches.h" #include "testing/gmock/include/gmock/gmock.h" -IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Tts) { +// This extension API is currently only supported on Chrome OS. +#if defined(OS_CHROMEOS) +#define MAYBE_Tts Tts +#else +#define MAYBE_Tts DISABLED_Tts +#endif + +IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Tts) { CommandLine::ForCurrentProcess()->AppendSwitch( switches::kEnableExperimentalExtensionApis); - #if defined(OS_CHROMEOS) chromeos::CrosMock crosMock; crosMock.InitMockSpeechSynthesisLibrary(); crosMock.SetSpeechSynthesisLibraryExpectations(); - #endif ASSERT_TRUE(RunExtensionTest("tts")) << message_; } |