Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: ash/system/chromeos/bluetooth/tray_bluetooth.cc

Issue 2041233005: Moves ash::user::LoginStatus to ash/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "ash/system/chromeos/bluetooth/tray_bluetooth.h" 5 #include "ash/system/chromeos/bluetooth/tray_bluetooth.h"
6 6
7 #include "ash/common/session/session_state_delegate.h" 7 #include "ash/common/session/session_state_delegate.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/system/tray/fixed_sized_scroll_view.h" 9 #include "ash/system/tray/fixed_sized_scroll_view.h"
10 #include "ash/system/tray/hover_highlight_view.h" 10 #include "ash/system/tray/hover_highlight_view.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 91 }
92 92
93 private: 93 private:
94 DISALLOW_COPY_AND_ASSIGN(BluetoothDefaultView); 94 DISALLOW_COPY_AND_ASSIGN(BluetoothDefaultView);
95 }; 95 };
96 96
97 class BluetoothDetailedView : public TrayDetailsView, 97 class BluetoothDetailedView : public TrayDetailsView,
98 public ViewClickListener, 98 public ViewClickListener,
99 public views::ButtonListener { 99 public views::ButtonListener {
100 public: 100 public:
101 BluetoothDetailedView(SystemTrayItem* owner, user::LoginStatus login) 101 BluetoothDetailedView(SystemTrayItem* owner, LoginStatus login)
102 : TrayDetailsView(owner), 102 : TrayDetailsView(owner),
103 login_(login), 103 login_(login),
104 manage_devices_(NULL), 104 manage_devices_(NULL),
105 toggle_bluetooth_(NULL), 105 toggle_bluetooth_(NULL),
106 enable_bluetooth_(NULL) { 106 enable_bluetooth_(NULL) {
107 CreateItems(); 107 CreateItems();
108 } 108 }
109 109
110 ~BluetoothDetailedView() override { 110 ~BluetoothDetailedView() override {
111 // Stop discovering bluetooth devices when exiting BT detailed view. 111 // Stop discovering bluetooth devices when exiting BT detailed view.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 new_connected_devices); 187 new_connected_devices);
188 RemoveObsoleteBluetoothDevicesFromList(&paired_not_connected_devices_, 188 RemoveObsoleteBluetoothDevicesFromList(&paired_not_connected_devices_,
189 new_paired_not_connected_devices); 189 new_paired_not_connected_devices);
190 RemoveObsoleteBluetoothDevicesFromList(&discovered_not_paired_devices_, 190 RemoveObsoleteBluetoothDevicesFromList(&discovered_not_paired_devices_,
191 new_discovered_not_paired_devices); 191 new_discovered_not_paired_devices);
192 } 192 }
193 193
194 void AppendHeaderEntry() { 194 void AppendHeaderEntry() {
195 CreateSpecialRow(IDS_ASH_STATUS_TRAY_BLUETOOTH, this); 195 CreateSpecialRow(IDS_ASH_STATUS_TRAY_BLUETOOTH, this);
196 196
197 if (login_ == user::LOGGED_IN_LOCKED) 197 if (login_ == LoginStatus::LOCKED)
198 return; 198 return;
199 199
200 throbber_ = new ThrobberView; 200 throbber_ = new ThrobberView;
201 throbber_->SetTooltipText( 201 throbber_->SetTooltipText(
202 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING)); 202 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING));
203 footer()->AddView(throbber_, false /* separator */); 203 footer()->AddView(throbber_, false /* separator */);
204 204
205 // Do not allow toggling bluetooth in the lock screen. 205 // Do not allow toggling bluetooth in the lock screen.
206 ash::SystemTrayDelegate* delegate = 206 ash::SystemTrayDelegate* delegate =
207 ash::Shell::GetInstance()->system_tray_delegate(); 207 ash::Shell::GetInstance()->system_tray_delegate();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 ->ShouldShowSettings()) { 297 ->ShouldShowSettings()) {
298 return; 298 return;
299 } 299 }
300 300
301 // Add bluetooth device requires a browser window, hide it for non logged in 301 // Add bluetooth device requires a browser window, hide it for non logged in
302 // user. 302 // user.
303 bool userAddingRunning = ash::Shell::GetInstance() 303 bool userAddingRunning = ash::Shell::GetInstance()
304 ->session_state_delegate() 304 ->session_state_delegate()
305 ->IsInSecondaryLoginScreen(); 305 ->IsInSecondaryLoginScreen();
306 306
307 if (login_ == user::LOGGED_IN_NONE || login_ == user::LOGGED_IN_LOCKED || 307 if (login_ == LoginStatus::NOT_LOGGED_IN || login_ == LoginStatus::LOCKED ||
308 userAddingRunning) 308 userAddingRunning)
309 return; 309 return;
310 310
311 ash::SystemTrayDelegate* delegate = 311 ash::SystemTrayDelegate* delegate =
312 ash::Shell::GetInstance()->system_tray_delegate(); 312 ash::Shell::GetInstance()->system_tray_delegate();
313 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 313 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
314 HoverHighlightView* container = new HoverHighlightView(this); 314 HoverHighlightView* container = new HoverHighlightView(this);
315 container->AddLabel( 315 container->AddLabel(
316 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BLUETOOTH_MANAGE_DEVICES), 316 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BLUETOOTH_MANAGE_DEVICES),
317 gfx::ALIGN_LEFT, false /* highlight */); 317 gfx::ALIGN_LEFT, false /* highlight */);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // Overridden from ButtonListener. 385 // Overridden from ButtonListener.
386 void ButtonPressed(views::Button* sender, const ui::Event& event) override { 386 void ButtonPressed(views::Button* sender, const ui::Event& event) override {
387 ash::SystemTrayDelegate* delegate = 387 ash::SystemTrayDelegate* delegate =
388 ash::Shell::GetInstance()->system_tray_delegate(); 388 ash::Shell::GetInstance()->system_tray_delegate();
389 if (sender == toggle_bluetooth_) 389 if (sender == toggle_bluetooth_)
390 delegate->ToggleBluetooth(); 390 delegate->ToggleBluetooth();
391 else 391 else
392 NOTREACHED(); 392 NOTREACHED();
393 } 393 }
394 394
395 user::LoginStatus login_; 395 LoginStatus login_;
396 396
397 std::map<views::View*, std::string> device_map_; 397 std::map<views::View*, std::string> device_map_;
398 views::View* manage_devices_; 398 views::View* manage_devices_;
399 ThrobberView* throbber_; 399 ThrobberView* throbber_;
400 TrayPopupHeaderButton* toggle_bluetooth_; 400 TrayPopupHeaderButton* toggle_bluetooth_;
401 HoverHighlightView* enable_bluetooth_; 401 HoverHighlightView* enable_bluetooth_;
402 BluetoothDeviceList connected_devices_; 402 BluetoothDeviceList connected_devices_;
403 BluetoothDeviceList connecting_devices_; 403 BluetoothDeviceList connecting_devices_;
404 BluetoothDeviceList paired_not_connected_devices_; 404 BluetoothDeviceList paired_not_connected_devices_;
405 BluetoothDeviceList discovered_not_paired_devices_; 405 BluetoothDeviceList discovered_not_paired_devices_;
406 406
407 DISALLOW_COPY_AND_ASSIGN(BluetoothDetailedView); 407 DISALLOW_COPY_AND_ASSIGN(BluetoothDetailedView);
408 }; 408 };
409 409
410 } // namespace tray 410 } // namespace tray
411 411
412 TrayBluetooth::TrayBluetooth(SystemTray* system_tray) 412 TrayBluetooth::TrayBluetooth(SystemTray* system_tray)
413 : SystemTrayItem(system_tray), default_(NULL), detailed_(NULL) { 413 : SystemTrayItem(system_tray), default_(NULL), detailed_(NULL) {
414 Shell::GetInstance()->system_tray_notifier()->AddBluetoothObserver(this); 414 Shell::GetInstance()->system_tray_notifier()->AddBluetoothObserver(this);
415 } 415 }
416 416
417 TrayBluetooth::~TrayBluetooth() { 417 TrayBluetooth::~TrayBluetooth() {
418 Shell::GetInstance()->system_tray_notifier()->RemoveBluetoothObserver(this); 418 Shell::GetInstance()->system_tray_notifier()->RemoveBluetoothObserver(this);
419 } 419 }
420 420
421 views::View* TrayBluetooth::CreateTrayView(user::LoginStatus status) { 421 views::View* TrayBluetooth::CreateTrayView(LoginStatus status) {
422 return NULL; 422 return NULL;
423 } 423 }
424 424
425 views::View* TrayBluetooth::CreateDefaultView(user::LoginStatus status) { 425 views::View* TrayBluetooth::CreateDefaultView(LoginStatus status) {
426 CHECK(default_ == NULL); 426 CHECK(default_ == NULL);
427 default_ = 427 default_ =
428 new tray::BluetoothDefaultView(this, status != user::LOGGED_IN_LOCKED); 428 new tray::BluetoothDefaultView(this, status != LoginStatus::LOCKED);
429 return default_; 429 return default_;
430 } 430 }
431 431
432 views::View* TrayBluetooth::CreateDetailedView(user::LoginStatus status) { 432 views::View* TrayBluetooth::CreateDetailedView(LoginStatus status) {
433 if (!Shell::GetInstance()->system_tray_delegate()->GetBluetoothAvailable()) 433 if (!Shell::GetInstance()->system_tray_delegate()->GetBluetoothAvailable())
434 return NULL; 434 return NULL;
435 Shell::GetInstance()->metrics()->RecordUserMetricsAction( 435 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
436 ash::UMA_STATUS_AREA_DETAILED_BLUETOOTH_VIEW); 436 ash::UMA_STATUS_AREA_DETAILED_BLUETOOTH_VIEW);
437 CHECK(detailed_ == NULL); 437 CHECK(detailed_ == NULL);
438 detailed_ = new tray::BluetoothDetailedView(this, status); 438 detailed_ = new tray::BluetoothDetailedView(this, status);
439 detailed_->Update(); 439 detailed_->Update();
440 return detailed_; 440 return detailed_;
441 } 441 }
442 442
443 void TrayBluetooth::DestroyTrayView() {} 443 void TrayBluetooth::DestroyTrayView() {}
444 444
445 void TrayBluetooth::DestroyDefaultView() { 445 void TrayBluetooth::DestroyDefaultView() {
446 default_ = NULL; 446 default_ = NULL;
447 } 447 }
448 448
449 void TrayBluetooth::DestroyDetailedView() { 449 void TrayBluetooth::DestroyDetailedView() {
450 detailed_ = NULL; 450 detailed_ = NULL;
451 } 451 }
452 452
453 void TrayBluetooth::UpdateAfterLoginStatusChange(user::LoginStatus status) {} 453 void TrayBluetooth::UpdateAfterLoginStatusChange(LoginStatus status) {}
454 454
455 void TrayBluetooth::OnBluetoothRefresh() { 455 void TrayBluetooth::OnBluetoothRefresh() {
456 if (default_) 456 if (default_)
457 default_->UpdateLabel(); 457 default_->UpdateLabel();
458 else if (detailed_) 458 else if (detailed_)
459 detailed_->Update(); 459 detailed_->Update();
460 } 460 }
461 461
462 void TrayBluetooth::OnBluetoothDiscoveringChanged() { 462 void TrayBluetooth::OnBluetoothDiscoveringChanged() {
463 if (!detailed_) 463 if (!detailed_)
464 return; 464 return;
465 detailed_->Update(); 465 detailed_->Update();
466 } 466 }
467 467
468 } // namespace ash 468 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/bluetooth/tray_bluetooth.h ('k') | ash/system/chromeos/brightness/tray_brightness.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698