Introduce ENABLE_ON_DEVICE_TRANSLATION build flag
Currently, the BUILDFLAG check for OnDeviceTranslation functionality is implemented using win|macOS|Linux and !Android. However, OnDeviceTranslation only works on Windows, macOS, and Linux, so the !Android check is incorrect. To clean up this BUILDFLAG check, this CL introduces a new build flag called ENABLE_ON_DEVICE_TRANSLATION. This flag is equivalent to win|macOS|Linux. This CL includes the following behavioral changes: On OSes other than Win/Mac/Linux, even if EnableTranslationAPI feature is enabled, the TranslationManager interface will no longer be bound in the browser process, and OnDeviceTranslationService will no longer be bound on the service process. Change-Id: Ibd913e2f931ba7f4890d2b4c625883cb02e6d470 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5925293 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Giovanni Ortuno Urquidi <ortuno@chromium.org> Reviewed-by: Ming-Ying Chung <mych@chromium.org> Commit-Queue: Tsuyoshi Horo <horo@chromium.org> Cr-Commit-Position: refs/heads/main@{#1369343}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
61a9ecc883
commit
358ff3f5f3
chrome
browser
BUILD.gnDEPSchrome_browser_interface_binders.ccchrome_content_browser_client.cc
component_updater
on_device_translation
prefs
test
utility
components
content/utility
@ -26,6 +26,7 @@ import("//components/nacl/features.gni")
|
|||||||
import("//components/offline_pages/buildflags/features.gni")
|
import("//components/offline_pages/buildflags/features.gni")
|
||||||
import("//components/optimization_guide/features.gni")
|
import("//components/optimization_guide/features.gni")
|
||||||
import("//components/os_crypt/sync/features.gni")
|
import("//components/os_crypt/sync/features.gni")
|
||||||
|
import("//components/services/on_device_translation/buildflags/features.gni")
|
||||||
import("//components/spellcheck/spellcheck_build_features.gni")
|
import("//components/spellcheck/spellcheck_build_features.gni")
|
||||||
import("//crypto/features.gni")
|
import("//crypto/features.gni")
|
||||||
import("//device/vr/buildflags/buildflags.gni")
|
import("//device/vr/buildflags/buildflags.gni")
|
||||||
@ -868,8 +869,6 @@ static_library("browser") {
|
|||||||
"ntp_tiles/chrome_popular_sites_factory.h",
|
"ntp_tiles/chrome_popular_sites_factory.h",
|
||||||
"offline_items_collection/offline_content_aggregator_factory.cc",
|
"offline_items_collection/offline_content_aggregator_factory.cc",
|
||||||
"offline_items_collection/offline_content_aggregator_factory.h",
|
"offline_items_collection/offline_content_aggregator_factory.h",
|
||||||
"on_device_translation/translation_manager_impl.cc",
|
|
||||||
"on_device_translation/translation_manager_impl.h",
|
|
||||||
"optimization_guide/model_execution/chrome_on_device_model_service_controller.cc",
|
"optimization_guide/model_execution/chrome_on_device_model_service_controller.cc",
|
||||||
"optimization_guide/model_execution/chrome_on_device_model_service_controller.h",
|
"optimization_guide/model_execution/chrome_on_device_model_service_controller.h",
|
||||||
"optimization_guide/prediction/prediction_model_download_client.cc",
|
"optimization_guide/prediction/prediction_model_download_client.cc",
|
||||||
@ -2300,7 +2299,6 @@ static_library("browser") {
|
|||||||
"//components/services/heap_profiling",
|
"//components/services/heap_profiling",
|
||||||
"//components/services/language_detection/public/cpp",
|
"//components/services/language_detection/public/cpp",
|
||||||
"//components/services/language_detection/public/mojom",
|
"//components/services/language_detection/public/mojom",
|
||||||
"//components/services/on_device_translation:on_device_translation_service",
|
|
||||||
"//components/services/paint_preview_compositor/public/mojom:mojom",
|
"//components/services/paint_preview_compositor/public/mojom:mojom",
|
||||||
"//components/services/patch/content",
|
"//components/services/patch/content",
|
||||||
"//components/services/quarantine",
|
"//components/services/quarantine",
|
||||||
@ -3895,10 +3893,6 @@ static_library("browser") {
|
|||||||
"notifications/screen_capture_notification_blocker.cc",
|
"notifications/screen_capture_notification_blocker.cc",
|
||||||
"notifications/screen_capture_notification_blocker.h",
|
"notifications/screen_capture_notification_blocker.h",
|
||||||
"obsolete_system/obsolete_system.h",
|
"obsolete_system/obsolete_system.h",
|
||||||
"on_device_translation/service_controller.cc",
|
|
||||||
"on_device_translation/service_controller.h",
|
|
||||||
"on_device_translation/translator.cc",
|
|
||||||
"on_device_translation/translator.h",
|
|
||||||
"page_info/about_this_site_side_panel_throttle.cc",
|
"page_info/about_this_site_side_panel_throttle.cc",
|
||||||
"page_info/about_this_site_side_panel_throttle.h",
|
"page_info/about_this_site_side_panel_throttle.h",
|
||||||
"page_load_metrics/observers/non_tab_webui_page_load_metrics_observer.cc",
|
"page_load_metrics/observers/non_tab_webui_page_load_metrics_observer.cc",
|
||||||
@ -4235,9 +4229,6 @@ static_library("browser") {
|
|||||||
"//chrome/browser/media/router/discovery/access_code:access_code_sink_service",
|
"//chrome/browser/media/router/discovery/access_code:access_code_sink_service",
|
||||||
"//chrome/browser/metrics/desktop_session_duration",
|
"//chrome/browser/metrics/desktop_session_duration",
|
||||||
"//chrome/browser/new_tab_page/chrome_colors",
|
"//chrome/browser/new_tab_page/chrome_colors",
|
||||||
"//chrome/browser/on_device_translation:constants",
|
|
||||||
"//chrome/browser/on_device_translation:language_pack_util",
|
|
||||||
"//chrome/browser/on_device_translation:prefs",
|
|
||||||
"//chrome/browser/policy:path_parser",
|
"//chrome/browser/policy:path_parser",
|
||||||
"//chrome/browser/resources:component_extension_resources",
|
"//chrome/browser/resources:component_extension_resources",
|
||||||
"//chrome/browser/screen_ai:prefs",
|
"//chrome/browser/screen_ai:prefs",
|
||||||
@ -8042,6 +8033,22 @@ static_library("browser") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (enable_on_device_translation) {
|
||||||
|
sources += [
|
||||||
|
"on_device_translation/service_controller.cc",
|
||||||
|
"on_device_translation/service_controller.h",
|
||||||
|
"on_device_translation/translation_manager_impl.cc",
|
||||||
|
"on_device_translation/translation_manager_impl.h",
|
||||||
|
"on_device_translation/translator.cc",
|
||||||
|
"on_device_translation/translator.h",
|
||||||
|
]
|
||||||
|
deps += [
|
||||||
|
"//chrome/browser/on_device_translation:constants",
|
||||||
|
"//chrome/browser/on_device_translation:language_pack_util",
|
||||||
|
"//chrome/browser/on_device_translation:prefs",
|
||||||
|
"//components/services/on_device_translation:on_device_translation_service",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
if (enable_pdf) {
|
if (enable_pdf) {
|
||||||
sources += [
|
sources += [
|
||||||
@ -8541,6 +8548,7 @@ static_library("browser_public_dependencies") {
|
|||||||
"//components/reporting/proto:configuration_file_proto",
|
"//components/reporting/proto:configuration_file_proto",
|
||||||
"//components/safe_browsing:buildflags",
|
"//components/safe_browsing:buildflags",
|
||||||
"//components/search_engines",
|
"//components/search_engines",
|
||||||
|
"//components/services/on_device_translation/buildflags",
|
||||||
"//components/services/storage/public/mojom",
|
"//components/services/storage/public/mojom",
|
||||||
"//components/session_proto_db:session_proto_db",
|
"//components/session_proto_db:session_proto_db",
|
||||||
"//components/sharing_message",
|
"//components/sharing_message",
|
||||||
|
@ -332,6 +332,7 @@ include_rules = [
|
|||||||
"+components/services/heap_profiling",
|
"+components/services/heap_profiling",
|
||||||
"+components/services/language_detection/public/cpp",
|
"+components/services/language_detection/public/cpp",
|
||||||
"+components/services/language_detection/public/mojom",
|
"+components/services/language_detection/public/mojom",
|
||||||
|
"+components/services/on_device_translation/buildflags",
|
||||||
"+components/services/on_device_translation/public",
|
"+components/services/on_device_translation/public",
|
||||||
"+components/services/paint_preview_compositor/public/mojom",
|
"+components/services/paint_preview_compositor/public/mojom",
|
||||||
"+components/services/patch/content",
|
"+components/services/patch/content",
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include "chrome/browser/history_clusters/history_clusters_service_factory.h"
|
#include "chrome/browser/history_clusters/history_clusters_service_factory.h"
|
||||||
#include "chrome/browser/media/media_engagement_score_details.mojom.h"
|
#include "chrome/browser/media/media_engagement_score_details.mojom.h"
|
||||||
#include "chrome/browser/navigation_predictor/navigation_predictor.h"
|
#include "chrome/browser/navigation_predictor/navigation_predictor.h"
|
||||||
#include "chrome/browser/on_device_translation/translation_manager_impl.h"
|
|
||||||
#include "chrome/browser/optimization_guide/optimization_guide_internals_ui.h"
|
#include "chrome/browser/optimization_guide/optimization_guide_internals_ui.h"
|
||||||
#include "chrome/browser/password_manager/chrome_password_manager_client.h"
|
#include "chrome/browser/password_manager/chrome_password_manager_client.h"
|
||||||
#include "chrome/browser/predictors/lcp_critical_path_predictor/lcp_critical_path_predictor_host.h"
|
#include "chrome/browser/predictors/lcp_critical_path_predictor/lcp_critical_path_predictor_host.h"
|
||||||
@ -89,6 +88,7 @@
|
|||||||
#include "components/security_state/content/content_utils.h"
|
#include "components/security_state/content/content_utils.h"
|
||||||
#include "components/security_state/content/security_state_tab_helper.h"
|
#include "components/security_state/content/security_state_tab_helper.h"
|
||||||
#include "components/security_state/core/security_state.h"
|
#include "components/security_state/core/security_state.h"
|
||||||
|
#include "components/services/on_device_translation/buildflags/buildflags.h"
|
||||||
#include "components/signin/public/identity_manager/identity_manager.h"
|
#include "components/signin/public/identity_manager/identity_manager.h"
|
||||||
#include "components/site_engagement/core/mojom/site_engagement_details.mojom.h"
|
#include "components/site_engagement/core/mojom/site_engagement_details.mojom.h"
|
||||||
#include "components/translate/content/common/translate.mojom.h"
|
#include "components/translate/content/common/translate.mojom.h"
|
||||||
@ -110,7 +110,6 @@
|
|||||||
#include "third_party/blink/public/mojom/facilitated_payments/payment_link_handler.mojom.h"
|
#include "third_party/blink/public/mojom/facilitated_payments/payment_link_handler.mojom.h"
|
||||||
#include "third_party/blink/public/mojom/lcp_critical_path_predictor/lcp_critical_path_predictor.mojom.h"
|
#include "third_party/blink/public/mojom/lcp_critical_path_predictor/lcp_critical_path_predictor.mojom.h"
|
||||||
#include "third_party/blink/public/mojom/loader/navigation_predictor.mojom.h"
|
#include "third_party/blink/public/mojom/loader/navigation_predictor.mojom.h"
|
||||||
#include "third_party/blink/public/mojom/on_device_translation/translation_manager.mojom.h"
|
|
||||||
#include "third_party/blink/public/mojom/payments/payment_credential.mojom.h"
|
#include "third_party/blink/public/mojom/payments/payment_credential.mojom.h"
|
||||||
#include "third_party/blink/public/mojom/payments/payment_request.mojom.h"
|
#include "third_party/blink/public/mojom/payments/payment_request.mojom.h"
|
||||||
#include "third_party/blink/public/mojom/prerender/prerender.mojom.h"
|
#include "third_party/blink/public/mojom/prerender/prerender.mojom.h"
|
||||||
@ -509,6 +508,11 @@
|
|||||||
#include "components/signin/public/base/signin_switches.h"
|
#include "components/signin/public/base/signin_switches.h"
|
||||||
#endif // BUILDFLAG(ENABLE_DICE_SUPPORT)
|
#endif // BUILDFLAG(ENABLE_DICE_SUPPORT)
|
||||||
|
|
||||||
|
#if BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION)
|
||||||
|
#include "chrome/browser/on_device_translation/translation_manager_impl.h"
|
||||||
|
#include "third_party/blink/public/mojom/on_device_translation/translation_manager.mojom.h"
|
||||||
|
#endif // BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION)
|
||||||
|
|
||||||
namespace chrome::internal {
|
namespace chrome::internal {
|
||||||
|
|
||||||
using content::RegisterWebUIControllerInterfaceBinder;
|
using content::RegisterWebUIControllerInterfaceBinder;
|
||||||
@ -1109,10 +1113,12 @@ void PopulateChromeFrameBinders(
|
|||||||
base::BindRepeating(&printing::CreateWebPrintingServiceForFrame));
|
base::BindRepeating(&printing::CreateWebPrintingServiceForFrame));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION)
|
||||||
if (base::FeatureList::IsEnabled(blink::features::kEnableTranslationAPI)) {
|
if (base::FeatureList::IsEnabled(blink::features::kEnableTranslationAPI)) {
|
||||||
map->Add<blink::mojom::TranslationManager>(
|
map->Add<blink::mojom::TranslationManager>(
|
||||||
base::BindRepeating(&TranslationManagerImpl::Create));
|
base::BindRepeating(&TranslationManagerImpl::Create));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if BUILDFLAG(IS_ANDROID)
|
#if BUILDFLAG(IS_ANDROID)
|
||||||
if (base::FeatureList::IsEnabled(blink::features::kPaymentLinkDetection)) {
|
if (base::FeatureList::IsEnabled(blink::features::kPaymentLinkDetection)) {
|
||||||
|
@ -108,7 +108,6 @@
|
|||||||
#include "chrome/browser/net/profile_network_context_service.h"
|
#include "chrome/browser/net/profile_network_context_service.h"
|
||||||
#include "chrome/browser/net/profile_network_context_service_factory.h"
|
#include "chrome/browser/net/profile_network_context_service_factory.h"
|
||||||
#include "chrome/browser/net/system_network_context_manager.h"
|
#include "chrome/browser/net/system_network_context_manager.h"
|
||||||
#include "chrome/browser/on_device_translation/service_controller.h"
|
|
||||||
#include "chrome/browser/optimization_guide/chrome_browser_main_extra_parts_optimization_guide.h"
|
#include "chrome/browser/optimization_guide/chrome_browser_main_extra_parts_optimization_guide.h"
|
||||||
#include "chrome/browser/payments/payment_request_display_manager_factory.h"
|
#include "chrome/browser/payments/payment_request_display_manager_factory.h"
|
||||||
#include "chrome/browser/performance_manager/public/chrome_browser_main_extra_parts_performance_manager.h"
|
#include "chrome/browser/performance_manager/public/chrome_browser_main_extra_parts_performance_manager.h"
|
||||||
@ -312,6 +311,7 @@
|
|||||||
#include "components/security_interstitials/content/ssl_error_handler.h"
|
#include "components/security_interstitials/content/ssl_error_handler.h"
|
||||||
#include "components/security_interstitials/content/ssl_error_navigation_throttle.h"
|
#include "components/security_interstitials/content/ssl_error_navigation_throttle.h"
|
||||||
#include "components/security_state/core/security_state.h"
|
#include "components/security_state/core/security_state.h"
|
||||||
|
#include "components/services/on_device_translation/buildflags/buildflags.h"
|
||||||
#include "components/site_isolation/pref_names.h"
|
#include "components/site_isolation/pref_names.h"
|
||||||
#include "components/site_isolation/preloaded_isolated_origins.h"
|
#include "components/site_isolation/preloaded_isolated_origins.h"
|
||||||
#include "components/site_isolation/site_isolation_policy.h"
|
#include "components/site_isolation/site_isolation_policy.h"
|
||||||
@ -807,6 +807,10 @@
|
|||||||
#include "components/feed/feed_feature_list.h"
|
#include "components/feed/feed_feature_list.h"
|
||||||
#endif // BUILDFLAG(IS_ANDROID)
|
#endif // BUILDFLAG(IS_ANDROID)
|
||||||
|
|
||||||
|
#if BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION)
|
||||||
|
#include "chrome/browser/on_device_translation/service_controller.h"
|
||||||
|
#endif // BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION)
|
||||||
|
|
||||||
using blink::mojom::EffectiveConnectionType;
|
using blink::mojom::EffectiveConnectionType;
|
||||||
using blink::web_pref::WebPreferences;
|
using blink::web_pref::WebPreferences;
|
||||||
using content::BrowserThread;
|
using content::BrowserThread;
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
#include "components/history_embeddings/history_embeddings_features.h"
|
#include "components/history_embeddings/history_embeddings_features.h"
|
||||||
#include "components/nacl/common/buildflags.h"
|
#include "components/nacl/common/buildflags.h"
|
||||||
#include "components/safe_browsing/core/common/features.h"
|
#include "components/safe_browsing/core/common/features.h"
|
||||||
|
#include "components/services/on_device_translation/buildflags/buildflags.h"
|
||||||
#include "device/vr/buildflags/buildflags.h"
|
#include "device/vr/buildflags/buildflags.h"
|
||||||
#include "ppapi/buildflags/buildflags.h"
|
#include "ppapi/buildflags/buildflags.h"
|
||||||
#include "third_party/widevine/cdm/buildflags.h"
|
#include "third_party/widevine/cdm/buildflags.h"
|
||||||
@ -82,11 +83,6 @@
|
|||||||
#include "media/base/media_switches.h"
|
#include "media/base/media_switches.h"
|
||||||
#endif // !BUILDFLAG(IS_ANDROID)
|
#endif // !BUILDFLAG(IS_ANDROID)
|
||||||
|
|
||||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
|
|
||||||
#include "chrome/browser/component_updater/translate_kit_component_installer.h"
|
|
||||||
#include "chrome/browser/component_updater/translate_kit_language_pack_component_installer.h"
|
|
||||||
#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||||
#include "chrome/browser/component_updater/smart_dim_component_installer.h"
|
#include "chrome/browser/component_updater/smart_dim_component_installer.h"
|
||||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||||
@ -95,6 +91,11 @@
|
|||||||
#include "chrome/browser/component_updater/media_foundation_widevine_cdm_component_installer.h"
|
#include "chrome/browser/component_updater/media_foundation_widevine_cdm_component_installer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION)
|
||||||
|
#include "chrome/browser/component_updater/translate_kit_component_installer.h"
|
||||||
|
#include "chrome/browser/component_updater/translate_kit_language_pack_component_installer.h"
|
||||||
|
#endif // BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION)
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
|
#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
|
||||||
#include "chrome/browser/component_updater/widevine_cdm_component_installer.h"
|
#include "chrome/browser/component_updater/widevine_cdm_component_installer.h"
|
||||||
#endif // BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
|
#endif // BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
|
||||||
@ -232,14 +233,14 @@ void RegisterComponentsForUpdate() {
|
|||||||
|
|
||||||
RegisterPlusAddressBlocklistComponent(cus);
|
RegisterPlusAddressBlocklistComponent(cus);
|
||||||
|
|
||||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
|
#if BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION)
|
||||||
// TODO(crbug.com/364795294): Support other platforms.
|
// TODO(crbug.com/364795294): Support other platforms.
|
||||||
RegisterTranslateKitComponent(cus, g_browser_process->local_state(),
|
RegisterTranslateKitComponent(cus, g_browser_process->local_state(),
|
||||||
/*force_install=*/false,
|
/*force_install=*/false,
|
||||||
/*registered_callback=*/base::OnceClosure());
|
/*registered_callback=*/base::OnceClosure());
|
||||||
RegisterTranslateKitLanguagePackComponentsForUpdate(
|
RegisterTranslateKitLanguagePackComponentsForUpdate(
|
||||||
cus, g_browser_process->local_state());
|
cus, g_browser_process->local_state());
|
||||||
#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
|
#endif // BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION)
|
||||||
|
|
||||||
RegisterOpenCookieDatabaseComponent(cus);
|
RegisterOpenCookieDatabaseComponent(cus);
|
||||||
}
|
}
|
||||||
|
@ -21,14 +21,11 @@
|
|||||||
#include "chrome/browser/on_device_translation/pref_names.h"
|
#include "chrome/browser/on_device_translation/pref_names.h"
|
||||||
#include "components/component_updater/component_updater_service.h"
|
#include "components/component_updater/component_updater_service.h"
|
||||||
#include "components/crx_file/id_util.h"
|
#include "components/crx_file/id_util.h"
|
||||||
|
#include "components/services/on_device_translation/public/cpp/features.h"
|
||||||
#include "components/update_client/update_client_errors.h"
|
#include "components/update_client/update_client_errors.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "crypto/sha2.h"
|
#include "crypto/sha2.h"
|
||||||
|
|
||||||
#if !BUILDFLAG(IS_ANDROID)
|
|
||||||
#include "components/services/on_device_translation/public/cpp/features.h"
|
|
||||||
#endif // !BUILDFLAG(IS_ANDROID)
|
|
||||||
|
|
||||||
namespace component_updater {
|
namespace component_updater {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -36,3 +36,26 @@ source_set("language_pack_util") {
|
|||||||
|
|
||||||
deps = [ "//base" ]
|
deps = [ "//base" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
source_set("unit_tests") {
|
||||||
|
testonly = true
|
||||||
|
sources = [
|
||||||
|
"../component_updater/translate_kit_component_installer_unittest.cc",
|
||||||
|
"../component_updater/translate_kit_language_pack_component_installer_unittest.cc",
|
||||||
|
"language_pack_util_unittest.cc",
|
||||||
|
"translation_manager_impl_unittest.cc",
|
||||||
|
]
|
||||||
|
deps = [
|
||||||
|
":language_pack_util",
|
||||||
|
":prefs",
|
||||||
|
"//base",
|
||||||
|
"//base/test:test_support",
|
||||||
|
"//chrome/browser",
|
||||||
|
"//components/component_updater:test_support",
|
||||||
|
"//components/crx_file",
|
||||||
|
"//components/prefs",
|
||||||
|
"//components/services/on_device_translation/public/cpp",
|
||||||
|
"//components/sync_preferences:test_support",
|
||||||
|
"//content/test:test_support",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#if !BUILDFLAG(IS_ANDROID)
|
|
||||||
#include "base/feature_list.h"
|
#include "base/feature_list.h"
|
||||||
#include "base/strings/string_split.h"
|
#include "base/strings/string_split.h"
|
||||||
#include "chrome/browser/on_device_translation/language_pack_util.h"
|
#include "chrome/browser/on_device_translation/language_pack_util.h"
|
||||||
@ -16,15 +15,13 @@
|
|||||||
#include "components/language/core/browser/pref_names.h"
|
#include "components/language/core/browser/pref_names.h"
|
||||||
#include "components/prefs/pref_service.h"
|
#include "components/prefs/pref_service.h"
|
||||||
#include "components/services/on_device_translation/public/cpp/features.h"
|
#include "components/services/on_device_translation/public/cpp/features.h"
|
||||||
#include "ui/base/l10n/l10n_util.h"
|
|
||||||
#endif // !BUILDFLAG(IS_ANDROID)
|
|
||||||
#include "content/public/browser/render_frame_host.h"
|
#include "content/public/browser/render_frame_host.h"
|
||||||
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
|
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
|
||||||
#include "third_party/blink/public/mojom/on_device_translation/translation_manager.mojom.h"
|
#include "third_party/blink/public/mojom/on_device_translation/translation_manager.mojom.h"
|
||||||
|
#include "ui/base/l10n/l10n_util.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
#if !BUILDFLAG(IS_ANDROID)
|
|
||||||
using on_device_translation::SupportedLanguage;
|
using on_device_translation::SupportedLanguage;
|
||||||
|
|
||||||
bool IsInAcceptLanguage(const std::vector<std::string_view>& accept_languages,
|
bool IsInAcceptLanguage(const std::vector<std::string_view>& accept_languages,
|
||||||
@ -44,7 +41,6 @@ bool IsSupportedPopularLanguage(const std::string& lang) {
|
|||||||
}
|
}
|
||||||
return on_device_translation::IsPopularLanguage(*supported_lang);
|
return on_device_translation::IsPopularLanguage(*supported_lang);
|
||||||
}
|
}
|
||||||
#endif // !BUILDFLAG(IS_ANDROID)
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@ -70,8 +66,6 @@ void TranslationManagerImpl::CanCreateTranslator(
|
|||||||
const std::string& source_lang,
|
const std::string& source_lang,
|
||||||
const std::string& target_lang,
|
const std::string& target_lang,
|
||||||
CanCreateTranslatorCallback callback) {
|
CanCreateTranslatorCallback callback) {
|
||||||
// The API is not supported on Android yet.
|
|
||||||
#if !BUILDFLAG(IS_ANDROID)
|
|
||||||
CHECK(browser_context_);
|
CHECK(browser_context_);
|
||||||
if (!PassAcceptLanguagesCheck(
|
if (!PassAcceptLanguagesCheck(
|
||||||
Profile::FromBrowserContext(browser_context_.get())
|
Profile::FromBrowserContext(browser_context_.get())
|
||||||
@ -83,9 +77,6 @@ void TranslationManagerImpl::CanCreateTranslator(
|
|||||||
}
|
}
|
||||||
OnDeviceTranslationServiceController::GetInstance()->CanTranslate(
|
OnDeviceTranslationServiceController::GetInstance()->CanTranslate(
|
||||||
source_lang, target_lang, std::move(callback));
|
source_lang, target_lang, std::move(callback));
|
||||||
#else
|
|
||||||
std::move(callback).Run(false);
|
|
||||||
#endif // !BUILDFLAG(IS_ANDROID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TranslationManagerImpl::CreateTranslator(
|
void TranslationManagerImpl::CreateTranslator(
|
||||||
@ -93,8 +84,6 @@ void TranslationManagerImpl::CreateTranslator(
|
|||||||
const std::string& target_lang,
|
const std::string& target_lang,
|
||||||
mojo::PendingReceiver<blink::mojom::Translator> receiver,
|
mojo::PendingReceiver<blink::mojom::Translator> receiver,
|
||||||
CreateTranslatorCallback callback) {
|
CreateTranslatorCallback callback) {
|
||||||
// The API is not supported on Android yet.
|
|
||||||
#if !BUILDFLAG(IS_ANDROID)
|
|
||||||
CHECK(browser_context_);
|
CHECK(browser_context_);
|
||||||
if (!PassAcceptLanguagesCheck(
|
if (!PassAcceptLanguagesCheck(
|
||||||
Profile::FromBrowserContext(browser_context_.get())
|
Profile::FromBrowserContext(browser_context_.get())
|
||||||
@ -108,12 +97,8 @@ void TranslationManagerImpl::CreateTranslator(
|
|||||||
std::make_unique<Translator>(source_lang, target_lang,
|
std::make_unique<Translator>(source_lang, target_lang,
|
||||||
std::move(callback)),
|
std::move(callback)),
|
||||||
std::move(receiver));
|
std::move(receiver));
|
||||||
#else
|
|
||||||
std::move(callback).Run(false);
|
|
||||||
#endif // !BUILDFLAG(IS_ANDROID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !BUILDFLAG(IS_ANDROID)
|
|
||||||
// static
|
// static
|
||||||
bool TranslationManagerImpl::PassAcceptLanguagesCheck(
|
bool TranslationManagerImpl::PassAcceptLanguagesCheck(
|
||||||
const std::string& accept_languages_str,
|
const std::string& accept_languages_str,
|
||||||
@ -152,4 +137,3 @@ bool TranslationManagerImpl::PassAcceptLanguagesCheck(
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif // !BUILDFLAG(IS_ANDROID)
|
|
||||||
|
@ -49,11 +49,9 @@ class TranslationManagerImpl
|
|||||||
mojo::PendingReceiver<blink::mojom::Translator> receiver,
|
mojo::PendingReceiver<blink::mojom::Translator> receiver,
|
||||||
CreateTranslatorCallback callback) override;
|
CreateTranslatorCallback callback) override;
|
||||||
|
|
||||||
#if !BUILDFLAG(IS_ANDROID)
|
|
||||||
static bool PassAcceptLanguagesCheck(const std::string& accept_languages_str,
|
static bool PassAcceptLanguagesCheck(const std::string& accept_languages_str,
|
||||||
const std::string& source_lang,
|
const std::string& source_lang,
|
||||||
const std::string& target_lang);
|
const std::string& target_lang);
|
||||||
#endif // !BUILDFLAG(IS_ANDROID)
|
|
||||||
|
|
||||||
base::WeakPtr<content::BrowserContext> browser_context_;
|
base::WeakPtr<content::BrowserContext> browser_context_;
|
||||||
mojo::Receiver<blink::mojom::TranslationManager> receiver_{this};
|
mojo::Receiver<blink::mojom::TranslationManager> receiver_{this};
|
||||||
|
@ -98,6 +98,7 @@
|
|||||||
#include "chrome/browser/ui/webui/print_preview/policy_settings.h"
|
#include "chrome/browser/ui/webui/print_preview/policy_settings.h"
|
||||||
#include "components/plus_addresses/plus_address_prefs.h"
|
#include "components/plus_addresses/plus_address_prefs.h"
|
||||||
#include "components/privacy_sandbox/tpcd_pref_names.h"
|
#include "components/privacy_sandbox/tpcd_pref_names.h"
|
||||||
|
#include "components/services/on_device_translation/buildflags/buildflags.h"
|
||||||
#include "components/sharing_message/sharing_sync_preference.h"
|
#include "components/sharing_message/sharing_sync_preference.h"
|
||||||
#include "components/signin/core/browser/active_primary_accounts_metrics_recorder.h"
|
#include "components/signin/core/browser/active_primary_accounts_metrics_recorder.h"
|
||||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||||
@ -287,7 +288,6 @@
|
|||||||
#include "chrome/browser/new_tab_page/modules/v2/calendar/google_calendar_page_handler.h"
|
#include "chrome/browser/new_tab_page/modules/v2/calendar/google_calendar_page_handler.h"
|
||||||
#include "chrome/browser/new_tab_page/modules/v2/most_relevant_tab_resumption/most_relevant_tab_resumption_page_handler.h"
|
#include "chrome/browser/new_tab_page/modules/v2/most_relevant_tab_resumption/most_relevant_tab_resumption_page_handler.h"
|
||||||
#include "chrome/browser/new_tab_page/promos/promo_service.h"
|
#include "chrome/browser/new_tab_page/promos/promo_service.h"
|
||||||
#include "chrome/browser/on_device_translation/pref_names.h"
|
|
||||||
#include "chrome/browser/policy/developer_tools_policy_handler.h"
|
#include "chrome/browser/policy/developer_tools_policy_handler.h"
|
||||||
#include "chrome/browser/promos/promos_utils.h"
|
#include "chrome/browser/promos/promos_utils.h"
|
||||||
#include "chrome/browser/screen_ai/pref_names.h"
|
#include "chrome/browser/screen_ai/pref_names.h"
|
||||||
@ -543,6 +543,10 @@
|
|||||||
#include "chrome/browser/ash/wallpaper_handlers/wallpaper_prefs.h"
|
#include "chrome/browser/ash/wallpaper_handlers/wallpaper_prefs.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION)
|
||||||
|
#include "chrome/browser/on_device_translation/pref_names.h"
|
||||||
|
#endif // BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION)
|
||||||
|
|
||||||
#if BUILDFLAG(ENTERPRISE_DATA_CONTROLS)
|
#if BUILDFLAG(ENTERPRISE_DATA_CONTROLS)
|
||||||
#include "components/enterprise/data_controls/core/browser/prefs.h"
|
#include "components/enterprise/data_controls/core/browser/prefs.h"
|
||||||
#endif
|
#endif
|
||||||
@ -1751,9 +1755,12 @@ void RegisterLocalState(PrefRegistrySimple* registry) {
|
|||||||
task_manager::TaskManagerInterface::RegisterPrefs(registry);
|
task_manager::TaskManagerInterface::RegisterPrefs(registry);
|
||||||
UpgradeDetector::RegisterPrefs(registry);
|
UpgradeDetector::RegisterPrefs(registry);
|
||||||
registry->RegisterIntegerPref(prefs::kLastWhatsNewVersion, 0);
|
registry->RegisterIntegerPref(prefs::kLastWhatsNewVersion, 0);
|
||||||
on_device_translation::RegisterLocalStatePrefs(registry);
|
|
||||||
#endif // BUILDFLAG(IS_ANDROID)
|
#endif // BUILDFLAG(IS_ANDROID)
|
||||||
|
|
||||||
|
#if BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION)
|
||||||
|
on_device_translation::RegisterLocalStatePrefs(registry);
|
||||||
|
#endif // BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION)
|
||||||
|
|
||||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
|
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
|
||||||
WhatsNewUI::RegisterLocalStatePrefs(registry);
|
WhatsNewUI::RegisterLocalStatePrefs(registry);
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,6 +31,7 @@ import("//components/offline_pages/buildflags/features.gni")
|
|||||||
import("//components/optimization_guide/features.gni")
|
import("//components/optimization_guide/features.gni")
|
||||||
import("//components/os_crypt/sync/features.gni")
|
import("//components/os_crypt/sync/features.gni")
|
||||||
import("//components/safe_browsing/buildflags.gni")
|
import("//components/safe_browsing/buildflags.gni")
|
||||||
|
import("//components/services/on_device_translation/buildflags/features.gni")
|
||||||
import("//components/soda/buildflags.gni")
|
import("//components/soda/buildflags.gni")
|
||||||
import("//components/spellcheck/spellcheck_build_features.gni")
|
import("//components/spellcheck/spellcheck_build_features.gni")
|
||||||
import("//crypto/features.gni")
|
import("//crypto/features.gni")
|
||||||
@ -7284,8 +7285,6 @@ test("unit_tests") {
|
|||||||
"../browser/new_tab_page/promos/promo_service_unittest.cc",
|
"../browser/new_tab_page/promos/promo_service_unittest.cc",
|
||||||
"../browser/notifications/muted_notification_handler_unittest.cc",
|
"../browser/notifications/muted_notification_handler_unittest.cc",
|
||||||
"../browser/notifications/screen_capture_notification_blocker_unittest.cc",
|
"../browser/notifications/screen_capture_notification_blocker_unittest.cc",
|
||||||
"../browser/on_device_translation/language_pack_util_unittest.cc",
|
|
||||||
"../browser/on_device_translation/translation_manager_impl_unittest.cc",
|
|
||||||
"../browser/password_manager/generated_password_leak_detection_pref_unittest.cc",
|
"../browser/password_manager/generated_password_leak_detection_pref_unittest.cc",
|
||||||
"../browser/platform_util_unittest.cc",
|
"../browser/platform_util_unittest.cc",
|
||||||
"../browser/policy/policy_path_parser_unittest.cc",
|
"../browser/policy/policy_path_parser_unittest.cc",
|
||||||
@ -7620,13 +7619,10 @@ test("unit_tests") {
|
|||||||
|
|
||||||
if (is_linux || is_mac || is_win) {
|
if (is_linux || is_mac || is_win) {
|
||||||
sources += [
|
sources += [
|
||||||
"../browser/component_updater/translate_kit_component_installer_unittest.cc",
|
|
||||||
"../browser/component_updater/translate_kit_language_pack_component_installer_unittest.cc",
|
|
||||||
"../browser/supervised_user/linux_mac_windows/supervised_user_extensions_metrics_delegate_impl_unittest.cc",
|
"../browser/supervised_user/linux_mac_windows/supervised_user_extensions_metrics_delegate_impl_unittest.cc",
|
||||||
"../browser/ui/sync/sync_passphrase_dialog_unittest.cc",
|
"../browser/ui/sync/sync_passphrase_dialog_unittest.cc",
|
||||||
"../browser/ui/webui/settings/accessibility_main_handler_unittest.cc",
|
"../browser/ui/webui/settings/accessibility_main_handler_unittest.cc",
|
||||||
]
|
]
|
||||||
deps += [ "//chrome/browser/on_device_translation:prefs" ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sources += [
|
sources += [
|
||||||
@ -7766,7 +7762,6 @@ test("unit_tests") {
|
|||||||
"//chrome/browser/new_tab_page/chrome_colors",
|
"//chrome/browser/new_tab_page/chrome_colors",
|
||||||
"//chrome/browser/new_tab_page/modules/v2/calendar:mojo_bindings",
|
"//chrome/browser/new_tab_page/modules/v2/calendar:mojo_bindings",
|
||||||
"//chrome/browser/new_tab_page/modules/v2/most_relevant_tab_resumption:mojo_bindings",
|
"//chrome/browser/new_tab_page/modules/v2/most_relevant_tab_resumption:mojo_bindings",
|
||||||
"//chrome/browser/on_device_translation:language_pack_util",
|
|
||||||
"//chrome/browser/profile_resetter:fake_profile_resetter",
|
"//chrome/browser/profile_resetter:fake_profile_resetter",
|
||||||
"//chrome/browser/resource_coordinator:tab_manager_features",
|
"//chrome/browser/resource_coordinator:tab_manager_features",
|
||||||
"//chrome/browser/resources:component_extension_resources_grit",
|
"//chrome/browser/resources:component_extension_resources_grit",
|
||||||
@ -7866,7 +7861,7 @@ test("unit_tests") {
|
|||||||
"//components/services/app_service",
|
"//components/services/app_service",
|
||||||
"//components/services/app_service/public/cpp:test_support",
|
"//components/services/app_service/public/cpp:test_support",
|
||||||
"//components/services/app_service/public/cpp:unit_tests",
|
"//components/services/app_service/public/cpp:unit_tests",
|
||||||
"//components/services/on_device_translation/public/cpp",
|
"//components/services/on_device_translation/buildflags",
|
||||||
"//components/session_proto_db:session_proto_db",
|
"//components/session_proto_db:session_proto_db",
|
||||||
"//components/signin/public/base:signin_buildflags",
|
"//components/signin/public/base:signin_buildflags",
|
||||||
"//components/soda:constants",
|
"//components/soda:constants",
|
||||||
@ -9292,6 +9287,9 @@ test("unit_tests") {
|
|||||||
"../services/system_signals:unit_tests",
|
"../services/system_signals:unit_tests",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
if (enable_on_device_translation) {
|
||||||
|
deps += [ "//chrome/browser/on_device_translation:unit_tests" ]
|
||||||
|
}
|
||||||
|
|
||||||
if (enable_pdf) {
|
if (enable_pdf) {
|
||||||
sources += [
|
sources += [
|
||||||
|
@ -8,6 +8,7 @@ import("//build/config/sysroot.gni")
|
|||||||
import("//chrome/common/features.gni")
|
import("//chrome/common/features.gni")
|
||||||
import("//chrome/services/speech/buildflags/buildflags.gni")
|
import("//chrome/services/speech/buildflags/buildflags.gni")
|
||||||
import("//chromeos/ash/components/assistant/assistant.gni")
|
import("//chromeos/ash/components/assistant/assistant.gni")
|
||||||
|
import("//components/services/on_device_translation/buildflags/features.gni")
|
||||||
import("//crypto/features.gni")
|
import("//crypto/features.gni")
|
||||||
import("//extensions/buildflags/buildflags.gni")
|
import("//extensions/buildflags/buildflags.gni")
|
||||||
import("//pdf/features.gni")
|
import("//pdf/features.gni")
|
||||||
@ -47,7 +48,7 @@ static_library("utility") {
|
|||||||
"//components/safe_browsing:buildflags",
|
"//components/safe_browsing:buildflags",
|
||||||
"//components/search_engines",
|
"//components/search_engines",
|
||||||
"//components/services/language_detection",
|
"//components/services/language_detection",
|
||||||
"//components/services/on_device_translation:on_device_translation_service",
|
"//components/services/on_device_translation/buildflags",
|
||||||
"//components/services/paint_preview_compositor",
|
"//components/services/paint_preview_compositor",
|
||||||
"//components/services/patch:lib",
|
"//components/services/patch:lib",
|
||||||
"//components/services/unzip:lib",
|
"//components/services/unzip:lib",
|
||||||
@ -269,4 +270,8 @@ static_library("utility") {
|
|||||||
if (enable_browser_speech_service) {
|
if (enable_browser_speech_service) {
|
||||||
deps += [ "//chrome/services/speech:lib" ]
|
deps += [ "//chrome/services/speech:lib" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (enable_on_device_translation) {
|
||||||
|
deps += [ "//components/services/on_device_translation:on_device_translation_service" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#include "components/safe_browsing/buildflags.h"
|
#include "components/safe_browsing/buildflags.h"
|
||||||
#include "components/services/language_detection/language_detection_service_impl.h"
|
#include "components/services/language_detection/language_detection_service_impl.h"
|
||||||
#include "components/services/language_detection/public/mojom/language_detection.mojom.h"
|
#include "components/services/language_detection/public/mojom/language_detection.mojom.h"
|
||||||
#include "components/services/on_device_translation/on_device_translation_service.h"
|
#include "components/services/on_device_translation/buildflags/buildflags.h"
|
||||||
#include "components/services/patch/file_patcher_impl.h"
|
#include "components/services/patch/file_patcher_impl.h"
|
||||||
#include "components/services/patch/public/mojom/file_patcher.mojom.h"
|
#include "components/services/patch/public/mojom/file_patcher.mojom.h"
|
||||||
#include "components/services/unzip/public/mojom/unzipper.mojom.h"
|
#include "components/services/unzip/public/mojom/unzipper.mojom.h"
|
||||||
@ -144,6 +144,10 @@ static_assert(BUILDFLAG(ENABLE_PRINTING), "ChromeOS Ash must enable Printing");
|
|||||||
#include "chromeos/components/quick_answers/public/mojom/spell_check.mojom.h"
|
#include "chromeos/components/quick_answers/public/mojom/spell_check.mojom.h"
|
||||||
#endif // BUILDFLAG(IS_CHROMEOS)
|
#endif // BUILDFLAG(IS_CHROMEOS)
|
||||||
|
|
||||||
|
#if BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION)
|
||||||
|
#include "components/services/on_device_translation/on_device_translation_service.h"
|
||||||
|
#endif // BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION)
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
auto RunFilePatcher(mojo::PendingReceiver<patch::mojom::FilePatcher> receiver) {
|
auto RunFilePatcher(mojo::PendingReceiver<patch::mojom::FilePatcher> receiver) {
|
||||||
@ -433,12 +437,14 @@ auto RunMahiContentExtractionServiceFactory(
|
|||||||
}
|
}
|
||||||
#endif // BUILDFLAG(IS_CHROMEOS)
|
#endif // BUILDFLAG(IS_CHROMEOS)
|
||||||
|
|
||||||
|
#if BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION)
|
||||||
auto RunOnDeviceTranslationService(
|
auto RunOnDeviceTranslationService(
|
||||||
mojo::PendingReceiver<
|
mojo::PendingReceiver<
|
||||||
on_device_translation::mojom::OnDeviceTranslationService> receiver) {
|
on_device_translation::mojom::OnDeviceTranslationService> receiver) {
|
||||||
return std::make_unique<on_device_translation::OnDeviceTranslationService>(
|
return std::make_unique<on_device_translation::OnDeviceTranslationService>(
|
||||||
std::move(receiver));
|
std::move(receiver));
|
||||||
}
|
}
|
||||||
|
#endif // BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION)
|
||||||
|
|
||||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||||
auto RunBabelOrcaTachyonParsingService(
|
auto RunBabelOrcaTachyonParsingService(
|
||||||
@ -555,7 +561,9 @@ void RegisterMainThreadServices(mojo::ServiceFactory& services) {
|
|||||||
services.Add(RunMahiContentExtractionServiceFactory);
|
services.Add(RunMahiContentExtractionServiceFactory);
|
||||||
#endif // BUILDFLAG(IS_CHROMEOS)
|
#endif // BUILDFLAG(IS_CHROMEOS)
|
||||||
|
|
||||||
|
#if BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION)
|
||||||
services.Add(RunOnDeviceTranslationService);
|
services.Add(RunOnDeviceTranslationService);
|
||||||
|
#endif // BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterIOThreadServices(mojo::ServiceFactory& services) {
|
void RegisterIOThreadServices(mojo::ServiceFactory& services) {
|
||||||
|
@ -12,6 +12,7 @@ import("//components/enterprise/buildflags/buildflags.gni")
|
|||||||
import("//components/nacl/features.gni")
|
import("//components/nacl/features.gni")
|
||||||
import("//components/optimization_guide/features.gni")
|
import("//components/optimization_guide/features.gni")
|
||||||
import("//components/safe_browsing/buildflags.gni")
|
import("//components/safe_browsing/buildflags.gni")
|
||||||
|
import("//components/services/on_device_translation/buildflags/features.gni")
|
||||||
import("//components/supervised_user/buildflags.gni")
|
import("//components/supervised_user/buildflags.gni")
|
||||||
import("//extensions/buildflags/buildflags.gni")
|
import("//extensions/buildflags/buildflags.gni")
|
||||||
import("//media/media_options.gni")
|
import("//media/media_options.gni")
|
||||||
@ -871,7 +872,7 @@ test("components_unittests") {
|
|||||||
deps += [ "//components/tpcd/enterprise_reporting:unit_tests" ]
|
deps += [ "//components/tpcd/enterprise_reporting:unit_tests" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_linux || is_win || is_mac) {
|
if (enable_on_device_translation) {
|
||||||
deps += [ "//components/services/on_device_translation:unit_tests" ]
|
deps += [ "//components/services/on_device_translation:unit_tests" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
# Copyright 2024 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.
|
||||||
|
|
||||||
|
import("//build/buildflag_header.gni")
|
||||||
|
import("//components/services/on_device_translation/buildflags/features.gni")
|
||||||
|
|
||||||
|
buildflag_header("buildflags") {
|
||||||
|
header = "buildflags.h"
|
||||||
|
flags = [ "ENABLE_ON_DEVICE_TRANSLATION=$enable_on_device_translation" ]
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
# Copyright 2024 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.
|
||||||
|
|
||||||
|
declare_args() {
|
||||||
|
# On Device Translation is still not supported on other platforms.
|
||||||
|
# TODO(crbug.com/364795294): Support other platforms.
|
||||||
|
enable_on_device_translation = is_mac || is_win || is_linux
|
||||||
|
}
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import("//build/config/chromeos/ui_mode.gni")
|
import("//build/config/chromeos/ui_mode.gni")
|
||||||
import("//chromeos/ash/components/assistant/assistant.gni")
|
import("//chromeos/ash/components/assistant/assistant.gni")
|
||||||
|
import("//components/services/on_device_translation/buildflags/features.gni")
|
||||||
import("//device/vr/buildflags/buildflags.gni")
|
import("//device/vr/buildflags/buildflags.gni")
|
||||||
import("//media/gpu/args.gni")
|
import("//media/gpu/args.gni")
|
||||||
import("//media/media_options.gni")
|
import("//media/media_options.gni")
|
||||||
@ -43,7 +44,7 @@ source_set("utility") {
|
|||||||
"//build:branding_buildflags",
|
"//build:branding_buildflags",
|
||||||
"//build:chromeos_buildflags",
|
"//build:chromeos_buildflags",
|
||||||
"//components/optimization_guide/core:features",
|
"//components/optimization_guide/core:features",
|
||||||
"//components/services/on_device_translation:on_device_translation_service",
|
"//components/services/on_device_translation/buildflags",
|
||||||
"//components/services/storage",
|
"//components/services/storage",
|
||||||
"//components/services/storage/public/mojom",
|
"//components/services/storage/public/mojom",
|
||||||
"//content:export",
|
"//content:export",
|
||||||
@ -155,6 +156,10 @@ source_set("utility") {
|
|||||||
deps += [ "//services/accessibility:lib" ]
|
deps += [ "//services/accessibility:lib" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (enable_on_device_translation) {
|
||||||
|
deps += [ "//components/services/on_device_translation:on_device_translation_service" ]
|
||||||
|
}
|
||||||
|
|
||||||
if (enable_vr && !is_android) {
|
if (enable_vr && !is_android) {
|
||||||
deps += [
|
deps += [
|
||||||
"//content/services/isolated_xr_device:lib",
|
"//content/services/isolated_xr_device:lib",
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "base/timer/hi_res_timer_manager.h"
|
#include "base/timer/hi_res_timer_manager.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "build/chromeos_buildflags.h"
|
#include "build/chromeos_buildflags.h"
|
||||||
|
#include "components/services/on_device_translation/buildflags/buildflags.h"
|
||||||
#include "content/child/child_process.h"
|
#include "content/child/child_process.h"
|
||||||
#include "content/common/content_switches_internal.h"
|
#include "content/common/content_switches_internal.h"
|
||||||
#include "content/common/features.h"
|
#include "content/common/features.h"
|
||||||
@ -102,9 +103,10 @@
|
|||||||
sandbox::TargetServices* g_utility_target_services = nullptr;
|
sandbox::TargetServices* g_utility_target_services = nullptr;
|
||||||
#endif // BUILDFLAG(IS_WIN)
|
#endif // BUILDFLAG(IS_WIN)
|
||||||
|
|
||||||
#if BUILDFLAG(IS_LINUX)
|
#if BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION) && BUILDFLAG(IS_LINUX)
|
||||||
#include "components/services/on_device_translation/sandbox_hook.h"
|
#include "components/services/on_device_translation/sandbox_hook.h"
|
||||||
#endif // BUILDFLAG(IS_LINUX)
|
#endif // BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION) && BUILDFLAG(IS_LINUX)
|
||||||
|
|
||||||
namespace content {
|
namespace content {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -292,12 +294,12 @@ int UtilityMain(MainFunctionParams parameters) {
|
|||||||
pre_sandbox_hook =
|
pre_sandbox_hook =
|
||||||
base::BindOnce(&speech::SpeechRecognitionPreSandboxHook);
|
base::BindOnce(&speech::SpeechRecognitionPreSandboxHook);
|
||||||
break;
|
break;
|
||||||
#if BUILDFLAG(IS_LINUX)
|
#if BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION) && BUILDFLAG(IS_LINUX)
|
||||||
case sandbox::mojom::Sandbox::kOnDeviceTranslation:
|
case sandbox::mojom::Sandbox::kOnDeviceTranslation:
|
||||||
pre_sandbox_hook = base::BindOnce(
|
pre_sandbox_hook = base::BindOnce(
|
||||||
&on_device_translation::OnDeviceTranslationSandboxHook);
|
&on_device_translation::OnDeviceTranslationSandboxHook);
|
||||||
break;
|
break;
|
||||||
#endif // BUILDFLAG(IS_LINUX)
|
#endif // BUILDFLAG(ENABLE_ON_DEVICE_TRANSLATION) && BUILDFLAG(IS_LINUX)
|
||||||
#if BUILDFLAG(ENABLE_SCREEN_AI_SERVICE)
|
#if BUILDFLAG(ENABLE_SCREEN_AI_SERVICE)
|
||||||
case sandbox::mojom::Sandbox::kScreenAI:
|
case sandbox::mojom::Sandbox::kScreenAI:
|
||||||
pre_sandbox_hook =
|
pre_sandbox_hook =
|
||||||
|
Reference in New Issue
Block a user