lacros: Hook up EchoPrivate.

This CL compiles the code on Lacros and fixes a few compile errors.

      website works.

Test: Navigate to google.com/chromebook/perks/ and confirm that the
Bug: 1270543
Change-Id: If95cf60dee4851da5131e06cad0f91c383879aa5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3594709
Commit-Queue: Erik Chen <[email protected]>
Reviewed-by: Jenny Zhang <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Reviewed-by: Devlin Cronin <[email protected]>
Cr-Commit-Position: refs/heads/main@{#995054}
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 7865dba..3097c6c 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -5172,6 +5172,8 @@
       "chromeos/app_mode/kiosk_session_plugin_handler_delegate.h",
       "chromeos/app_mode/kiosk_settings_navigation_throttle.cc",
       "chromeos/app_mode/kiosk_settings_navigation_throttle.h",
+      "chromeos/extensions/echo_private/echo_private_api.cc",
+      "chromeos/extensions/echo_private/echo_private_api.h",
       "chromeos/extensions/info_private_api.cc",
       "chromeos/extensions/info_private_api.h",
       "chromeos/policy/dlp/clipboard_bubble.cc",
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd
index 3aef1d92..e0ca63a4 100644
--- a/chrome/browser/browser_resources.grd
+++ b/chrome/browser/browser_resources.grd
@@ -138,6 +138,9 @@
       <include name="IDR_USB_DEVICE_MOJOM_WEBUI_JS" file="${root_gen_dir}\mojom-webui\services\device\public\mojom\usb_device.mojom-webui.js" use_base_dir="false" type="BINDATA" />
       <include name="IDR_WEBSTORE_MANIFEST" file="resources\webstore_app\manifest.json" type="BINDATA" />
       <include name="IDR_CRYPTOTOKEN_MANIFEST" file="resources\cryptotoken\manifest.json" type="BINDATA" />
+      <if expr="chromeos_ash or chromeos_lacros">
+        <include name="IDR_ECHO_MANIFEST" file="resources\chromeos\echo\manifest.json" type="BINDATA" />
+      </if>
       <if expr="chromeos_ash">
         <!-- Shared images for ChromeOS WebUIs -->
         <include name="IDR_CHROME_OS_AN_ERROR_OCCURRED_SVG" file="resources\chromeos\images\an_error_occurred.svg" type="BINDATA" />
@@ -207,7 +210,6 @@
         <!-- Note: mobile_setup_ui.cc does not support compressed resources. -->
         <include name="IDR_MOBILE_SETUP_PORTAL_PAGE_HTML" file="resources\chromeos\mobile_setup_portal.html" flattenhtml="true" type="BINDATA" />
 
-        <include name="IDR_ECHO_MANIFEST" file="resources\chromeos\echo\manifest.json" type="BINDATA" />
         <include name="IDR_OS_CREDITS_HTML" file="resources\chromeos\about_os_credits.html" flattenhtml="true" type="BINDATA" />
         <include name="IDR_CERT_MANAGER_DIALOG_HTML" file="resources\chromeos\certificate_manager_dialog.html" type="BINDATA" />
         <include name="IDR_SLOW_CSS" file="resources\chromeos\slow.css" type="BINDATA" />
diff --git a/chrome/browser/chromeos/extensions/echo_private/echo_private_api.cc b/chrome/browser/chromeos/extensions/echo_private/echo_private_api.cc
index ae94301..c4c4561 100644
--- a/chrome/browser/chromeos/extensions/echo_private/echo_private_api.cc
+++ b/chrome/browser/chromeos/extensions/echo_private/echo_private_api.cc
@@ -16,10 +16,6 @@
 #include "base/time/time.h"
 #include "base/values.h"
 #include "build/chromeos_buildflags.h"
-#include "chrome/browser/ash/crosapi/crosapi_ash.h"
-#include "chrome/browser/ash/crosapi/crosapi_manager.h"
-#include "chrome/browser/ash/crosapi/echo_private_ash.h"
-#include "chrome/browser/ash/settings/cros_settings.h"
 #include "chrome/browser/browser_process.h"
 #include "chrome/browser/extensions/extension_tab_util.h"
 #include "chrome/browser/profiles/profile.h"
@@ -29,7 +25,6 @@
 #include "chrome/common/extensions/api/echo_private.h"
 #include "chrome/common/pref_names.h"
 #include "chrome/common/url_constants.h"
-#include "chromeos/system/statistics_provider.h"
 #include "components/prefs/pref_registry_simple.h"
 #include "components/prefs/pref_service.h"
 #include "components/prefs/scoped_user_pref_update.h"
@@ -39,8 +34,15 @@
 #include "extensions/common/extension.h"
 #include "extensions/common/mojom/view_type.mojom.h"
 
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "chrome/browser/ash/crosapi/crosapi_ash.h"
+#include "chrome/browser/ash/crosapi/crosapi_manager.h"
+#include "chrome/browser/ash/crosapi/echo_private_ash.h"
+#endif
+
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
 #include "chrome/browser/ui/lacros/window_utility.h"
+#include "chromeos/crosapi/mojom/echo_private.mojom.h"
 #include "chromeos/lacros/lacros_service.h"
 #endif
 
@@ -97,7 +99,7 @@
   if (lacros_service->IsAvailable<crosapi::mojom::EchoPrivate>() &&
       static_cast<uint32_t>(lacros_service->GetInterfaceVersion(
           crosapi::mojom::EchoPrivate::Uuid_)) >=
-          crosapi::mojom::EchoPrivate::kRegistrationCodeMinVersion) {
+          crosapi::mojom::EchoPrivate::kGetRegistrationCodeMinVersion) {
     lacros_service->GetRemote<crosapi::mojom::EchoPrivate>()
         ->GetRegistrationCode(type.value(), std::move(callback));
   } else {
diff --git a/chrome/browser/extensions/component_extensions_allowlist/allowlist.cc b/chrome/browser/extensions/component_extensions_allowlist/allowlist.cc
index bbe54f7..c8b91e6 100644
--- a/chrome/browser/extensions/component_extensions_allowlist/allowlist.cc
+++ b/chrome/browser/extensions/component_extensions_allowlist/allowlist.cc
@@ -81,7 +81,6 @@
     case IDR_ARC_SUPPORT_MANIFEST:
     case IDR_AUDIO_PLAYER_MANIFEST:
     case IDR_CHROME_APP_MANIFEST:
-    case IDR_ECHO_MANIFEST:
     case IDR_FILEMANAGER_MANIFEST:
     case IDR_IMAGE_LOADER_MANIFEST:
     case IDR_KEYBOARD_MANIFEST:
@@ -94,6 +93,7 @@
 
 #if BUILDFLAG(IS_CHROMEOS)
     case IDR_CONTACT_CENTER_INSIGHTS_MANIFEST:
+    case IDR_ECHO_MANIFEST:
 #endif
       return true;
   }
diff --git a/chrome/browser/extensions/component_loader.cc b/chrome/browser/extensions/component_loader.cc
index 7813ae9..f062bc8 100644
--- a/chrome/browser/extensions/component_loader.cc
+++ b/chrome/browser/extensions/component_loader.cc
@@ -515,6 +515,11 @@
           l10n_util::GetStringUTF8(IDS_FEEDBACK_REPORT_PAGE_TITLE));
     }
 
