system_tray_delegate.h revision a02191e04bc25c4935f804f2c080ae28663d096d
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 114namespace tray { 115class UserAccountsDelegate; 116} // namespace tray 117 118class 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 virtual bool IsOobeCompleted() const = 0; 134 135 // Shows UI for changing user's profile picture. 136 virtual void ChangeProfilePicture() = 0; 137 138 // Returns the domain that manages the device, if it is enterprise-enrolled. 139 virtual const std::string GetEnterpriseDomain() const = 0; 140 141 // Returns notification for enterprise enrolled devices. 142 virtual const base::string16 GetEnterpriseMessage() const = 0; 143 144 // Returns the display email of user that manages current 145 // locally managed user. 146 virtual const std::string GetLocallyManagedUserManager() const = 0; 147 148 // Returns the name of user that manages current locally managed user. 149 virtual const base::string16 GetLocallyManagedUserManagerName() const = 0; 150 151 // Returns notification for locally managed users. 152 virtual const base::string16 GetLocallyManagedUserMessage() const = 0; 153 154 // Returns whether a system upgrade is available. 155 virtual bool SystemShouldUpgrade() const = 0; 156 157 // Returns the desired hour clock type. 158 virtual base::HourClockType GetHourClockType() const = 0; 159 160 // Shows settings. 161 virtual void ShowSettings() = 0; 162 163 // Returns true if settings menu item should appear. 164 virtual bool ShouldShowSettings() = 0; 165 166 // Shows the settings related to date, timezone etc. 167 virtual void ShowDateSettings() = 0; 168 169 // Shows the settings related to network. If |service_path| is not empty, 170 // show the settings for that network. 171 virtual void ShowNetworkSettings(const std::string& service_path) = 0; 172 173 // Shows the settings related to bluetooth. 174 virtual void ShowBluetoothSettings() = 0; 175 176 // Shows settings related to multiple displays. 177 virtual void ShowDisplaySettings() = 0; 178 179 // Shows the page that lets you disable performance tracing. 180 virtual void ShowChromeSlow() = 0; 181 182 // Returns true if the notification for the display configuration change 183 // should appear. 184 virtual bool ShouldShowDisplayNotification() = 0; 185 186 // Shows settings related to Google Drive. 187 virtual void ShowDriveSettings() = 0; 188 189 // Shows settings related to input methods. 190 virtual void ShowIMESettings() = 0; 191 192 // Shows help. 193 virtual void ShowHelp() = 0; 194 195 // Show accessilibity help. 196 virtual void ShowAccessibilityHelp() = 0; 197 198 // Show the settings related to accessilibity. 199 virtual void ShowAccessibilitySettings() = 0; 200 201 // Shows more information about public account mode. 202 virtual void ShowPublicAccountInfo() = 0; 203 204 // Shows information about enterprise enrolled devices. 205 virtual void ShowEnterpriseInfo() = 0; 206 207 // Shows information about locally managed users. 208 virtual void ShowLocallyManagedUserInfo() = 0; 209 210 // Shows login UI to add other users to this session. 211 virtual void ShowUserLogin() = 0; 212 213 // Shows the spring charger replacement dialog if necessary. 214 // Returns true if the dialog is shown by the call. 215 virtual bool ShowSpringChargerReplacementDialog() = 0; 216 217 // True if the spring charger replacement dialog is visible. 218 virtual bool IsSpringChargerReplacementDialogVisible() = 0; 219 220 // True if user has confirmed using safe spring charger. 221 virtual bool HasUserConfirmedSafeSpringCharger() = 0; 222 223 // Attempts to shut down the system. 224 virtual void ShutDown() = 0; 225 226 // Attempts to sign out the user. 227 virtual void SignOut() = 0; 228 229 // Attempts to lock the screen. 230 virtual void RequestLockScreen() = 0; 231 232 // Attempts to restart the system for update. 233 virtual void RequestRestartForUpdate() = 0; 234 235 // Returns a list of available bluetooth devices. 236 virtual void GetAvailableBluetoothDevices(BluetoothDeviceList* devices) = 0; 237 238 // Requests bluetooth start discovering devices. 239 virtual void BluetoothStartDiscovering() = 0; 240 241 // Requests bluetooth stop discovering devices. 242 virtual void BluetoothStopDiscovering() = 0; 243 244 // Connect to a specific bluetooth device. 245 virtual void ConnectToBluetoothDevice(const std::string& address) = 0; 246 247 // Returns true if bluetooth adapter is discovering bluetooth devices. 248 virtual bool IsBluetoothDiscovering() = 0; 249 250 // Returns the currently selected IME. 251 virtual void GetCurrentIME(IMEInfo* info) = 0; 252 253 // Returns a list of availble IMEs. 254 virtual void GetAvailableIMEList(IMEInfoList* list) = 0; 255 256 // Returns a list of properties for the currently selected IME. 257 virtual void GetCurrentIMEProperties(IMEPropertyInfoList* list) = 0; 258 259 // Switches to the selected input method. 260 virtual void SwitchIME(const std::string& ime_id) = 0; 261 262 // Activates an IME property. 263 virtual void ActivateIMEProperty(const std::string& key) = 0; 264 265 // Cancels ongoing drive operation. 266 virtual void CancelDriveOperation(int32 operation_id) = 0; 267 268 // Returns information about the ongoing drive operations. 269 virtual void GetDriveOperationStatusList( 270 DriveOperationStatusList* list) = 0; 271 272 // Shows UI to configure or activate the network specified by |network_id|, 273 // which may include showing Payment or Portal UI when appropriate. 274 // |parent_window| is used to parent any configuration UI. If NULL a default 275 // window will be used. 276 virtual void ShowNetworkConfigure(const std::string& network_id, 277 gfx::NativeWindow parent_window) = 0; 278 279 // Shows UI to enroll the network specified by |network_id| if appropriate 280 // and returns true, otherwise returns false. |parent_window| is used 281 // to parent any configuration UI. If NULL a default window will be used. 282 virtual bool EnrollNetwork(const std::string& network_id, 283 gfx::NativeWindow parent_window) = 0; 284 285 // Shows UI to manage bluetooth devices. 286 virtual void ManageBluetoothDevices() = 0; 287 288 // Toggles bluetooth. 289 virtual void ToggleBluetooth() = 0; 290 291 // Shows UI to unlock a mobile sim. 292 virtual void ShowMobileSimDialog() = 0; 293 294 // Shows UI to setup a mobile network. 295 virtual void ShowMobileSetupDialog(const std::string& service_path) = 0; 296 297 // Shows UI to connect to an unlisted network of type |type|. On Chrome OS 298 // |type| corresponds to a Shill network type. 299 virtual void ShowOtherNetworkDialog(const std::string& type) = 0; 300 301 // Returns whether bluetooth capability is available. 302 virtual bool GetBluetoothAvailable() = 0; 303 304 // Returns whether bluetooth is enabled. 305 virtual bool GetBluetoothEnabled() = 0; 306 307 // Returns whether the delegate has initiated a bluetooth discovery session. 308 virtual bool GetBluetoothDiscovering() = 0; 309 310 // Shows UI for changing proxy settings. 311 virtual void ChangeProxySettings() = 0; 312 313 // Returns VolumeControlDelegate. 314 virtual VolumeControlDelegate* GetVolumeControlDelegate() const = 0; 315 316 // Sets VolumeControlDelegate. 317 virtual void SetVolumeControlDelegate( 318 scoped_ptr<VolumeControlDelegate> delegate) = 0; 319 320 // Retrieves the session start time. Returns |false| if the time is not set. 321 virtual bool GetSessionStartTime(base::TimeTicks* session_start_time) = 0; 322 323 // Retrieves the session length limit. Returns |false| if no limit is set. 324 virtual bool GetSessionLengthLimit(base::TimeDelta* session_length_limit) = 0; 325 326 // Get the system tray menu size in pixels (dependent on the language). 327 virtual int GetSystemTrayMenuWidth() = 0; 328 329 // The active user has been changed. This will be called when the UI is ready 330 // to be switched to the new user. 331 // Note: This will happen after SessionStateObserver::ActiveUserChanged fires. 332 virtual void ActiveUserWasChanged() = 0; 333 334 // Returns true when |network| is behind captive portal. 335 virtual bool IsNetworkBehindCaptivePortal( 336 const std::string& service_path) const = 0; 337 338 // Returns true when the Search key is configured to be treated as Caps Lock. 339 virtual bool IsSearchKeyMappedToCapsLock() = 0; 340 341 // Returns accounts delegate for given user. 342 virtual tray::UserAccountsDelegate* GetUserAccountsDelegate( 343 const std::string& user_id) = 0; 344}; 345 346} // namespace ash 347 348#endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_DELEGATE_H_ 349