Rename GlicConfiguration to GlicLauncherConfiguration
The launcher prefs (enabled and keyboard shortcut) are installation- global whereas the rest are per-profile so it doesn't make sense to
bundle them in the same place.
This CL is a first step to split the per-profile prefs into a profile-
scoped object.
This is a non-functional change.
Bug: 379168195
Change-Id: I08e5a63f0a4bd61371412850f632fa9101735d57
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6114450
Reviewed-by: Anthony Cui <[email protected]>
Owners-Override: David Bokan <[email protected]>
Commit-Queue: David Bokan <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1400946}
diff --git a/chrome/browser/glic/launcher/BUILD.gn b/chrome/browser/glic/launcher/BUILD.gn
index 8f01f22d..eb80769 100644
--- a/chrome/browser/glic/launcher/BUILD.gn
+++ b/chrome/browser/glic/launcher/BUILD.gn
@@ -5,8 +5,8 @@
source_set("launcher") {
sources = [
"glic_background_mode_manager.h",
- "glic_configuration.h",
"glic_controller.h",
+ "glic_launcher_configuration.h",
]
deps = [
@@ -20,8 +20,8 @@
source_set("impl") {
sources = [
"glic_background_mode_manager.cc",
- "glic_configuration.cc",
"glic_controller.cc",
+ "glic_launcher_configuration.cc",
"glic_status_icon.cc",
"glic_status_icon.h",
]
diff --git a/chrome/browser/glic/launcher/glic_background_mode_manager.cc b/chrome/browser/glic/launcher/glic_background_mode_manager.cc
index aaefe09..73e1daf 100644
--- a/chrome/browser/glic/launcher/glic_background_mode_manager.cc
+++ b/chrome/browser/glic/launcher/glic_background_mode_manager.cc
@@ -9,6 +9,7 @@
#include "base/check.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/glic/launcher/glic_controller.h"
+#include "chrome/browser/glic/launcher/glic_launcher_configuration.h"
#include "chrome/browser/glic/launcher/glic_status_icon.h"
#include "components/keep_alive_registry/keep_alive_types.h"
#include "components/keep_alive_registry/scoped_keep_alive.h"
@@ -18,7 +19,7 @@
namespace glic {
GlicBackgroundModeManager::GlicBackgroundModeManager(StatusTray* status_tray)
- : configuration_(std::make_unique<GlicConfiguration>(this)),
+ : configuration_(std::make_unique<GlicLauncherConfiguration>(this)),
controller_(std::make_unique<GlicController>()),
status_tray_(status_tray),
enabled_(configuration_->IsEnabled()),
diff --git a/chrome/browser/glic/launcher/glic_background_mode_manager.h b/chrome/browser/glic/launcher/glic_background_mode_manager.h
index 6a2529b..195ae26 100644
--- a/chrome/browser/glic/launcher/glic_background_mode_manager.h
+++ b/chrome/browser/glic/launcher/glic_background_mode_manager.h
@@ -8,7 +8,7 @@
#include <memory>
#include "base/memory/raw_ptr.h"
-#include "chrome/browser/glic/launcher/glic_configuration.h"
+#include "chrome/browser/glic/launcher/glic_launcher_configuration.h"
#include "ui/base/accelerators/global_accelerator_listener/global_accelerator_listener.h"
class GlicController;
@@ -27,7 +27,7 @@
// chrome is set to keep alive the browser process, so that this class can
// listen to a global hotkey, and provide a status icon for triggering the UI.
class GlicBackgroundModeManager
- : public GlicConfiguration::Observer,
+ : public GlicLauncherConfiguration::Observer,
public ui::GlobalAcceleratorListener::Observer {
public:
explicit GlicBackgroundModeManager(StatusTray* status_tray);
@@ -53,7 +53,7 @@
void UpdateState();
// A helper class for observing pref changes.
- std::unique_ptr<GlicConfiguration> configuration_;
+ std::unique_ptr<GlicLauncherConfiguration> configuration_;
// An abstraction used to show/hide the UI.
std::unique_ptr<GlicController> controller_;
diff --git a/chrome/browser/glic/launcher/glic_background_mode_manager_browsertest.cc b/chrome/browser/glic/launcher/glic_background_mode_manager_browsertest.cc
index bd728fd0..416f80b 100644
--- a/chrome/browser/glic/launcher/glic_background_mode_manager_browsertest.cc
+++ b/chrome/browser/glic/launcher/glic_background_mode_manager_browsertest.cc
@@ -9,7 +9,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/global_shortcut_listener.h"
#include "chrome/browser/glic/glic_pref_names.h"
-#include "chrome/browser/glic/launcher/glic_configuration.h"
+#include "chrome/browser/glic/launcher/glic_launcher_configuration.h"
#include "chrome/browser/global_features.h"
#include "chrome/browser/status_icons/status_tray.h"
#include "chrome/common/chrome_features.h"
@@ -49,8 +49,9 @@
void RegisterHotkey(ui::Accelerator updated_hotkey) {
auto hotkey_dictionary =
base::Value::Dict()
- .Set(GlicConfiguration::kHotkeyKeyCode, updated_hotkey.key_code())
- .Set(GlicConfiguration::kHotkeyModifiers,
+ .Set(GlicLauncherConfiguration::kHotkeyKeyCode,
+ updated_hotkey.key_code())
+ .Set(GlicLauncherConfiguration::kHotkeyModifiers,
updated_hotkey.modifiers());
g_browser_process->local_state()->SetDict(prefs::kGlicLauncherGlobalHotkey,
std::move(hotkey_dictionary));
diff --git a/chrome/browser/glic/launcher/glic_configuration.cc b/chrome/browser/glic/launcher/glic_launcher_configuration.cc
similarity index 71%
rename from chrome/browser/glic/launcher/glic_configuration.cc
rename to chrome/browser/glic/launcher/glic_launcher_configuration.cc
index 8cf841e..55addf8 100644
--- a/chrome/browser/glic/launcher/glic_configuration.cc
+++ b/chrome/browser/glic/launcher/glic_launcher_configuration.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/glic/launcher/glic_configuration.h"
+#include "chrome/browser/glic/launcher/glic_launcher_configuration.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
@@ -15,24 +15,27 @@
namespace glic {
-GlicConfiguration::GlicConfiguration(Observer* manager) : manager_(manager) {
+GlicLauncherConfiguration::GlicLauncherConfiguration(Observer* manager)
+ : manager_(manager) {
if (PrefService* local_state = g_browser_process->local_state()) {
pref_registrar_.Init(local_state);
pref_registrar_.Add(
prefs::kGlicLauncherEnabled,
- base::BindRepeating(&GlicConfiguration::OnEnabledPrefChanged,
+ base::BindRepeating(&GlicLauncherConfiguration::OnEnabledPrefChanged,
base::Unretained(this)));
pref_registrar_.Add(
prefs::kGlicLauncherGlobalHotkey,
- base::BindRepeating(&GlicConfiguration::OnGlobalHotkeyPrefChanged,
- base::Unretained(this)));
+ base::BindRepeating(
+ &GlicLauncherConfiguration::OnGlobalHotkeyPrefChanged,
+ base::Unretained(this)));
}
}
-GlicConfiguration::~GlicConfiguration() = default;
+GlicLauncherConfiguration::~GlicLauncherConfiguration() = default;
// static
-void GlicConfiguration::RegisterLocalStatePrefs(PrefRegistrySimple* registry) {
+void GlicLauncherConfiguration::RegisterLocalStatePrefs(
+ PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(prefs::kGlicLauncherEnabled, false);
registry->RegisterDictionaryPref(
prefs::kGlicLauncherGlobalHotkey,
@@ -42,18 +45,19 @@
}
// static
-void GlicConfiguration::RegisterProfilePrefs(PrefRegistrySimple* registry) {
+void GlicLauncherConfiguration::RegisterProfilePrefs(
+ PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(prefs::kGlicMicrophoneEnabled, false);
registry->RegisterBooleanPref(prefs::kGlicGeolocationEnabled, false);
registry->RegisterBooleanPref(prefs::kGlicTabContextEnabled, false);
}
-bool GlicConfiguration::IsEnabled() {
+bool GlicLauncherConfiguration::IsEnabled() {
return g_browser_process->local_state()->GetBoolean(
prefs::kGlicLauncherEnabled);
}
-ui::Accelerator GlicConfiguration::GetGlobalHotkey() {
+ui::Accelerator GlicLauncherConfiguration::GetGlobalHotkey() {
const base::Value::Dict& hotkey_dictionary =
g_browser_process->local_state()->GetDict(
prefs::kGlicLauncherGlobalHotkey);
@@ -71,11 +75,11 @@
return hotkey;
}
-void GlicConfiguration::OnEnabledPrefChanged() {
+void GlicLauncherConfiguration::OnEnabledPrefChanged() {
manager_->OnEnabledChanged(IsEnabled());
}
-void GlicConfiguration::OnGlobalHotkeyPrefChanged() {
+void GlicLauncherConfiguration::OnGlobalHotkeyPrefChanged() {
manager_->OnGlobalHotkeyChanged(GetGlobalHotkey());
}
diff --git a/chrome/browser/glic/launcher/glic_configuration.h b/chrome/browser/glic/launcher/glic_launcher_configuration.h
similarity index 78%
rename from chrome/browser/glic/launcher/glic_configuration.h
rename to chrome/browser/glic/launcher/glic_launcher_configuration.h
index c7b1be3..74f44f0 100644
--- a/chrome/browser/glic/launcher/glic_configuration.h
+++ b/chrome/browser/glic/launcher/glic_launcher_configuration.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_GLIC_LAUNCHER_GLIC_CONFIGURATION_H_
-#define CHROME_BROWSER_GLIC_LAUNCHER_GLIC_CONFIGURATION_H_
+#ifndef CHROME_BROWSER_GLIC_LAUNCHER_GLIC_LAUNCHER_CONFIGURATION_H_
+#define CHROME_BROWSER_GLIC_LAUNCHER_GLIC_LAUNCHER_CONFIGURATION_H_
#include "base/observer_list.h"
#include "base/observer_list_types.h"
@@ -16,7 +16,7 @@
// This class observes and reports changes to glic prefs such as the
// enabled/disabled state, and the hotkey for launching the UI. Owned by
// GlicBackgroundModeManager.
-class GlicConfiguration {
+class GlicLauncherConfiguration {
public:
class Observer : public base::CheckedObserver {
public:
@@ -27,8 +27,8 @@
static constexpr char kHotkeyKeyCode[] = "keycode";
static constexpr char kHotkeyModifiers[] = "modifiers";
- explicit GlicConfiguration(Observer* manager);
- ~GlicConfiguration();
+ explicit GlicLauncherConfiguration(Observer* manager);
+ ~GlicLauncherConfiguration();
static void RegisterLocalStatePrefs(PrefRegistrySimple* registry);
static void RegisterProfilePrefs(PrefRegistrySimple* registry);
@@ -47,4 +47,4 @@
};
} // namespace glic
-#endif // CHROME_BROWSER_GLIC_LAUNCHER_GLIC_CONFIGURATION_H_
+#endif // CHROME_BROWSER_GLIC_LAUNCHER_GLIC_LAUNCHER_CONFIGURATION_H_
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index e82a0252..97819ed 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -547,7 +547,7 @@
#endif
#if BUILDFLAG(ENABLE_GLIC)
-#include "chrome/browser/glic/launcher/glic_configuration.h"
+#include "chrome/browser/glic/launcher/glic_launcher_configuration.h"
#endif
namespace {
@@ -2001,7 +2001,7 @@
registry->RegisterIntegerPref(prefs::kChromeDataRegionSetting, 0);
#if BUILDFLAG(ENABLE_GLIC)
- glic::GlicConfiguration::RegisterLocalStatePrefs(registry);
+ glic::GlicLauncherConfiguration::RegisterLocalStatePrefs(registry);
#endif
registry->RegisterIntegerPref(prefs::kToastAlertLevel, 0);
@@ -2038,7 +2038,7 @@
DownloadPrefs::RegisterProfilePrefs(registry);
fingerprinting_protection_filter::prefs::RegisterProfilePrefs(registry);
#if BUILDFLAG(ENABLE_GLIC)
- glic::GlicConfiguration::RegisterProfilePrefs(registry);
+ glic::GlicLauncherConfiguration::RegisterProfilePrefs(registry);
#endif
permissions::PermissionHatsTriggerHelper::RegisterProfilePrefs(registry);
history_clusters::prefs::RegisterProfilePrefs(registry);