Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/tray_tracing.h" | 5 #include "ash/common/system/chromeos/tray_tracing.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/metrics/user_metrics_action.h" | 8 #include "ash/common/metrics/user_metrics_action.h" |
| 9 #include "ash/common/system/tray/actionable_view.h" | 9 #include "ash/common/system/tray/actionable_view.h" |
| 10 #include "ash/common/system/tray/fixed_sized_image_view.h" | 10 #include "ash/common/system/tray/fixed_sized_image_view.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 explicit DefaultTracingView(SystemTrayItem* owner) | 34 explicit DefaultTracingView(SystemTrayItem* owner) |
| 35 : ActionableView(owner, TrayPopupInkDropStyle::FILL_BOUNDS) { | 35 : ActionableView(owner, TrayPopupInkDropStyle::FILL_BOUNDS) { |
| 36 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 36 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 37 | 37 |
| 38 SetLayoutManager(new views::FillLayout); | 38 SetLayoutManager(new views::FillLayout); |
| 39 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView(); | 39 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView(); |
| 40 AddChildView(tri_view); | 40 AddChildView(tri_view); |
| 41 image_ = TrayPopupUtils::CreateMainImageView(); | 41 image_ = TrayPopupUtils::CreateMainImageView(); |
| 42 tri_view->AddView(TriView::Container::START, image_); | 42 tri_view->AddView(TriView::Container::START, image_); |
| 43 | 43 |
| 44 label_ = TrayPopupUtils::CreateDefaultLabel(); | 44 auto label = TrayPopupUtils::CreateDefaultLabel(); |
| 45 label_->SetMultiLine(true); | 45 label->SetMultiLine(true); |
| 46 label_->SetText(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_TRACING)); | 46 label->SetText(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_TRACING)); |
| 47 tri_view->AddView(TriView::Container::CENTER, label_); | 47 tri_view->AddView(TriView::Container::CENTER, label); |
| 48 | 48 |
| 49 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { | 49 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { |
| 50 UpdateStyle(); | 50 TrayPopupItemStyle style( |
| 51 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); | |
| 52 style.SetupLabel(label); | |
| 53 image_->SetImage( | |
|
tdanderson
2017/02/01 23:01:52
I think |image_| can be made a non-member as well,
Evan Stade
2017/02/02 22:49:53
Done.
| |
| 54 gfx::CreateVectorIcon(kSystemMenuTracingIcon, style.GetIconColor())); | |
| 55 | |
| 51 SetInkDropMode(InkDropHostView::InkDropMode::ON); | 56 SetInkDropMode(InkDropHostView::InkDropMode::ON); |
| 52 } else { | 57 } else { |
| 53 // The icon doesn't change in non-md. | 58 // The icon doesn't change in non-md. |
| 54 image_->SetImage( | 59 image_->SetImage( |
| 55 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_TRACING).ToImageSkia()); | 60 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_TRACING).ToImageSkia()); |
| 56 } | 61 } |
| 57 } | 62 } |
| 58 | 63 |
| 59 ~DefaultTracingView() override {} | 64 ~DefaultTracingView() override {} |
| 60 | 65 |
| 61 private: | 66 private: |
| 62 // Update text and image color based on the current theme of the system. | |
| 63 void UpdateStyle() { | |
| 64 TrayPopupItemStyle style(GetNativeTheme(), | |
| 65 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); | |
| 66 style.SetupLabel(label_); | |
| 67 image_->SetImage( | |
| 68 gfx::CreateVectorIcon(kSystemMenuTracingIcon, style.GetIconColor())); | |
| 69 } | |
| 70 | |
| 71 // ActionableView: | |
| 72 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { | |
| 73 ActionableView::OnNativeThemeChanged(theme); | |
| 74 | |
| 75 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) | |
| 76 return; | |
| 77 UpdateStyle(); | |
| 78 } | |
| 79 | |
| 80 bool PerformAction(const ui::Event& event) override { | 67 bool PerformAction(const ui::Event& event) override { |
| 81 WmShell::Get()->RecordUserMetricsAction( | 68 WmShell::Get()->RecordUserMetricsAction( |
| 82 UMA_STATUS_AREA_TRACING_DEFAULT_SELECTED); | 69 UMA_STATUS_AREA_TRACING_DEFAULT_SELECTED); |
| 83 WmShell::Get()->system_tray_controller()->ShowChromeSlow(); | 70 WmShell::Get()->system_tray_controller()->ShowChromeSlow(); |
| 84 CloseSystemBubble(); | 71 CloseSystemBubble(); |
| 85 return true; | 72 return true; |
| 86 } | 73 } |
| 87 | 74 |
| 88 views::ImageView* image_; | 75 views::ImageView* image_; |
| 89 views::Label* label_; | |
| 90 | 76 |
| 91 DISALLOW_COPY_AND_ASSIGN(DefaultTracingView); | 77 DISALLOW_COPY_AND_ASSIGN(DefaultTracingView); |
| 92 }; | 78 }; |
| 93 | 79 |
| 94 } // namespace tray | 80 } // namespace tray |
| 95 | 81 |
| 96 //////////////////////////////////////////////////////////////////////////////// | 82 //////////////////////////////////////////////////////////////////////////////// |
| 97 // ash::TrayTracing | 83 // ash::TrayTracing |
| 98 | 84 |
| 99 TrayTracing::TrayTracing(SystemTray* system_tray) | 85 TrayTracing::TrayTracing(SystemTray* system_tray) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 default_ = NULL; | 117 default_ = NULL; |
| 132 } | 118 } |
| 133 | 119 |
| 134 void TrayTracing::DestroyDetailedView() {} | 120 void TrayTracing::DestroyDetailedView() {} |
| 135 | 121 |
| 136 void TrayTracing::OnTracingModeChanged(bool value) { | 122 void TrayTracing::OnTracingModeChanged(bool value) { |
| 137 SetTrayIconVisible(value); | 123 SetTrayIconVisible(value); |
| 138 } | 124 } |
| 139 | 125 |
| 140 } // namespace ash | 126 } // namespace ash |
| OLD | NEW |