system_tray_delegate.h revision 868fa2fe829687343ffae624259930155e16dbd8
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 19namespace base { 20class TimeDelta; 21class TimeTicks; 22} 23 24namespace ash { 25 26struct ASH_EXPORT NetworkIconInfo { 27 NetworkIconInfo(); 28 ~NetworkIconInfo(); 29 30 bool highlight() const { return connected || connecting; } 31 32 bool connecting; 33 bool connected; 34 bool tray_icon_visible; 35 gfx::ImageSkia image; 36 base::string16 name; 37 base::string16 description; 38 std::string service_path; 39 bool is_cellular; 40}; 41 42struct ASH_EXPORT BluetoothDeviceInfo { 43 BluetoothDeviceInfo(); 44 ~BluetoothDeviceInfo(); 45 46 std::string address; 47 base::string16 display_name; 48 bool connected; 49 bool connecting; 50 bool paired; 51}; 52 53typedef std::vector<BluetoothDeviceInfo> BluetoothDeviceList; 54 55// Structure that packs progress information of each operation. 56struct ASH_EXPORT DriveOperationStatus { 57 enum OperationType { 58 OPERATION_UPLOAD, 59 OPERATION_DOWNLOAD 60 }; 61 62 enum OperationState { 63 OPERATION_NOT_STARTED, 64 OPERATION_IN_PROGRESS, 65 OPERATION_COMPLETED, 66 OPERATION_FAILED, 67 }; 68 69 DriveOperationStatus(); 70 ~DriveOperationStatus(); 71 72 // Unique ID for the operation. 73 int32 id; 74 75 // File path. 76 base::FilePath file_path; 77 // Current operation completion progress [0.0 - 1.0]. 78 double progress; 79 OperationType type; 80 OperationState state; 81}; 82 83typedef std::vector<DriveOperationStatus> DriveOperationStatusList; 84 85 86struct ASH_EXPORT IMEPropertyInfo { 87 IMEPropertyInfo(); 88 ~IMEPropertyInfo(); 89 90 bool selected; 91 std::string key; 92 base::string16 name; 93}; 94 95typedef std::vector<IMEPropertyInfo> IMEPropertyInfoList; 96 97struct ASH_EXPORT IMEInfo { 98 IMEInfo(); 99 ~IMEInfo(); 100 101 bool selected; 102 bool third_party; 103 std::string id; 104 base::string16 name; 105 base::string16 medium_name; 106 base::string16 short_name; 107}; 108 109typedef std::vector<IMEInfo> IMEInfoList; 110 111class VolumeControlDelegate; 112 113class SystemTrayDelegate { 114 public: 115 virtual ~SystemTrayDelegate() {} 116 117 // Called after SystemTray has been instantiated. 118 virtual void Initialize() = 0; 119 120 // Called before SystemTray is destroyed. 121 virtual void Shutdown() = 0; 122 123 // Returns true if system tray should be visible on startup. 124 virtual bool GetTrayVisibilityOnStartup() = 0; 125 126 // Gets information about the active user. 127 virtual user::LoginStatus GetUserLoginStatus() const = 0; 128 virtual bool IsOobeCompleted() const = 0; 129 130 // Shows UI for changing user's profile picture. 131 virtual void ChangeProfilePicture() = 0; 132 133 // Returns the domain that manages the device, if it is enterprise-enrolled. 134 virtual const std::string GetEnterpriseDomain() const = 0; 135 136 // Returns notification for enterprise enrolled devices. 137 virtual const base::string16 GetEnterpriseMessage() const = 0; 138 139 // Returns the email of user that manages current locally managed user. 140 virtual const std::string GetLocallyManagedUserManager() const = 0; 141 142 // Returns notification for locally managed users. 143 virtual const base::string16 GetLocallyManagedUserMessage() const = 0; 144 145 // Returns whether a system upgrade is available. 146 virtual bool SystemShouldUpgrade() const = 0; 147 148 // Returns the desired hour clock type. 149 virtual base::HourClockType GetHourClockType() const = 0; 150 151 // Shows settings. 152 virtual void ShowSettings() = 0; 153 154 // Shows the settings related to date, timezone etc. 155 virtual void ShowDateSettings() = 0; 156 157 // Shows the settings related to network. If |service_path| is not empty, 158 // show the settings for that network. 159 virtual void ShowNetworkSettings(const std::string& service_path) = 0; 160 161 // Shows the settings related to bluetooth. 162 virtual void ShowBluetoothSettings() = 0; 163 164 // Shows settings related to multiple displays. 165 virtual void ShowDisplaySettings() = 0; 166 167 // Shows settings related to Google Drive. 168 virtual void ShowDriveSettings() = 0; 169 170 // Shows settings related to input methods. 171 virtual void ShowIMESettings() = 0; 172 173 // Shows help. 174 virtual void ShowHelp() = 0; 175 176 // Show accessilibity help. 177 virtual void ShowAccessibilityHelp() = 0; 178 179 // Show the settings related to accessilibity. 180 virtual void ShowAccessibilitySettings() = 0; 181 182 // Shows more information about public account mode. 183 virtual void ShowPublicAccountInfo() = 0; 184 185 // Shows information about enterprise enrolled devices. 186 virtual void ShowEnterpriseInfo() = 0; 187 188 // Shows information about locally managed users. 189 virtual void ShowLocallyManagedUserInfo() = 0; 190 191 // Shows login UI to add other users to this session. 192 virtual void ShowUserLogin() = 0; 193 194 // Attempts to shut down the system. 195 virtual void ShutDown() = 0; 196 197 // Attempts to sign out the user. 198 virtual void SignOut() = 0; 199 200 // Attempts to lock the screen. 201 virtual void RequestLockScreen() = 0; 202 203 // Attempts to restart the system for update. 204 virtual void RequestRestartForUpdate() = 0; 205 206 // Returns a list of available bluetooth devices. 207 virtual void GetAvailableBluetoothDevices(BluetoothDeviceList* devices) = 0; 208 209 // Requests bluetooth start discovering devices. 210 virtual void BluetoothStartDiscovering() = 0; 211 212 // Requests bluetooth stop discovering devices. 213 virtual void BluetoothStopDiscovering() = 0; 214 215 // Connect to a specific bluetooth device. 216 virtual void ConnectToBluetoothDevice(const std::string& address) = 0; 217 218 // Returns true if bluetooth adapter is discovering bluetooth devices. 219 virtual bool IsBluetoothDiscovering() = 0; 220 221 // Returns the currently selected IME. 222 virtual void GetCurrentIME(IMEInfo* info) = 0; 223 224 // Returns a list of availble IMEs. 225 virtual void GetAvailableIMEList(IMEInfoList* list) = 0; 226 227 // Returns a list of properties for the currently selected IME. 228 virtual void GetCurrentIMEProperties(IMEPropertyInfoList* list) = 0; 229 230 // Switches to the selected input method. 231 virtual void SwitchIME(const std::string& ime_id) = 0; 232 233 // Activates an IME property. 234 virtual void ActivateIMEProperty(const std::string& key) = 0; 235 236 // Cancels ongoing drive operation. 237 virtual void CancelDriveOperation(int32 operation_id) = 0; 238 239 // Returns information about the ongoing drive operations. 240 virtual void GetDriveOperationStatusList( 241 DriveOperationStatusList* list) = 0; 242 243 // Shows UI to configure or activate the network specified by |network_id|. 244 virtual void ConfigureNetwork(const std::string& network_id) = 0; 245 246 // Sends a connect request for the network specified by |network_id|. 247 virtual void ConnectToNetwork(const std::string& network_id) = 0; 248 249 // Shows UI to add a new bluetooth device. 250 virtual void AddBluetoothDevice() = 0; 251 252 // Toggles bluetooth. 253 virtual void ToggleBluetooth() = 0; 254 255 // Shows UI to unlock a mobile sim. 256 virtual void ShowMobileSimDialog() = 0; 257 258 // Shows UI to connect to an unlisted wifi network. 259 virtual void ShowOtherWifi() = 0; 260 261 // Shows UI to configure vpn. 262 virtual void ShowOtherVPN() = 0; 263 264 // Shows UI to search for cellular networks. 265 virtual void ShowOtherCellular() = 0; 266 267 // Returns whether bluetooth capability is available. 268 virtual bool GetBluetoothAvailable() = 0; 269 270 // Returns whether bluetooth is enabled. 271 virtual bool GetBluetoothEnabled() = 0; 272 273 // Retrieves information about the carrier and locale specific |setup_url|. 274 // If none of the carrier info/setup URL cannot be retrieved, returns false. 275 // Note: |setup_url| is returned when carrier is not defined (no SIM card). 276 virtual bool GetCellularCarrierInfo(std::string* carrier_id, 277 std::string* topup_url, 278 std::string* setup_url) = 0; 279 280 // Opens the cellular network specific URL. 281 virtual void ShowCellularURL(const std::string& url) = 0; 282 283 // Shows UI for changing proxy settings. 284 virtual void ChangeProxySettings() = 0; 285 286 // Returns VolumeControlDelegate. 287 virtual VolumeControlDelegate* GetVolumeControlDelegate() const = 0; 288 289 // Sets VolumeControlDelegate. 290 virtual void SetVolumeControlDelegate( 291 scoped_ptr<VolumeControlDelegate> delegate) = 0; 292 293 // Retrieves the session start time. Returns |false| if the time is not set. 294 virtual bool GetSessionStartTime(base::TimeTicks* session_start_time) = 0; 295 296 // Retrieves the session length limit. Returns |false| if no limit is set. 297 virtual bool GetSessionLengthLimit(base::TimeDelta* session_length_limit) = 0; 298 299 // Get the system tray menu size in pixels (dependent on the language). 300 virtual int GetSystemTrayMenuWidth() = 0; 301 302 // Returns the duration formatted as a localized string. 303 // TODO(stevenjb): Move TimeFormat from src/chrome to src/ui so that it can be 304 // accessed without going through the delegate. crbug.com/222697 305 virtual base::string16 FormatTimeDuration( 306 const base::TimeDelta& delta) const = 0; 307 308 // Speaks the given text if spoken feedback is enabled. 309 virtual void MaybeSpeak(const std::string& utterance) const = 0; 310 311 // Creates a dummy delegate for testing. 312 static SystemTrayDelegate* CreateDummyDelegate(); 313}; 314 315} // namespace ash 316 317#endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_DELEGATE_H_ 318