Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/arc/tts/arc_tts_service.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "chrome/browser/speech/tts_controller.h" | |
| 9 #include "components/arc/arc_bridge_service.h" | |
| 10 | |
| 11 namespace arc { | |
| 12 | |
| 13 ArcTtsService::ArcTtsService(ArcBridgeService* bridge_service) | |
| 14 : ArcService(bridge_service), binding_(this) { | |
| 15 arc_bridge_service()->tts()->AddObserver(this); | |
| 16 } | |
| 17 | |
| 18 ArcTtsService::~ArcTtsService() {} | |
|
hidehiko
2016/07/26 17:59:18
arc_bridge_service()->tts()->RemoveObserver(this);
David Tseng
2016/07/27 22:50:59
Done.
| |
| 19 | |
| 20 void ArcTtsService::OnInstanceReady() { | |
| 21 mojom::TtsInstance* tts_instance = arc_bridge_service()->tts()->instance(); | |
| 22 if (!tts_instance) { | |
| 23 LOG(ERROR) << "OnTtsInstanceReady called, " | |
| 24 << "but no tts instance found"; | |
| 25 return; | |
| 26 } | |
| 27 tts_instance->Init(binding_.CreateInterfacePtrAndBind()); | |
| 28 } | |
| 29 | |
| 30 void ArcTtsService::OnTtsEvent(uint32_t id, mojom::TtsEventType event_type) { | |
| 31 if (!TtsController::GetInstance()) | |
| 32 return; | |
| 33 | |
| 34 TtsEventType chrome_event_type; | |
| 35 switch (event_type) { | |
| 36 case mojom::TtsEventType::START: | |
| 37 chrome_event_type = TTS_EVENT_START; | |
| 38 break; | |
| 39 case mojom::TtsEventType::END: | |
| 40 chrome_event_type = TTS_EVENT_END; | |
| 41 break; | |
| 42 case mojom::TtsEventType::INTERRUPTED: | |
| 43 chrome_event_type = TTS_EVENT_INTERRUPTED; | |
| 44 break; | |
| 45 case mojom::TtsEventType::ERROR: | |
| 46 chrome_event_type = TTS_EVENT_ERROR; | |
| 47 break; | |
| 48 } | |
| 49 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.
| |
| 50 } | |
| 51 | |
| 52 } // namespace arc | |
| OLD | NEW |