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