1 // Copyright 2016 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. 4 5 #ifndef CHROME_BROWSER_UI_ASH_SYSTEM_TRAY_CLIENT_H_ 6 #define CHROME_BROWSER_UI_ASH_SYSTEM_TRAY_CLIENT_H_ 7 8 #include "ash/public/cpp/system_tray_client.h" 9 #include "base/macros.h" 10 #include "chrome/browser/chromeos/system/system_clock_observer.h" 11 #include "chrome/browser/upgrade_detector/upgrade_observer.h" 12 #include "components/policy/core/common/cloud/cloud_policy_store.h" 13 14 namespace ash { 15 struct LocaleInfo; 16 class SystemTray; 17 enum class LoginStatus; 18 enum class NotificationStyle; 19 } // namespace ash 20 21 // Handles method calls delegated back to chrome from ash. Also notifies ash of 22 // relevant state changes in chrome. 23 // TODO: Consider renaming this to SystemTrayClientImpl. 24 class SystemTrayClient : public ash::SystemTrayClient, 25 public chromeos::system::SystemClockObserver, 26 public policy::CloudPolicyStore::Observer, 27 public UpgradeObserver { 28 public: 29 SystemTrayClient(); 30 ~SystemTrayClient() override; 31 32 static SystemTrayClient* Get(); 33 34 // Shows an update icon for an Adobe Flash update and forces a device reboot 35 // when the update is applied. 36 void SetFlashUpdateAvailable(); 37 38 // Specifies if notification is recommended or required by administrator and 39 // triggers the notification to be shown with the given body and title. 40 void SetUpdateNotificationState(ash::NotificationStyle style, 41 const base::string16& notification_title, 42 const base::string16& notification_body); 43 44 // Wrappers around ash::mojom::SystemTray interface: 45 void SetPrimaryTrayEnabled(bool enabled); 46 void SetPrimaryTrayVisible(bool visible); 47 void SetPerformanceTracingIconVisible(bool visible); 48 void SetLocaleList(std::vector<ash::LocaleInfo> locale_list, 49 const std::string& current_locale_iso_code); 50 51 // ash::SystemTrayClient: 52 void ShowSettings() override; 53 void ShowBluetoothSettings() override; 54 void ShowBluetoothPairingDialog(const std::string& address, 55 const base::string16& name_for_display, 56 bool paired, 57 bool connected) override; 58 void ShowDateSettings() override; 59 void ShowSetTimeDialog() override; 60 void ShowDisplaySettings() override; 61 void ShowPowerSettings() override; 62 void ShowChromeSlow() override; 63 void ShowIMESettings() override; 64 void ShowConnectedDevicesSettings() override; 65 void ShowTetherNetworkSettings() override; 66 void ShowAboutChromeOS() override; 67 void ShowHelp() override; 68 void ShowAccessibilityHelp() override; 69 void ShowAccessibilitySettings() override; 70 void ShowGestureEducationHelp() override; 71 void ShowPaletteHelp() override; 72 void ShowPaletteSettings() override; 73 void ShowPublicAccountInfo() override; 74 void ShowEnterpriseInfo() override; 75 void ShowNetworkConfigure(const std::string& network_id) override; 76 void ShowNetworkCreate(const std::string& type) override; 77 void ShowThirdPartyVpnCreate(const std::string& extension_id) override; 78 void ShowArcVpnCreate(const std::string& app_id) override; 79 void ShowNetworkSettings(const std::string& network_id) override; 80 void ShowMultiDeviceSetup() override; 81 void RequestRestartForUpdate() override; 82 void SetLocaleAndExit(const std::string& locale_iso_code) override; 83 84 private: 85 // Helper function shared by ShowNetworkSettings() and ShowNetworkConfigure(). 86 void ShowNetworkSettingsHelper(const std::string& network_id, 87 bool show_configure); 88 89 // Requests that ash show the update available icon. 90 void HandleUpdateAvailable(); 91 92 // chromeos::system::SystemClockObserver: 93 void OnSystemClockChanged(chromeos::system::SystemClock* clock) override; 94 95 // UpgradeObserver implementation. 96 void OnUpdateOverCellularAvailable() override; 97 void OnUpdateOverCellularOneTimePermissionGranted() override; 98 void OnUpgradeRecommended() override; 99 100 // policy::CloudPolicyStore::Observer 101 void OnStoreLoaded(policy::CloudPolicyStore* store) override; 102 void OnStoreError(policy::CloudPolicyStore* store) override; 103 104 void UpdateEnterpriseDomainInfo(); 105 106 // The system tray model in ash. 107 ash::SystemTray* const system_tray_; 108 109 // Whether an Adobe Flash component update is available. 110 bool flash_update_available_ = false; 111 112 // Tells update notification style, for example required by administrator. 113 ash::NotificationStyle update_notification_style_; 114 115 // Update notification title to be overwritten. 116 base::string16 update_notification_title_; 117 118 // Update notification body to be overwritten. 119 base::string16 update_notification_body_; 120 121 // Avoid sending ash an empty enterprise domain manager at startup and 122 // suppress duplicate IPCs during the session. 123 std::string last_enterprise_domain_manager_; 124 bool last_active_directory_managed_ = false; 125 126 DISALLOW_COPY_AND_ASSIGN(SystemTrayClient); 127 }; 128 129 #endif // CHROME_BROWSER_UI_ASH_SYSTEM_TRAY_CLIENT_H_ 130