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

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

Issue 2365523002: Materialized the font/icon color for some default rows in the system menu. (Closed)
Patch Set: Applied TrayPopupItemStyle to Network, SMS, Tracing, OS Update. Created 4 years, 3 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/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
9 #include "ash/common/system/tray/fixed_sized_scroll_view.h" 9 #include "ash/common/system/tray/fixed_sized_scroll_view.h"
10 #include "ash/common/system/tray/hover_highlight_view.h" 10 #include "ash/common/system/tray/hover_highlight_view.h"
11 #include "ash/common/system/tray/system_tray.h" 11 #include "ash/common/system/tray/system_tray.h"
12 #include "ash/common/system/tray/system_tray_delegate.h" 12 #include "ash/common/system/tray/system_tray_delegate.h"
13 #include "ash/common/system/tray/system_tray_notifier.h" 13 #include "ash/common/system/tray/system_tray_notifier.h"
14 #include "ash/common/system/tray/throbber_view.h" 14 #include "ash/common/system/tray/throbber_view.h"
15 #include "ash/common/system/tray/tray_constants.h" 15 #include "ash/common/system/tray/tray_constants.h"
16 #include "ash/common/system/tray/tray_details_view.h" 16 #include "ash/common/system/tray/tray_details_view.h"
17 #include "ash/common/system/tray/tray_item_more.h" 17 #include "ash/common/system/tray/tray_item_more.h"
18 #include "ash/common/system/tray/tray_popup_header_button.h" 18 #include "ash/common/system/tray/tray_popup_header_button.h"
19 #include "ash/common/system/tray/tray_popup_item_style.h"
19 #include "ash/common/wm_shell.h" 20 #include "ash/common/wm_shell.h"
20 #include "ash/resources/vector_icons/vector_icons.h" 21 #include "ash/resources/vector_icons/vector_icons.h"
21 #include "grit/ash_resources.h" 22 #include "grit/ash_resources.h"
22 #include "grit/ash_strings.h" 23 #include "grit/ash_strings.h"
23 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
25 #include "ui/gfx/image/image.h" 26 #include "ui/gfx/image/image.h"
26 #include "ui/gfx/paint_vector_icon.h" 27 #include "ui/gfx/paint_vector_icon.h"
27 #include "ui/views/controls/button/toggle_button.h" 28 #include "ui/views/controls/button/toggle_button.h"
28 #include "ui/views/controls/image_view.h" 29 #include "ui/views/controls/image_view.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 65 }
65 } 66 }
66 67
67 } // namespace 68 } // namespace
68 69
69 class BluetoothDefaultView : public TrayItemMore { 70 class BluetoothDefaultView : public TrayItemMore {
70 public: 71 public:
71 BluetoothDefaultView(SystemTrayItem* owner, bool show_more) 72 BluetoothDefaultView(SystemTrayItem* owner, bool show_more)
72 : TrayItemMore(owner, show_more) { 73 : TrayItemMore(owner, show_more) {
73 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) { 74 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) {
75 // The icon doesn't change in non-md.
74 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 76 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
75 SetImage( 77 SetImage(
76 *bundle.GetImageNamed(IDR_AURA_UBER_TRAY_BLUETOOTH).ToImageSkia()); 78 *bundle.GetImageNamed(IDR_AURA_UBER_TRAY_BLUETOOTH).ToImageSkia());
77 } 79 }
78 Update();
79 } 80 }
80 81
81 ~BluetoothDefaultView() override {} 82 ~BluetoothDefaultView() override {}
82 83
83 void Update() { 84 void Update() {
84 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); 85 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate();
85 const bool enabled = delegate->GetBluetoothEnabled(); 86 const bool enabled = delegate->GetBluetoothEnabled();
86 if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
87 SetImage(gfx::CreateVectorIcon(
88 enabled ? kSystemMenuBluetoothIcon : kSystemMenuBluetoothDisabledIcon,
89 kMenuIconColor));
90 }
91
92 if (delegate->GetBluetoothAvailable()) { 87 if (delegate->GetBluetoothAvailable()) {
93 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 88 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
94 const base::string16 label = rb.GetLocalizedString( 89 const base::string16 label = rb.GetLocalizedString(
95 enabled ? IDS_ASH_STATUS_TRAY_BLUETOOTH_ENABLED 90 enabled ? IDS_ASH_STATUS_TRAY_BLUETOOTH_ENABLED
96 : IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED); 91 : IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED);
97 SetLabel(label); 92 SetLabel(label);
98 SetAccessibleName(label); 93 SetAccessibleName(label);
99 SetVisible(true); 94 SetVisible(true);
100 } else { 95 } else {
101 SetVisible(false); 96 SetVisible(false);
102 } 97 }
98 UpdateStyle();
99 }
100
101 protected:
102 // TrayItemMore:
103 std::unique_ptr<TrayPopupItemStyle> CreateStyle() const override {
104 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate();
105 std::unique_ptr<TrayPopupItemStyle> style =
106 base::MakeUnique<TrayPopupItemStyle>(
107 GetNativeTheme(),
108 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
109
110 style->set_color_style(
111 delegate->GetBluetoothEnabled()
112 ? TrayPopupItemStyle::ColorStyle::ACTIVE
113 : delegate->GetBluetoothAvailable()
114 ? TrayPopupItemStyle::ColorStyle::INACTIVE
115 : TrayPopupItemStyle::ColorStyle::DISABLED);
116
117 return style;
118 }
119
120 void UpdateStyle() override {
121 TrayItemMore::UpdateStyle();
122
123 if (!MaterialDesignController::IsSystemTrayMenuMaterial())
124 return;
125
126 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate();
127 std::unique_ptr<TrayPopupItemStyle> style = CreateStyle();
128
129 SetImage(gfx::CreateVectorIcon(delegate->GetBluetoothEnabled()
130 ? kSystemMenuBluetoothIcon
131 : kSystemMenuBluetoothDisabledIcon,
132 style->GetForegroundColor()));
103 } 133 }
104 134
105 private: 135 private:
106 DISALLOW_COPY_AND_ASSIGN(BluetoothDefaultView); 136 DISALLOW_COPY_AND_ASSIGN(BluetoothDefaultView);
107 }; 137 };
108 138
109 class BluetoothDetailedView : public TrayDetailsView { 139 class BluetoothDetailedView : public TrayDetailsView {
110 public: 140 public:
111 BluetoothDetailedView(SystemTrayItem* owner, LoginStatus login) 141 BluetoothDetailedView(SystemTrayItem* owner, LoginStatus login)
112 : TrayDetailsView(owner), 142 : TrayDetailsView(owner),
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 } 473 }
444 474
445 views::View* TrayBluetooth::CreateTrayView(LoginStatus status) { 475 views::View* TrayBluetooth::CreateTrayView(LoginStatus status) {
446 return NULL; 476 return NULL;
447 } 477 }
448 478
449 views::View* TrayBluetooth::CreateDefaultView(LoginStatus status) { 479 views::View* TrayBluetooth::CreateDefaultView(LoginStatus status) {
450 CHECK(default_ == NULL); 480 CHECK(default_ == NULL);
451 default_ = 481 default_ =
452 new tray::BluetoothDefaultView(this, status != LoginStatus::LOCKED); 482 new tray::BluetoothDefaultView(this, status != LoginStatus::LOCKED);
483 default_->Update();
453 return default_; 484 return default_;
454 } 485 }
455 486
456 views::View* TrayBluetooth::CreateDetailedView(LoginStatus status) { 487 views::View* TrayBluetooth::CreateDetailedView(LoginStatus status) {
457 if (!WmShell::Get()->system_tray_delegate()->GetBluetoothAvailable()) 488 if (!WmShell::Get()->system_tray_delegate()->GetBluetoothAvailable())
458 return NULL; 489 return NULL;
459 WmShell::Get()->RecordUserMetricsAction( 490 WmShell::Get()->RecordUserMetricsAction(
460 UMA_STATUS_AREA_DETAILED_BLUETOOTH_VIEW); 491 UMA_STATUS_AREA_DETAILED_BLUETOOTH_VIEW);
461 CHECK(detailed_ == NULL); 492 CHECK(detailed_ == NULL);
462 detailed_ = new tray::BluetoothDetailedView(this, status); 493 detailed_ = new tray::BluetoothDetailedView(this, status);
(...skipping 20 matching lines...) Expand all
483 detailed_->Update(); 514 detailed_->Update();
484 } 515 }
485 516
486 void TrayBluetooth::OnBluetoothDiscoveringChanged() { 517 void TrayBluetooth::OnBluetoothDiscoveringChanged() {
487 if (!detailed_) 518 if (!detailed_)
488 return; 519 return;
489 detailed_->Update(); 520 detailed_->Update();
490 } 521 }
491 522
492 } // namespace ash 523 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698