Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: chrome/browser/speech/extension_api/tts_extension_api_mac.mm

Issue 9967021: Uses a system-wide notion of isSpeaking in the Mac extension TTS api. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <string> 5 #include <string>
6 6
7 #include "base/mac/cocoa_protocols.h" 7 #include "base/mac/cocoa_protocols.h"
8 #include "base/memory/scoped_nsobject.h" 8 #include "base/memory/scoped_nsobject.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 bool ExtensionTtsPlatformImplMac::StopSpeaking() { 123 bool ExtensionTtsPlatformImplMac::StopSpeaking() {
124 if (speech_synthesizer_.get()) { 124 if (speech_synthesizer_.get()) {
125 [speech_synthesizer_ stopSpeaking]; 125 [speech_synthesizer_ stopSpeaking];
126 speech_synthesizer_.reset(nil); 126 speech_synthesizer_.reset(nil);
127 } 127 }
128 return true; 128 return true;
129 } 129 }
130 130
131 bool ExtensionTtsPlatformImplMac::IsSpeaking() { 131 bool ExtensionTtsPlatformImplMac::IsSpeaking() {
132 // Note: this is OK even if speech_synthesizer_ is nil, it will return false. 132 return [NSSpeechSynthesizer isAnyApplicationSpeaking];
133 return [speech_synthesizer_ isSpeaking];
134 } 133 }
135 134
136 bool ExtensionTtsPlatformImplMac::SendsEvent(TtsEventType event_type) { 135 bool ExtensionTtsPlatformImplMac::SendsEvent(TtsEventType event_type) {
137 return (event_type == TTS_EVENT_START || 136 return (event_type == TTS_EVENT_START ||
138 event_type == TTS_EVENT_END || 137 event_type == TTS_EVENT_END ||
139 event_type == TTS_EVENT_WORD || 138 event_type == TTS_EVENT_WORD ||
140 event_type == TTS_EVENT_ERROR); 139 event_type == TTS_EVENT_ERROR);
141 } 140 }
142 141
143 void ExtensionTtsPlatformImplMac::OnSpeechEvent( 142 void ExtensionTtsPlatformImplMac::OnSpeechEvent(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 - (void)speechSynthesizer:(NSSpeechSynthesizer*)sender 201 - (void)speechSynthesizer:(NSSpeechSynthesizer*)sender
203 didEncounterErrorAtIndex:(NSUInteger)character_index 202 didEncounterErrorAtIndex:(NSUInteger)character_index
204 ofString:(NSString*)string 203 ofString:(NSString*)string
205 message:(NSString*)message { 204 message:(NSString*)message {
206 std::string message_utf8 = base::SysNSStringToUTF8(message); 205 std::string message_utf8 = base::SysNSStringToUTF8(message);
207 ttsImplMac_->OnSpeechEvent(sender, TTS_EVENT_ERROR, character_index, 206 ttsImplMac_->OnSpeechEvent(sender, TTS_EVENT_ERROR, character_index,
208 message_utf8); 207 message_utf8);
209 } 208 }
210 209
211 @end 210 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698