File: system_tray_client_impl.h

package info (click to toggle)
chromium 120.0.6099.224-1~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 6,112,112 kB
  • sloc: cpp: 32,907,025; ansic: 8,148,123; javascript: 3,679,536; python: 2,031,248; asm: 959,718; java: 804,675; xml: 617,256; sh: 111,417; objc: 100,835; perl: 88,443; cs: 53,032; makefile: 29,579; fortran: 24,137; php: 21,162; tcl: 21,147; sql: 20,809; ruby: 17,735; pascal: 12,864; yacc: 8,045; lisp: 3,388; lex: 1,323; ada: 727; awk: 329; jsp: 267; csh: 117; exp: 43; sed: 37
file content (166 lines) | stat: -rw-r--r-- 6,783 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// Copyright 2016 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_UI_ASH_SYSTEM_TRAY_CLIENT_IMPL_H_
#define CHROME_BROWSER_UI_ASH_SYSTEM_TRAY_CLIENT_IMPL_H_

#include "ash/public/cpp/system_tray_client.h"
#include "ash/public/cpp/update_types.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_piece.h"
#include "chrome/browser/ash/system/system_clock_observer.h"
#include "chrome/browser/upgrade_detector/upgrade_observer.h"
#include "components/access_code_cast/common/access_code_cast_metrics.h"
#include "components/policy/core/common/cloud/cloud_policy_store.h"
#include "third_party/abseil-cpp/absl/types/optional.h"

namespace ash {
struct DeviceEnterpriseInfo;
struct LocaleInfo;
class SystemTray;
enum class LoginStatus;
enum class NotificationStyle;
}  // namespace ash

class Profile;

