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/screen_security/screen_tray_item.h" | 5 #include "ash/common/system/chromeos/screen_security/screen_tray_item.h" |
6 | 6 |
| 7 #include "ash/common/material_design/material_design_controller.h" |
7 #include "ash/common/shelf/wm_shelf_util.h" | 8 #include "ash/common/shelf/wm_shelf_util.h" |
8 #include "ash/common/system/tray/fixed_sized_image_view.h" | 9 #include "ash/common/system/tray/fixed_sized_image_view.h" |
9 #include "ash/common/system/tray/tray_constants.h" | 10 #include "ash/common/system/tray/tray_constants.h" |
| 11 #include "grit/ash_resources.h" |
10 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
| 13 #include "ui/gfx/paint_vector_icon.h" |
| 14 #include "ui/gfx/vector_icons_public.h" |
11 #include "ui/message_center/message_center.h" | 15 #include "ui/message_center/message_center.h" |
12 #include "ui/views/controls/label.h" | 16 #include "ui/views/controls/label.h" |
13 #include "ui/views/layout/box_layout.h" | 17 #include "ui/views/layout/box_layout.h" |
14 | 18 |
15 namespace { | 19 namespace { |
16 const int kStopButtonRightPadding = 18; | 20 const int kStopButtonRightPadding = 18; |
17 } // namespace | 21 } // namespace |
18 | 22 |
19 namespace ash { | 23 namespace ash { |
20 namespace tray { | 24 namespace tray { |
21 | 25 |
22 // ScreenTrayView implementations. | 26 // ScreenTrayView implementations. |
23 ScreenTrayView::ScreenTrayView(ScreenTrayItem* screen_tray_item, int icon_id) | 27 ScreenTrayView::ScreenTrayView(ScreenTrayItem* screen_tray_item) |
24 : TrayItemView(screen_tray_item), screen_tray_item_(screen_tray_item) { | 28 : TrayItemView(screen_tray_item), screen_tray_item_(screen_tray_item) { |
25 CreateImageView(); | 29 CreateImageView(); |
26 image_view()->SetImage(ui::ResourceBundle::GetSharedInstance() | 30 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { |
27 .GetImageNamed(icon_id) | 31 image_view()->SetImage(gfx::CreateVectorIcon( |
28 .ToImageSkia()); | 32 gfx::VectorIconId::SYSTEM_TRAY_SCREEN_SHARE, kTrayIconColor)); |
29 | 33 } else { |
| 34 image_view()->SetImage(ui::ResourceBundle::GetSharedInstance() |
| 35 .GetImageNamed(IDR_AURA_UBER_TRAY_SCREENSHARE) |
| 36 .ToImageSkia()); |
| 37 } |
30 Update(); | 38 Update(); |
31 } | 39 } |
32 | 40 |
33 ScreenTrayView::~ScreenTrayView() {} | 41 ScreenTrayView::~ScreenTrayView() {} |
34 | 42 |
35 void ScreenTrayView::Update() { | 43 void ScreenTrayView::Update() { |
36 SetVisible(screen_tray_item_->is_started()); | 44 SetVisible(screen_tray_item_->is_started()); |
37 } | 45 } |
38 | 46 |
39 // ScreenStatusView implementations. | 47 // ScreenStatusView implementations. |
40 ScreenStatusView::ScreenStatusView(ScreenTrayItem* screen_tray_item, | 48 ScreenStatusView::ScreenStatusView(ScreenTrayItem* screen_tray_item, |
41 int icon_id, | |
42 const base::string16& label_text, | 49 const base::string16& label_text, |
43 const base::string16& stop_button_text) | 50 const base::string16& stop_button_text) |
44 : screen_tray_item_(screen_tray_item), | 51 : screen_tray_item_(screen_tray_item), |
45 icon_(NULL), | 52 icon_(NULL), |
46 label_(NULL), | 53 label_(NULL), |
47 stop_button_(NULL), | 54 stop_button_(NULL), |
48 icon_id_(icon_id), | |
49 label_text_(label_text), | 55 label_text_(label_text), |
50 stop_button_text_(stop_button_text) { | 56 stop_button_text_(stop_button_text) { |
51 CreateItems(); | 57 CreateItems(); |
52 Update(); | 58 Update(); |
53 } | 59 } |
54 | 60 |
55 ScreenStatusView::~ScreenStatusView() {} | 61 ScreenStatusView::~ScreenStatusView() {} |
56 | 62 |
57 void ScreenStatusView::Layout() { | 63 void ScreenStatusView::Layout() { |
58 views::View::Layout(); | 64 views::View::Layout(); |
(...skipping 16 matching lines...) Expand all Loading... |
75 | 81 |
76 void ScreenStatusView::ButtonPressed(views::Button* sender, | 82 void ScreenStatusView::ButtonPressed(views::Button* sender, |
77 const ui::Event& event) { | 83 const ui::Event& event) { |
78 DCHECK(sender == stop_button_); | 84 DCHECK(sender == stop_button_); |
79 screen_tray_item_->Stop(); | 85 screen_tray_item_->Stop(); |
80 screen_tray_item_->RecordStoppedFromDefaultViewMetric(); | 86 screen_tray_item_->RecordStoppedFromDefaultViewMetric(); |
81 } | 87 } |
82 | 88 |
83 void ScreenStatusView::CreateItems() { | 89 void ScreenStatusView::CreateItems() { |
84 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); | 90 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); |
85 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | |
86 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, | 91 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, |
87 kTrayPopupPaddingHorizontal, 0, | 92 kTrayPopupPaddingHorizontal, 0, |
88 kTrayPopupPaddingBetweenItems)); | 93 kTrayPopupPaddingBetweenItems)); |
| 94 |
89 icon_ = new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); | 95 icon_ = new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); |
90 icon_->SetImage(bundle.GetImageNamed(icon_id_).ToImageSkia()); | 96 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
| 97 icon_->SetImage(gfx::CreateVectorIcon( |
| 98 gfx::VectorIconId::SYSTEM_MENU_SCREEN_SHARE, kMenuIconColor)); |
| 99 } else { |
| 100 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 101 icon_->SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_SCREENSHARE_DARK) |
| 102 .ToImageSkia()); |
| 103 } |
91 AddChildView(icon_); | 104 AddChildView(icon_); |
| 105 |
92 label_ = new views::Label; | 106 label_ = new views::Label; |
93 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 107 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
94 label_->SetMultiLine(true); | 108 label_->SetMultiLine(true); |
95 label_->SetText(label_text_); | 109 label_->SetText(label_text_); |
96 AddChildView(label_); | 110 AddChildView(label_); |
97 | 111 |
98 stop_button_ = new TrayPopupLabelButton(this, stop_button_text_); | 112 stop_button_ = new TrayPopupLabelButton(this, stop_button_text_); |
99 AddChildView(stop_button_); | 113 AddChildView(stop_button_); |
100 } | 114 } |
101 | 115 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 201 |
188 // Center the item dependent on the orientation of the shelf. | 202 // Center the item dependent on the orientation of the shelf. |
189 views::BoxLayout::Orientation layout = IsHorizontalAlignment(alignment) | 203 views::BoxLayout::Orientation layout = IsHorizontalAlignment(alignment) |
190 ? views::BoxLayout::kHorizontal | 204 ? views::BoxLayout::kHorizontal |
191 : views::BoxLayout::kVertical; | 205 : views::BoxLayout::kVertical; |
192 tray_view_->SetLayoutManager(new views::BoxLayout(layout, 0, 0, 0)); | 206 tray_view_->SetLayoutManager(new views::BoxLayout(layout, 0, 0, 0)); |
193 tray_view_->Layout(); | 207 tray_view_->Layout(); |
194 } | 208 } |
195 | 209 |
196 } // namespace ash | 210 } // namespace ash |
OLD | NEW |