summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_tts_api_mac.mm
diff options
context:
space:
mode:
authordtseng@chromium.org <dtseng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 18:07:40 +0000
committerdtseng@chromium.org <dtseng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 18:07:40 +0000
commit9203e592f9b700178a7610e418faa41b7323bb8d (patch)
treeb7ab2b8dcf86b0d95d71a9fa29e41e2109d5c90e /chrome/browser/extensions/extension_tts_api_mac.mm
parent91484afdf575b8dd68ba92238338085f8758dbcd (diff)
downloadchromium_src-9203e592f9b700178a7610e418faa41b7323bb8d.zip
chromium_src-9203e592f9b700178a7610e418faa41b7323bb8d.tar.gz
chromium_src-9203e592f9b700178a7610e418faa41b7323bb8d.tar.bz2
Reland 3149027.
Review URL: http://codereview.chromium.org/3236004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57701 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_tts_api_mac.mm')
-rw-r--r--chrome/browser/extensions/extension_tts_api_mac.mm39
1 files changed, 39 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_tts_api_mac.mm b/chrome/browser/extensions/extension_tts_api_mac.mm
new file mode 100644
index 0000000..98e49e3
--- /dev/null
+++ b/chrome/browser/extensions/extension_tts_api_mac.mm
@@ -0,0 +1,39 @@
+// 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];
+}