// Handles method calls delegated back to chrome from ash. Also notifies ash of
// relevant state changes in chrome.
class SystemTrayClientImpl : public ash::SystemTrayClient,
                             public ash::system::SystemClockObserver,
                             public policy::CloudPolicyStore::Observer,
                             public UpgradeObserver {
 public:
  SystemTrayClientImpl();

  SystemTrayClientImpl(const SystemTrayClientImpl&) = delete;
  SystemTrayClientImpl& operator=(const SystemTrayClientImpl&) = delete;

  ~SystemTrayClientImpl() override;

  static SystemTrayClientImpl* Get();

  // Specifies if notification is recommended or required by administrator and
  // triggers the notification to be shown with the given body and title.
  // Only applies to OS updates.
  virtual void SetRelaunchNotificationState(
      const ash::RelaunchNotificationState& relaunch_notification_state);

  // Resets update state to hide notification.
  void ResetUpdateState();

  // Wrappers around ash::mojom::SystemTray interface:
  void SetPrimaryTrayEnabled(bool enabled);
  void SetPrimaryTrayVisible(bool visible);
  void SetPerformanceTracingIconVisible(bool visible);
  void SetLocaleList(std::vector<ash::LocaleInfo> locale_list,
                     const std::string& current_locale_iso_code);
  void SetShowEolNotice(bool show, bool eol_passed_recently);

  // ash::SystemTrayClient:
  void ShowSettings(int64_t display_id) override;
  void ShowAccountSettings() override;
  void ShowBluetoothSettings() override;
  void ShowBluetoothSettings(const std::string& device_id) override;
  void ShowBluetoothPairingDialog(
      absl::optional<base::StringPiece> device_address) override;
  void ShowDateSettings() override;
  void ShowSetTimeDialog() override;
  void ShowDisplaySettings() override;
  void ShowDarkModeSettings() override;
  void ShowStorageSettings() override;
  void ShowPowerSettings() override;
  void ShowPrivacyAndSecuritySettings() override;
  void ShowPrivacyHubSettings() override;
  void ShowSpeakOnMuteDetectionSettings() override;
  void ShowSmartPrivacySettings() override;
  void ShowChromeSlow() override;
  void ShowIMESettings() override;
  void ShowConnectedDevicesSettings() override;
  void ShowTetherNetworkSettings() override;
  void ShowWifiSyncSettings() override;
  void ShowAboutChromeOS() override;
  void ShowAboutChromeOSDetails() override;
  void ShowAccessibilityHelp() override;
  void ShowAccessibilitySettings() override;
  void ShowColorCorrectionSettings() override;
  void ShowGestureEducationHelp() override;
  void ShowPaletteHelp() override;
  void ShowPaletteSettings() override;
  void ShowEnterpriseInfo() override;
  void ShowNetworkConfigure(const std::string& network_id) override;
  void ShowNetworkCreate(const std::string& type) override;
  void ShowSettingsCellularSetup(bool show_psim_flow) override;
  void ShowSettingsSimUnlock() override;
  void ShowApnSubpage(const std::string& network_id) override;
  void ShowThirdPartyVpnCreate(const std::string& extension_id) override;
  void ShowArcVpnCreate(const std::string& app_id) override;
  void ShowNetworkSettings(const std::string& network_id) override;
  void ShowHotspotSubpage() override;
  void ShowMultiDeviceSetup() override;
  void ShowFirmwareUpdate() override;
  void SetLocaleAndExit(const std::string& locale_iso_code) override;
  void ShowAccessCodeCastingDialog(
      AccessCodeCastDialogOpenLocation open_location) override;
  void ShowCalendarEvent(const absl::optional<GURL>& event_url,
                         const base::Time& date,
                         bool& opened_pwa,
                         GURL& finalized_event_url) override;
  void ShowVideoConference(const GURL& video_conference_url) override;
  void ShowChannelInfoAdditionalDetails() override;
  void ShowChannelInfoGiveFeedback() override;
  void ShowAudioSettings() override;
  void ShowEolInfoPage() override;
  void RecordEolNoticeShown() override;
  bool IsUserFeedbackEnabled() override;
  void ShowTouchpadSettings() override;
  void ShowRemapKeysSubpage(int device_id) override;

 protected:
  // Used by mocks in tests.
  explicit SystemTrayClientImpl(SystemTrayClientImpl* mock_instance);

 private:
  // Observes profile changed and profile's policy changed.
  class EnterpriseAccountObserver;

  // Helper function shared by ShowNetworkSettings() and ShowNetworkConfigure().
  void ShowNetworkSettingsHelper(const std::string& network_id,
                                 bool show_configure);

  // Requests that ash show the update available icon.
  void HandleUpdateAvailable();

  // ash::system::SystemClockObserver:
  void OnSystemClockChanged(ash::system::SystemClock* clock) override;

  // UpgradeObserver implementation.
  void OnUpdateDeferred(bool use_notification) override;
  void OnUpdateOverCellularAvailable() override;
  void OnUpdateOverCellularOneTimePermissionGranted() override;
  void OnUpgradeRecommended() override;

  // policy::CloudPolicyStore::Observer
  void OnStoreLoaded(policy::CloudPolicyStore* store) override;
  void OnStoreError(policy::CloudPolicyStore* store) override;

  void UpdateDeviceEnterpriseInfo();
  void UpdateEnterpriseAccountDomainInfo(Profile* profile);

  // The system tray model in ash.
  const raw_ptr<ash::SystemTray> system_tray_;

  // Information on whether the update is recommended or required.
  ash::RelaunchNotificationState relaunch_notification_state_;

  std::unique_ptr<ash::DeviceEnterpriseInfo> last_device_enterprise_info_;
  std::string last_enterprise_account_domain_manager_;

  std::unique_ptr<EnterpriseAccountObserver> enterprise_account_observer_;

  // Whether the eol incentive is due to a recently pasesed end of life date.
  bool eol_incentive_recently_passed_ = false;
};

#endif  // CHROME_BROWSER_UI_ASH_SYSTEM_TRAY_CLIENT_IMPL_H_