1 // Copyright (c) 2012 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 ASH_SYSTEM_TRAY_SYSTEM_TRAY_DELEGATE_H_ 6 #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_DELEGATE_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "ash/ash_export.h" 12 #include "ash/system/user/login_status.h" 13 #include "base/files/file_path.h" 14 #include "base/i18n/time_formatting.h" 15 #include "base/memory/scoped_ptr.h" 16 #include "base/strings/string16.h" 17 #include "ui/gfx/image/image_skia.h" 18 #include "ui/gfx/native_widget_types.h" 19 20 namespace base { 21 class TimeDelta; 22 class TimeTicks; 23 } 24 25 namespace ash { 26 27 struct ASH_EXPORT NetworkIconInfo { 28 NetworkIconInfo(); 29 ~NetworkIconInfo(); 30 31 bool highlight() const { return connected || connecting; } 32 33 bool connecting; 34 bool connected; 35 bool tray_icon_visible; 36 gfx::ImageSkia image; 37 base::string16 name; 38 base::string16 description; 39 std::string service_path; 40 bool is_cellular; 41 }; 42 43 struct ASH_EXPORT BluetoothDeviceInfo { 44 BluetoothDeviceInfo(); 45 ~BluetoothDeviceInfo(); 46 47 std::string address; 48 base::string16 display_name; 49 bool connected; 50 bool connecting; 51 bool paired; 52 }; 53 54 typedef std::vector<BluetoothDeviceInfo> BluetoothDeviceList; 55 56 // Structure that packs progress information of each operation. 57 struct ASH_EXPORT DriveOperationStatus { 58 enum OperationType { 59 OPERATION_UPLOAD, 60 OPERATION_DOWNLOAD 61 }; 62 63 enum OperationState { 64 OPERATION_NOT_STARTED, 65 OPERATION_IN_PROGRESS, 66 OPERATION_COMPLETED, 67 OPERATION_FAILED, 68 }; 69 70 DriveOperationStatus(); 71 ~DriveOperationStatus(); 72 73 // Unique ID for the operation. 74 int32 id; 75 76 // File path. 77 base::FilePath file_path; 78 // Current operation completion progress [0.0 - 1.0]. 79 double progress; 80 OperationType type; 81 OperationState state; 82 }; 83 84 typedef std::vector<DriveOperationStatus> DriveOperationStatusList; 85 86 87 struct ASH_EXPORT IMEPropertyInfo { 88 IMEPropertyInfo(); 89 ~IMEPropertyInfo(); 90 91 bool selected; 92 std::string key; 93 base::string16 name; 94 }; 95 96 typedef std::vector<IMEPropertyInfo> IMEPropertyInfoList; 97 98 struct ASH_EXPORT IMEInfo { 99 IMEInfo(); 100 ~IMEInfo(); 101 102 bool selected; 103 bool third_party; 104 std::string id; 105 base::string16 name; 106 base::string16 medium_name; 107 base::string16 short_name; 108 }; 109 110 typedef std::vector<IMEInfo> IMEInfoList; 111 112 class VolumeControlDelegate; 113 114 namespace tray { 115 class UserAccountsDelegate; 116 } // namespace tray 117 118 class ASH_EXPORT SystemTrayDelegate { 119 public: 120 virtual ~SystemTrayDelegate() {} 121 122 // Called after SystemTray has been instantiated. 123 virtual void Initialize() = 0; 124 125 // Called before SystemTray is destroyed. 126 virtual void Shutdown() = 0; 127 128 // Returns true if system tray should be visible on startup. 129 virtual bool GetTrayVisibilityOnStartup() = 0; 130 131 // Gets information about the active user. 132 virtual user::LoginStatus GetUserLoginStatus() const = 0; 133 134 // Shows UI for changing user's profile picture. 135 virtual void ChangeProfilePicture() = 0; 136 137 // Returns the domain that manages the device, if it is enterprise-enrolled. 138 virtual const std::string GetEnterpriseDomain() const = 0; 139 140 // Returns notification for enterprise enrolled devices. 141 virtual const base::string16 GetEnterpriseMessage() const = 0; 142 143 // Returns the display email of user that manages current 144 // locally managed user. 145 virtual const std::string GetLocallyManagedUserManager() const = 0; 146 147 // Returns the name of user that manages current locally managed user. 148 virtual const base::string16 GetLocallyManagedUserManagerName() const = 0; 149 150 // Returns notification for locally managed users. 151 virtual const base::string16 GetLocallyManagedUserMessage() const = 0; 152 153 // Returns whether a system upgrade is available. 154 virtual bool SystemShouldUpgrade() const = 0; 155 156 // Returns the desired hour clock type. 157 virtual base::HourClockType GetHourClockType() const = 0; 158 159 // Shows settings. 160 virtual void ShowSettings() = 0; 161 162 // Returns true if settings menu item should appear. 163 virtual bool ShouldShowSettings() = 0; 164 165 // Shows the settings related to date, timezone etc. 166 virtual void ShowDateSettings() = 0; 167 168 // Shows the dialog to set system time, date, and timezone. 169 virtual void ShowSetTimeDialog() = 0; 170 171 // Shows the settings related to network. If |service_path| is not empty, 172 // show the settings for that network. 173 virtual void ShowNetworkSettings(const std::string& service_path) = 0; 174 175 // Shows the settings related to bluetooth. 176 virtual void ShowBluetoothSettings() = 0; 177 178 // Shows settings related to multiple displays. 179 virtual void ShowDisplaySettings() = 0; 180 181 // Shows the page that lets you disable performance tracing. 182 virtual void ShowChromeSlow() = 0; 183 184 // Returns true if the notification for the display configuration change 185 // should appear. 186 virtual bool ShouldShowDisplayNotification() = 0; 187 188 // Shows settings related to Google Drive. 189 virtual void ShowDriveSettings() = 0; 190 191 // Shows settings related to input methods. 192 virtual void ShowIMESettings() = 0; 193 194 // Shows help. 195 virtual void ShowHelp() = 0; 196 197 // Show accessilibity help. 198 virtual void ShowAccessibilityHelp() = 0; 199 200 // Show the settings related to accessilibity. 201 virtual void ShowAccessibilitySettings() = 0; 202 203 // Shows more information about public account mode. 204 virtual void ShowPublicAccountInfo() = 0; 205 206 // Shows information about enterprise enrolled devices. 207 virtual void ShowEnterpriseInfo() = 0; 208 209 // Shows information about locally managed users. 210 virtual void ShowLocallyManagedUserInfo() = 0; 211 212 // Shows login UI to add other users to this session. 213 virtual void ShowUserLogin() = 0; 214 215 // Shows the spring charger replacement dialog if necessary. 216 // Returns true if the dialog is shown by the call. 217 virtual bool ShowSpringChargerReplacementDialog() = 0; 218 219 // True if the spring charger replacement dialog is visible. 220 virtual bool IsSpringChargerReplacementDialogVisible() = 0; 221 222 // True if user has confirmed using safe spring charger. 223 virtual bool HasUserConfirmedSafeSpringCharger() = 0; 224 225 // Attempts to shut down the system. 226 virtual void ShutDown() = 0; 227 228 // Attempts to sign out the user. 229 virtual void SignOut() = 0; 230 231 // Attempts to lock the screen. 232 virtual void RequestLockScreen() = 0; 233 234 // Attempts to restart the system for update. 235 virtual void RequestRestartForUpdate() = 0; 236 237 // Returns a list of available bluetooth devices. 238 virtual void GetAvailableBluetoothDevices(BluetoothDeviceList* devices) = 0; 239 240 // Requests bluetooth start discovering devices. 241 virtual void BluetoothStartDiscovering() = 0; 242 243 // Requests bluetooth stop discovering devices. 244 virtual void BluetoothStopDiscovering() = 0; 245 246 // Connect to a specific bluetooth device. 247 virtual void ConnectToBluetoothDevice(const std::string& address) = 0; 248 249 // Returns true if bluetooth adapter is discovering bluetooth devices. 250 virtual bool IsBluetoothDiscovering() = 0; 251 252 // Returns the currently selected IME. 253 virtual void GetCurrentIME(IMEInfo* info) = 0; 254 255 // Returns a list of availble IMEs. 256 virtual void GetAvailableIMEList(IMEInfoList* list) = 0; 257 258 // Returns a list of properties for the currently selected IME. 259 virtual void GetCurrentIMEProperties(IMEPropertyInfoList* list) = 0; 260 261 // Switches to the selected input method. 262 virtual void SwitchIME(const std::string& ime_id) = 0; 263 264 // Activates an IME property. 265 virtual void ActivateIMEProperty(const std::string& key) = 0; 266 267 // Cancels ongoing drive operation. 268 virtual void CancelDriveOperation(int32 operation_id) = 0; 269 270 // Returns information about the ongoing drive operations. 271 virtual void GetDriveOperationStatusList( 272 DriveOperationStatusList* list) = 0; 273 274 // Shows UI to configure or activate the network specified by |network_id|, 275 // which may include showing Payment or Portal UI when appropriate. 276 // |parent_window| is used to parent any configuration UI. If NULL a default 277 // window will be used. 278 virtual void ShowNetworkConfigure(const std::string& network_id, 279 gfx::NativeWindow parent_window) = 0; 280 281 // Shows UI to enroll the network specified by |network_id| if appropriate 282 // and returns true, otherwise returns false. |parent_window| is used 283 // to parent any configuration UI. If NULL a default window will be used. 284 virtual bool EnrollNetwork(const std::string& network_id, 285 gfx::NativeWindow parent_window) = 0; 286 287 // Shows UI to manage bluetooth devices. 288 virtual void ManageBluetoothDevices() = 0; 289 290 // Toggles bluetooth. 291 virtual void ToggleBluetooth() = 0; 292 293 // Shows UI to unlock a mobile sim. 294 virtual void ShowMobileSimDialog() = 0; 295 296 // Shows UI to setup a mobile network. 297 virtual void ShowMobileSetupDialog(const std::string& service_path) = 0; 298 299 // Shows UI to connect to an unlisted network of type |type|. On Chrome OS 300 // |type| corresponds to a Shill network type. 301 virtual void ShowOtherNetworkDialog(const std::string& type) = 0; 302 303 // Returns whether bluetooth capability is available. 304 virtual bool GetBluetoothAvailable() = 0; 305 306 // Returns whether bluetooth is enabled. 307 virtual bool GetBluetoothEnabled() = 0; 308 309 // Returns whether the delegate has initiated a bluetooth discovery session. 310 virtual bool GetBluetoothDiscovering() = 0; 311 312 // Shows UI for changing proxy settings. 313 virtual void ChangeProxySettings() = 0; 314 315 // Returns VolumeControlDelegate. 316 virtual VolumeControlDelegate* GetVolumeControlDelegate() const = 0; 317 318 // Sets VolumeControlDelegate. 319 virtual void SetVolumeControlDelegate( 320 scoped_ptr<VolumeControlDelegate> delegate) = 0; 321 322 // Retrieves the session start time. Returns |false| if the time is not set. 323 virtual bool GetSessionStartTime(base::TimeTicks* session_start_time) = 0; 324 325 // Retrieves the session length limit. Returns |false| if no limit is set. 326 virtual bool GetSessionLengthLimit(base::TimeDelta* session_length_limit) = 0; 327 328 // Get the system tray menu size in pixels (dependent on the language). 329 virtual int GetSystemTrayMenuWidth() = 0; 330 331 // The active user has been changed. This will be called when the UI is ready 332 // to be switched to the new user. 333 // Note: This will happen after SessionStateObserver::ActiveUserChanged fires. 334 virtual void ActiveUserWasChanged() = 0; 335 336 // Returns true when |network| is behind captive portal. 337 virtual bool IsNetworkBehindCaptivePortal( 338 const std::string& service_path) const = 0; 339 340 // Returns true when the Search key is configured to be treated as Caps Lock. 341 virtual bool IsSearchKeyMappedToCapsLock() = 0; 342 343 // Returns accounts delegate for given user. 344 virtual tray::UserAccountsDelegate* GetUserAccountsDelegate( 345 const std::string& user_id) = 0; 346 }; 347 348 } // namespace ash 349 350 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_DELEGATE_H_ 351