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

Unified Diff: ash/common/system/chromeos/bluetooth/tray_bluetooth.cc

Issue 2381493005: Add bluetooth device type icons on MD system tray. (Closed)
Patch Set: Revert PS4 and fix a header file to be included. 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 side-by-side diff with in-line comments
Download patch
Index: ash/common/system/chromeos/bluetooth/tray_bluetooth.cc
diff --git a/ash/common/system/chromeos/bluetooth/tray_bluetooth.cc b/ash/common/system/chromeos/bluetooth/tray_bluetooth.cc
index c3cd91d650e401804fb35d316d98df250546cc4d..6e6042356fb4eaec6c18121d2980a2b6e49c8343 100644
--- a/ash/common/system/chromeos/bluetooth/tray_bluetooth.cc
+++ b/ash/common/system/chromeos/bluetooth/tray_bluetooth.cc
@@ -23,8 +23,10 @@
#include "grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/gfx/color_palette.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/paint_vector_icon.h"
+#include "ui/gfx/vector_icons_public.h"
#include "ui/views/controls/button/toggle_button.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
@@ -230,10 +232,12 @@ class BluetoothDetailedView : public TrayDetailsView {
}
void UpdateHeaderEntry() {
- if (toggle_bluetooth_) {
- toggle_bluetooth_->SetToggled(
- !WmShell::Get()->system_tray_delegate()->GetBluetoothEnabled());
- }
+ bool is_bluetooth_enabled =
+ WmShell::Get()->system_tray_delegate()->GetBluetoothEnabled();
+ if (toggle_)
+ toggle_->SetIsOn(is_bluetooth_enabled, false);
+ else if (toggle_bluetooth_)
+ toggle_bluetooth_->SetToggled(!is_bluetooth_enabled);
}
void UpdateDeviceScrollList() {
@@ -280,11 +284,18 @@ class BluetoothDetailedView : public TrayDetailsView {
bool enabled) {
for (size_t i = 0; i < list.size(); ++i) {
HoverHighlightView* container =
- AddScrollListItem(list[i].display_name, highlight, checked, enabled);
+ MaterialDesignController::IsSystemTrayMenuMaterial()
+ ? AddScrollListItemWithIcon(list[i].display_name, highlight,
+ checked, enabled, list[i].icon_image)
+ : AddScrollListItem(list[i].display_name, highlight, checked,
+ enabled);
device_map_[container] = list[i].address;
}
}
+ // TODO(fukino): Remove this code when material design is enabled by default,
+ // since AddScrollListItem should be used only in the old design.
+ // See crbug.com/614453".
HoverHighlightView* AddScrollListItem(const base::string16& text,
bool highlight,
bool checked,
@@ -297,6 +308,25 @@ class BluetoothDetailedView : public TrayDetailsView {
return container;
}
+ HoverHighlightView* AddScrollListItemWithIcon(const base::string16& text,
+ bool highlight,
+ bool checked,
+ bool enabled,
+ const gfx::ImageSkia& image) {
+ HoverHighlightView* container = new HoverHighlightView(this);
+ const int padding = (kMenuButtonSize - image.width()) / 2;
+ container->AddIconAndLabelCustomSize(
+ image, text, highlight,
+ image.width() + kMenuSeparatorVerticalPadding * 2, padding, padding);
+ gfx::ImageSkia check_mark =
+ CreateVectorIcon(gfx::VectorIconId::CHECK_CIRCLE, gfx::kGoogleGreen700);
+ container->AddRightIcon(check_mark, check_mark.width());
+ container->SetRightIconVisible(checked);
+ container->text_label()->SetEnabled(enabled);
+ scroll_content()->AddChildView(container);
+ return container;
+ }
+
// Add settings entries.
void AppendSettingsEntries() {
if (!WmShell::Get()->system_tray_delegate()->ShouldShowSettings())
@@ -389,9 +419,10 @@ class BluetoothDetailedView : public TrayDetailsView {
void HandleButtonPressed(views::Button* sender,
const ui::Event& event) override {
if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
- // TODO(fukino): Make the toggle button functional.
if (sender == toggle_)
- toggle_->SetIsOn(toggle_->is_on(), true);
+ WmShell::Get()->system_tray_delegate()->ToggleBluetooth();
+ else
+ NOTREACHED();
return;
}
« no previous file with comments | « no previous file | ash/common/system/tray/system_tray_delegate.h » ('j') | chrome/browser/ui/ash/system_tray_delegate_chromeos.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698