Move per-profile prefs into a per-profile object
The location/microphone/tab-access prefs are per-profile and would more
appropriately live on an object scoped to a single profile, rather than
the global GlicLauncherConfiguration.
This CL moves these prefs to a new GlicProfileConfiguration which is
owned by the GlicKeyedService, a per-profile object.
This is a non-functional change.
Bug: 379168195
Change-Id: I295e49a81e679bb1fd7692e320059e9e09027d78
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6127753
Owners-Override: David Bokan <[email protected]>
Commit-Queue: David Bokan <[email protected]>
Reviewed-by: Anthony Cui <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1400967}
diff --git a/chrome/browser/glic/BUILD.gn b/chrome/browser/glic/BUILD.gn
index 1ae9809..d9491ed 100644
--- a/chrome/browser/glic/BUILD.gn
+++ b/chrome/browser/glic/BUILD.gn
@@ -9,6 +9,7 @@
"glic_keyed_service_factory.h",
"glic_page_context_fetcher.h",
"glic_pref_names.h",
+ "glic_profile_configuration.h",
"glic_profile_manager.h",
"glic_tab_indicator_helper.h",
"glic_window_controller.h",
@@ -21,6 +22,7 @@
"//chrome/browser/ui:browser_list",
"//chrome/browser/ui/tabs:tab_strip_model_observer",
"//chrome/browser/ui/webui/glic:mojo_bindings",
+ "//components/prefs",
"//content/public/browser",
"//ui/views:views",
]
@@ -32,6 +34,7 @@
"glic_keyed_service.cc",
"glic_keyed_service_factory.cc",
"glic_page_context_fetcher.cc",
+ "glic_profile_configuration.cc",
"glic_profile_manager.cc",
"glic_tab_indicator_helper.cc",
"glic_window_controller.cc",
diff --git a/chrome/browser/glic/glic_keyed_service.h b/chrome/browser/glic/glic_keyed_service.h
index e1a585b..919b532 100644
--- a/chrome/browser/glic/glic_keyed_service.h
+++ b/chrome/browser/glic/glic_keyed_service.h
@@ -10,6 +10,7 @@
#include "base/callback_list.h"
#include "base/memory/raw_ptr.h"
#include "chrome/browser/glic/glic_focused_tab_manager.h"
+#include "chrome/browser/glic/glic_profile_configuration.h"
#include "chrome/browser/glic/glic_window_controller.h"
#include "chrome/browser/ui/webui/glic/glic.mojom.h"
#include "components/keyed_service/core/keyed_service.h"
@@ -77,6 +78,7 @@
raw_ptr<content::BrowserContext> browser_context_;
+ GlicProfileConfiguration configuration_;
GlicWindowController window_controller_;
GlicFocusedTabManager focused_tab_manager_;
// Unowned
diff --git a/chrome/browser/glic/glic_profile_configuration.cc b/chrome/browser/glic/glic_profile_configuration.cc
new file mode 100644
index 0000000..656fa1f
--- /dev/null
+++ b/chrome/browser/glic/glic_profile_configuration.cc
@@ -0,0 +1,29 @@
+// 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 "chrome/browser/glic/glic_profile_configuration.h"
+
+#include "base/values.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/glic/glic_pref_names.h"
+#include "chrome/browser/profiles/profile.h"
+#include "components/prefs/pref_registry_simple.h"
+#include "components/prefs/pref_service.h"
+#include "ui/base/accelerators/accelerator.h"
+#include "ui/events/event_constants.h"
+#include "ui/events/keycodes/keyboard_codes.h"
+
+namespace glic {
+
+GlicProfileConfiguration::~GlicProfileConfiguration() = default;
+
+// static
+void GlicProfileConfiguration::RegisterProfilePrefs(
+ PrefRegistrySimple* registry) {
+ registry->RegisterBooleanPref(prefs::kGlicMicrophoneEnabled, false);
+ registry->RegisterBooleanPref(prefs::kGlicGeolocationEnabled, false);
+ registry->RegisterBooleanPref(prefs::kGlicTabContextEnabled, false);
+}
+
+} // namespace glic
diff --git a/chrome/browser/glic/glic_profile_configuration.h b/chrome/browser/glic/glic_profile_configuration.h
new file mode 100644
index 0000000..9caf149
--- /dev/null
+++ b/chrome/browser/glic/glic_profile_configuration.h
@@ -0,0 +1,29 @@
+// 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 CHROME_BROWSER_GLIC_GLIC_PROFILE_CONFIGURATION_H_
+#define CHROME_BROWSER_GLIC_GLIC_PROFILE_CONFIGURATION_H_
+
+#include "base/observer_list.h"
+#include "base/observer_list_types.h"
+#include "components/prefs/pref_change_registrar.h"
+#include "ui/base/accelerators/accelerator.h"
+
+class PrefRegistrySimple;
+
+namespace glic {
+
+// This class manages interaction with the prefs system for Glic per-profile
+// settings. For launcher settings, which are per-installation, see
+// GlicLauncherConfiguration.
+class GlicProfileConfiguration {
+ public:
+ GlicProfileConfiguration() = default;
+ ~GlicProfileConfiguration();
+
+ static void RegisterProfilePrefs(PrefRegistrySimple* registry);
+};
+} // namespace glic
+
+#endif // CHROME_BROWSER_GLIC_GLIC_PROFILE_CONFIGURATION_H_
diff --git a/chrome/browser/glic/launcher/glic_launcher_configuration.cc b/chrome/browser/glic/launcher/glic_launcher_configuration.cc
index 55addf8..cbece99 100644
--- a/chrome/browser/glic/launcher/glic_launcher_configuration.cc
+++ b/chrome/browser/glic/launcher/glic_launcher_configuration.cc
@@ -44,14 +44,6 @@
.Set(kHotkeyModifiers, ui::EF_NONE));
}
-// static
-void GlicLauncherConfiguration::RegisterProfilePrefs(
- PrefRegistrySimple* registry) {
- registry->RegisterBooleanPref(prefs::kGlicMicrophoneEnabled, false);
- registry->RegisterBooleanPref(prefs::kGlicGeolocationEnabled, false);
- registry->RegisterBooleanPref(prefs::kGlicTabContextEnabled, false);
-}
-
bool GlicLauncherConfiguration::IsEnabled() {
return g_browser_process->local_state()->GetBoolean(
prefs::kGlicLauncherEnabled);
diff --git a/chrome/browser/glic/launcher/glic_launcher_configuration.h b/chrome/browser/glic/launcher/glic_launcher_configuration.h
index 74f44f0..d36a98e 100644
--- a/chrome/browser/glic/launcher/glic_launcher_configuration.h
+++ b/chrome/browser/glic/launcher/glic_launcher_configuration.h
@@ -31,7 +31,6 @@
~GlicLauncherConfiguration();
static void RegisterLocalStatePrefs(PrefRegistrySimple* registry);
- static void RegisterProfilePrefs(PrefRegistrySimple* registry);
bool IsEnabled();
diff --git a/chrome/browser/prefs/BUILD.gn b/chrome/browser/prefs/BUILD.gn
index dd7d081..d7f773e 100644
--- a/chrome/browser/prefs/BUILD.gn
+++ b/chrome/browser/prefs/BUILD.gn
@@ -312,7 +312,10 @@
}
if (enable_glic) {
- deps += [ "//chrome/browser/glic/launcher" ]
+ deps += [
+ "//chrome/browser/glic",
+ "//chrome/browser/glic/launcher",
+ ]
}
}
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 97819ed..edbfb77e 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -547,6 +547,7 @@
#endif
#if BUILDFLAG(ENABLE_GLIC)
+#include "chrome/browser/glic/glic_profile_configuration.h"
#include "chrome/browser/glic/launcher/glic_launcher_configuration.h"
#endif
@@ -2038,7 +2039,7 @@
DownloadPrefs::RegisterProfilePrefs(registry);
fingerprinting_protection_filter::prefs::RegisterProfilePrefs(registry);
#if BUILDFLAG(ENABLE_GLIC)
- glic::GlicLauncherConfiguration::RegisterProfilePrefs(registry);
+ glic::GlicProfileConfiguration::RegisterProfilePrefs(registry);
#endif
permissions::PermissionHatsTriggerHelper::RegisterProfilePrefs(registry);
history_clusters::prefs::RegisterProfilePrefs(registry);