From cb34fe338a80e2dd2f21d9b51a14cd8d3a55f227 Mon Sep 17 00:00:00 2001 From: Vignesh Shenvi <vshenvi@google.com> Date: Fri, 4 Oct 2024 02:40:12 +0000 Subject: [PATCH] Prefs for tracking disabled extensions with OnTask This change introduces a new list pref that OnTask components will use to track disabled extension ids in the user pref store. This is primarily needed to restore extensions to their previous state at the end of an OnTask session or if the device goes through a reboot cycle. Bug: b:365850329 Change-Id: Ib9a1ae96868af2b66bbf75d5ae0cb852ada68847 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5905657 Reviewed-by: April Zhou <aprilzhou@google.com> Reviewed-by: Matthew Zhu <zhumatthew@google.com> Commit-Queue: Vignesh Shenvi <vshenvi@google.com> Reviewed-by: Erik Chen <erikchen@chromium.org> Cr-Commit-Position: refs/heads/main@{#1364010} --- chrome/browser/BUILD.gn | 1 + chrome/browser/prefs/browser_prefs.cc | 2 ++ chromeos/ash/components/boca/on_task/BUILD.gn | 3 +++ .../components/boca/on_task/on_task_prefs.cc | 20 ++++++++++++++++++ .../components/boca/on_task/on_task_prefs.h | 21 +++++++++++++++++++ 5 files changed, 47 insertions(+) create mode 100644 chromeos/ash/components/boca/on_task/on_task_prefs.cc create mode 100644 chromeos/ash/components/boca/on_task/on_task_prefs.h diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index 7eb08e8c1e4dc..078f73444bcef 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn @@ -5285,6 +5285,7 @@ static_library("browser") { "//chromeos/ash/components/audio", "//chromeos/ash/components/audio/public/mojom", "//chromeos/ash/components/boca", + "//chromeos/ash/components/boca/on_task", "//chromeos/ash/components/browser_context_helper", "//chromeos/ash/components/carrier_lock", "//chromeos/ash/components/channel", diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc index c4cda530ba2a6..8f7f92615f499 100644 --- a/chrome/browser/prefs/browser_prefs.cc +++ b/chrome/browser/prefs/browser_prefs.cc @@ -440,6 +440,7 @@ #include "chrome/browser/ui/webui/settings/reset_settings_handler.h" #include "chrome/browser/upgrade_detector/upgrade_detector_chromeos.h" #include "chromeos/ash/components/audio/audio_devices_pref_handler_impl.h" +#include "chromeos/ash/components/boca/on_task/on_task_prefs.h" #include "chromeos/ash/components/local_search_service/search_metrics_reporter.h" #include "chromeos/ash/components/network/cellular_esim_profile_handler_impl.h" #include "chromeos/ash/components/network/cellular_metrics_logger.h" @@ -2233,6 +2234,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry, wallpaper_handlers::prefs::RegisterProfilePrefs(registry); ash::reporting::RegisterProfilePrefs(registry); ChromeMediaAppGuestUIDelegate::RegisterProfilePrefs(registry); + ash::boca::RegisterOnTaskProfilePrefs(registry); #endif // BUILDFLAG(IS_CHROMEOS_ASH) #if BUILDFLAG(IS_CHROMEOS_LACROS) diff --git a/chromeos/ash/components/boca/on_task/BUILD.gn b/chromeos/ash/components/boca/on_task/BUILD.gn index e5dcd156df6e1..d99030034627f 100644 --- a/chromeos/ash/components/boca/on_task/BUILD.gn +++ b/chromeos/ash/components/boca/on_task/BUILD.gn @@ -10,6 +10,8 @@ static_library("on_task") { sources = [ "on_task_blocklist.cc", "on_task_blocklist.h", + "on_task_prefs.cc", + "on_task_prefs.h", "on_task_session_manager.cc", "on_task_session_manager.h", "on_task_system_web_app_manager.h", @@ -22,6 +24,7 @@ static_library("on_task") { "//chromeos/ash/components/boca/proto", "//components/google/core/common", "//components/policy/core/browser", + "//components/pref_registry", "//components/sessions", "//components/sessions:session_id", "//content/public/browser", diff --git a/chromeos/ash/components/boca/on_task/on_task_prefs.cc b/chromeos/ash/components/boca/on_task/on_task_prefs.cc new file mode 100644 index 0000000000000..84b06e323b0fb --- /dev/null +++ b/chromeos/ash/components/boca/on_task/on_task_prefs.cc @@ -0,0 +1,20 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chromeos/ash/components/boca/on_task/on_task_prefs.h" + +#include "base/check.h" +#include "components/pref_registry/pref_registry_syncable.h" + +namespace ash::boca { + +// A list pref used to track disabled extensions for OnTask. +const char kDisabledOnTaskExtensions[] = "boca.disabled_on_task_extensions"; + +void RegisterOnTaskProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { + CHECK(registry); + registry->RegisterListPref(kDisabledOnTaskExtensions); +} + +} // namespace ash::boca diff --git a/chromeos/ash/components/boca/on_task/on_task_prefs.h b/chromeos/ash/components/boca/on_task/on_task_prefs.h new file mode 100644 index 0000000000000..9b0c2755545a4 --- /dev/null +++ b/chromeos/ash/components/boca/on_task/on_task_prefs.h @@ -0,0 +1,21 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROMEOS_ASH_COMPONENTS_BOCA_ON_TASK_ON_TASK_PREFS_H_ +#define CHROMEOS_ASH_COMPONENTS_BOCA_ON_TASK_ON_TASK_PREFS_H_ + +namespace user_prefs { +class PrefRegistrySyncable; +} + +namespace ash::boca { + +// A list pref used to track disabled extensions for OnTask. +extern const char kDisabledOnTaskExtensions[]; + +void RegisterOnTaskProfilePrefs(user_prefs::PrefRegistrySyncable* registry); + +} // namespace ash::boca + +#endif // CHROMEOS_ASH_COMPONENTS_BOCA_ON_TASK_ON_TASK_PREFS_H_