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

Side by Side Diff: ash/system/chromeos/rotation/tray_rotation_lock.cc

Issue 2700653002: [Ash MD] Remove pre-MD code from TrayImageItem and subclasses (Closed)
Patch Set: Created 3 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/system/chromeos/rotation/tray_rotation_lock.h" 5 #include "ash/system/chromeos/rotation/tray_rotation_lock.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/system/tray/system_tray.h" 7 #include "ash/common/system/tray/system_tray.h"
9 #include "ash/common/system/tray/tray_constants.h" 8 #include "ash/common/system/tray/tray_constants.h"
10 #include "ash/common/system/tray/tray_item_more.h" 9 #include "ash/common/system/tray/tray_item_more.h"
11 #include "ash/common/system/tray/tray_popup_item_style.h" 10 #include "ash/common/system/tray/tray_popup_item_style.h"
12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 11 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
13 #include "ash/common/wm_shell.h" 12 #include "ash/common/wm_shell.h"
14 #include "ash/display/screen_orientation_controller_chromeos.h" 13 #include "ash/display/screen_orientation_controller_chromeos.h"
15 #include "ash/resources/vector_icons/vector_icons.h" 14 #include "ash/resources/vector_icons/vector_icons.h"
16 #include "ash/shell.h" 15 #include "ash/shell.h"
17 #include "grit/ash_resources.h"
18 #include "grit/ash_strings.h" 16 #include "grit/ash_strings.h"
19 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/display/display.h" 18 #include "ui/display/display.h"
22 #include "ui/gfx/paint_vector_icon.h" 19 #include "ui/gfx/paint_vector_icon.h"
23 20
24 namespace ash { 21 namespace ash {
25 22
26 namespace tray { 23 namespace tray {
27 24
28 // Extends TrayItemMore, however does not make use of the chevron, nor of the 25 // Extends TrayItemMore, however does not make use of the chevron, nor of the
29 // DetailedView. This was chosen over ActionableView in order to reuse the 26 // DetailedView. This was chosen over ActionableView in order to reuse the
30 // layout and styling of labels and images. This allows RotationLockDefaultView 27 // layout and styling of labels and images. This allows RotationLockDefaultView
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 79 }
83 80
84 void RotationLockDefaultView::UpdateStyle() { 81 void RotationLockDefaultView::UpdateStyle() {
85 TrayItemMore::UpdateStyle(); 82 TrayItemMore::UpdateStyle();
86 UpdateImage(); 83 UpdateImage();
87 } 84 }
88 85
89 void RotationLockDefaultView::UpdateImage() { 86 void RotationLockDefaultView::UpdateImage() {
90 const bool rotation_locked = 87 const bool rotation_locked =
91 Shell::GetInstance()->screen_orientation_controller()->rotation_locked(); 88 Shell::GetInstance()->screen_orientation_controller()->rotation_locked();
92 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { 89 std::unique_ptr<TrayPopupItemStyle> style = CreateStyle();
93 std::unique_ptr<TrayPopupItemStyle> style = CreateStyle(); 90 SetImage(gfx::CreateVectorIcon(rotation_locked
94 SetImage(gfx::CreateVectorIcon(rotation_locked 91 ? kSystemMenuRotationLockLockedIcon
95 ? kSystemMenuRotationLockLockedIcon 92 : kSystemMenuRotationLockAutoIcon,
96 : kSystemMenuRotationLockAutoIcon, 93 kMenuIconSize, style->GetIconColor()));
97 kMenuIconSize, style->GetIconColor()));
98 } else {
99 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
100 const int resource_id = rotation_locked
101 ? IDR_AURA_UBER_TRAY_AUTO_ROTATION_LOCKED_DARK
102 : IDR_AURA_UBER_TRAY_AUTO_ROTATION_DARK;
103 SetImage(*bundle.GetImageNamed(resource_id).ToImageSkia());
104 }
105
106 base::string16 label = l10n_util::GetStringUTF16( 94 base::string16 label = l10n_util::GetStringUTF16(
107 rotation_locked ? IDS_ASH_STATUS_TRAY_ROTATION_LOCK_LOCKED 95 rotation_locked ? IDS_ASH_STATUS_TRAY_ROTATION_LOCK_LOCKED
108 : IDS_ASH_STATUS_TRAY_ROTATION_LOCK_AUTO); 96 : IDS_ASH_STATUS_TRAY_ROTATION_LOCK_AUTO);
109 SetLabel(label); 97 SetLabel(label);
110 SetAccessibleName(label); 98 SetAccessibleName(label);
111 } 99 }
112 100
113 } // namespace tray 101 } // namespace tray
114 102
115 TrayRotationLock::TrayRotationLock(SystemTray* system_tray) 103 TrayRotationLock::TrayRotationLock(SystemTray* system_tray)
116 : TrayImageItem(system_tray, 104 : TrayImageItem(system_tray,
117 IDR_AURA_UBER_TRAY_AUTO_ROTATION_LOCKED, 105 kSystemTrayRotationLockLockedIcon,
118 UMA_ROTATION_LOCK), 106 UMA_ROTATION_LOCK),
119 observing_rotation_(false), 107 observing_rotation_(false),
120 observing_shell_(true) { 108 observing_shell_(true) {
121 WmShell::Get()->AddShellObserver(this); 109 WmShell::Get()->AddShellObserver(this);
122 } 110 }
123 111
124 TrayRotationLock::~TrayRotationLock() { 112 TrayRotationLock::~TrayRotationLock() {
125 StopObservingShell(); 113 StopObservingShell();
126 } 114 }
127 115
128 void TrayRotationLock::OnRotationLockChanged(bool rotation_locked) { 116 void TrayRotationLock::OnRotationLockChanged(bool rotation_locked) {
129 tray_view()->SetVisible(ShouldBeVisible()); 117 tray_view()->SetVisible(ShouldBeVisible());
130 } 118 }
131 119
132 views::View* TrayRotationLock::CreateDefaultView(LoginStatus status) { 120 views::View* TrayRotationLock::CreateDefaultView(LoginStatus status) {
133 if (OnPrimaryDisplay()) 121 if (OnPrimaryDisplay())
134 return new tray::RotationLockDefaultView(this); 122 return new tray::RotationLockDefaultView(this);
135 return NULL; 123 return nullptr;
136 } 124 }
137 125
138 void TrayRotationLock::OnMaximizeModeStarted() { 126 void TrayRotationLock::OnMaximizeModeStarted() {
139 tray_view()->SetVisible( 127 tray_view()->SetVisible(
140 Shell::GetInstance()->screen_orientation_controller()->rotation_locked()); 128 Shell::GetInstance()->screen_orientation_controller()->rotation_locked());
141 Shell::GetInstance()->screen_orientation_controller()->AddObserver(this); 129 Shell::GetInstance()->screen_orientation_controller()->AddObserver(this);
142 observing_rotation_ = true; 130 observing_rotation_ = true;
143 } 131 }
144 132
145 void TrayRotationLock::OnMaximizeModeEnded() { 133 void TrayRotationLock::OnMaximizeModeEnded() {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 173 }
186 174
187 void TrayRotationLock::StopObservingShell() { 175 void TrayRotationLock::StopObservingShell() {
188 if (!observing_shell_) 176 if (!observing_shell_)
189 return; 177 return;
190 WmShell::Get()->RemoveShellObserver(this); 178 WmShell::Get()->RemoveShellObserver(this);
191 observing_shell_ = false; 179 observing_shell_ = false;
192 } 180 }
193 181
194 } // namespace ash 182 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698