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

Side by Side Diff: ash/system/chromeos/settings/tray_settings.cc

Issue 2041233005: Moves ash::user::LoginStatus to ash/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweaks Created 4 years, 6 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/system/chromeos/settings/tray_settings.h" 5 #include "ash/system/chromeos/settings/tray_settings.h"
6 6
7 #include "ash/session/session_state_delegate.h" 7 #include "ash/session/session_state_delegate.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/system/chromeos/power/power_status.h" 9 #include "ash/system/chromeos/power/power_status.h"
10 #include "ash/system/chromeos/power/power_status_view.h" 10 #include "ash/system/chromeos/power/power_status_view.h"
(...skipping 13 matching lines...) Expand all
24 #include "ui/views/layout/box_layout.h" 24 #include "ui/views/layout/box_layout.h"
25 #include "ui/views/layout/fill_layout.h" 25 #include "ui/views/layout/fill_layout.h"
26 #include "ui/views/view.h" 26 #include "ui/views/view.h"
27 27
28 namespace ash { 28 namespace ash {
29 namespace tray { 29 namespace tray {
30 30
31 class SettingsDefaultView : public ActionableView, 31 class SettingsDefaultView : public ActionableView,
32 public PowerStatus::Observer { 32 public PowerStatus::Observer {
33 public: 33 public:
34 explicit SettingsDefaultView(user::LoginStatus status) 34 explicit SettingsDefaultView(LoginStatus status)
35 : login_status_(status), 35 : login_status_(status), label_(NULL), power_status_view_(NULL) {
36 label_(NULL),
37 power_status_view_(NULL) {
38 PowerStatus::Get()->AddObserver(this); 36 PowerStatus::Get()->AddObserver(this);
39 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, 37 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
40 ash::kTrayPopupPaddingHorizontal, 0, 38 ash::kTrayPopupPaddingHorizontal, 0,
41 ash::kTrayPopupPaddingBetweenItems)); 39 ash::kTrayPopupPaddingBetweenItems));
42 40
43 bool power_view_right_align = false; 41 bool power_view_right_align = false;
44 bool userAddingRunning = ash::Shell::GetInstance() 42 bool userAddingRunning = ash::Shell::GetInstance()
45 ->session_state_delegate() 43 ->session_state_delegate()
46 ->IsInSecondaryLoginScreen(); 44 ->IsInSecondaryLoginScreen();
47 45
48 if (login_status_ != user::LOGGED_IN_NONE && 46 if (login_status_ != LoginStatus::NOT_LOGGED_IN &&
49 login_status_ != user::LOGGED_IN_LOCKED && !userAddingRunning) { 47 login_status_ != LoginStatus::LOCKED && !userAddingRunning) {
50 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 48 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
51 views::ImageView* icon = 49 views::ImageView* icon =
52 new ash::FixedSizedImageView(0, ash::kTrayPopupItemHeight); 50 new ash::FixedSizedImageView(0, ash::kTrayPopupItemHeight);
53 icon->SetImage( 51 icon->SetImage(
54 rb.GetImageNamed(IDR_AURA_UBER_TRAY_SETTINGS).ToImageSkia()); 52 rb.GetImageNamed(IDR_AURA_UBER_TRAY_SETTINGS).ToImageSkia());
55 icon->set_id(test::kSettingsTrayItemViewId); 53 icon->set_id(test::kSettingsTrayItemViewId);
56 AddChildView(icon); 54 AddChildView(icon);
57 55
58 base::string16 text = rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_SETTINGS); 56 base::string16 text = rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_SETTINGS);
59 label_ = new views::Label(text); 57 label_ = new views::Label(text);
(...skipping 11 matching lines...) Expand all
71 } 69 }
72 70
73 ~SettingsDefaultView() override { PowerStatus::Get()->RemoveObserver(this); } 71 ~SettingsDefaultView() override { PowerStatus::Get()->RemoveObserver(this); }
74 72
75 // Overridden from ash::ActionableView. 73 // Overridden from ash::ActionableView.
76 bool PerformAction(const ui::Event& event) override { 74 bool PerformAction(const ui::Event& event) override {
77 bool userAddingRunning = ash::Shell::GetInstance() 75 bool userAddingRunning = ash::Shell::GetInstance()
78 ->session_state_delegate() 76 ->session_state_delegate()
79 ->IsInSecondaryLoginScreen(); 77 ->IsInSecondaryLoginScreen();
80 78
81 if (login_status_ == user::LOGGED_IN_NONE || 79 if (login_status_ == LoginStatus::NOT_LOGGED_IN ||
82 login_status_ == user::LOGGED_IN_LOCKED || userAddingRunning) 80 login_status_ == LoginStatus::LOCKED || userAddingRunning)
83 return false; 81 return false;
84 82
85 ash::Shell::GetInstance()->system_tray_delegate()->ShowSettings(); 83 ash::Shell::GetInstance()->system_tray_delegate()->ShowSettings();
86 return true; 84 return true;
87 } 85 }
88 86
89 // Overridden from views::View. 87 // Overridden from views::View.
90 void Layout() override { 88 void Layout() override {
91 views::View::Layout(); 89 views::View::Layout();
92 90
(...skipping 20 matching lines...) Expand all
113 return; 111 return;
114 112
115 base::string16 accessible_name = label_ ? 113 base::string16 accessible_name = label_ ?
116 label_->text() + base::ASCIIToUTF16(", ") + 114 label_->text() + base::ASCIIToUTF16(", ") +
117 PowerStatus::Get()->GetAccessibleNameString(true) : 115 PowerStatus::Get()->GetAccessibleNameString(true) :
118 PowerStatus::Get()->GetAccessibleNameString(true); 116 PowerStatus::Get()->GetAccessibleNameString(true);
119 SetAccessibleName(accessible_name); 117 SetAccessibleName(accessible_name);
120 } 118 }
121 119
122 private: 120 private:
123 user::LoginStatus login_status_; 121 LoginStatus login_status_;
124 views::Label* label_; 122 views::Label* label_;
125 ash::PowerStatusView* power_status_view_; 123 ash::PowerStatusView* power_status_view_;
126 124
127 DISALLOW_COPY_AND_ASSIGN(SettingsDefaultView); 125 DISALLOW_COPY_AND_ASSIGN(SettingsDefaultView);
128 }; 126 };
129 127
130 } // namespace tray 128 } // namespace tray
131 129
132 TraySettings::TraySettings(SystemTray* system_tray) 130 TraySettings::TraySettings(SystemTray* system_tray)
133 : SystemTrayItem(system_tray), 131 : SystemTrayItem(system_tray),
134 default_view_(NULL) { 132 default_view_(NULL) {
135 } 133 }
136 134
137 TraySettings::~TraySettings() { 135 TraySettings::~TraySettings() {
138 } 136 }
139 137
140 views::View* TraySettings::CreateTrayView(user::LoginStatus status) { 138 views::View* TraySettings::CreateTrayView(LoginStatus status) {
141 return NULL; 139 return NULL;
142 } 140 }
143 141
144 views::View* TraySettings::CreateDefaultView(user::LoginStatus status) { 142 views::View* TraySettings::CreateDefaultView(LoginStatus status) {
145 if ((status == user::LOGGED_IN_NONE || status == user::LOGGED_IN_LOCKED) && 143 if ((status == LoginStatus::NOT_LOGGED_IN || status == LoginStatus::LOCKED) &&
146 !PowerStatus::Get()->IsBatteryPresent()) 144 !PowerStatus::Get()->IsBatteryPresent())
147 return NULL; 145 return NULL;
148 if (!ash::Shell::GetInstance()->system_tray_delegate()->ShouldShowSettings()) 146 if (!ash::Shell::GetInstance()->system_tray_delegate()->ShouldShowSettings())
149 return NULL; 147 return NULL;
150 CHECK(default_view_ == NULL); 148 CHECK(default_view_ == NULL);
151 default_view_ = new tray::SettingsDefaultView(status); 149 default_view_ = new tray::SettingsDefaultView(status);
152 return default_view_; 150 return default_view_;
153 } 151 }
154 152
155 views::View* TraySettings::CreateDetailedView(user::LoginStatus status) { 153 views::View* TraySettings::CreateDetailedView(LoginStatus status) {
156 NOTIMPLEMENTED(); 154 NOTIMPLEMENTED();
157 return NULL; 155 return NULL;
158 } 156 }
159 157
160 void TraySettings::DestroyTrayView() { 158 void TraySettings::DestroyTrayView() {
161 } 159 }
162 160
163 void TraySettings::DestroyDefaultView() { 161 void TraySettings::DestroyDefaultView() {
164 default_view_ = NULL; 162 default_view_ = NULL;
165 } 163 }
166 164
167 void TraySettings::DestroyDetailedView() { 165 void TraySettings::DestroyDetailedView() {
168 } 166 }
169 167
170 void TraySettings::UpdateAfterLoginStatusChange(user::LoginStatus status) { 168 void TraySettings::UpdateAfterLoginStatusChange(LoginStatus status) {}
171 }
172 169
173 } // namespace ash 170 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698