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

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

Issue 2316183003: Move a bunch of ash-only vector icons to ash/. (Closed)
Patch Set: drop the "id". Just "icon". It's cleaner. 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
« no previous file with comments | « ash/common/system/tray/label_tray_view.cc ('k') | ash/common/system/tray/tray_item_more.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/tray_image_item.h" 5 #include "ash/common/system/tray/tray_image_item.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/shelf/wm_shelf_util.h" 8 #include "ash/common/shelf/wm_shelf_util.h"
9 #include "ash/common/system/tray/system_tray.h" 9 #include "ash/common/system/tray/system_tray.h"
10 #include "ash/common/system/tray/tray_constants.h" 10 #include "ash/common/system/tray/tray_constants.h"
11 #include "ash/common/system/tray/tray_item_view.h" 11 #include "ash/common/system/tray/tray_item_view.h"
12 #include "ash/common/system/tray/tray_utils.h" 12 #include "ash/common/system/tray/tray_utils.h"
13 #include "ash/resources/vector_icons/vector_icons.h"
13 #include "grit/ash_resources.h" 14 #include "grit/ash_resources.h"
14 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/gfx/image/image.h" 16 #include "ui/gfx/image/image.h"
16 #include "ui/gfx/paint_vector_icon.h" 17 #include "ui/gfx/paint_vector_icon.h"
17 #include "ui/gfx/vector_icons_public.h"
18 #include "ui/views/controls/image_view.h" 18 #include "ui/views/controls/image_view.h"
19 #include "ui/views/layout/box_layout.h" 19 #include "ui/views/layout/box_layout.h"
20 20
21 namespace ash { 21 namespace ash {
22 22
23 namespace { 23 namespace {
24 24
25 // Maps a non-MD PNG resource id to its corresponding MD vector icon id. 25 // Maps a non-MD PNG resource id to its corresponding MD vector icon.
26 // TODO(tdanderson): Remove this once material design is enabled by 26 // TODO(tdanderson): Remove this once material design is enabled by
27 // default. See crbug.com/614453. 27 // default. See crbug.com/614453.
28 gfx::VectorIconId ResourceIdToVectorIconId(int resource_id) { 28 const gfx::VectorIcon& ResourceIdToVectorIcon(int resource_id) {
29 gfx::VectorIconId vector_id = gfx::VectorIconId::VECTOR_ICON_NONE;
30 switch (resource_id) { 29 switch (resource_id) {
31 case IDR_AURA_UBER_TRAY_ACCESSIBILITY: 30 case IDR_AURA_UBER_TRAY_ACCESSIBILITY:
32 return gfx::VectorIconId::SYSTEM_TRAY_ACCESSIBILITY; 31 return kSystemTrayAccessibilityIcon;
33 case IDR_AURA_UBER_TRAY_UPDATE: 32 case IDR_AURA_UBER_TRAY_UPDATE:
34 return gfx::VectorIconId::SYSTEM_TRAY_UPDATE; 33 return kSystemTrayUpdateIcon;
35 case IDR_AURA_UBER_TRAY_VOLUME_MUTE: 34 case IDR_AURA_UBER_TRAY_VOLUME_MUTE:
36 return gfx::VectorIconId::SYSTEM_TRAY_VOLUME_MUTE; 35 return kSystemTrayVolumeMuteIcon;
37 #if defined(OS_CHROMEOS) 36 #if defined(OS_CHROMEOS)
38 case IDR_AURA_UBER_TRAY_AUTO_ROTATION_LOCKED: 37 case IDR_AURA_UBER_TRAY_AUTO_ROTATION_LOCKED:
39 return gfx::VectorIconId::SYSTEM_TRAY_ROTATION_LOCK_LOCKED; 38 return kSystemTrayRotationLockLockedIcon;
40 case IDR_AURA_UBER_TRAY_CAPS_LOCK: 39 case IDR_AURA_UBER_TRAY_CAPS_LOCK:
41 return gfx::VectorIconId::SYSTEM_TRAY_CAPS_LOCK; 40 return kSystemTrayCapsLockIcon;
42 case IDR_AURA_UBER_TRAY_TRACING: 41 case IDR_AURA_UBER_TRAY_TRACING:
43 // TODO(tdanderson): Update the icon used for tracing or remove it from 42 // TODO(tdanderson): Update the icon used for tracing or remove it from
44 // the system tray. See crbug.com/625691. 43 // the system tray. See crbug.com/625691.
45 return gfx::VectorIconId::CODE; 44 return kSystemMenuTimerIcon;
46 #endif 45 #endif
47 default: 46 default:
48 NOTREACHED(); 47 NOTREACHED();
49 break; 48 break;
50 } 49 }
51 50
52 return vector_id; 51 return gfx::kNoneIcon;
53 } 52 }
54 53
55 } // namespace 54 } // namespace
56 55
57 TrayImageItem::TrayImageItem(SystemTray* system_tray, 56 TrayImageItem::TrayImageItem(SystemTray* system_tray,
58 int resource_id, 57 int resource_id,
59 UmaType uma_type) 58 UmaType uma_type)
60 : SystemTrayItem(system_tray, uma_type), 59 : SystemTrayItem(system_tray, uma_type),
61 resource_id_(resource_id), 60 resource_id_(resource_id),
62 icon_color_(kTrayIconColor), 61 icon_color_(kTrayIconColor),
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 tray_view_->SetLayoutManager(new views::BoxLayout(layout, 0, 0, 0)); 118 tray_view_->SetLayoutManager(new views::BoxLayout(layout, 0, 0, 0));
120 tray_view_->Layout(); 119 tray_view_->Layout();
121 } 120 }
122 121
123 void TrayImageItem::UpdateImageOnImageView() { 122 void TrayImageItem::UpdateImageOnImageView() {
124 if (!tray_view_) 123 if (!tray_view_)
125 return; 124 return;
126 125
127 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { 126 if (MaterialDesignController::UseMaterialDesignSystemIcons()) {
128 tray_view_->image_view()->SetImage(gfx::CreateVectorIcon( 127 tray_view_->image_view()->SetImage(gfx::CreateVectorIcon(
129 ResourceIdToVectorIconId(resource_id_), kTrayIconSize, icon_color_)); 128 ResourceIdToVectorIcon(resource_id_), kTrayIconSize, icon_color_));
130 } else { 129 } else {
131 tray_view_->image_view()->SetImage(ui::ResourceBundle::GetSharedInstance() 130 tray_view_->image_view()->SetImage(ui::ResourceBundle::GetSharedInstance()
132 .GetImageNamed(resource_id_) 131 .GetImageNamed(resource_id_)
133 .ToImageSkia()); 132 .ToImageSkia());
134 } 133 }
135 } 134 }
136 135
137 } // namespace ash 136 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/label_tray_view.cc ('k') | ash/common/system/tray/tray_item_more.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698