OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h" | 5 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "ash/ash_switches.h" | 12 #include "ash/ash_switches.h" |
13 #include "ash/desktop_background/desktop_background_controller.h" | 13 #include "ash/desktop_background/desktop_background_controller.h" |
| 14 #include "ash/session_state_delegate.h" |
| 15 #include "ash/session_state_observer.h" |
14 #include "ash/shell.h" | 16 #include "ash/shell.h" |
15 #include "ash/shell_delegate.h" | 17 #include "ash/shell_delegate.h" |
16 #include "ash/shell_window_ids.h" | 18 #include "ash/shell_window_ids.h" |
17 #include "ash/system/bluetooth/bluetooth_observer.h" | 19 #include "ash/system/bluetooth/bluetooth_observer.h" |
18 #include "ash/system/brightness/brightness_observer.h" | 20 #include "ash/system/brightness/brightness_observer.h" |
19 #include "ash/system/chromeos/audio/audio_observer.h" | 21 #include "ash/system/chromeos/audio/audio_observer.h" |
20 #include "ash/system/chromeos/network/network_observer.h" | 22 #include "ash/system/chromeos/network/network_observer.h" |
21 #include "ash/system/chromeos/network/network_tray_delegate.h" | 23 #include "ash/system/chromeos/network/network_tray_delegate.h" |
22 #include "ash/system/date/clock_observer.h" | 24 #include "ash/system/date/clock_observer.h" |
23 #include "ash/system/drive/drive_observer.h" | 25 #include "ash/system/drive/drive_observer.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 public SessionManagerClient::Observer, | 230 public SessionManagerClient::Observer, |
229 public NetworkLibrary::NetworkManagerObserver, | 231 public NetworkLibrary::NetworkManagerObserver, |
230 public drive::JobListObserver, | 232 public drive::JobListObserver, |
231 public content::NotificationObserver, | 233 public content::NotificationObserver, |
232 public input_method::InputMethodManager::Observer, | 234 public input_method::InputMethodManager::Observer, |
233 public system::TimezoneSettings::Observer, | 235 public system::TimezoneSettings::Observer, |
234 public chromeos::SystemClockClient::Observer, | 236 public chromeos::SystemClockClient::Observer, |
235 public device::BluetoothAdapter::Observer, | 237 public device::BluetoothAdapter::Observer, |
236 public SystemKeyEventListener::CapsLockObserver, | 238 public SystemKeyEventListener::CapsLockObserver, |
237 public ash::NetworkTrayDelegate, | 239 public ash::NetworkTrayDelegate, |
238 public policy::CloudPolicyStore::Observer { | 240 public policy::CloudPolicyStore::Observer, |
| 241 public ash::SessionStateObserver { |
239 public: | 242 public: |
240 SystemTrayDelegate() | 243 SystemTrayDelegate() |
241 : ui_weak_ptr_factory_( | 244 : ui_weak_ptr_factory_( |
242 new base::WeakPtrFactory<SystemTrayDelegate>(this)), | 245 new base::WeakPtrFactory<SystemTrayDelegate>(this)), |
243 user_profile_(NULL), | 246 user_profile_(NULL), |
244 clock_type_(base::k24HourClock), | 247 clock_type_(base::k24HourClock), |
245 search_key_mapped_to_(input_method::kSearchKey), | 248 search_key_mapped_to_(input_method::kSearchKey), |
246 screen_locked_(false), | 249 screen_locked_(false), |
247 have_session_start_time_(false), | 250 have_session_start_time_(false), |
248 have_session_length_limit_(false), | 251 have_session_length_limit_(false), |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 305 |
303 system::TimezoneSettings::GetInstance()->AddObserver(this); | 306 system::TimezoneSettings::GetInstance()->AddObserver(this); |
304 DBusThreadManager::Get()->GetSystemClockClient()->AddObserver(this); | 307 DBusThreadManager::Get()->GetSystemClockClient()->AddObserver(this); |
305 | 308 |
306 if (SystemKeyEventListener::GetInstance()) | 309 if (SystemKeyEventListener::GetInstance()) |
307 SystemKeyEventListener::GetInstance()->AddCapsLockObserver(this); | 310 SystemKeyEventListener::GetInstance()->AddCapsLockObserver(this); |
308 | 311 |
309 device::BluetoothAdapterFactory::GetAdapter( | 312 device::BluetoothAdapterFactory::GetAdapter( |
310 base::Bind(&SystemTrayDelegate::InitializeOnAdapterReady, | 313 base::Bind(&SystemTrayDelegate::InitializeOnAdapterReady, |
311 ui_weak_ptr_factory_->GetWeakPtr())); | 314 ui_weak_ptr_factory_->GetWeakPtr())); |
| 315 |
| 316 ash::Shell::GetInstance()->session_state_delegate()-> |
| 317 AddSessionStateObserver(this); |
312 } | 318 } |
313 | 319 |
314 virtual void Shutdown() OVERRIDE { | 320 virtual void Shutdown() OVERRIDE { |
315 data_promo_notification_.reset(); | 321 data_promo_notification_.reset(); |
316 } | 322 } |
317 | 323 |
318 void InitializeOnAdapterReady( | 324 void InitializeOnAdapterReady( |
319 scoped_refptr<device::BluetoothAdapter> adapter) { | 325 scoped_refptr<device::BluetoothAdapter> adapter) { |
320 bluetooth_adapter_ = adapter; | 326 bluetooth_adapter_ = adapter; |
321 CHECK(bluetooth_adapter_); | 327 CHECK(bluetooth_adapter_); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 367 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
362 DBusThreadManager::Get()->GetSystemClockClient()->RemoveObserver(this); | 368 DBusThreadManager::Get()->GetSystemClockClient()->RemoveObserver(this); |
363 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); | 369 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); |
364 if (crosnet) | 370 if (crosnet) |
365 crosnet->RemoveNetworkManagerObserver(this); | 371 crosnet->RemoveNetworkManagerObserver(this); |
366 input_method::InputMethodManager::Get()->RemoveObserver(this); | 372 input_method::InputMethodManager::Get()->RemoveObserver(this); |
367 system::TimezoneSettings::GetInstance()->RemoveObserver(this); | 373 system::TimezoneSettings::GetInstance()->RemoveObserver(this); |
368 if (SystemKeyEventListener::GetInstance()) | 374 if (SystemKeyEventListener::GetInstance()) |
369 SystemKeyEventListener::GetInstance()->RemoveCapsLockObserver(this); | 375 SystemKeyEventListener::GetInstance()->RemoveCapsLockObserver(this); |
370 bluetooth_adapter_->RemoveObserver(this); | 376 bluetooth_adapter_->RemoveObserver(this); |
| 377 ash::Shell::GetInstance()->session_state_delegate()-> |
| 378 RemoveSessionStateObserver(this); |
371 | 379 |
372 // Stop observing gdata operations. | 380 // Stop observing gdata operations. |
373 DriveIntegrationService* integration_service = | 381 DriveIntegrationService* integration_service = |
374 FindDriveIntegrationService(); | 382 FindDriveIntegrationService(); |
375 if (integration_service) | 383 if (integration_service) |
376 integration_service->job_list()->RemoveObserver(this); | 384 integration_service->job_list()->RemoveObserver(this); |
377 | 385 |
378 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = | 386 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = |
379 g_browser_process->browser_policy_connector()-> | 387 g_browser_process->browser_policy_connector()-> |
380 GetDeviceCloudPolicyManager(); | 388 GetDeviceCloudPolicyManager(); |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 | 1274 |
1267 // Overridden from CloudPolicyStore::Observer | 1275 // Overridden from CloudPolicyStore::Observer |
1268 virtual void OnStoreLoaded(policy::CloudPolicyStore* store) OVERRIDE { | 1276 virtual void OnStoreLoaded(policy::CloudPolicyStore* store) OVERRIDE { |
1269 UpdateEnterpriseDomain(); | 1277 UpdateEnterpriseDomain(); |
1270 } | 1278 } |
1271 | 1279 |
1272 virtual void OnStoreError(policy::CloudPolicyStore* store) OVERRIDE { | 1280 virtual void OnStoreError(policy::CloudPolicyStore* store) OVERRIDE { |
1273 UpdateEnterpriseDomain(); | 1281 UpdateEnterpriseDomain(); |
1274 } | 1282 } |
1275 | 1283 |
| 1284 // Overridden from ash::SessionStateObserver |
| 1285 virtual void ActiveUserChanged(const std::string& user_id) OVERRIDE { |
| 1286 GetSystemTrayNotifier()->NotifyUserUpdate(); |
| 1287 } |
| 1288 |
1276 void UpdateCellular() { | 1289 void UpdateCellular() { |
1277 const CellularNetworkVector& cellular_networks = | 1290 const CellularNetworkVector& cellular_networks = |
1278 CrosLibrary::Get()->GetNetworkLibrary()->cellular_networks(); | 1291 CrosLibrary::Get()->GetNetworkLibrary()->cellular_networks(); |
1279 if (cellular_networks.empty()) | 1292 if (cellular_networks.empty()) |
1280 return; | 1293 return; |
1281 // We only care about the first cellular network (in practice there will | 1294 // We only care about the first cellular network (in practice there will |
1282 // only ever be one) | 1295 // only ever be one) |
1283 const CellularNetwork* cellular = cellular_networks[0]; | 1296 const CellularNetwork* cellular = cellular_networks[0]; |
1284 if (cellular->activation_state() == ACTIVATION_STATE_ACTIVATING) { | 1297 if (cellular->activation_state() == ACTIVATION_STATE_ACTIVATING) { |
1285 cellular_activating_ = true; | 1298 cellular_activating_ = true; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); | 1337 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); |
1325 }; | 1338 }; |
1326 | 1339 |
1327 } // namespace | 1340 } // namespace |
1328 | 1341 |
1329 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 1342 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
1330 return new chromeos::SystemTrayDelegate(); | 1343 return new chromeos::SystemTrayDelegate(); |
1331 } | 1344 } |
1332 | 1345 |
1333 } // namespace chromeos | 1346 } // namespace chromeos |
OLD | NEW |