system_tray_delegate.h revision b2df76ea8fec9e32f6f3718986dba0d95315b29c
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/power/power_supply_status.h" 13#include "ash/system/user/login_status.h" 14#include "base/files/file_path.h" 15#include "base/i18n/time_formatting.h" 16#include "base/memory/scoped_ptr.h" 17#include "base/string16.h" 18#include "ui/gfx/image/image_skia.h" 19 20namespace base { 21class TimeDelta; 22class TimeTicks; 23} 24 25namespace ash { 26 27struct 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 43struct 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 54typedef std::vector<BluetoothDeviceInfo> BluetoothDeviceList; 55 56// Structure that packs progress information of each operation. 57struct 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 84typedef std::vector<DriveOperationStatus> DriveOperationStatusList; 85 86 87struct ASH_EXPORT IMEPropertyInfo { 88 IMEPropertyInfo(); 89 ~IMEPropertyInfo(); 90 91 bool selected; 92 std::string key; 93 base::string16 name; 94}; 95 96typedef std::vector<IMEPropertyInfo> IMEPropertyInfoList; 97 98struct 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 110typedef std::vector<IMEInfo> IMEInfoList; 111 112class VolumeControlDelegate; 113 114typedef std::vector<std::string> UserEmailList; 115 116class SystemTrayDelegate { 117 public: 118 virtual ~SystemTrayDelegate() {} 119 120 // Called after SystemTray has been instantiated. 121 virtual void Initialize() = 0; 122 123 // Called before SystemTray is destroyed. 124 virtual void Shutdown() = 0; 125 126 // Returns true if system tray should be visible on startup. 127 virtual bool GetTrayVisibilityOnStartup() = 0; 128 129 // Gets information about the active user. 130 virtual const base::string16 GetUserDisplayName() const = 0; 131 virtual const std::string GetUserEmail() const = 0; 132 virtual const gfx::ImageSkia& GetUserImage() const = 0; 133 virtual user::LoginStatus GetUserLoginStatus() const = 0; 134 virtual bool IsOobeCompleted() const = 0; 135 136 // Returns a list of all logged in users. 137 virtual void GetLoggedInUsers(UserEmailList* users) = 0; 138 139 // Switches to another active user (if that user has already signed in). 140 virtual void SwitchActiveUser(const std::string& email) = 0; 141 142 // Shows UI for changing user's profile picture. 143 virtual void ChangeProfilePicture() = 0; 144 145 // Returns the domain that manages the device, if it is enterprise-enrolled. 146 virtual const std::string GetEnterpriseDomain() const = 0; 147 148 // Returns notification for enterprise enrolled devices. 149 virtual const base::string16 GetEnterpriseMessage() const = 0; 150 151 // Returns the email of user that manages current locally managed user. 152 virtual const std::string GetLocallyManagedUserManager() const = 0; 153 154 // Returns notification for locally managed users. 155 virtual const base::string16 GetLocallyManagedUserMessage() const = 0; 156 157 // Returns whether a system upgrade is available. 158 virtual bool SystemShouldUpgrade() const = 0; 159 160 // Returns the desired hour clock type. 161 virtual base::HourClockType GetHourClockType() const = 0; 162 163 // Gets the current power supply status. 164 virtual PowerSupplyStatus GetPowerSupplyStatus() const = 0; 165 166 // Requests a status update. 167 virtual void RequestStatusUpdate() const = 0; 168 169 // Shows settings. 170 virtual void ShowSettings() = 0; 171 172 // Shows the settings related to date, timezone etc. 173 virtual void ShowDateSettings() = 0; 174 175 // Shows the settings related to network. 176 virtual void ShowNetworkSettings() = 0; 177 178 // Shows the settings related to bluetooth. 179 virtual void ShowBluetoothSettings() = 0; 180 181 // Shows settings related to multiple displays. 182 virtual void ShowDisplaySettings() = 0; 183 184 // Shows settings related to Google Drive. 185 virtual void ShowDriveSettings() = 0; 186 187 // Shows settings related to input methods. 188 virtual void ShowIMESettings() = 0; 189 190 // Shows help. 191 virtual void ShowHelp() = 0; 192 193 // Show accessilibity help. 194 virtual void ShowAccessibilityHelp() = 0; 195 196 // Show the settings related to accessilibity. 197 virtual void ShowAccessibilitySettings() = 0; 198 199 // Shows more information about public account mode. 200 virtual void ShowPublicAccountInfo() = 0; 201 202 // Shows information about enterprise enrolled devices. 203 virtual void ShowEnterpriseInfo() = 0; 204 205 // Shows information about locally managed users. 206 virtual void ShowLocallyManagedUserInfo() = 0; 207 208 // Shows login UI to add other users to this session. 209 virtual void ShowUserLogin() = 0; 210 211 // Attempts to shut down the system. 212 virtual void ShutDown() = 0; 213 214 // Attempts to sign out the user. 215 virtual void SignOut() = 0; 216 217 // Attempts to lock the screen. 218 virtual void RequestLockScreen() = 0; 219 220 // Attempts to restart the system. 221 virtual void RequestRestart() = 0; 222 223 // Returns a list of available bluetooth devices. 224 virtual void GetAvailableBluetoothDevices(BluetoothDeviceList* devices) = 0; 225 226 // Requests bluetooth start discovering devices. 227 virtual void BluetoothStartDiscovering() = 0; 228 229 // Requests bluetooth stop discovering devices. 230 virtual void BluetoothStopDiscovering() = 0; 231 232 // Connect to a specific bluetooth device. 233 virtual void ConnectToBluetoothDevice(const std::string& address) = 0; 234 235 // Returns true if bluetooth adapter is discovering bluetooth devices. 236 virtual bool IsBluetoothDiscovering() = 0; 237 238 // Returns the currently selected IME. 239 virtual void GetCurrentIME(IMEInfo* info) = 0; 240 241 // Returns a list of availble IMEs. 242 virtual void GetAvailableIMEList(IMEInfoList* list) = 0; 243 244 // Returns a list of properties for the currently selected IME. 245 virtual void GetCurrentIMEProperties(IMEPropertyInfoList* list) = 0; 246 247 // Switches to the selected input method. 248 virtual void SwitchIME(const std::string& ime_id) = 0; 249 250 // Activates an IME property. 251 virtual void ActivateIMEProperty(const std::string& key) = 0; 252 253 // Cancels ongoing drive operation. 254 virtual void CancelDriveOperation(int32 operation_id) = 0; 255 256 // Returns information about the ongoing drive operations. 257 virtual void GetDriveOperationStatusList( 258 DriveOperationStatusList* list) = 0; 259 260 // Returns information about the most relevant network. Relevance is 261 // determined by the implementor (e.g. a connecting network may be more 262 // relevant over a connected network etc.) 263 virtual void GetMostRelevantNetworkIcon(NetworkIconInfo* info, 264 bool large) = 0; 265 266 virtual void GetVirtualNetworkIcon(ash::NetworkIconInfo* info) = 0; 267 268 // Returns information about the available networks. 269 virtual void GetAvailableNetworks(std::vector<NetworkIconInfo>* list) = 0; 270 271 // Returns the information about all virtual networks. 272 virtual void GetVirtualNetworks(std::vector<NetworkIconInfo>* list) = 0; 273 274 // Connects to the network specified by the unique id. 275 virtual void ConnectToNetwork(const std::string& network_id) = 0; 276 277 // Gets the network IP address, and the mac addresses for the ethernet and 278 // wifi devices. If any of this is unavailable, empty strings are returned. 279 virtual void GetNetworkAddresses(std::string* ip_address, 280 std::string* ethernet_mac_address, 281 std::string* wifi_mac_address) = 0; 282 283 // Requests network scan when list of networks is opened. 284 virtual void RequestNetworkScan() = 0; 285 286 // Shous UI to add a new bluetooth device. 287 virtual void AddBluetoothDevice() = 0; 288 289 // Toggles airplane mode. 290 virtual void ToggleAirplaneMode() = 0; 291 292 // Toggles wifi network. 293 virtual void ToggleWifi() = 0; 294 295 // Toggles mobile network. 296 virtual void ToggleMobile() = 0; 297 298 // Toggles bluetooth. 299 virtual void ToggleBluetooth() = 0; 300 301 // Shows UI to connect to an unlisted wifi network. 302 virtual void ShowOtherWifi() = 0; 303 304 // Shows UI to configure vpn. 305 virtual void ShowOtherVPN() = 0; 306 307 // Shows UI to search for cellular networks. 308 virtual void ShowOtherCellular() = 0; 309 310 // Returns whether the system is connected to any network. 311 virtual bool IsNetworkConnected() = 0; 312 313 // Returns whether wifi is available. 314 virtual bool GetWifiAvailable() = 0; 315 316 // Returns whether mobile networking (cellular or wimax) is available. 317 virtual bool GetMobileAvailable() = 0; 318 319 // Returns whether bluetooth capability is available. 320 virtual bool GetBluetoothAvailable() = 0; 321 322 // Returns whether wifi is enabled. 323 virtual bool GetWifiEnabled() = 0; 324 325 // Returns whether mobile (cellular or wimax) networking is enabled. 326 virtual bool GetMobileEnabled() = 0; 327 328 // Returns whether bluetooth is enabled. 329 virtual bool GetBluetoothEnabled() = 0; 330 331 // Returns whether mobile scanning is supported. 332 virtual bool GetMobileScanSupported() = 0; 333 334 // Retrieves information about the carrier and locale specific |setup_url|. 335 // If none of the carrier info/setup URL cannot be retrieved, returns false. 336 // Note: |setup_url| is returned when carrier is not defined (no SIM card). 337 virtual bool GetCellularCarrierInfo(std::string* carrier_id, 338 std::string* topup_url, 339 std::string* setup_url) = 0; 340 341 // Returns whether the network manager is scanning for wifi networks. 342 virtual bool GetWifiScanning() = 0; 343 344 // Returns whether the network manager is initializing the cellular modem. 345 virtual bool GetCellularInitializing() = 0; 346 347 // Opens the cellular network specific URL. 348 virtual void ShowCellularURL(const std::string& url) = 0; 349 350 // Shows UI for changing proxy settings. 351 virtual void ChangeProxySettings() = 0; 352 353 // Returns VolumeControlDelegate. 354 virtual VolumeControlDelegate* GetVolumeControlDelegate() const = 0; 355 356 // Sets VolumeControlDelegate. 357 virtual void SetVolumeControlDelegate( 358 scoped_ptr<VolumeControlDelegate> delegate) = 0; 359 360 // Retrieves the session start time. Returns |false| if the time is not set. 361 virtual bool GetSessionStartTime(base::TimeTicks* session_start_time) = 0; 362 363 // Retrieves the session length limit. Returns |false| if no limit is set. 364 virtual bool GetSessionLengthLimit(base::TimeDelta* session_length_limit) = 0; 365 366 // Get the system tray menu size in pixels (dependent on the language). 367 virtual int GetSystemTrayMenuWidth() = 0; 368 369 // Returns the duration formatted as a localized string. 370 // TODO(stevenjb): Move TimeFormat from src/chrome to src/ui so that it can be 371 // accessed without going through the delegate. crbug.com/222697 372 virtual base::string16 FormatTimeDuration( 373 const base::TimeDelta& delta) const = 0; 374 375 // Speaks the given text if spoken feedback is enabled. 376 virtual void MaybeSpeak(const std::string& utterance) const = 0; 377 378 // Creates a dummy delegate for testing. 379 static SystemTrayDelegate* CreateDummyDelegate(); 380}; 381 382} // namespace ash 383 384#endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_DELEGATE_H_ 385