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

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: Addressed tdanderson@ comments from previous patch set. 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
« no previous file with comments | « ash/BUILD.gn ('k') | ash/common/system/chromeos/network/tray_network.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 = TrayItemMore::CreateStyle();
106 style->set_color_style(
107 delegate->GetBluetoothEnabled()
108 ? TrayPopupItemStyle::ColorStyle::ACTIVE
109 : delegate->GetBluetoothAvailable()
110 ? TrayPopupItemStyle::ColorStyle::INACTIVE
111 : TrayPopupItemStyle::ColorStyle::DISABLED);
112
113 return style;
114 }
115
116 void UpdateStyle() override {
117 TrayItemMore::UpdateStyle();
118
119 if (!MaterialDesignController::IsSystemTrayMenuMaterial())
120 return;
121
122 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate();
123 std::unique_ptr<TrayPopupItemStyle> style = CreateStyle();
124
125 SetImage(gfx::CreateVectorIcon(delegate->GetBluetoothEnabled()
126 ? kSystemMenuBluetoothIcon
127 : kSystemMenuBluetoothDisabledIcon,
128 style->GetForegroundColor()));
103 } 129 }
104 130
105 private: 131 private:
106 DISALLOW_COPY_AND_ASSIGN(BluetoothDefaultView); 132 DISALLOW_COPY_AND_ASSIGN(BluetoothDefaultView);
107 }; 133 };
108 134
109 class BluetoothDetailedView : public TrayDetailsView { 135 class BluetoothDetailedView : public TrayDetailsView {
110 public: 136 public:
111 BluetoothDetailedView(SystemTrayItem* owner, LoginStatus login) 137 BluetoothDetailedView(SystemTrayItem* owner, LoginStatus login)
112 : TrayDetailsView(owner), 138 : TrayDetailsView(owner),
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 } 469 }
444 470
445 views::View* TrayBluetooth::CreateTrayView(LoginStatus status) { 471 views::View* TrayBluetooth::CreateTrayView(LoginStatus status) {
446 return NULL; 472 return NULL;
447 } 473 }
448 474
449 views::View* TrayBluetooth::CreateDefaultView(LoginStatus status) { 475 views::View* TrayBluetooth::CreateDefaultView(LoginStatus status) {
450 CHECK(default_ == NULL); 476 CHECK(default_ == NULL);
451 default_ = 477 default_ =
452 new tray::BluetoothDefaultView(this, status != LoginStatus::LOCKED); 478 new tray::BluetoothDefaultView(this, status != LoginStatus::LOCKED);
479 default_->Update();
453 return default_; 480 return default_;
454 } 481 }
455 482
456 views::View* TrayBluetooth::CreateDetailedView(LoginStatus status) { 483 views::View* TrayBluetooth::CreateDetailedView(LoginStatus status) {
457 if (!WmShell::Get()->system_tray_delegate()->GetBluetoothAvailable()) 484 if (!WmShell::Get()->system_tray_delegate()->GetBluetoothAvailable())
458 return NULL; 485 return NULL;
459 WmShell::Get()->RecordUserMetricsAction( 486 WmShell::Get()->RecordUserMetricsAction(
460 UMA_STATUS_AREA_DETAILED_BLUETOOTH_VIEW); 487 UMA_STATUS_AREA_DETAILED_BLUETOOTH_VIEW);
461 CHECK(detailed_ == NULL); 488 CHECK(detailed_ == NULL);
462 detailed_ = new tray::BluetoothDetailedView(this, status); 489 detailed_ = new tray::BluetoothDetailedView(this, status);
(...skipping 20 matching lines...) Expand all
483 detailed_->Update(); 510 detailed_->Update();
484 } 511 }
485 512
486 void TrayBluetooth::OnBluetoothDiscoveringChanged() { 513 void TrayBluetooth::OnBluetoothDiscoveringChanged() {
487 if (!detailed_) 514 if (!detailed_)
488 return; 515 return;
489 detailed_->Update(); 516 detailed_->Update();
490 } 517 }
491 518
492 } // namespace ash 519 } // namespace ash
OLDNEW
« no previous file with comments | « ash/BUILD.gn ('k') | ash/common/system/chromeos/network/tray_network.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698