OLD | NEW |
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 64 } |
65 | 65 |
66 if (PowerStatus::Get()->IsBatteryPresent()) { | 66 if (PowerStatus::Get()->IsBatteryPresent()) { |
67 power_status_view_ = new ash::PowerStatusView( | 67 power_status_view_ = new ash::PowerStatusView( |
68 ash::PowerStatusView::VIEW_DEFAULT, power_view_right_align); | 68 ash::PowerStatusView::VIEW_DEFAULT, power_view_right_align); |
69 AddChildView(power_status_view_); | 69 AddChildView(power_status_view_); |
70 OnPowerStatusChanged(); | 70 OnPowerStatusChanged(); |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 virtual ~SettingsDefaultView() { | 74 ~SettingsDefaultView() override { PowerStatus::Get()->RemoveObserver(this); } |
75 PowerStatus::Get()->RemoveObserver(this); | |
76 } | |
77 | 75 |
78 // Overridden from ash::ActionableView. | 76 // Overridden from ash::ActionableView. |
79 virtual bool PerformAction(const ui::Event& event) override { | 77 bool PerformAction(const ui::Event& event) override { |
80 bool userAddingRunning = ash::Shell::GetInstance() | 78 bool userAddingRunning = ash::Shell::GetInstance() |
81 ->session_state_delegate() | 79 ->session_state_delegate() |
82 ->IsInSecondaryLoginScreen(); | 80 ->IsInSecondaryLoginScreen(); |
83 | 81 |
84 if (login_status_ == user::LOGGED_IN_NONE || | 82 if (login_status_ == user::LOGGED_IN_NONE || |
85 login_status_ == user::LOGGED_IN_LOCKED || userAddingRunning) | 83 login_status_ == user::LOGGED_IN_LOCKED || userAddingRunning) |
86 return false; | 84 return false; |
87 | 85 |
88 ash::Shell::GetInstance()->system_tray_delegate()->ShowSettings(); | 86 ash::Shell::GetInstance()->system_tray_delegate()->ShowSettings(); |
89 return true; | 87 return true; |
90 } | 88 } |
91 | 89 |
92 // Overridden from views::View. | 90 // Overridden from views::View. |
93 virtual void Layout() override { | 91 void Layout() override { |
94 views::View::Layout(); | 92 views::View::Layout(); |
95 | 93 |
96 if (label_ && power_status_view_) { | 94 if (label_ && power_status_view_) { |
97 // Let the box-layout do the layout first. Then move power_status_view_ | 95 // Let the box-layout do the layout first. Then move power_status_view_ |
98 // to right align if it is created. | 96 // to right align if it is created. |
99 gfx::Size size = power_status_view_->GetPreferredSize(); | 97 gfx::Size size = power_status_view_->GetPreferredSize(); |
100 gfx::Rect bounds(size); | 98 gfx::Rect bounds(size); |
101 bounds.set_x(width() - size.width() - ash::kTrayPopupPaddingBetweenItems); | 99 bounds.set_x(width() - size.width() - ash::kTrayPopupPaddingBetweenItems); |
102 bounds.set_y((height() - size.height()) / 2); | 100 bounds.set_y((height() - size.height()) / 2); |
103 power_status_view_->SetBoundsRect(bounds); | 101 power_status_view_->SetBoundsRect(bounds); |
104 } | 102 } |
105 } | 103 } |
106 | 104 |
107 // Overridden from views::View. | 105 // Overridden from views::View. |
108 virtual void ChildPreferredSizeChanged(views::View* child) override { | 106 void ChildPreferredSizeChanged(views::View* child) override { |
109 views::View::ChildPreferredSizeChanged(child); | 107 views::View::ChildPreferredSizeChanged(child); |
110 Layout(); | 108 Layout(); |
111 } | 109 } |
112 | 110 |
113 // Overridden from PowerStatus::Observer. | 111 // Overridden from PowerStatus::Observer. |
114 virtual void OnPowerStatusChanged() override { | 112 void OnPowerStatusChanged() override { |
115 if (!PowerStatus::Get()->IsBatteryPresent()) | 113 if (!PowerStatus::Get()->IsBatteryPresent()) |
116 return; | 114 return; |
117 | 115 |
118 base::string16 accessible_name = label_ ? | 116 base::string16 accessible_name = label_ ? |
119 label_->text() + base::ASCIIToUTF16(", ") + | 117 label_->text() + base::ASCIIToUTF16(", ") + |
120 PowerStatus::Get()->GetAccessibleNameString(true) : | 118 PowerStatus::Get()->GetAccessibleNameString(true) : |
121 PowerStatus::Get()->GetAccessibleNameString(true); | 119 PowerStatus::Get()->GetAccessibleNameString(true); |
122 SetAccessibleName(accessible_name); | 120 SetAccessibleName(accessible_name); |
123 } | 121 } |
124 | 122 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 default_view_ = NULL; | 165 default_view_ = NULL; |
168 } | 166 } |
169 | 167 |
170 void TraySettings::DestroyDetailedView() { | 168 void TraySettings::DestroyDetailedView() { |
171 } | 169 } |
172 | 170 |
173 void TraySettings::UpdateAfterLoginStatusChange(user::LoginStatus status) { | 171 void TraySettings::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
174 } | 172 } |
175 | 173 |
176 } // namespace ash | 174 } // namespace ash |
OLD | NEW |