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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/arc/arc_tts_service.cc
diff --git a/chrome/browser/chromeos/arc/arc_tts_service.cc b/chrome/browser/chromeos/arc/arc_tts_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ab570152277daca708ffa932aedb318e1f823502
--- /dev/null
+++ b/chrome/browser/chromeos/arc/arc_tts_service.cc
@@ -0,0 +1,58 @@
+// 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 "chrome/browser/chromeos/arc/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() {
+ arc_bridge_service()->tts()->RemoveObserver(this);
+}
+
+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,
+ uint32_t char_index,
+ const mojo::String& error_msg) {
+ 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, char_index,
+ error_msg);
+}
+
+} // namespace arc
« 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