#include "chrome/browser/extensions/chrome_extensions_browser_interface_binders.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "build/branding_buildflags.h"
#include "build/chromeos_buildflags.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "extensions/common/extension.h"
#include "extensions/common/permissions/api_permission.h"
#include "extensions/common/permissions/permissions_data.h"
#if BUILDFLAG(IS_CHROMEOS)
#include "build/config/chromebox_for_meetings/buildflags.h"
#include "chromeos/components/remote_apps/mojom/remote_apps.mojom.h"
#include "chromeos/services/chromebox_for_meetings/public/cpp/appid_util.h"
#include "chromeos/services/chromebox_for_meetings/public/cpp/service_connection.h"
#include "chromeos/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h"
#include "chromeos/services/chromebox_for_meetings/public/mojom/xu_camera.mojom.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/webui/camera_app_ui/camera_app_ui.h"
#include "chrome/browser/ash/remote_apps/remote_apps_manager.h"
#include "chrome/browser/ash/remote_apps/remote_apps_manager_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/speech/extension_api/tts_engine_extension_observer_chromeos.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chromeos/ash/components/enhanced_network_tts/enhanced_network_tts_impl.h"
#include "chromeos/ash/components/enhanced_network_tts/mojom/enhanced_network_tts.mojom.h"
#include "chromeos/ash/components/language_packs/language_packs_impl.h"
#include "chromeos/ash/components/language_packs/public/mojom/language_packs.mojom.h"
#include "chromeos/components/remote_apps/mojom/remote_apps.mojom.h"
#include "chromeos/services/media_perception/public/mojom/media_perception.mojom.h"
#include "chromeos/services/tts/public/mojom/tts_service.mojom.h"
#include "extensions/browser/api/extensions_api_client.h"
#include "extensions/browser/api/media_perception_private/media_perception_api_delegate.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "ui/accessibility/accessibility_features.h"
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
#include "chromeos/ash/services/ime/public/mojom/input_engine.mojom.h"
#include "chromeos/services/machine_learning/public/cpp/service_connection.h"
#include "ui/base/ime/ash/extension_ime_util.h"
#include "ui/base/ime/ash/input_method_manager.h"
#endif
#if BUILDFLAG(PLATFORM_CFM)
#include "chrome/browser/ash/chromebox_for_meetings/xu_camera/xu_camera_service.h"
#include "chromeos/ash/components/chromebox_for_meetings/features.h"
#endif
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chrome/browser/lacros/remote_apps/remote_apps_proxy_lacros.h"
#include "chrome/browser/lacros/remote_apps/remote_apps_proxy_lacros_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "extensions/common/features/behavior_feature.h"
#include "extensions/common/features/feature.h"
#include "extensions/common/features/feature_provider.h"
#endif
namespace extensions {
namespace {
#if BUILDFLAG(IS_CHROMEOS_ASH)
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
void BindInputEngineManager(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<ash::ime::mojom::InputEngineManager> receiver) {
ash::input_method::InputMethodManager::Get()->ConnectInputEngineManager(
std::move(receiver));
}
void BindMachineLearningService(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<
chromeos::machine_learning::mojom::MachineLearningService> receiver) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
chromeos::machine_learning::ServiceConnection::GetInstance()
->BindMachineLearningService(std::move(receiver));
}
#endif
void BindLanguagePacks(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<ash::language::mojom::LanguagePacks> receiver) {
ash::language_packs::LanguagePacksImpl::GetInstance().BindReceiver(
std::move(receiver));
}
void BindGoogleTtsStream(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<chromeos::tts::mojom::GoogleTtsStream> receiver) {
TtsEngineExtensionObserverChromeOS::GetInstance(
Profile::FromBrowserContext(render_frame_host->GetBrowserContext()))
->BindGoogleTtsStream(std::move(receiver));
}
void BindEnhancedNetworkTts(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<ash::enhanced_network_tts::mojom::EnhancedNetworkTts>
receiver) {
ash::enhanced_network_tts::EnhancedNetworkTtsImpl::GetInstance()
.BindReceiverAndURLFactory(
std::move(receiver),
Profile::FromBrowserContext(render_frame_host->GetBrowserContext())
->GetURLLoaderFactory());
}
#endif
#if BUILDFLAG(IS_CHROMEOS)
void BindRemoteAppsFactory(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<chromeos::remote_apps::mojom::RemoteAppsFactory>
pending_receiver) {
#if BUILDFLAG(IS_CHROMEOS_ASH)
ash::RemoteAppsManager* remote_apps_manager =
ash::RemoteAppsManagerFactory::GetForProfile(
Profile::FromBrowserContext(render_frame_host->GetBrowserContext()));
DCHECK(remote_apps_manager);
remote_apps_manager->BindFactoryInterface(std::move(pending_receiver));
#else
chromeos::RemoteAppsProxyLacros* remote_apps_proxy_lacros =
chromeos::RemoteAppsProxyLacrosFactory::GetForBrowserContext(
Profile::FromBrowserContext(render_frame_host->GetBrowserContext()));
DCHECK(remote_apps_proxy_lacros);
remote_apps_proxy_lacros->BindFactoryInterface(std::move(pending_receiver));
#endif
}
void BindCfmServiceContext(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<chromeos::cfm::mojom::CfmServiceContext> receiver) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
chromeos::cfm::ServiceConnection::GetInstance()->BindServiceContext(
std::move(receiver));
}
#endif
}
void PopulateChromeFrameBindersForExtension(
mojo::BinderMapWithContext<content::RenderFrameHost*>* binder_map,
content::RenderFrameHost* render_frame_host,
const Extension* extension) { … }
}