blob: 22338839387b35637f409c8d425ee0bd5c563920 [file] [log] [blame]
David Bokan709ff8a2024-12-30 18:55:011// Copyright 2024 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/glic/glic_profile_configuration.h"
6
7#include "base/values.h"
8#include "chrome/browser/browser_process.h"
9#include "chrome/browser/glic/glic_pref_names.h"
David Bokan7412e912025-01-10 19:07:3210#include "chrome/browser/glic/launcher/glic_background_mode_manager.h"
David Bokan709ff8a2024-12-30 18:55:0111#include "chrome/browser/profiles/profile.h"
12#include "components/prefs/pref_registry_simple.h"
13#include "components/prefs/pref_service.h"
14#include "ui/base/accelerators/accelerator.h"
15#include "ui/events/event_constants.h"
16#include "ui/events/keycodes/keyboard_codes.h"
17
18namespace glic {
19
David Bokanc5e12cc2025-01-10 16:53:0520GlicProfileConfiguration::GlicProfileConfiguration(Profile* profile)
21 : profile_(*profile) {
22 pref_registrar_.Init(profile_->GetPrefs());
23 pref_registrar_.Add(
24 prefs::kGlicEnabledByPolicy,
25 base::BindRepeating(&GlicProfileConfiguration::OnEnabledByPolicyChanged,
26 base::Unretained(this)));
27}
28
David Bokan709ff8a2024-12-30 18:55:0129GlicProfileConfiguration::~GlicProfileConfiguration() = default;
30
31// static
32void GlicProfileConfiguration::RegisterProfilePrefs(
33 PrefRegistrySimple* registry) {
David Bokanc5e12cc2025-01-10 16:53:0534 registry->RegisterBooleanPref(prefs::kGlicEnabledByPolicy, true);
David Bokan709ff8a2024-12-30 18:55:0135 registry->RegisterBooleanPref(prefs::kGlicMicrophoneEnabled, false);
36 registry->RegisterBooleanPref(prefs::kGlicGeolocationEnabled, false);
37 registry->RegisterBooleanPref(prefs::kGlicTabContextEnabled, false);
38}
39
David Bokanc5e12cc2025-01-10 16:53:0540bool GlicProfileConfiguration::IsEnabledByPolicy() const {
41 return profile_->GetPrefs()->GetBoolean(prefs::kGlicEnabledByPolicy);
42}
43
44void GlicProfileConfiguration::OnEnabledByPolicyChanged() {
45 // TODO(crbug.com/382722218): Update UI in each window to remove/add Glic
46 // button.
David Bokan7412e912025-01-10 19:07:3247 GlicBackgroundModeManager::GetInstance()->OnPolicyChanged();
David Bokanc5e12cc2025-01-10 16:53:0548}
49
David Bokan709ff8a2024-12-30 18:55:0150} // namespace glic