blob: 837e0335ef6956797cd7938c994f2c767b90e42d [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"
10#include "chrome/browser/profiles/profile.h"
11#include "components/prefs/pref_registry_simple.h"
12#include "components/prefs/pref_service.h"
13#include "ui/base/accelerators/accelerator.h"
14#include "ui/events/event_constants.h"
15#include "ui/events/keycodes/keyboard_codes.h"
16
17namespace glic {
18
David Bokanc5e12cc2025-01-10 16:53:0519GlicProfileConfiguration::GlicProfileConfiguration(Profile* profile)
20 : profile_(*profile) {
21 pref_registrar_.Init(profile_->GetPrefs());
22 pref_registrar_.Add(
23 prefs::kGlicEnabledByPolicy,
24 base::BindRepeating(&GlicProfileConfiguration::OnEnabledByPolicyChanged,
25 base::Unretained(this)));
26}
27
David Bokan709ff8a2024-12-30 18:55:0128GlicProfileConfiguration::~GlicProfileConfiguration() = default;
29
30// static
31void GlicProfileConfiguration::RegisterProfilePrefs(
32 PrefRegistrySimple* registry) {
David Bokanc5e12cc2025-01-10 16:53:0533 registry->RegisterBooleanPref(prefs::kGlicEnabledByPolicy, true);
David Bokan709ff8a2024-12-30 18:55:0134 registry->RegisterBooleanPref(prefs::kGlicMicrophoneEnabled, false);
35 registry->RegisterBooleanPref(prefs::kGlicGeolocationEnabled, false);
36 registry->RegisterBooleanPref(prefs::kGlicTabContextEnabled, false);
37}
38
David Bokanc5e12cc2025-01-10 16:53:0539bool GlicProfileConfiguration::IsEnabledByPolicy() const {
40 return profile_->GetPrefs()->GetBoolean(prefs::kGlicEnabledByPolicy);
41}
42
43void GlicProfileConfiguration::OnEnabledByPolicyChanged() {
44 // TODO(crbug.com/382722218): Update UI in each window to remove/add Glic
45 // button.
46 // TODO(crbug.com/382722218): Update background mode in response to changed
47 // policy.
48}
49
David Bokan709ff8a2024-12-30 18:55:0150} // namespace glic