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

Side by Side Diff: ash/common/system/tray/label_tray_view.cc

Issue 2316183003: Move a bunch of ash-only vector icons to ash/. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
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/tray/label_tray_view.h" 5 #include "ash/common/system/tray/label_tray_view.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/system/tray/hover_highlight_view.h" 8 #include "ash/common/system/tray/hover_highlight_view.h"
9 #include "ash/common/system/tray/tray_constants.h" 9 #include "ash/common/system/tray/tray_constants.h"
10 #include "ash/common/system/tray/view_click_listener.h" 10 #include "ash/common/system/tray/view_click_listener.h"
11 #include "ash/resources/vector_icons/vector_icons.h"
11 #include "grit/ash_resources.h" 12 #include "grit/ash_resources.h"
12 #include "ui/base/resource/resource_bundle.h" 13 #include "ui/base/resource/resource_bundle.h"
13 #include "ui/gfx/font.h" 14 #include "ui/gfx/font.h"
14 #include "ui/gfx/paint_vector_icon.h" 15 #include "ui/gfx/paint_vector_icon.h"
15 #include "ui/gfx/vector_icons_public.h"
16 #include "ui/views/border.h" 16 #include "ui/views/border.h"
17 #include "ui/views/controls/label.h" 17 #include "ui/views/controls/label.h"
18 #include "ui/views/layout/fill_layout.h" 18 #include "ui/views/layout/fill_layout.h"
19 19
20 namespace ash { 20 namespace ash {
21 21
22 namespace { 22 namespace {
23 23
24 // Maps a non-MD PNG resource id to its corresponding MD vector icon id. 24 // Maps a non-MD PNG resource id to its corresponding MD vector icon id.
tdanderson 2016/09/07 22:36:13 nit: "to its corresponding MD vector icon id" -> m
Evan Stade 2016/09/07 22:41:51 Done.
25 // TODO(tdanderson): Remove this once material design is enabled by 25 // TODO(tdanderson): Remove this once material design is enabled by
26 // default. See crbug.com/614453. 26 // default. See crbug.com/614453.
27 gfx::VectorIconId ResourceIdToVectorIconId(int resource_id) { 27 const gfx::VectorIcon& ResourceIdToVectorIcon(int resource_id) {
28 gfx::VectorIconId vector_id = gfx::VectorIconId::VECTOR_ICON_NONE;
29 #if defined(OS_CHROMEOS) 28 #if defined(OS_CHROMEOS)
30 switch (resource_id) { 29 switch (resource_id) {
31 case IDR_AURA_UBER_TRAY_ENTERPRISE: 30 case IDR_AURA_UBER_TRAY_ENTERPRISE:
32 return gfx::VectorIconId::SYSTEM_MENU_BUSINESS; 31 return kSystemMenuBusinessIcon;
33 case IDR_AURA_UBER_TRAY_BUBBLE_SESSION_LENGTH_LIMIT: 32 case IDR_AURA_UBER_TRAY_BUBBLE_SESSION_LENGTH_LIMIT:
34 return gfx::VectorIconId::SYSTEM_MENU_TIMER; 33 return kSystemMenuTimerIcon;
35 case IDR_AURA_UBER_TRAY_CHILD_USER: 34 case IDR_AURA_UBER_TRAY_CHILD_USER:
36 return gfx::VectorIconId::SYSTEM_MENU_CHILD_USER; 35 return kSystemMenuChildUserIcon;
37 case IDR_AURA_UBER_TRAY_SUPERVISED_USER: 36 case IDR_AURA_UBER_TRAY_SUPERVISED_USER:
38 return gfx::VectorIconId::SYSTEM_MENU_SUPERVISED_USER; 37 return kSystemMenuSupervisedUserIcon;
39 default: 38 default:
40 NOTREACHED(); 39 NOTREACHED();
41 break; 40 break;
42 } 41 }
43 #endif // defined(OS_CHROMEOS) 42 #endif // defined(OS_CHROMEOS)
44 43
45 return vector_id; 44 return gfx::kNoneIcon;
46 } 45 }
47 46
48 } // namespace 47 } // namespace
49 48
50 LabelTrayView::LabelTrayView(ViewClickListener* click_listener, 49 LabelTrayView::LabelTrayView(ViewClickListener* click_listener,
51 int icon_resource_id) 50 int icon_resource_id)
52 : click_listener_(click_listener), icon_resource_id_(icon_resource_id) { 51 : click_listener_(click_listener), icon_resource_id_(icon_resource_id) {
53 SetLayoutManager(new views::FillLayout()); 52 SetLayoutManager(new views::FillLayout());
54 SetVisible(false); 53 SetVisible(false);
55 } 54 }
(...skipping 15 matching lines...) Expand all
71 } 70 }
72 } 71 }
73 72
74 views::View* LabelTrayView::CreateChildView( 73 views::View* LabelTrayView::CreateChildView(
75 const base::string16& message) const { 74 const base::string16& message) const {
76 HoverHighlightView* child = new HoverHighlightView(click_listener_); 75 HoverHighlightView* child = new HoverHighlightView(click_listener_);
77 if (icon_resource_id_) { 76 if (icon_resource_id_) {
78 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 77 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
79 gfx::ImageSkia icon = 78 gfx::ImageSkia icon =
80 MaterialDesignController::IsSystemTrayMenuMaterial() 79 MaterialDesignController::IsSystemTrayMenuMaterial()
81 ? gfx::CreateVectorIcon(ResourceIdToVectorIconId(icon_resource_id_), 80 ? gfx::CreateVectorIcon(ResourceIdToVectorIcon(icon_resource_id_),
82 kMenuIconColor) 81 kMenuIconColor)
83 : *rb.GetImageSkiaNamed(icon_resource_id_); 82 : *rb.GetImageSkiaNamed(icon_resource_id_);
84 child->AddIconAndLabel(icon, message, false /* highlight */); 83 child->AddIconAndLabel(icon, message, false /* highlight */);
85 child->SetBorder(views::Border::CreateEmptyBorder( 84 child->SetBorder(views::Border::CreateEmptyBorder(
86 0, kTrayPopupPaddingHorizontal, 0, kTrayPopupPaddingHorizontal)); 85 0, kTrayPopupPaddingHorizontal, 0, kTrayPopupPaddingHorizontal));
87 child->text_label()->SetMultiLine(true); 86 child->text_label()->SetMultiLine(true);
88 child->text_label()->SizeToFit(kTrayNotificationContentsWidth); 87 child->text_label()->SizeToFit(kTrayNotificationContentsWidth);
89 } else { 88 } else {
90 child->AddLabel(message, gfx::ALIGN_LEFT, false /* highlight */); 89 child->AddLabel(message, gfx::ALIGN_LEFT, false /* highlight */);
91 child->text_label()->SetMultiLine(true); 90 child->text_label()->SetMultiLine(true);
92 child->text_label()->SizeToFit(kTrayNotificationContentsWidth + 91 child->text_label()->SizeToFit(kTrayNotificationContentsWidth +
93 kNotificationIconWidth); 92 kNotificationIconWidth);
94 } 93 }
95 child->text_label()->SetAllowCharacterBreak(true); 94 child->text_label()->SetAllowCharacterBreak(true);
96 child->SetExpandable(true); 95 child->SetExpandable(true);
97 child->SetVisible(true); 96 child->SetVisible(true);
98 return child; 97 return child;
99 } 98 }
100 99
101 } // namespace ash 100 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698