| 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/mac/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" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 { |
| 52 public: | 52 public: |
| 53 virtual bool PlatformImplAvailable() override { | 53 bool PlatformImplAvailable() override { return true; } |
| 54 return true; | |
| 55 } | |
| 56 | 54 |
| 57 virtual bool Speak( | 55 bool Speak(int utterance_id, |
| 58 int utterance_id, | 56 const std::string& utterance, |
| 59 const std::string& utterance, | 57 const std::string& lang, |
| 60 const std::string& lang, | 58 const VoiceData& voice, |
| 61 const VoiceData& voice, | 59 const UtteranceContinuousParameters& params) override; |
| 62 const UtteranceContinuousParameters& params) override; | |
| 63 | 60 |
| 64 virtual bool StopSpeaking() override; | 61 bool StopSpeaking() override; |
| 65 | 62 |
| 66 virtual void Pause() override; | 63 void Pause() override; |
| 67 | 64 |
| 68 virtual void Resume() override; | 65 void Resume() override; |
| 69 | 66 |
| 70 virtual bool IsSpeaking() override; | 67 bool IsSpeaking() override; |
| 71 | 68 |
| 72 virtual void GetVoices(std::vector<VoiceData>* out_voices) override; | 69 void GetVoices(std::vector<VoiceData>* out_voices) override; |
| 73 | 70 |
| 74 // Called by ChromeTtsDelegate when we get a callback from the | 71 // Called by ChromeTtsDelegate when we get a callback from the |
| 75 // native speech engine. | 72 // native speech engine. |
| 76 void OnSpeechEvent(NSSpeechSynthesizer* sender, | 73 void OnSpeechEvent(NSSpeechSynthesizer* sender, |
| 77 TtsEventType event_type, | 74 TtsEventType event_type, |
| 78 int char_index, | 75 int char_index, |
| 79 const std::string& error_message); | 76 const std::string& error_message); |
| 80 | 77 |
| 81 // Get the single instance of this class. | 78 // Get the single instance of this class. |
| 82 static TtsPlatformImplMac* GetInstance(); | 79 static TtsPlatformImplMac* GetInstance(); |
| 83 | 80 |
| 84 private: | 81 private: |
| 85 TtsPlatformImplMac(); | 82 TtsPlatformImplMac(); |
| 86 virtual ~TtsPlatformImplMac(); | 83 ~TtsPlatformImplMac() override; |
| 87 | 84 |
| 88 base::scoped_nsobject<SingleUseSpeechSynthesizer> speech_synthesizer_; | 85 base::scoped_nsobject<SingleUseSpeechSynthesizer> speech_synthesizer_; |
| 89 base::scoped_nsobject<ChromeTtsDelegate> delegate_; | 86 base::scoped_nsobject<ChromeTtsDelegate> delegate_; |
| 90 int utterance_id_; | 87 int utterance_id_; |
| 91 std::string utterance_; | 88 std::string utterance_; |
| 92 int last_char_index_; | 89 int last_char_index_; |
| 93 bool paused_; | 90 bool paused_; |
| 94 | 91 |
| 95 friend struct DefaultSingletonTraits<TtsPlatformImplMac>; | 92 friend struct DefaultSingletonTraits<TtsPlatformImplMac>; |
| 96 | 93 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 didSpeak_ = true; | 341 didSpeak_ = true; |
| 345 return [super startSpeakingString:utterance_]; | 342 return [super startSpeakingString:utterance_]; |
| 346 } | 343 } |
| 347 | 344 |
| 348 - (bool)startSpeakingString:(NSString*)utterance { | 345 - (bool)startSpeakingString:(NSString*)utterance { |
| 349 CHECK(false); | 346 CHECK(false); |
| 350 return false; | 347 return false; |
| 351 } | 348 } |
| 352 | 349 |
| 353 @end | 350 @end |
| OLD | NEW |