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

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

Issue 2699443004: Modify TrayItemMore to use enabled status (Closed)
Patch Set: Removed non-MD Created 3 years, 10 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/common/system/chromeos/bluetooth/tray_bluetooth.h" 5 #include "ash/common/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/common/system/tray/hover_highlight_view.h" 8 #include "ash/common/system/tray/hover_highlight_view.h"
9 #include "ash/common/system/tray/system_tray.h" 9 #include "ash/common/system/tray/system_tray.h"
10 #include "ash/common/system/tray/system_tray_delegate.h" 10 #include "ash/common/system/tray/system_tray_delegate.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 return connected ? ash::kSystemMenuBluetoothConnectedIcon 105 return connected ? ash::kSystemMenuBluetoothConnectedIcon
106 : ash::kSystemMenuBluetoothIcon; 106 : ash::kSystemMenuBluetoothIcon;
107 } 107 }
108 108
109 const int kDisabledPanelLabelBaselineY = 20; 109 const int kDisabledPanelLabelBaselineY = 20;
110 110
111 } // namespace 111 } // namespace
112 112
113 class BluetoothDefaultView : public TrayItemMore { 113 class BluetoothDefaultView : public TrayItemMore {
114 public: 114 public:
115 BluetoothDefaultView(SystemTrayItem* owner, bool show_more) 115 explicit BluetoothDefaultView(SystemTrayItem* owner) : TrayItemMore(owner) {}
116 : TrayItemMore(owner, show_more) {}
117
118 ~BluetoothDefaultView() override {} 116 ~BluetoothDefaultView() override {}
119 117
120 void Update() { 118 void Update() {
121 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); 119 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate();
122 const bool enabled = delegate->GetBluetoothEnabled(); 120 const bool enabled = delegate->GetBluetoothEnabled();
123 if (delegate->GetBluetoothAvailable()) { 121 if (delegate->GetBluetoothAvailable()) {
124 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 122 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
125 const base::string16 label = rb.GetLocalizedString( 123 const base::string16 label = rb.GetLocalizedString(
126 enabled ? IDS_ASH_STATUS_TRAY_BLUETOOTH_ENABLED 124 enabled ? IDS_ASH_STATUS_TRAY_BLUETOOTH_ENABLED
127 : IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED); 125 : IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED);
128 SetLabel(label); 126 SetLabel(label);
129 SetAccessibleName(label); 127 SetAccessibleName(label);
130 SetVisible(true); 128 SetVisible(true);
131 } else { 129 } else {
132 SetVisible(false); 130 SetVisible(false);
133 } 131 }
134 UpdateStyle(); 132 UpdateStyle();
135 } 133 }
136 134
137 protected: 135 protected:
138 // TrayItemMore: 136 // TrayItemMore:
139 std::unique_ptr<TrayPopupItemStyle> CreateStyle() const override { 137 std::unique_ptr<TrayPopupItemStyle> HandleCreateStyle() const override {
140 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); 138 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate();
141 std::unique_ptr<TrayPopupItemStyle> style = TrayItemMore::CreateStyle(); 139 std::unique_ptr<TrayPopupItemStyle> style =
140 TrayItemMore::HandleCreateStyle();
142 style->set_color_style( 141 style->set_color_style(
143 delegate->GetBluetoothEnabled() 142 delegate->GetBluetoothEnabled()
144 ? TrayPopupItemStyle::ColorStyle::ACTIVE 143 ? TrayPopupItemStyle::ColorStyle::ACTIVE
145 : delegate->GetBluetoothAvailable() 144 : delegate->GetBluetoothAvailable()
146 ? TrayPopupItemStyle::ColorStyle::INACTIVE 145 ? TrayPopupItemStyle::ColorStyle::INACTIVE
147 : TrayPopupItemStyle::ColorStyle::DISABLED); 146 : TrayPopupItemStyle::ColorStyle::DISABLED);
148 147
149 return style; 148 return style;
150 } 149 }
151 150
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 TrayBluetooth::~TrayBluetooth() { 574 TrayBluetooth::~TrayBluetooth() {
576 WmShell::Get()->system_tray_notifier()->RemoveBluetoothObserver(this); 575 WmShell::Get()->system_tray_notifier()->RemoveBluetoothObserver(this);
577 } 576 }
578 577
579 views::View* TrayBluetooth::CreateTrayView(LoginStatus status) { 578 views::View* TrayBluetooth::CreateTrayView(LoginStatus status) {
580 return NULL; 579 return NULL;
581 } 580 }
582 581
583 views::View* TrayBluetooth::CreateDefaultView(LoginStatus status) { 582 views::View* TrayBluetooth::CreateDefaultView(LoginStatus status) {
584 CHECK(default_ == NULL); 583 CHECK(default_ == NULL);
585 default_ = 584 default_ = new tray::BluetoothDefaultView(this);
586 new tray::BluetoothDefaultView(this, status != LoginStatus::LOCKED); 585 default_->SetEnabled(status != LoginStatus::LOCKED);
587 default_->Update(); 586 default_->Update();
588 return default_; 587 return default_;
589 } 588 }
590 589
591 views::View* TrayBluetooth::CreateDetailedView(LoginStatus status) { 590 views::View* TrayBluetooth::CreateDetailedView(LoginStatus status) {
592 if (!WmShell::Get()->system_tray_delegate()->GetBluetoothAvailable()) 591 if (!WmShell::Get()->system_tray_delegate()->GetBluetoothAvailable())
593 return NULL; 592 return NULL;
594 WmShell::Get()->RecordUserMetricsAction( 593 WmShell::Get()->RecordUserMetricsAction(
595 UMA_STATUS_AREA_DETAILED_BLUETOOTH_VIEW); 594 UMA_STATUS_AREA_DETAILED_BLUETOOTH_VIEW);
596 CHECK(detailed_ == NULL); 595 CHECK(detailed_ == NULL);
(...skipping 21 matching lines...) Expand all
618 detailed_->Update(); 617 detailed_->Update();
619 } 618 }
620 619
621 void TrayBluetooth::OnBluetoothDiscoveringChanged() { 620 void TrayBluetooth::OnBluetoothDiscoveringChanged() {
622 if (!detailed_) 621 if (!detailed_)
623 return; 622 return;
624 detailed_->Update(); 623 detailed_->Update();
625 } 624 }
626 625
627 } // namespace ash 626 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/common/system/chromeos/cast/tray_cast.cc » ('j') | ash/common/system/tray/tray_item_more.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698