| 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 "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 Loading... |
| 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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 TrayBluetooth::~TrayBluetooth() { | 580 TrayBluetooth::~TrayBluetooth() { |
| 582 WmShell::Get()->system_tray_notifier()->RemoveBluetoothObserver(this); | 581 WmShell::Get()->system_tray_notifier()->RemoveBluetoothObserver(this); |
| 583 } | 582 } |
| 584 | 583 |
| 585 views::View* TrayBluetooth::CreateTrayView(LoginStatus status) { | 584 views::View* TrayBluetooth::CreateTrayView(LoginStatus status) { |
| 586 return NULL; | 585 return NULL; |
| 587 } | 586 } |
| 588 | 587 |
| 589 views::View* TrayBluetooth::CreateDefaultView(LoginStatus status) { | 588 views::View* TrayBluetooth::CreateDefaultView(LoginStatus status) { |
| 590 CHECK(default_ == NULL); | 589 CHECK(default_ == NULL); |
| 591 default_ = | 590 default_ = new tray::BluetoothDefaultView(this); |
| 592 new tray::BluetoothDefaultView(this, status != LoginStatus::LOCKED); | 591 default_->SetEnabled(status != LoginStatus::LOCKED); |
| 593 default_->Update(); | 592 default_->Update(); |
| 594 return default_; | 593 return default_; |
| 595 } | 594 } |
| 596 | 595 |
| 597 views::View* TrayBluetooth::CreateDetailedView(LoginStatus status) { | 596 views::View* TrayBluetooth::CreateDetailedView(LoginStatus status) { |
| 598 if (!WmShell::Get()->system_tray_delegate()->GetBluetoothAvailable()) | 597 if (!WmShell::Get()->system_tray_delegate()->GetBluetoothAvailable()) |
| 599 return NULL; | 598 return NULL; |
| 600 WmShell::Get()->RecordUserMetricsAction( | 599 WmShell::Get()->RecordUserMetricsAction( |
| 601 UMA_STATUS_AREA_DETAILED_BLUETOOTH_VIEW); | 600 UMA_STATUS_AREA_DETAILED_BLUETOOTH_VIEW); |
| 602 CHECK(detailed_ == NULL); | 601 CHECK(detailed_ == NULL); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 624 detailed_->Update(); | 623 detailed_->Update(); |
| 625 } | 624 } |
| 626 | 625 |
| 627 void TrayBluetooth::OnBluetoothDiscoveringChanged() { | 626 void TrayBluetooth::OnBluetoothDiscoveringChanged() { |
| 628 if (!detailed_) | 627 if (!detailed_) |
| 629 return; | 628 return; |
| 630 detailed_->Update(); | 629 detailed_->Update(); |
| 631 } | 630 } |
| 632 | 631 |
| 633 } // namespace ash | 632 } // namespace ash |
| OLD | NEW |