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