| 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 "chrome/browser/chromeos/dbus/speech_synthesizer_client.h" | 5 #include "chrome/browser/chromeos/dbus/speech_synthesizer_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "chrome/browser/chromeos/system/runtime_environment.h" | 9 #include "chrome/browser/chromeos/system/runtime_environment.h" |
| 10 #include "dbus/bus.h" | 10 #include "dbus/bus.h" |
| 11 #include "dbus/message.h" | 11 #include "dbus/message.h" |
| 12 #include "dbus/object_path.h" | |
| 13 #include "dbus/object_proxy.h" | 12 #include "dbus/object_proxy.h" |
| 14 #include "third_party/cros_system_api/dbus/service_constants.h" | 13 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 15 | 14 |
| 16 namespace chromeos { | 15 namespace chromeos { |
| 17 | 16 |
| 18 // TODO(chaitanyag): rename to "locale" after making equivalent change in | 17 // TODO(chaitanyag): rename to "locale" after making equivalent change in |
| 19 // Chrome OS code. | 18 // Chrome OS code. |
| 20 const char SpeechSynthesizerClient::kSpeechPropertyLocale[] = "name"; | 19 const char SpeechSynthesizerClient::kSpeechPropertyLocale[] = "name"; |
| 21 | 20 |
| 22 const char SpeechSynthesizerClient::kSpeechPropertyGender[] = "gender"; | 21 const char SpeechSynthesizerClient::kSpeechPropertyGender[] = "gender"; |
| 23 const char SpeechSynthesizerClient::kSpeechPropertyRate[] = "rate"; | 22 const char SpeechSynthesizerClient::kSpeechPropertyRate[] = "rate"; |
| 24 const char SpeechSynthesizerClient::kSpeechPropertyPitch[] = "pitch"; | 23 const char SpeechSynthesizerClient::kSpeechPropertyPitch[] = "pitch"; |
| 25 const char SpeechSynthesizerClient::kSpeechPropertyVolume[] = "volume"; | 24 const char SpeechSynthesizerClient::kSpeechPropertyVolume[] = "volume"; |
| 26 const char SpeechSynthesizerClient::kSpeechPropertyEquals[] = "="; | 25 const char SpeechSynthesizerClient::kSpeechPropertyEquals[] = "="; |
| 27 const char SpeechSynthesizerClient::kSpeechPropertyDelimiter[] = ";"; | 26 const char SpeechSynthesizerClient::kSpeechPropertyDelimiter[] = ";"; |
| 28 | 27 |
| 29 class SpeechSynthesizerClientImpl : public SpeechSynthesizerClient { | 28 class SpeechSynthesizerClientImpl : public SpeechSynthesizerClient { |
| 30 public: | 29 public: |
| 31 explicit SpeechSynthesizerClientImpl(dbus::Bus* bus) | 30 explicit SpeechSynthesizerClientImpl(dbus::Bus* bus) |
| 32 : proxy_(NULL), | 31 : proxy_(NULL), |
| 33 weak_ptr_factory_(this) { | 32 weak_ptr_factory_(this) { |
| 34 proxy_ = bus->GetObjectProxy( | 33 proxy_ = bus->GetObjectProxy( |
| 35 speech_synthesis::kSpeechSynthesizerServiceName, | 34 speech_synthesis::kSpeechSynthesizerServiceName, |
| 36 dbus::ObjectPath(speech_synthesis::kSpeechSynthesizerServicePath)); | 35 speech_synthesis::kSpeechSynthesizerServicePath); |
| 37 } | 36 } |
| 38 virtual ~SpeechSynthesizerClientImpl() {} | 37 virtual ~SpeechSynthesizerClientImpl() {} |
| 39 | 38 |
| 40 virtual void Speak(const std::string& text, | 39 virtual void Speak(const std::string& text, |
| 41 const std::string& properties) OVERRIDE { | 40 const std::string& properties) OVERRIDE { |
| 42 dbus::MethodCall method_call(speech_synthesis::kSpeechSynthesizerInterface, | 41 dbus::MethodCall method_call(speech_synthesis::kSpeechSynthesizerInterface, |
| 43 speech_synthesis::kSpeak); | 42 speech_synthesis::kSpeak); |
| 44 dbus::MessageWriter writer(&method_call); | 43 dbus::MessageWriter writer(&method_call); |
| 45 writer.AppendString(text); | 44 writer.AppendString(text); |
| 46 writer.AppendString(properties); | 45 writer.AppendString(properties); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // static | 126 // static |
| 128 SpeechSynthesizerClient* SpeechSynthesizerClient::Create(dbus::Bus* bus) { | 127 SpeechSynthesizerClient* SpeechSynthesizerClient::Create(dbus::Bus* bus) { |
| 129 if (system::runtime_environment::IsRunningOnChromeOS()) { | 128 if (system::runtime_environment::IsRunningOnChromeOS()) { |
| 130 return new SpeechSynthesizerClientImpl(bus); | 129 return new SpeechSynthesizerClientImpl(bus); |
| 131 } else { | 130 } else { |
| 132 return new SpeechSynthesizerClientStubImpl(); | 131 return new SpeechSynthesizerClientStubImpl(); |
| 133 } | 132 } |
| 134 } | 133 } |
| 135 | 134 |
| 136 } // namespace chromeos | 135 } // namespace chromeos |
| OLD | NEW |