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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/memory/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/extensions/extension_function.h" | 11 #include "chrome/browser/extensions/extension_function.h" |
12 #include "chrome/browser/speech/tts_controller.h" | 12 #include "chrome/browser/speech/tts_controller.h" |
13 #include "chrome/browser/speech/tts_platform.h" | 13 #include "chrome/browser/speech/tts_platform.h" |
14 | 14 |
15 #import <Cocoa/Cocoa.h> | 15 #import <Cocoa/Cocoa.h> |
16 | 16 |
17 class TtsPlatformImplMac; | 17 class TtsPlatformImplMac; |
(...skipping 13 matching lines...) Expand all Loading... |
31 // | 31 // |
32 // We construct a new NSSpeechSynthesizer for each utterance, for | 32 // We construct a new NSSpeechSynthesizer for each utterance, for |
33 // two reasons: | 33 // two reasons: |
34 // 1. To associate delegate callbacks with a particular utterance, | 34 // 1. To associate delegate callbacks with a particular utterance, |
35 // without assuming anything undocumented about the protocol. | 35 // without assuming anything undocumented about the protocol. |
36 // 2. To work around http://openradar.appspot.com/radar?id=2854403, | 36 // 2. To work around http://openradar.appspot.com/radar?id=2854403, |
37 // where Nuance voices don't retain the utterance string and | 37 // where Nuance voices don't retain the utterance string and |
38 // crash when trying to call willSpeakWord. | 38 // crash when trying to call willSpeakWord. |
39 @interface SingleUseSpeechSynthesizer : NSSpeechSynthesizer { | 39 @interface SingleUseSpeechSynthesizer : NSSpeechSynthesizer { |
40 @private | 40 @private |
41 scoped_nsobject<NSString> utterance_; | 41 base::scoped_nsobject<NSString> utterance_; |
42 bool didSpeak_; | 42 bool didSpeak_; |
43 } | 43 } |
44 | 44 |
45 - (id)initWithUtterance:(NSString*)utterance; | 45 - (id)initWithUtterance:(NSString*)utterance; |
46 - (bool)startSpeakingRetainedUtterance; | 46 - (bool)startSpeakingRetainedUtterance; |
47 - (bool)startSpeakingString:(NSString*)utterance; | 47 - (bool)startSpeakingString:(NSString*)utterance; |
48 | 48 |
49 @end | 49 @end |
50 | 50 |
51 class TtsPlatformImplMac : public TtsPlatformImpl { | 51 class TtsPlatformImplMac : public TtsPlatformImpl { |
(...skipping 26 matching lines...) Expand all Loading... |
78 int char_index, | 78 int char_index, |
79 const std::string& error_message); | 79 const std::string& error_message); |
80 | 80 |
81 // Get the single instance of this class. | 81 // Get the single instance of this class. |
82 static TtsPlatformImplMac* GetInstance(); | 82 static TtsPlatformImplMac* GetInstance(); |
83 | 83 |
84 private: | 84 private: |
85 TtsPlatformImplMac(); | 85 TtsPlatformImplMac(); |
86 virtual ~TtsPlatformImplMac(); | 86 virtual ~TtsPlatformImplMac(); |
87 | 87 |
88 scoped_nsobject<SingleUseSpeechSynthesizer> speech_synthesizer_; | 88 base::scoped_nsobject<SingleUseSpeechSynthesizer> speech_synthesizer_; |
89 scoped_nsobject<ChromeTtsDelegate> delegate_; | 89 base::scoped_nsobject<ChromeTtsDelegate> delegate_; |
90 int utterance_id_; | 90 int utterance_id_; |
91 std::string utterance_; | 91 std::string utterance_; |
92 bool sent_start_event_; | 92 bool sent_start_event_; |
93 int last_char_index_; | 93 int last_char_index_; |
94 bool paused_; | 94 bool paused_; |
95 | 95 |
96 friend struct DefaultSingletonTraits<TtsPlatformImplMac>; | 96 friend struct DefaultSingletonTraits<TtsPlatformImplMac>; |
97 | 97 |
98 DISALLOW_COPY_AND_ASSIGN(TtsPlatformImplMac); | 98 DISALLOW_COPY_AND_ASSIGN(TtsPlatformImplMac); |
99 }; | 99 }; |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 didSpeak_ = true; | 343 didSpeak_ = true; |
344 return [super startSpeakingString:utterance_]; | 344 return [super startSpeakingString:utterance_]; |
345 } | 345 } |
346 | 346 |
347 - (bool)startSpeakingString:(NSString*)utterance { | 347 - (bool)startSpeakingString:(NSString*)utterance { |
348 CHECK(false); | 348 CHECK(false); |
349 return false; | 349 return false; |
350 } | 350 } |
351 | 351 |
352 @end | 352 @end |
OLD | NEW |