Home | History | Annotate | Download | only in tray
      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 
     19 namespace base {
     20 class TimeDelta;
     21 class TimeTicks;
     22 }
     23 
     24 namespace ash {
     25 
     26 struct 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 
     42 struct 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 
     53 typedef std::vector<BluetoothDeviceInfo> BluetoothDeviceList;
     54 
     55 struct ASH_EXPORT IMEPropertyInfo {
     56   IMEPropertyInfo();
     57   ~IMEPropertyInfo();
     58 
     59   bool selected;
     60   std::string key;
     61   base::string16 name;
     62 };
     63 
     64 typedef std::vector<IMEPropertyInfo> IMEPropertyInfoList;
     65 
     66 struct ASH_EXPORT IMEInfo {
     67   IMEInfo();
     68   ~IMEInfo();
     69 
     70   bool selected;
     71   bool third_party;
     72   std::string id;
     73   base::string16 name;
     74   base::string16 medium_name;
     75   base::string16 short_name;
     76 };
     77 
     78 typedef std::vector<IMEInfo> IMEInfoList;
     79 
     80 class VolumeControlDelegate;
     81 
     82 namespace tray {
     83 class UserAccountsDelegate;
     84 }  // namespace tray
     85 
     86 class ASH_EXPORT SystemTrayDelegate {
     87  public:
     88   virtual ~SystemTrayDelegate() {}
     89 
     90   // Called after SystemTray has been instantiated.
     91   virtual void Initialize() = 0;
     92 
     93   // Called before SystemTray is destroyed.
     94   virtual void Shutdown() = 0;
     95 
     96   // Returns true if system tray should be visible on startup.
     97   virtual bool GetTrayVisibilityOnStartup() = 0;
     98 
     99   // Gets information about the active user.
    100   virtual user::LoginStatus GetUserLoginStatus() const = 0;
    101 
    102   // Shows UI for changing user's profile picture.
    103   virtual void ChangeProfilePicture() = 0;
    104 
    105   // Returns the domain that manages the device, if it is enterprise-enrolled.
    106   virtual const std::string GetEnterpriseDomain() const = 0;
    107 
    108   // Returns notification for enterprise enrolled devices.
    109   virtual const base::string16 GetEnterpriseMessage() const = 0;
    110 
    111   // Returns the display email of the user that manages the current supervised
    112   // user.
    113   virtual const std::string GetSupervisedUserManager() const = 0;
    114 
    115   // Returns the name of the user that manages the current supervised user.
    116   virtual const base::string16 GetSupervisedUserManagerName() const = 0;
    117 
    118   // Returns the notification for supervised users.
    119   virtual const base::string16 GetSupervisedUserMessage() const = 0;
    120 
    121   // Returns true if the current user is supervised.
    122   virtual bool IsUserSupervised() const = 0;
    123 
    124   // Returns whether a system upgrade is available.
    125   virtual bool SystemShouldUpgrade() const = 0;
    126 
    127   // Returns the desired hour clock type.
    128   virtual base::HourClockType GetHourClockType() const = 0;
    129 
    130   // Shows settings.
    131   virtual void ShowSettings() = 0;
    132 
    133   // Returns true if settings menu item should appear.
    134   virtual bool ShouldShowSettings() = 0;
    135 
    136   // Shows the settings related to date, timezone etc.
    137   virtual void ShowDateSettings() = 0;
    138 
    139   // Shows the dialog to set system time, date, and timezone.
    140   virtual void ShowSetTimeDialog() = 0;
    141 
    142   // Shows the settings related to network. If |service_path| is not empty,
    143   // show the settings for that network.
    144   virtual void ShowNetworkSettings(const std::string& service_path) = 0;
    145 
    146   // Shows the settings related to bluetooth.
    147   virtual void ShowBluetoothSettings() = 0;
    148 
    149   // Shows settings related to multiple displays.
    150   virtual void ShowDisplaySettings() = 0;
    151 
    152   // Shows the page that lets you disable performance tracing.
    153   virtual void ShowChromeSlow() = 0;
    154 
    155   // Returns true if the notification for the display configuration change
    156   // should appear.
    157   virtual bool ShouldShowDisplayNotification() = 0;
    158 
    159   // Shows settings related to input methods.
    160   virtual void ShowIMESettings() = 0;
    161 
    162   // Shows help.
    163   virtual void ShowHelp() = 0;
    164 
    165   // Show accessilibity help.
    166   virtual void ShowAccessibilityHelp() = 0;
    167 
    168   // Show the settings related to accessilibity.
    169   virtual void ShowAccessibilitySettings() = 0;
    170 
    171   // Shows more information about public account mode.
    172   virtual void ShowPublicAccountInfo() = 0;
    173 
    174   // Shows information about enterprise enrolled devices.
    175   virtual void ShowEnterpriseInfo() = 0;
    176 
    177   // Shows information about supervised users.
    178   virtual void ShowSupervisedUserInfo() = 0;
    179 
    180   // Shows login UI to add other users to this session.
    181   virtual void ShowUserLogin() = 0;
    182 
    183   // Shows the spring charger replacement dialog if necessary.
    184   // Returns true if the dialog is shown by the call.
    185   virtual bool ShowSpringChargerReplacementDialog() = 0;
    186 
    187   // True if the spring charger replacement dialog is visible.
    188   virtual bool IsSpringChargerReplacementDialogVisible() = 0;
    189 
    190   // True if user has confirmed using safe spring charger.
    191   virtual bool HasUserConfirmedSafeSpringCharger() = 0;
    192 
    193   // Attempts to shut down the system.
    194   virtual void ShutDown() = 0;
    195 
    196   // Attempts to sign out the user.
    197   virtual void SignOut() = 0;
    198 
    199   // Attempts to lock the screen.
    200   virtual void RequestLockScreen() = 0;
    201 
    202   // Attempts to restart the system for update.
    203   virtual void RequestRestartForUpdate() = 0;
    204 
    205   // Returns a list of available bluetooth devices.
    206   virtual void GetAvailableBluetoothDevices(BluetoothDeviceList* devices) = 0;
    207 
    208   // Requests bluetooth start discovering devices.
    209   virtual void BluetoothStartDiscovering() = 0;
    210 
    211   // Requests bluetooth stop discovering devices.
    212   virtual void BluetoothStopDiscovering() = 0;
    213 
    214   // Connect to a specific bluetooth device.
    215   virtual void ConnectToBluetoothDevice(const std::string& address) = 0;
    216 
    217   // Returns true if bluetooth adapter is discovering bluetooth devices.
    218   virtual bool IsBluetoothDiscovering() = 0;
    219 
    220   // Returns the currently selected IME.
    221   virtual void GetCurrentIME(IMEInfo* info) = 0;
    222 
    223   // Returns a list of availble IMEs.
    224   virtual void GetAvailableIMEList(IMEInfoList* list) = 0;
    225 
    226   // Returns a list of properties for the currently selected IME.
    227   virtual void GetCurrentIMEProperties(IMEPropertyInfoList* list) = 0;
    228 
    229   // Switches to the selected input method.
    230   virtual void SwitchIME(const std::string& ime_id) = 0;
    231 
    232   // Activates an IME property.
    233   virtual void ActivateIMEProperty(const std::string& key) = 0;
    234 
    235   // Shows UI to configure or activate the network specified by |network_id|,
    236   // which may include showing Payment or Portal UI when appropriate.
    237   virtual void ShowNetworkConfigure(const std::string& network_id) = 0;
    238 
    239   // Shows UI to enroll the network specified by |network_id| if appropriate
    240   // and returns true, otherwise returns false.
    241   virtual bool EnrollNetwork(const std::string& network_id) = 0;
    242 
    243   // Shows UI to manage bluetooth devices.
    244   virtual void ManageBluetoothDevices() = 0;
    245 
    246   // Toggles bluetooth.
    247   virtual void ToggleBluetooth() = 0;
    248 
    249   // Shows UI to unlock a mobile sim.
    250   virtual void ShowMobileSimDialog() = 0;
    251 
    252   // Shows UI to setup a mobile network.
    253   virtual void ShowMobileSetupDialog(const std::string& service_path) = 0;
    254 
    255   // Shows UI to connect to an unlisted network of type |type|. On Chrome OS
    256   // |type| corresponds to a Shill network type.
    257   virtual void ShowOtherNetworkDialog(const std::string& type) = 0;
    258 
    259   // Returns whether bluetooth capability is available.
    260   virtual bool GetBluetoothAvailable() = 0;
    261 
    262   // Returns whether bluetooth is enabled.
    263   virtual bool GetBluetoothEnabled() = 0;
    264 
    265   // Returns whether the delegate has initiated a bluetooth discovery session.
    266   virtual bool GetBluetoothDiscovering() = 0;
    267 
    268   // Shows UI for changing proxy settings.
    269   virtual void ChangeProxySettings() = 0;
    270 
    271   // Returns VolumeControlDelegate.
    272   virtual VolumeControlDelegate* GetVolumeControlDelegate() const = 0;
    273 
    274   // Sets VolumeControlDelegate.
    275   virtual void SetVolumeControlDelegate(
    276       scoped_ptr<VolumeControlDelegate> delegate) = 0;
    277 
    278   // Retrieves the session start time. Returns |false| if the time is not set.
    279   virtual bool GetSessionStartTime(base::TimeTicks* session_start_time) = 0;
    280 
    281   // Retrieves the session length limit. Returns |false| if no limit is set.
    282   virtual bool GetSessionLengthLimit(base::TimeDelta* session_length_limit) = 0;
    283 
    284   // Get the system tray menu size in pixels (dependent on the language).
    285   virtual int GetSystemTrayMenuWidth() = 0;
    286 
    287   // The active user has been changed. This will be called when the UI is ready
    288   // to be switched to the new user.
    289   // Note: This will happen after SessionStateObserver::ActiveUserChanged fires.
    290   virtual void ActiveUserWasChanged() = 0;
    291 
    292   // Returns true when the Search key is configured to be treated as Caps Lock.
    293   virtual bool IsSearchKeyMappedToCapsLock() = 0;
    294 
    295   // Returns accounts delegate for given user.
    296   virtual tray::UserAccountsDelegate* GetUserAccountsDelegate(
    297       const std::string& user_id) = 0;
    298 };
    299 
    300 }  // namespace ash
    301 
    302 #endif  // ASH_SYSTEM_TRAY_SYSTEM_TRAY_DELEGATE_H_
    303