Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / ui / ash / system_tray_delegate_chromeos.h
blob58f93a885b8dabbabb59f8296f815360f3be3563
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_ASH_SYSTEM_TRAY_DELEGATE_CHROMEOS_H_
6 #define CHROME_BROWSER_UI_ASH_SYSTEM_TRAY_DELEGATE_CHROMEOS_H_
8 #include <string>
9 #include <vector>
11 #include "ash/session/session_state_observer.h"
12 #include "ash/system/chromeos/supervised/custodian_info_tray_observer.h"
13 #include "ash/system/tray/system_tray.h"
14 #include "ash/system/tray/system_tray_delegate.h"
15 #include "ash/system/tray/system_tray_notifier.h"
16 #include "base/callback_forward.h"
17 #include "base/callback_list.h"
18 #include "base/compiler_specific.h"
19 #include "base/containers/scoped_ptr_hash_map.h"
20 #include "base/memory/ref_counted.h"
21 #include "base/memory/weak_ptr.h"
22 #include "base/observer_list.h"
23 #include "base/prefs/pref_change_registrar.h"
24 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
25 #include "chrome/browser/chromeos/settings/shutdown_policy_handler.h"
26 #include "chrome/browser/chromeos/system/system_clock.h"
27 #include "chrome/browser/chromeos/system/system_clock_observer.h"
28 #include "chrome/browser/profiles/profile.h"
29 #include "chrome/browser/supervised_user/supervised_user_service_observer.h"
30 #include "chrome/browser/ui/browser_list_observer.h"
31 #include "chromeos/audio/cras_audio_handler.h"
32 #include "chromeos/dbus/session_manager_client.h"
33 #include "components/policy/core/common/cloud/cloud_policy_store.h"
34 #include "components/user_manager/user_manager.h"
35 #include "content/public/browser/notification_observer.h"
36 #include "content/public/browser/notification_registrar.h"
37 #include "device/bluetooth/bluetooth_adapter.h"
38 #include "device/bluetooth/bluetooth_discovery_session.h"
39 #include "extensions/browser/app_window/app_window_registry.h"
40 #include "ui/base/ime/chromeos/input_method_manager.h"
41 #include "ui/chromeos/ime/input_method_menu_manager.h"
43 namespace ash {
44 class VPNDelegate;
47 namespace user_manager {
48 class User;
51 namespace chromeos {
53 class SystemTrayDelegateChromeOS
54 : public ui::ime::InputMethodMenuManager::Observer,
55 public ash::SystemTrayDelegate,
56 public SessionManagerClient::Observer,
57 public content::NotificationObserver,
58 public input_method::InputMethodManager::Observer,
59 public chromeos::CrasAudioHandler::AudioObserver,
60 public device::BluetoothAdapter::Observer,
61 public policy::CloudPolicyStore::Observer,
62 public ash::SessionStateObserver,
63 public chrome::BrowserListObserver,
64 public extensions::AppWindowRegistry::Observer,
65 public user_manager::UserManager::UserSessionStateObserver,
66 public SupervisedUserServiceObserver,
67 public ShutdownPolicyHandler::Delegate,
68 public system::SystemClockObserver {
69 public:
70 SystemTrayDelegateChromeOS();
72 ~SystemTrayDelegateChromeOS() override;
74 void InitializeOnAdapterReady(
75 scoped_refptr<device::BluetoothAdapter> adapter);
77 // Overridden from ash::SystemTrayDelegate:
78 void Initialize() override;
79 void Shutdown() override;
80 bool GetTrayVisibilityOnStartup() override;
81 ash::user::LoginStatus GetUserLoginStatus() const override;
82 void ChangeProfilePicture() override;
83 const std::string GetEnterpriseDomain() const override;
84 const base::string16 GetEnterpriseMessage() const override;
85 const std::string GetSupervisedUserManager() const override;
86 const base::string16 GetSupervisedUserManagerName() const override;
87 const base::string16 GetSupervisedUserMessage() const override;
88 bool IsUserSupervised() const override;
89 bool IsUserChild() const override;
90 void GetSystemUpdateInfo(ash::UpdateInfo* info) const override;
91 base::HourClockType GetHourClockType() const override;
92 void ShowSettings() override;
93 bool ShouldShowSettings() override;
94 void ShowDateSettings() override;
95 void ShowSetTimeDialog() override;
96 void ShowNetworkSettingsForGuid(const std::string& guid) override;
97 void ShowDisplaySettings() override;
98 void ShowChromeSlow() override;
99 bool ShouldShowDisplayNotification() override;
100 void ShowIMESettings() override;
101 void ShowHelp() override;
102 void ShowAccessibilityHelp() override;
103 void ShowAccessibilitySettings() override;
104 void ShowPublicAccountInfo() override;
105 void ShowSupervisedUserInfo() override;
106 void ShowEnterpriseInfo() override;
107 void ShowUserLogin() override;
108 void SignOut() override;
109 void RequestLockScreen() override;
110 void RequestRestartForUpdate() override;
111 void GetAvailableBluetoothDevices(ash::BluetoothDeviceList* list) override;
112 void BluetoothStartDiscovering() override;
113 void BluetoothStopDiscovering() override;
114 void ConnectToBluetoothDevice(const std::string& address) override;
115 bool IsBluetoothDiscovering() override;
116 void GetCurrentIME(ash::IMEInfo* info) override;
117 void GetAvailableIMEList(ash::IMEInfoList* list) override;
118 void GetCurrentIMEProperties(ash::IMEPropertyInfoList* list) override;
119 void SwitchIME(const std::string& ime_id) override;
120 void ActivateIMEProperty(const std::string& key) override;
121 void ManageBluetoothDevices() override;
122 void ToggleBluetooth() override;
123 void ShowOtherNetworkDialog(const std::string& type) override;
124 bool GetBluetoothAvailable() override;
125 bool GetBluetoothEnabled() override;
126 bool GetBluetoothDiscovering() override;
127 void ChangeProxySettings() override;
128 ash::CastConfigDelegate* GetCastConfigDelegate() const override;
129 ash::NetworkingConfigDelegate* GetNetworkingConfigDelegate() const override;
130 ash::VolumeControlDelegate* GetVolumeControlDelegate() const override;
131 void SetVolumeControlDelegate(
132 scoped_ptr<ash::VolumeControlDelegate> delegate) override;
133 bool GetSessionStartTime(base::TimeTicks* session_start_time) override;
134 bool GetSessionLengthLimit(base::TimeDelta* session_length_limit) override;
135 int GetSystemTrayMenuWidth() override;
136 void ActiveUserWasChanged() override;
137 bool IsSearchKeyMappedToCapsLock() override;
138 ash::tray::UserAccountsDelegate* GetUserAccountsDelegate(
139 const std::string& user_id) override;
140 void AddCustodianInfoTrayObserver(
141 ash::CustodianInfoTrayObserver* observer) override;
142 void RemoveCustodianInfoTrayObserver(
143 ash::CustodianInfoTrayObserver* observer) override;
144 void AddShutdownPolicyObserver(
145 ash::ShutdownPolicyObserver* observer) override;
146 void RemoveShutdownPolicyObserver(
147 ash::ShutdownPolicyObserver* observer) override;
148 void ShouldRebootOnShutdown(
149 const ash::RebootOnShutdownCallback& callback) override;
150 ash::VPNDelegate* GetVPNDelegate() const override;
152 // Overridden from user_manager::UserManager::UserSessionStateObserver:
153 void UserAddedToSession(const user_manager::User* active_user) override;
154 void ActiveUserChanged(const user_manager::User* active_user) override;
156 void UserChangedChildStatus(user_manager::User* user) override;
158 // browser tests need to call ShouldUse24HourClock().
159 bool GetShouldUse24HourClockForTesting() const;
161 // chromeos::system::SystemClockObserver implementation.
162 void OnSystemClockChanged(system::SystemClock*) override;
164 private:
166 ash::SystemTray* GetPrimarySystemTray();
168 ash::SystemTrayNotifier* GetSystemTrayNotifier();
170 void SetProfile(Profile* profile);
172 bool UnsetProfile(Profile* profile);
174 bool ShouldUse24HourClock() const;
176 void UpdateShowLogoutButtonInTray();
178 void UpdateLogoutDialogDuration();
180 void UpdateSessionStartTime();
182 void UpdateSessionLengthLimit();
184 void StopObservingAppWindowRegistry();
186 void StopObservingCustodianInfoChanges();
188 // Notify observers if the current user has no more open browser or app
189 // windows.
190 void NotifyIfLastWindowClosed();
192 // Overridden from SessionManagerClient::Observer.
193 void ScreenIsLocked() override;
194 void ScreenIsUnlocked() override;
196 gfx::NativeWindow GetNativeWindow() const;
198 // content::NotificationObserver implementation.
199 void Observe(int type,
200 const content::NotificationSource& source,
201 const content::NotificationDetails& details) override;
203 void OnLanguageRemapSearchKeyToChanged();
205 void OnAccessibilityModeChanged(
206 ui::AccessibilityNotificationVisibility notify);
208 void UpdatePerformanceTracing();
210 // Overridden from InputMethodManager::Observer.
211 void InputMethodChanged(input_method::InputMethodManager* manager,
212 Profile* profile,
213 bool show_message) override;
215 // Overridden from InputMethodMenuManager::Observer.
216 void InputMethodMenuItemChanged(
217 ui::ime::InputMethodMenuManager* manager) override;
219 // Overridden from CrasAudioHandler::AudioObserver.
220 void OnOutputNodeVolumeChanged(uint64_t node_id, int volume) override;
221 void OnOutputMuteChanged(bool mute_on, bool system_adjust) override;
222 void OnInputNodeGainChanged(uint64_t node_id, int gain) override;
223 void OnInputMuteChanged(bool mute_on) override;
224 void OnAudioNodesChanged() override;
225 void OnActiveOutputNodeChanged() override;
226 void OnActiveInputNodeChanged() override;
228 // Overridden from BluetoothAdapter::Observer.
229 void AdapterPresentChanged(device::BluetoothAdapter* adapter,
230 bool present) override;
231 void AdapterPoweredChanged(device::BluetoothAdapter* adapter,
232 bool powered) override;
233 void AdapterDiscoveringChanged(device::BluetoothAdapter* adapter,
234 bool discovering) override;
235 void DeviceAdded(device::BluetoothAdapter* adapter,
236 device::BluetoothDevice* device) override;
237 void DeviceChanged(device::BluetoothAdapter* adapter,
238 device::BluetoothDevice* device) override;
239 void DeviceRemoved(device::BluetoothAdapter* adapter,
240 device::BluetoothDevice* device) override;
242 void OnStartBluetoothDiscoverySession(
243 scoped_ptr<device::BluetoothDiscoverySession> discovery_session);
245 void UpdateEnterpriseDomain();
247 // Overridden from CloudPolicyStore::Observer
248 void OnStoreLoaded(policy::CloudPolicyStore* store) override;
249 void OnStoreError(policy::CloudPolicyStore* store) override;
251 // Overridden from ash::SessionStateObserver
252 void UserAddedToSession(const std::string& user_id) override;
253 void ActiveUserChanged(const std::string& user_id) override;
255 // Overridden from chrome::BrowserListObserver:
256 void OnBrowserRemoved(Browser* browser) override;
258 // Overridden from extensions::AppWindowRegistry::Observer:
259 void OnAppWindowRemoved(extensions::AppWindow* app_window) override;
261 // Overridden from SupervisedUserServiceObserver:
262 void OnCustodianInfoChanged() override;
264 void OnAccessibilityStatusChanged(
265 const AccessibilityStatusEventDetails& details);
267 // Overridden from ShutdownPolicyObserver::Delegate.
268 void OnShutdownPolicyChanged(bool reboot_on_shutdown) override;
270 // helper methods used by GetSupervisedUserMessage.
271 const base::string16 GetLegacySupervisedUserMessage() const;
272 const base::string16 GetChildUserMessage() const;
274 scoped_ptr<content::NotificationRegistrar> registrar_;
275 scoped_ptr<PrefChangeRegistrar> local_state_registrar_;
276 scoped_ptr<PrefChangeRegistrar> user_pref_registrar_;
277 Profile* user_profile_;
278 base::HourClockType clock_type_;
279 int search_key_mapped_to_;
280 bool screen_locked_;
281 bool have_session_start_time_;
282 base::TimeTicks session_start_time_;
283 bool have_session_length_limit_;
284 base::TimeDelta session_length_limit_;
285 std::string enterprise_domain_;
286 bool should_run_bluetooth_discovery_;
287 bool session_started_;
289 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_;
290 scoped_ptr<device::BluetoothDiscoverySession> bluetooth_discovery_session_;
291 scoped_ptr<ash::CastConfigDelegate> cast_config_delegate_;
292 scoped_ptr<ash::NetworkingConfigDelegate> networking_config_delegate_;
293 scoped_ptr<ash::VolumeControlDelegate> volume_control_delegate_;
294 scoped_ptr<AccessibilityStatusSubscription> accessibility_subscription_;
295 base::ScopedPtrHashMap<std::string,
296 scoped_ptr<ash::tray::UserAccountsDelegate>>
297 accounts_delegates_;
298 scoped_ptr<ShutdownPolicyHandler> shutdown_policy_handler_;
299 scoped_ptr<ash::VPNDelegate> vpn_delegate_;
301 base::ObserverList<ash::CustodianInfoTrayObserver>
302 custodian_info_changed_observers_;
304 base::ObserverList<ash::ShutdownPolicyObserver> shutdown_policy_observers_;
306 base::WeakPtrFactory<SystemTrayDelegateChromeOS> weak_ptr_factory_;
308 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegateChromeOS);
311 ash::SystemTrayDelegate* CreateSystemTrayDelegate();
313 } // namespace chromeos
314 #endif // CHROME_BROWSER_UI_ASH_SYSTEM_TRAY_DELEGATE_CHROMEOS_H_