Chromium Code Reviews| 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/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/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) { |
| 72 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) { | 73 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
| 74 style()->SetFontStyle( | |
| 75 TrayPopupItemStyle::FontStyle::MAIN_PANEL_SECTION_ROW); | |
| 76 } else { | |
| 77 // The image does not need to change for non-material. | |
| 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(); | |
|
tdanderson
2016/09/12 18:51:47
I don't think you need to give this a name since y
bruthig
2016/09/15 18:56:29
Done.
| |
| 91 | |
| 85 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 92 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
| 86 SetImage(gfx::CreateVectorIcon( | 93 // Toggle the style here because there is no bluetooth enabled/disabled |
| 94 // event to observe. | |
| 95 style()->SetColorStyle( | |
| 96 enabled ? TrayPopupItemStyle::ColorStyle::ACTIVE | |
| 97 : is_bluetooth_available | |
| 98 ? TrayPopupItemStyle::ColorStyle::INACTIVE | |
| 99 : TrayPopupItemStyle::ColorStyle::DISABLED); | |
| 100 // UpdateContent() should be called due to the style change above. | |
|
tdanderson
2016/09/12 18:51:47
Did you mean to actually call UpdateContent() here
bruthig
2016/09/15 18:56:29
It will be called via TrayItemMore::OnTrayPopupIte
tdanderson
2016/09/15 19:49:33
I read the 'should' in this comment as "[you the d
| |
| 101 } else { | |
| 102 UpdateContent(); | |
| 103 } | |
| 104 } | |
| 105 | |
| 106 protected: | |
| 107 void UpdateContent() override { | |
|
tdanderson
2016/09/12 18:51:47
private seems like a better choice than protected
bruthig
2016/09/15 18:56:29
Done.
| |
| 108 TrayItemMore::UpdateContent(); | |
| 109 | |
| 110 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); | |
| 111 const bool enabled = delegate->GetBluetoothEnabled(); | |
| 112 const bool is_bluetooth_available = delegate->GetBluetoothAvailable(); | |
| 113 | |
| 114 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | |
| 115 gfx::ImageSkia image = gfx::CreateVectorIcon( | |
| 87 enabled ? kSystemMenuBluetoothIcon : kSystemMenuBluetoothDisabledIcon, | 116 enabled ? kSystemMenuBluetoothIcon : kSystemMenuBluetoothDisabledIcon, |
| 88 kMenuIconColor)); | 117 style()->GetForegroundColor()); |
| 118 SetImage(image); | |
| 89 } | 119 } |
| 90 | 120 |
| 91 if (delegate->GetBluetoothAvailable()) { | 121 if (is_bluetooth_available) { |
| 92 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 122 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 93 const base::string16 label = rb.GetLocalizedString( | 123 const base::string16 label = rb.GetLocalizedString( |
| 94 enabled ? IDS_ASH_STATUS_TRAY_BLUETOOTH_ENABLED | 124 enabled ? IDS_ASH_STATUS_TRAY_BLUETOOTH_ENABLED |
| 95 : IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED); | 125 : IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED); |
| 96 SetLabel(label); | 126 SetLabel(label); |
| 97 SetAccessibleName(label); | 127 SetAccessibleName(label); |
| 98 SetVisible(true); | 128 SetVisible(true); |
| 99 } else { | 129 } else { |
| 100 SetVisible(false); | 130 SetVisible(false); |
| 101 } | 131 } |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 detailed_->Update(); | 504 detailed_->Update(); |
| 475 } | 505 } |
| 476 | 506 |
| 477 void TrayBluetooth::OnBluetoothDiscoveringChanged() { | 507 void TrayBluetooth::OnBluetoothDiscoveringChanged() { |
| 478 if (!detailed_) | 508 if (!detailed_) |
| 479 return; | 509 return; |
| 480 detailed_->Update(); | 510 detailed_->Update(); |
| 481 } | 511 } |
| 482 | 512 |
| 483 } // namespace ash | 513 } // namespace ash |
| OLD | NEW |