+#if BUILDFLAG(IS_CHROMEOS)
+    Add(IDR_ECHO_MANIFEST,
+        base::FilePath(FILE_PATH_LITERAL("/usr/share/chromeos-assets/echo")));
+#endif
+
 #if BUILDFLAG(IS_CHROMEOS_ASH)
     if (command_line->HasSwitch(switches::kLoadGuestModeTestExtension)) {
       base::FilePath path = base::FilePath(command_line->GetSwitchValueASCII(
@@ -539,9 +544,6 @@
       ExtensionsBrowserClient::Get()->GetOffTheRecordContext(profile_);
 #endif  // BUILDFLAG(GOOGLE_CHROME_BRANDING)
 
-    Add(IDR_ECHO_MANIFEST,
-        base::FilePath(FILE_PATH_LITERAL("/usr/share/chromeos-assets/echo")));
-
     if (!command_line->HasSwitch(ash::switches::kGuestSession)) {
       Add(IDR_WALLPAPERMANAGER_MANIFEST,
           base::FilePath(FILE_PATH_LITERAL("chromeos/wallpaper_manager")));
diff --git a/chrome/browser/extensions/extension_keeplist_ash.cc b/chrome/browser/extensions/extension_keeplist_ash.cc
index 11fb755..0e21025 100644
--- a/chrome/browser/extensions/extension_keeplist_ash.cc
+++ b/chrome/browser/extensions/extension_keeplist_ash.cc
@@ -38,8 +38,8 @@
         extension_misc::kGuestModeTestExtensionId,
         extension_misc::kCryptotokenExtensionId,
         extension_misc::kKeyboardExtensionId,
-        extension_misc::kHelpAppExtensionId, extension_misc::kEchoExtensionId,
-        extension_misc::kGCSEExtensionId, extension_misc::kGnubbyV3ExtensionId,
+        extension_misc::kHelpAppExtensionId, extension_misc::kGCSEExtensionId,
+        extension_misc::kGnubbyV3ExtensionId,
         file_manager::kImageLoaderExtensionId
   });
   return base::Contains(*keep_list, extension_id) ||
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index a04816c..d7c4053 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -266,6 +266,7 @@
 
 #if BUILDFLAG(IS_CHROMEOS)
 #include "chrome/browser/apps/intent_helper/supported_links_infobar_prefs_service.h"
+#include "chrome/browser/chromeos/extensions/echo_private/echo_private_api.h"
 #include "chrome/browser/chromeos/policy/dlp/dlp_rules_manager_impl.h"
 #include "chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_api.h"
 #include "chrome/browser/policy/networking/policy_cert_service.h"
@@ -370,7 +371,6 @@
 #include "chrome/browser/ash/system/automatic_reboot_manager.h"
 #include "chrome/browser/ash/system/input_device_settings.h"
 #include "chrome/browser/ash/web_applications/help_app/help_app_notification_controller.h"
-#include "chrome/browser/chromeos/extensions/echo_private/echo_private_api.h"
 #include "chrome/browser/chromeos/extensions/login_screen/login/prefs.h"
 #include "chrome/browser/device_identity/chromeos/device_oauth2_token_store_chromeos.h"
 #include "chrome/browser/extensions/extension_assets_manager_chromeos.h"
@@ -1116,7 +1116,6 @@
   chromeos::DeviceOAuth2TokenStoreChromeOS::RegisterPrefs(registry);
   ash::device_settings_cache::RegisterPrefs(registry);
   ash::EasyUnlockService::RegisterPrefs(registry);
-  chromeos::echo_offer::RegisterPrefs(registry);
   ash::EnableAdbSideloadingScreen::RegisterPrefs(registry);
   ash::device_activity::DeviceActivityController::RegisterPrefs(registry);
   chromeos::EnableDebuggingScreenHandler::RegisterPrefs(registry);
@@ -1177,6 +1176,7 @@
 #endif  // BUILDFLAG(IS_CHROMEOS_ASH)
 
 #if BUILDFLAG(IS_CHROMEOS)
+  chromeos::echo_offer::RegisterPrefs(registry);
   policy::SystemFeaturesDisableListPolicyHandler::RegisterPrefs(registry);
   policy::DlpRulesManagerImpl::RegisterPrefs(registry);
 #endif  // BUILDFLAG(IS_CHROMEOS)
diff --git a/chrome/common/extensions/api/_permission_features.json b/chrome/common/extensions/api/_permission_features.json
index 4eafb53..6e26b63 100644
--- a/chrome/common/extensions/api/_permission_features.json
+++ b/chrome/common/extensions/api/_permission_features.json
@@ -664,7 +664,7 @@
     "channel": "stable",
     "extension_types": ["extension", "legacy_packaged_app", "platform_app"],
     "location": "component",
-    "platforms": ["chromeos"]
+    "platforms": ["chromeos", "lacros"]
   },
   "pageCapture": {
     "channel": "stable",
diff --git a/chrome/common/extensions/api/api_sources.gni b/chrome/common/extensions/api/api_sources.gni
index 4373142..5f41b55 100644
--- a/chrome/common/extensions/api/api_sources.gni
+++ b/chrome/common/extensions/api/api_sources.gni
@@ -75,6 +75,7 @@
 
 if (is_chromeos) {
   schema_sources_ += [
+    "echo_private.json",
     "enterprise_device_attributes.idl",
     "enterprise_networking_attributes.idl",
     "enterprise_platform_keys.idl",
@@ -99,7 +100,6 @@
     "certificate_provider.idl",
     "certificate_provider_internal.idl",
     "document_scan.idl",
-    "echo_private.json",
     "enterprise_platform_keys_private.json",
     "file_manager_private.idl",
     "file_manager_private_internal.idl",
diff --git a/chrome/common/extensions/extension_constants.cc b/chrome/common/extensions/extension_constants.cc
index 218ffee..d046b4d0 100644
--- a/chrome/common/extensions/extension_constants.cc
+++ b/chrome/common/extensions/extension_constants.cc
@@ -74,6 +74,7 @@
 #if BUILDFLAG(IS_CHROMEOS)
 const char kAssessmentAssistantExtensionId[] =
     "gndmhdcefbhlchkhipcnnbkcmicncehk";
+const char kEchoExtensionId[] = "kddnkjkcjddckihglkfcickdhbmaodcn";
 const char kGnubbyAppId[] = "beknehfpfkghjoafdifaflglpjkojoco";
 const char kGnubbyV3ExtensionId[] = "lfboplenmmjcmpbkeemecobbadnmpfhi";
 const char kGCSEExtensionId[] = "cfmgaohenjcikllcgjpepfadgbflcjof";
@@ -120,7 +121,6 @@
     "gjjabgpgjpampikjhjpfhneeoapjbjaf";
 const char kWallpaperManagerId[] = "obklkkbkpaoaejdabbfldmcfplpdgolj";
 const char kHelpAppExtensionId[] = "honijodknafkokifofgiaalefdiedpko";
-const char kEchoExtensionId[] = "kddnkjkcjddckihglkfcickdhbmaodcn";
 #endif  // BUILDFLAG(IS_CHROMEOS_ASH)
 #if BUILDFLAG(ENABLE_HANGOUT_SERVICES_EXTENSION)
 // The extension id of the Hangout Service extnsion.
diff --git a/chrome/common/extensions/extension_constants.h b/chrome/common/extensions/extension_constants.h
index 8d11c3d..a8a664fb 100644
--- a/chrome/common/extensions/extension_constants.h
+++ b/chrome/common/extensions/extension_constants.h
@@ -160,6 +160,8 @@
 #if BUILDFLAG(IS_CHROMEOS)
 // The extension id of the Assessment Assistant extension.
 extern const char kAssessmentAssistantExtensionId[];
+// The extension id of the extension responsible for providing chromeos perks.
+extern const char kEchoExtensionId[];
 // The extension id of the Gnubby chrome app.
 extern const char kGnubbyAppId[];
 // The extension id of the new v3 Gnubby extension.
@@ -230,7 +232,6 @@
 extern const char kWallpaperManagerId[];
 // The extension id of official HelpApp extension.
 extern const char kHelpAppExtensionId[];
-extern const char kEchoExtensionId[];
 #endif
 #if BUILDFLAG(ENABLE_HANGOUT_SERVICES_EXTENSION)
 // The extension id of the Hangout Service extnsion.
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 5baa4ecb..e858a554 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -2448,10 +2448,6 @@
 // versions.
 const char kUsersLastInputMethod[] = "UsersLRUInputMethod";
 
-// A dictionary pref of the echo offer check flag. It sets offer info when
-// an offer is checked.
-const char kEchoCheckedOffers[] = "EchoCheckedOffers";
-
 // Key name of a dictionary in local state to store cached multiprofle user
 // behavior policy value.
 const char kCachedMultiProfileUserBehavior[] = "CachedMultiProfileUserBehavior";
@@ -2888,6 +2884,10 @@
 const char kSigninInterceptionEnabled[] = "signin.interception_enabled";
 
 #if BUILDFLAG(IS_CHROMEOS)
+// A dictionary pref of the echo offer check flag. It sets offer info when
+// an offer is checked.
+const char kEchoCheckedOffers[] = "EchoCheckedOffers";
+
 // Boolean pref indicating whether the user is allowed to create secondary
 // profiles in Lacros browser. This is set by a policy, and the default value
 // for managed users is false.
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 957e43f..c4b2126 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -769,7 +769,6 @@
 extern const char kDeviceEnrollmentCanExit[];
 extern const char kDeviceDMToken[];
 extern const char kUsersLastInputMethod[];
-extern const char kEchoCheckedOffers[];
 extern const char kCachedMultiProfileUserBehavior[];
 extern const char kInitialLocale[];
 extern const char kDeviceRegistered[];
@@ -961,6 +960,7 @@
 extern const char kSigninAllowedOnNextStartup[];
 extern const char kSigninInterceptionEnabled[];
 #if BUILDFLAG(IS_CHROMEOS)
+extern const char kEchoCheckedOffers[];
 extern const char kLacrosSecondaryProfilesAllowed[];
 #endif  // BUILDFLAG(IS_CHROMEOS)