Chromium Code Reviews| Index: components/arc/tts/arc_tts_service.cc |
| diff --git a/components/arc/tts/arc_tts_service.cc b/components/arc/tts/arc_tts_service.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0154dbd42a5f5e624ad1c27b2cbc9414b0531f45 |
| --- /dev/null |
| +++ b/components/arc/tts/arc_tts_service.cc |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2016 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 "components/arc/tts/arc_tts_service.h" |
| + |
| +#include "base/logging.h" |
| +#include "chrome/browser/speech/tts_controller.h" |
| +#include "components/arc/arc_bridge_service.h" |
| + |
| +namespace arc { |
| + |
| +ArcTtsService::ArcTtsService(ArcBridgeService* bridge_service) |
| + : ArcService(bridge_service), binding_(this) { |
| + arc_bridge_service()->tts()->AddObserver(this); |
| +} |
| + |
| +ArcTtsService::~ArcTtsService() {} |
|
hidehiko
2016/07/26 17:59:18
arc_bridge_service()->tts()->RemoveObserver(this);
David Tseng
2016/07/27 22:50:59
Done.
|
| + |
| +void ArcTtsService::OnInstanceReady() { |
| + mojom::TtsInstance* tts_instance = arc_bridge_service()->tts()->instance(); |
| + if (!tts_instance) { |
| + LOG(ERROR) << "OnTtsInstanceReady called, " |
| + << "but no tts instance found"; |
| + return; |
| + } |
| + tts_instance->Init(binding_.CreateInterfacePtrAndBind()); |
| +} |
| + |
| +void ArcTtsService::OnTtsEvent(uint32_t id, mojom::TtsEventType event_type) { |
| + if (!TtsController::GetInstance()) |
| + return; |
| + |
| + TtsEventType chrome_event_type; |
| + switch (event_type) { |
| + case mojom::TtsEventType::START: |
| + chrome_event_type = TTS_EVENT_START; |
| + break; |
| + case mojom::TtsEventType::END: |
| + chrome_event_type = TTS_EVENT_END; |
| + break; |
| + case mojom::TtsEventType::INTERRUPTED: |
| + chrome_event_type = TTS_EVENT_INTERRUPTED; |
| + break; |
| + case mojom::TtsEventType::ERROR: |
| + chrome_event_type = TTS_EVENT_ERROR; |
| + break; |
| + } |
| + TtsController::GetInstance()->OnTtsEvent(id, chrome_event_type, 0, ""); |
|
hidehiko
2016/07/26 17:59:18
Could you comment 0 and "" for what?
dmazzoni
2016/07/26 22:12:58
To match other engines, I think the "end" event sh
hidehiko
2016/07/29 09:25:53
ping?
David Tseng
2016/08/01 20:21:41
Passing this through now from the Android end.
|
| +} |
| + |
| +} // namespace arc |