OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
tdanderson
2016/09/08 16:11:02
Can you also add a BUG=637846 to the CL descriptio
bruthig
2016/09/12 13:45:34
Done.
| |
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 "grit/ash_resources.h" | 21 #include "grit/ash_resources.h" |
21 #include "grit/ash_strings.h" | 22 #include "grit/ash_strings.h" |
22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
23 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
24 #include "ui/gfx/image/image.h" | 25 #include "ui/gfx/image/image.h" |
25 #include "ui/gfx/paint_vector_icon.h" | 26 #include "ui/gfx/paint_vector_icon.h" |
26 #include "ui/gfx/vector_icons_public.h" | 27 #include "ui/gfx/vector_icons_public.h" |
27 #include "ui/views/controls/image_view.h" | 28 #include "ui/views/controls/image_view.h" |
28 #include "ui/views/controls/label.h" | 29 #include "ui/views/controls/label.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 } | 63 } |
63 } | 64 } |
64 } | 65 } |
65 | 66 |
66 } // namespace | 67 } // namespace |
67 | 68 |
68 class BluetoothDefaultView : public TrayItemMore { | 69 class BluetoothDefaultView : public TrayItemMore { |
69 public: | 70 public: |
70 BluetoothDefaultView(SystemTrayItem* owner, bool show_more) | 71 BluetoothDefaultView(SystemTrayItem* owner, bool show_more) |
71 : TrayItemMore(owner, show_more) { | 72 : TrayItemMore(owner, show_more) { |
73 SetStyle(base::MakeUnique<TrayPopupItemStyle>( | |
tdanderson
2016/09/08 16:11:02
Put this behind an if (is_material) ?
bruthig
2016/09/12 13:45:33
Done.
| |
74 GetNativeTheme(), | |
75 TrayPopupItemStyle::FontStyle::MAIN_PANEL_SECTION_ROW)); | |
76 // The image does not need to change for non-material. | |
72 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) { | 77 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) { |
73 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 78 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
74 SetImage( | 79 SetImage( |
75 *bundle.GetImageNamed(IDR_AURA_UBER_TRAY_BLUETOOTH).ToImageSkia()); | 80 *bundle.GetImageNamed(IDR_AURA_UBER_TRAY_BLUETOOTH).ToImageSkia()); |
76 } | 81 } |
77 Update(); | 82 Update(); |
78 } | 83 } |
79 | 84 |
80 ~BluetoothDefaultView() override {} | 85 ~BluetoothDefaultView() override {} |
81 | 86 |
82 void Update() { | 87 void Update() { |
83 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); | 88 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); |
84 const bool enabled = delegate->GetBluetoothEnabled(); | 89 const bool enabled = delegate->GetBluetoothEnabled(); |
90 const bool is_bluetooth_available = delegate->GetBluetoothAvailable(); | |
91 | |
92 // Toggle the style here because there is no bluetooth enabled/disabled | |
93 // event to observe. | |
94 style()->SetColorStyle( | |
95 enabled ? TrayPopupItemStyle::ColorStyle::ACTIVE | |
96 : is_bluetooth_available | |
97 ? TrayPopupItemStyle::ColorStyle::INACTIVE | |
98 : TrayPopupItemStyle::ColorStyle::DISABLED); | |
99 | |
85 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 100 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
86 gfx::VectorIconId icon_id = | 101 gfx::VectorIconId icon_id = |
87 enabled ? gfx::VectorIconId::SYSTEM_MENU_BLUETOOTH | 102 enabled ? gfx::VectorIconId::SYSTEM_MENU_BLUETOOTH |
88 : gfx::VectorIconId::SYSTEM_MENU_BLUETOOTH_DISABLED; | 103 : gfx::VectorIconId::SYSTEM_MENU_BLUETOOTH_DISABLED; |
89 SetImage(gfx::CreateVectorIcon(icon_id, kMenuIconColor)); | 104 gfx::ImageSkia image = |
105 gfx::CreateVectorIcon(icon_id, style()->GetForegroundColor()); | |
106 SetImage(image); | |
90 } | 107 } |
91 | 108 |
92 if (delegate->GetBluetoothAvailable()) { | 109 if (is_bluetooth_available) { |
93 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 110 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
94 const base::string16 label = rb.GetLocalizedString( | 111 const base::string16 label = rb.GetLocalizedString( |
95 enabled ? IDS_ASH_STATUS_TRAY_BLUETOOTH_ENABLED | 112 enabled ? IDS_ASH_STATUS_TRAY_BLUETOOTH_ENABLED |
96 : IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED); | 113 : IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED); |
97 SetLabel(label); | 114 SetLabel(label); |
98 SetAccessibleName(label); | 115 SetAccessibleName(label); |
99 SetVisible(true); | 116 SetVisible(true); |
100 } else { | 117 } else { |
101 SetVisible(false); | 118 SetVisible(false); |
102 } | 119 } |
103 } | 120 } |
104 | 121 |
122 // TrayItemMore: | |
123 void OnTrayPopupItemStyleChanged() override { | |
124 Update(); | |
125 TrayItemMore::OnTrayPopupItemStyleChanged(); | |
126 } | |
127 | |
105 private: | 128 private: |
106 DISALLOW_COPY_AND_ASSIGN(BluetoothDefaultView); | 129 DISALLOW_COPY_AND_ASSIGN(BluetoothDefaultView); |
107 }; | 130 }; |
108 | 131 |
109 class BluetoothDetailedView : public TrayDetailsView { | 132 class BluetoothDetailedView : public TrayDetailsView { |
110 public: | 133 public: |
111 BluetoothDetailedView(SystemTrayItem* owner, LoginStatus login) | 134 BluetoothDetailedView(SystemTrayItem* owner, LoginStatus login) |
112 : TrayDetailsView(owner), | 135 : TrayDetailsView(owner), |
113 login_(login), | 136 login_(login), |
114 manage_devices_(nullptr), | 137 manage_devices_(nullptr), |
138 throbber_(nullptr), | |
115 toggle_bluetooth_(nullptr), | 139 toggle_bluetooth_(nullptr), |
116 enable_bluetooth_(nullptr) { | 140 enable_bluetooth_(nullptr) { |
117 CreateItems(); | 141 CreateItems(); |
118 } | 142 } |
119 | 143 |
120 ~BluetoothDetailedView() override { | 144 ~BluetoothDetailedView() override { |
121 // Stop discovering bluetooth devices when exiting BT detailed view. | 145 // Stop discovering bluetooth devices when exiting BT detailed view. |
122 BluetoothStopDiscovering(); | 146 BluetoothStopDiscovering(); |
123 } | 147 } |
124 | 148 |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 detailed_->Update(); | 498 detailed_->Update(); |
475 } | 499 } |
476 | 500 |
477 void TrayBluetooth::OnBluetoothDiscoveringChanged() { | 501 void TrayBluetooth::OnBluetoothDiscoveringChanged() { |
478 if (!detailed_) | 502 if (!detailed_) |
479 return; | 503 return; |
480 detailed_->Update(); | 504 detailed_->Update(); |
481 } | 505 } |
482 | 506 |
483 } // namespace ash | 507 } // namespace ash |
OLD | NEW |