Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: chrome/browser/chromeos/arc/arc_tts_service.cc

Issue 2180263002: Host side implementation of ARC tts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address last round. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/chromeos/arc/arc_tts_service.h ('k') | chrome/browser/speech/tts_chromeos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 "chrome/browser/chromeos/arc/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() {
19 arc_bridge_service()->tts()->RemoveObserver(this);
20 }
21
22 void ArcTtsService::OnInstanceReady() {
23 mojom::TtsInstance* tts_instance = arc_bridge_service()->tts()->instance();
24 if (!tts_instance) {
25 LOG(ERROR) << "OnTtsInstanceReady called, "
26 << "but no tts instance found";
27 return;
28 }
29 tts_instance->Init(binding_.CreateInterfacePtrAndBind());
30 }
31
32 void ArcTtsService::OnTtsEvent(uint32_t id,
33 mojom::TtsEventType event_type,
34 uint32_t char_index,
35 const mojo::String& error_msg) {
36 if (!TtsController::GetInstance())
37 return;
38
39 TtsEventType chrome_event_type;
40 switch (event_type) {
41 case mojom::TtsEventType::START:
42 chrome_event_type = TTS_EVENT_START;
43 break;
44 case mojom::TtsEventType::END:
45 chrome_event_type = TTS_EVENT_END;
46 break;
47 case mojom::TtsEventType::INTERRUPTED:
48 chrome_event_type = TTS_EVENT_INTERRUPTED;
49 break;
50 case mojom::TtsEventType::ERROR:
51 chrome_event_type = TTS_EVENT_ERROR;
52 break;
53 }
54 TtsController::GetInstance()->OnTtsEvent(id, chrome_event_type, char_index,
55 error_msg);
56 }
57
58 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_tts_service.h ('k') | chrome/browser/speech/tts_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698