| 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "chrome/browser/speech/tts_platform.h" | 6 #include "chrome/browser/speech/tts_platform.h" |
| 7 #include "components/arc/arc_bridge_service.h" | 7 #include "components/arc/arc_bridge_service.h" |
| 8 #include "components/arc/arc_service_manager.h" |
| 8 #include "components/arc/common/tts.mojom.h" | 9 #include "components/arc/common/tts.mojom.h" |
| 9 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 10 | 11 |
| 11 namespace { | 12 namespace { |
| 12 | 13 |
| 13 // For Speak and Stop. | 14 // For Speak and Stop. |
| 14 constexpr uint32_t kDefaultMinVersion = 0; | 15 constexpr uint32_t kDefaultMinVersion = 0; |
| 15 | 16 |
| 16 // Helper returning an ARC tts instance. | 17 // Helper returning an ARC tts instance. |
| 17 arc::mojom::TtsInstance* GetArcTts(const std::string& method_name_for_logging, | 18 arc::mojom::TtsInstance* GetArcTts(const std::string& method_name_for_logging, |
| 18 uint32_t min_version) { | 19 uint32_t min_version) { |
| 19 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 20 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 20 return arc::ArcBridgeService::Get() | 21 auto* const arc_service_manager = arc::ArcServiceManager::Get(); |
| 21 ? arc::ArcBridgeService::Get()->tts()->GetInstanceForMethod( | 22 if (!arc_service_manager) |
| 22 method_name_for_logging, min_version) | 23 return nullptr; |
| 23 : nullptr; | 24 |
| 25 return arc_service_manager->arc_bridge_service()->tts()->GetInstanceForMethod( |
| 26 method_name_for_logging, min_version); |
| 24 } | 27 } |
| 25 | 28 |
| 26 } // namespace | 29 } // namespace |
| 27 | 30 |
| 28 // This class includes extension-based tts through LoadBuiltInTtsExtension and | 31 // This class includes extension-based tts through LoadBuiltInTtsExtension and |
| 29 // native tts through ARC. | 32 // native tts through ARC. |
| 30 class TtsPlatformImplChromeOs : public TtsPlatformImpl { | 33 class TtsPlatformImplChromeOs : public TtsPlatformImpl { |
| 31 public: | 34 public: |
| 32 // TtsPlatformImpl overrides: | 35 // TtsPlatformImpl overrides: |
| 33 bool PlatformImplAvailable() override { | 36 bool PlatformImplAvailable() override { |
| 34 return arc::ArcBridgeService::Get() && | 37 return arc::ArcServiceManager::Get() && |
| 35 arc::ArcBridgeService::Get()->tts()->has_instance(); | 38 arc::ArcServiceManager::Get() |
| 39 ->arc_bridge_service() |
| 40 ->tts() |
| 41 ->has_instance(); |
| 36 } | 42 } |
| 37 | 43 |
| 38 bool LoadBuiltInTtsExtension( | 44 bool LoadBuiltInTtsExtension( |
| 39 content::BrowserContext* browser_context) override { | 45 content::BrowserContext* browser_context) override { |
| 40 TtsEngineDelegate* tts_engine_delegate = | 46 TtsEngineDelegate* tts_engine_delegate = |
| 41 TtsController::GetInstance()->GetTtsEngineDelegate(); | 47 TtsController::GetInstance()->GetTtsEngineDelegate(); |
| 42 if (tts_engine_delegate) | 48 if (tts_engine_delegate) |
| 43 return tts_engine_delegate->LoadBuiltInTtsExtension(browser_context); | 49 return tts_engine_delegate->LoadBuiltInTtsExtension(browser_context); |
| 44 return false; | 50 return false; |
| 45 } | 51 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 // static | 106 // static |
| 101 TtsPlatformImpl* TtsPlatformImpl::GetInstance() { | 107 TtsPlatformImpl* TtsPlatformImpl::GetInstance() { |
| 102 return TtsPlatformImplChromeOs::GetInstance(); | 108 return TtsPlatformImplChromeOs::GetInstance(); |
| 103 } | 109 } |
| 104 | 110 |
| 105 // static | 111 // static |
| 106 TtsPlatformImplChromeOs* | 112 TtsPlatformImplChromeOs* |
| 107 TtsPlatformImplChromeOs::GetInstance() { | 113 TtsPlatformImplChromeOs::GetInstance() { |
| 108 return base::Singleton<TtsPlatformImplChromeOs>::get(); | 114 return base::Singleton<TtsPlatformImplChromeOs>::get(); |
| 109 } | 115 } |
| OLD | NEW |