system_tray_delegate.h revision a3f7b4e666c476898878fa745f637129375cd889
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 the email of user that manages current locally managed user. 143 virtual const base::string16 GetLocallyManagedUserManagerName() const = 0; 144 145 // Returns notification for locally managed users. 146 virtual const base::string16 GetLocallyManagedUserMessage() const = 0; 147 148 // Returns whether a system upgrade is available. 149 virtual bool SystemShouldUpgrade() const = 0; 150 151 // Returns the desired hour clock type. 152 virtual base::HourClockType GetHourClockType() const = 0; 153 154 // Shows settings. 155 virtual void ShowSettings() = 0; 156 157 // Shows the settings related to date, timezone etc. 158 virtual void ShowDateSettings() = 0; 159 160 // Shows the settings related to network. If |service_path| is not empty, 161 // show the settings for that network. 162 virtual void ShowNetworkSettings(const std::string& service_path) = 0; 163 164 // Shows the settings related to bluetooth. 165 virtual void ShowBluetoothSettings() = 0; 166 167 // Shows settings related to multiple displays. 168 virtual void ShowDisplaySettings() = 0; 169 170 // Returns true if the notification for the display configuration change 171 // should appear. 172 virtual bool ShouldShowDisplayNotification() = 0; 173 174 // Shows settings related to Google Drive. 175 virtual void ShowDriveSettings() = 0; 176 177 // Shows settings related to input methods. 178 virtual void ShowIMESettings() = 0; 179 180 // Shows help. 181 virtual void ShowHelp() = 0; 182 183 // Show accessilibity help. 184 virtual void ShowAccessibilityHelp() = 0; 185 186 // Show the settings related to accessilibity. 187 virtual void ShowAccessibilitySettings() = 0; 188 189 // Shows more information about public account mode. 190 virtual void ShowPublicAccountInfo() = 0; 191 192 // Shows information about enterprise enrolled devices. 193 virtual void ShowEnterpriseInfo() = 0; 194 195 // Shows information about locally managed users. 196 virtual void ShowLocallyManagedUserInfo() = 0; 197 198 // Shows login UI to add other users to this session. 199 virtual void ShowUserLogin() = 0; 200 201 // Attempts to shut down the system. 202 virtual void ShutDown() = 0; 203 204 // Attempts to sign out the user. 205 virtual void SignOut() = 0; 206 207 // Attempts to lock the screen. 208 virtual void RequestLockScreen() = 0; 209 210 // Attempts to restart the system for update. 211 virtual void RequestRestartForUpdate() = 0; 212 213 // Returns a list of available bluetooth devices. 214 virtual void GetAvailableBluetoothDevices(BluetoothDeviceList* devices) = 0; 215 216 // Requests bluetooth start discovering devices. 217 virtual void BluetoothStartDiscovering() = 0; 218 219 // Requests bluetooth stop discovering devices. 220 virtual void BluetoothStopDiscovering() = 0; 221 222 // Connect to a specific bluetooth device. 223 virtual void ConnectToBluetoothDevice(const std::string& address) = 0; 224 225 // Returns true if bluetooth adapter is discovering bluetooth devices. 226 virtual bool IsBluetoothDiscovering() = 0; 227 228 // Returns the currently selected IME. 229 virtual void GetCurrentIME(IMEInfo* info) = 0; 230 231 // Returns a list of availble IMEs. 232 virtual void GetAvailableIMEList(IMEInfoList* list) = 0; 233 234 // Returns a list of properties for the currently selected IME. 235 virtual void GetCurrentIMEProperties(IMEPropertyInfoList* list) = 0; 236 237 // Switches to the selected input method. 238 virtual void SwitchIME(const std::string& ime_id) = 0; 239 240 // Activates an IME property. 241 virtual void ActivateIMEProperty(const std::string& key) = 0; 242 243 // Cancels ongoing drive operation. 244 virtual void CancelDriveOperation(int32 operation_id) = 0; 245 246 // Returns information about the ongoing drive operations. 247 virtual void GetDriveOperationStatusList( 248 DriveOperationStatusList* list) = 0; 249 250 // Shows UI to configure or activate the network specified by |network_id|. 251 virtual void ConfigureNetwork(const std::string& network_id) = 0; 252 253 // Sends a connect request for the network specified by |network_id|. 254 virtual void ConnectToNetwork(const std::string& network_id) = 0; 255 256 // Shows UI to manage bluetooth devices. 257 virtual void ManageBluetoothDevices() = 0; 258 259 // Toggles bluetooth. 260 virtual void ToggleBluetooth() = 0; 261 262 // Shows UI to unlock a mobile sim. 263 virtual void ShowMobileSimDialog() = 0; 264 265 // Shows UI to connect to an unlisted wifi network. 266 virtual void ShowOtherWifi() = 0; 267 268 // Shows UI to configure vpn. 269 virtual void ShowOtherVPN() = 0; 270 271 // Shows UI to search for cellular networks. 272 virtual void ShowOtherCellular() = 0; 273 274 // Returns whether bluetooth capability is available. 275 virtual bool GetBluetoothAvailable() = 0; 276 277 // Returns whether bluetooth is enabled. 278 virtual bool GetBluetoothEnabled() = 0; 279 280 // Retrieves information about the carrier and locale specific |setup_url|. 281 // If none of the carrier info/setup URL cannot be retrieved, returns false. 282 // Note: |setup_url| is returned when carrier is not defined (no SIM card). 283 virtual bool GetCellularCarrierInfo(std::string* carrier_id, 284 std::string* topup_url, 285 std::string* setup_url) = 0; 286 287 // Opens the cellular network specific URL. 288 virtual void ShowCellularURL(const std::string& url) = 0; 289 290 // Shows UI for changing proxy settings. 291 virtual void ChangeProxySettings() = 0; 292 293 // Returns VolumeControlDelegate. 294 virtual VolumeControlDelegate* GetVolumeControlDelegate() const = 0; 295 296 // Sets VolumeControlDelegate. 297 virtual void SetVolumeControlDelegate( 298 scoped_ptr<VolumeControlDelegate> delegate) = 0; 299 300 // Retrieves the session start time. Returns |false| if the time is not set. 301 virtual bool GetSessionStartTime(base::TimeTicks* session_start_time) = 0; 302 303 // Retrieves the session length limit. Returns |false| if no limit is set. 304 virtual bool GetSessionLengthLimit(base::TimeDelta* session_length_limit) = 0; 305 306 // Get the system tray menu size in pixels (dependent on the language). 307 virtual int GetSystemTrayMenuWidth() = 0; 308 309 // Returns the duration formatted as a localized string. 310 // TODO(stevenjb): Move TimeFormat from src/chrome to src/ui so that it can be 311 // accessed without going through the delegate. crbug.com/222697 312 virtual base::string16 FormatTimeDuration( 313 const base::TimeDelta& delta) const = 0; 314 315 // Speaks the given text if spoken feedback is enabled. 316 virtual void MaybeSpeak(const std::string& utterance) const = 0; 317 318 // Creates a dummy delegate for testing. 319 static SystemTrayDelegate* CreateDummyDelegate(); 320}; 321 322} // namespace ash 323 324#endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_DELEGATE_H_ 325