system_tray_delegate.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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  string16 name;
38  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  string16 display_name;
49  bool connected;
50  bool paired;
51  bool visible;
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    OPERATION_OTHER,
62  };
63
64  enum OperationState {
65    OPERATION_NOT_STARTED,
66    OPERATION_STARTED,
67    OPERATION_IN_PROGRESS,
68    OPERATION_COMPLETED,
69    OPERATION_FAILED,
70    OPERATION_SUSPENDED,
71  };
72
73  DriveOperationStatus();
74  ~DriveOperationStatus();
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  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  string16 name;
106  string16 medium_name;
107  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  // Returns true if system tray should be visible on startup.
122  virtual bool GetTrayVisibilityOnStartup() = 0;
123
124  // Gets information about the logged in user.
125  virtual const string16 GetUserDisplayName() const = 0;
126  virtual const std::string GetUserEmail() const = 0;
127  virtual const gfx::ImageSkia& GetUserImage() const = 0;
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 string16 GetEnterpriseMessage() const = 0;
139
140  // Returns whether a system upgrade is available.
141  virtual bool SystemShouldUpgrade() const = 0;
142
143  // Returns the desired hour clock type.
144  virtual base::HourClockType GetHourClockType() const = 0;
145
146  // Gets the current power supply status.
147  virtual PowerSupplyStatus GetPowerSupplyStatus() const = 0;
148
149  // Requests a status update.
150  virtual void RequestStatusUpdate() const = 0;
151
152  // Shows settings.
153  virtual void ShowSettings() = 0;
154
155  // Shows the settings related to date, timezone etc.
156  virtual void ShowDateSettings() = 0;
157
158  // Shows the settings related to network.
159  virtual void ShowNetworkSettings() = 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  // Shows more information about public account mode.
180  virtual void ShowPublicAccountInfo() = 0;
181
182  // Shows information about enterprise enrolled devices.
183  virtual void ShowEnterpriseInfo() = 0;
184
185  // Attempts to shut down the system.
186  virtual void ShutDown() = 0;
187
188  // Attempts to sign out the user.
189  virtual void SignOut() = 0;
190
191  // Attempts to lock the screen.
192  virtual void RequestLockScreen() = 0;
193
194  // Attempts to restart the system.
195  virtual void RequestRestart() = 0;
196
197  // Returns a list of available bluetooth devices.
198  virtual void GetAvailableBluetoothDevices(BluetoothDeviceList* devices) = 0;
199
200  // Requests bluetooth start discovering devices.
201  virtual void BluetoothStartDiscovering() = 0;
202
203  // Requests bluetooth stop discovering devices.
204  virtual void BluetoothStopDiscovering() = 0;
205
206  // Toggles connection to a specific bluetooth device.
207  virtual void ToggleBluetoothConnection(const std::string& address) = 0;
208
209  // Returns true if bluetooth adapter is discovering bluetooth devices.
210  virtual bool IsBluetoothDiscovering() = 0;
211
212  // Returns the currently selected IME.
213  virtual void GetCurrentIME(IMEInfo* info) = 0;
214
215  // Returns a list of availble IMEs.
216  virtual void GetAvailableIMEList(IMEInfoList* list) = 0;
217
218  // Returns a list of properties for the currently selected IME.
219  virtual void GetCurrentIMEProperties(IMEPropertyInfoList* list) = 0;
220
221  // Switches to the selected input method.
222  virtual void SwitchIME(const std::string& ime_id) = 0;
223
224  // Activates an IME property.
225  virtual void ActivateIMEProperty(const std::string& key) = 0;
226
227  // Cancels ongoing drive operation.
228  virtual void CancelDriveOperation(const base::FilePath& file_path) = 0;
229
230  // Returns information about the ongoing drive operations.
231  virtual void GetDriveOperationStatusList(
232      DriveOperationStatusList* list) = 0;
233
234  // Returns information about the most relevant network. Relevance is
235  // determined by the implementor (e.g. a connecting network may be more
236  // relevant over a connected network etc.)
237  virtual void GetMostRelevantNetworkIcon(NetworkIconInfo* info,
238                                          bool large) = 0;
239
240  virtual void GetVirtualNetworkIcon(ash::NetworkIconInfo* info) = 0;
241
242  // Returns information about the available networks.
243  virtual void GetAvailableNetworks(std::vector<NetworkIconInfo>* list) = 0;
244
245  // Returns the information about all virtual networks.
246  virtual void GetVirtualNetworks(std::vector<NetworkIconInfo>* list) = 0;
247
248  // Connects to the network specified by the unique id.
249  virtual void ConnectToNetwork(const std::string& network_id) = 0;
250
251  // Gets the network IP address, and the mac addresses for the ethernet and
252  // wifi devices. If any of this is unavailable, empty strings are returned.
253  virtual void GetNetworkAddresses(std::string* ip_address,
254                                   std::string* ethernet_mac_address,
255                                   std::string* wifi_mac_address) = 0;
256
257  // Requests network scan when list of networks is opened.
258  virtual void RequestNetworkScan() = 0;
259
260  // Shous UI to add a new bluetooth device.
261  virtual void AddBluetoothDevice() = 0;
262
263  // Toggles airplane mode.
264  virtual void ToggleAirplaneMode() = 0;
265
266  // Toggles wifi network.
267  virtual void ToggleWifi() = 0;
268
269  // Toggles mobile network.
270  virtual void ToggleMobile() = 0;
271
272  // Toggles bluetooth.
273  virtual void ToggleBluetooth() = 0;
274
275  // Shows UI to connect to an unlisted wifi network.
276  virtual void ShowOtherWifi() = 0;
277
278  // Shows UI to configure vpn.
279  virtual void ShowOtherVPN() = 0;
280
281  // Shows UI to search for cellular networks.
282  virtual void ShowOtherCellular() = 0;
283
284  // Returns whether the system is connected to any network.
285  virtual bool IsNetworkConnected() = 0;
286
287  // Returns whether wifi is available.
288  virtual bool GetWifiAvailable() = 0;
289
290  // Returns whether mobile networking (cellular or wimax) is available.
291  virtual bool GetMobileAvailable() = 0;
292
293  // Returns whether bluetooth capability is available.
294  virtual bool GetBluetoothAvailable() = 0;
295
296  // Returns whether wifi is enabled.
297  virtual bool GetWifiEnabled() = 0;
298
299  // Returns whether mobile (cellular or wimax) networking is enabled.
300  virtual bool GetMobileEnabled() = 0;
301
302  // Returns whether bluetooth is enabled.
303  virtual bool GetBluetoothEnabled() = 0;
304
305  // Returns whether mobile scanning is supported.
306  virtual bool GetMobileScanSupported() = 0;
307
308  // Retrieves information about the carrier and locale specific |setup_url|.
309  // If none of the carrier info/setup URL cannot be retrieved, returns false.
310  // Note: |setup_url| is returned when carrier is not defined (no SIM card).
311  virtual bool GetCellularCarrierInfo(std::string* carrier_id,
312                                      std::string* topup_url,
313                                      std::string* setup_url) = 0;
314
315  // Returns whether the network manager is scanning for wifi networks.
316  virtual bool GetWifiScanning() = 0;
317
318  // Returns whether the network manager is initializing the cellular modem.
319  virtual bool GetCellularInitializing() = 0;
320
321  // Opens the cellular network specific URL.
322  virtual void ShowCellularURL(const std::string& url) = 0;
323
324  // Shows UI for changing proxy settings.
325  virtual void ChangeProxySettings() = 0;
326
327  // Returns VolumeControlDelegate.
328  virtual VolumeControlDelegate* GetVolumeControlDelegate() const = 0;
329
330  // Sets VolumeControlDelegate.
331  virtual void SetVolumeControlDelegate(
332      scoped_ptr<VolumeControlDelegate> delegate) = 0;
333
334  // Retrieves the session start time. Returns |false| if the time is not set.
335  virtual bool GetSessionStartTime(base::TimeTicks* session_start_time) = 0;
336
337  // Retrieves the session length limit. Returns |false| if no limit is set.
338  virtual bool GetSessionLengthLimit(base::TimeDelta* session_length_limit) = 0;
339
340  // Get the system tray menu size in pixels (dependent on the language).
341  virtual int GetSystemTrayMenuWidth() = 0;
342
343  // Returns the duration formatted as a localized string.
344  // TODO(stevenjb): Move TimeFormat from src/chrome to src/ui so that it can be
345  // accessed without going through the delegate. crbug.com/222697
346  virtual string16 FormatTimeDuration(const base::TimeDelta& delta) const = 0;
347
348  // Speaks the given text if spoken feedback is enabled.
349  virtual void MaybeSpeak(const std::string& utterance) const = 0;
350
351  // Creates a dummy delegate for testing.
352  static SystemTrayDelegate* CreateDummyDelegate();
353};
354
355}  // namespace ash
356
357#endif  // ASH_SYSTEM_TRAY_SYSTEM_TRAY_DELEGATE_H_
358