| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2014 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 #include "chrome/browser/ui/ash/system_tray_delegate_common.h" |
| 6 |
| 7 #include "ash/shell.h" |
| 8 #include "ash/shell_delegate.h" |
| 9 #include "ash/system/tray/system_tray.h" |
| 10 #include "ash/system/tray/system_tray_notifier.h" |
| 11 #include "ash/volume_control_delegate.h" |
| 12 #include "base/time/time.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/lifetime/application_lifetime.h" |
| 15 #include "chrome/browser/profiles/profile_manager.h" |
| 16 #include "chrome/browser/ui/ash/system_tray_delegate_utils.h" |
| 17 #include "chrome/browser/ui/chrome_pages.h" |
| 18 #include "chrome/browser/ui/host_desktop.h" |
| 19 #include "chrome/browser/upgrade_detector.h" |
| 20 #include "chrome/grit/locale_settings.h" |
| 21 #include "content/public/browser/notification_service.h" |
| 22 #include "ui/base/l10n/l10n_util.h" |
| 23 |
| 24 SystemTrayDelegateCommon::SystemTrayDelegateCommon() |
| 25 : clock_type_(base::GetHourClockType()) { |
| 26 // Register notifications on construction so that events such as |
| 27 // PROFILE_CREATED do not get missed if they happen before Initialize(). |
| 28 registrar_.reset(new content::NotificationRegistrar); |
| 29 registrar_->Add(this, |
| 30 chrome::NOTIFICATION_UPGRADE_RECOMMENDED, |
| 31 content::NotificationService::AllSources()); |
| 32 } |
| 33 |
| 34 SystemTrayDelegateCommon::~SystemTrayDelegateCommon() { |
| 35 registrar_.reset(); |
| 36 } |
| 37 |
| 38 // Overridden from ash::SystemTrayDelegate: |
| 39 void SystemTrayDelegateCommon::Initialize() { |
| 40 UpdateClockType(); |
| 41 } |
| 42 |
| 43 void SystemTrayDelegateCommon::Shutdown() { |
| 44 } |
| 45 |
| 46 bool SystemTrayDelegateCommon::GetTrayVisibilityOnStartup() { |
| 47 return true; |
| 48 } |
| 49 |
| 50 ash::user::LoginStatus SystemTrayDelegateCommon::GetUserLoginStatus() const { |
| 51 return ash::user::LOGGED_IN_OWNER; |
| 52 } |
| 53 |
| 54 void SystemTrayDelegateCommon::ChangeProfilePicture() { |
| 55 } |
| 56 |
| 57 const std::string SystemTrayDelegateCommon::GetEnterpriseDomain() const { |
| 58 return std::string(); |
| 59 } |
| 60 |
| 61 const base::string16 SystemTrayDelegateCommon::GetEnterpriseMessage() const { |
| 62 return base::string16(); |
| 63 } |
| 64 |
| 65 const std::string SystemTrayDelegateCommon::GetSupervisedUserManager() const { |
| 66 return std::string(); |
| 67 } |
| 68 |
| 69 const base::string16 SystemTrayDelegateCommon::GetSupervisedUserManagerName() |
| 70 const { |
| 71 return base::string16(); |
| 72 } |
| 73 |
| 74 const base::string16 SystemTrayDelegateCommon::GetSupervisedUserMessage() |
| 75 const { |
| 76 return base::string16(); |
| 77 } |
| 78 |
| 79 bool SystemTrayDelegateCommon::IsUserSupervised() const { |
| 80 return false; |
| 81 } |
| 82 |
| 83 void SystemTrayDelegateCommon::GetSystemUpdateInfo( |
| 84 ash::UpdateInfo* info) const { |
| 85 GetUpdateInfo(UpgradeDetector::GetInstance(), info); |
| 86 } |
| 87 |
| 88 base::HourClockType SystemTrayDelegateCommon::GetHourClockType() const { |
| 89 return clock_type_; |
| 90 } |
| 91 |
| 92 void SystemTrayDelegateCommon::ShowSettings() { |
| 93 } |
| 94 |
| 95 bool SystemTrayDelegateCommon::ShouldShowSettings() { |
| 96 return true; |
| 97 } |
| 98 |
| 99 void SystemTrayDelegateCommon::ShowDateSettings() { |
| 100 } |
| 101 |
| 102 void SystemTrayDelegateCommon::ShowSetTimeDialog() { |
| 103 } |
| 104 |
| 105 void SystemTrayDelegateCommon::ShowNetworkSettings( |
| 106 const std::string& service_path) { |
| 107 } |
| 108 |
| 109 void SystemTrayDelegateCommon::ShowBluetoothSettings() { |
| 110 } |
| 111 |
| 112 void SystemTrayDelegateCommon::ShowDisplaySettings() { |
| 113 } |
| 114 |
| 115 void SystemTrayDelegateCommon::ShowChromeSlow() { |
| 116 } |
| 117 |
| 118 bool SystemTrayDelegateCommon::ShouldShowDisplayNotification() { |
| 119 return false; |
| 120 } |
| 121 |
| 122 void SystemTrayDelegateCommon::ShowIMESettings() { |
| 123 } |
| 124 |
| 125 void SystemTrayDelegateCommon::ShowHelp() { |
| 126 chrome::ShowHelpForProfile(ProfileManager::GetLastUsedProfile(), |
| 127 chrome::HOST_DESKTOP_TYPE_ASH, |
| 128 chrome::HELP_SOURCE_MENU); |
| 129 } |
| 130 |
| 131 void SystemTrayDelegateCommon::ShowAccessibilityHelp() { |
| 132 } |
| 133 |
| 134 void SystemTrayDelegateCommon::ShowAccessibilitySettings() { |
| 135 } |
| 136 |
| 137 void SystemTrayDelegateCommon::ShowPublicAccountInfo() { |
| 138 } |
| 139 |
| 140 void SystemTrayDelegateCommon::ShowSupervisedUserInfo() { |
| 141 } |
| 142 |
| 143 void SystemTrayDelegateCommon::ShowEnterpriseInfo() { |
| 144 } |
| 145 |
| 146 void SystemTrayDelegateCommon::ShowUserLogin() { |
| 147 } |
| 148 |
| 149 bool SystemTrayDelegateCommon::ShowSpringChargerReplacementDialog() { |
| 150 return false; |
| 151 } |
| 152 |
| 153 bool SystemTrayDelegateCommon::IsSpringChargerReplacementDialogVisible() { |
| 154 return false; |
| 155 } |
| 156 |
| 157 bool SystemTrayDelegateCommon::HasUserConfirmedSafeSpringCharger() { |
| 158 return false; |
| 159 } |
| 160 |
| 161 void SystemTrayDelegateCommon::ShutDown() { |
| 162 } |
| 163 |
| 164 void SystemTrayDelegateCommon::SignOut() { |
| 165 } |
| 166 |
| 167 void SystemTrayDelegateCommon::RequestLockScreen() { |
| 168 } |
| 169 |
| 170 void SystemTrayDelegateCommon::RequestRestartForUpdate() { |
| 171 chrome::AttemptRestart(); |
| 172 } |
| 173 |
| 174 void SystemTrayDelegateCommon::GetAvailableBluetoothDevices( |
| 175 ash::BluetoothDeviceList* list) { |
| 176 } |
| 177 |
| 178 void SystemTrayDelegateCommon::BluetoothStartDiscovering() { |
| 179 } |
| 180 |
| 181 void SystemTrayDelegateCommon::BluetoothStopDiscovering() { |
| 182 } |
| 183 |
| 184 void SystemTrayDelegateCommon::ConnectToBluetoothDevice( |
| 185 const std::string& address) { |
| 186 } |
| 187 |
| 188 bool SystemTrayDelegateCommon::IsBluetoothDiscovering() { |
| 189 return false; |
| 190 } |
| 191 |
| 192 void SystemTrayDelegateCommon::GetCurrentIME(ash::IMEInfo* info) { |
| 193 } |
| 194 |
| 195 void SystemTrayDelegateCommon::GetAvailableIMEList(ash::IMEInfoList* list) { |
| 196 } |
| 197 |
| 198 void SystemTrayDelegateCommon::GetCurrentIMEProperties( |
| 199 ash::IMEPropertyInfoList* list) { |
| 200 } |
| 201 |
| 202 void SystemTrayDelegateCommon::SwitchIME(const std::string& ime_id) { |
| 203 } |
| 204 |
| 205 void SystemTrayDelegateCommon::ActivateIMEProperty(const std::string& key) { |
| 206 } |
| 207 |
| 208 void SystemTrayDelegateCommon::ShowNetworkConfigure( |
| 209 const std::string& network_id) { |
| 210 } |
| 211 |
| 212 bool SystemTrayDelegateCommon::EnrollNetwork(const std::string& network_id) { |
| 213 return true; |
| 214 } |
| 215 |
| 216 void SystemTrayDelegateCommon::ManageBluetoothDevices() { |
| 217 } |
| 218 |
| 219 void SystemTrayDelegateCommon::ToggleBluetooth() { |
| 220 } |
| 221 |
| 222 void SystemTrayDelegateCommon::ShowMobileSimDialog() { |
| 223 } |
| 224 |
| 225 void SystemTrayDelegateCommon::ShowMobileSetupDialog( |
| 226 const std::string& service_path) { |
| 227 } |
| 228 |
| 229 void SystemTrayDelegateCommon::ShowOtherNetworkDialog(const std::string& type) { |
| 230 } |
| 231 |
| 232 bool SystemTrayDelegateCommon::GetBluetoothAvailable() { |
| 233 return false; |
| 234 } |
| 235 |
| 236 bool SystemTrayDelegateCommon::GetBluetoothEnabled() { |
| 237 return false; |
| 238 } |
| 239 |
| 240 bool SystemTrayDelegateCommon::GetBluetoothDiscovering() { |
| 241 return false; |
| 242 } |
| 243 |
| 244 void SystemTrayDelegateCommon::ChangeProxySettings() { |
| 245 } |
| 246 |
| 247 ash::VolumeControlDelegate* SystemTrayDelegateCommon::GetVolumeControlDelegate() |
| 248 const { |
| 249 return NULL; |
| 250 } |
| 251 |
| 252 void SystemTrayDelegateCommon::SetVolumeControlDelegate( |
| 253 scoped_ptr<ash::VolumeControlDelegate> delegate) { |
| 254 } |
| 255 |
| 256 bool SystemTrayDelegateCommon::GetSessionStartTime( |
| 257 base::TimeTicks* session_start_time) { |
| 258 return false; |
| 259 } |
| 260 |
| 261 bool SystemTrayDelegateCommon::GetSessionLengthLimit( |
| 262 base::TimeDelta* session_length_limit) { |
| 263 return false; |
| 264 } |
| 265 |
| 266 int SystemTrayDelegateCommon::GetSystemTrayMenuWidth() { |
| 267 return l10n_util::GetLocalizedContentsWidthInPixels( |
| 268 IDS_SYSTEM_TRAY_MENU_BUBBLE_WIDTH_PIXELS); |
| 269 } |
| 270 |
| 271 void SystemTrayDelegateCommon::ActiveUserWasChanged() { |
| 272 } |
| 273 |
| 274 bool SystemTrayDelegateCommon::IsSearchKeyMappedToCapsLock() { |
| 275 return false; |
| 276 } |
| 277 |
| 278 ash::tray::UserAccountsDelegate* |
| 279 SystemTrayDelegateCommon::GetUserAccountsDelegate(const std::string& user_id) { |
| 280 return NULL; |
| 281 } |
| 282 |
| 283 ash::SystemTrayNotifier* SystemTrayDelegateCommon::GetSystemTrayNotifier() { |
| 284 return ash::Shell::GetInstance()->system_tray_notifier(); |
| 285 } |
| 286 |
| 287 void SystemTrayDelegateCommon::UpdateClockType() { |
| 288 clock_type_ = (base::GetHourClockType() == base::k24HourClock) |
| 289 ? base::k24HourClock |
| 290 : base::k12HourClock; |
| 291 GetSystemTrayNotifier()->NotifyDateFormatChanged(); |
| 292 } |
| 293 |
| 294 void SystemTrayDelegateCommon::Observe( |
| 295 int type, |
| 296 const content::NotificationSource& source, |
| 297 const content::NotificationDetails& details) { |
| 298 if (type == chrome::NOTIFICATION_UPGRADE_RECOMMENDED) { |
| 299 ash::UpdateInfo info; |
| 300 GetUpdateInfo(content::Source<UpgradeDetector>(source).ptr(), &info); |
| 301 GetSystemTrayNotifier()->NotifyUpdateRecommended(info); |
| 302 } else { |
| 303 NOTREACHED(); |
| 304 } |
| 305 } |
| OLD | NEW |