| 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/common/system/chromeos/settings/tray_settings.h" | 5 #include "ash/common/system/chromeos/settings/tray_settings.h" |
| 6 | 6 |
| 7 #include "ash/common/session/session_state_delegate.h" | 7 #include "ash/common/session/session_state_delegate.h" |
| 8 #include "ash/common/system/chromeos/power/power_status.h" | 8 #include "ash/common/system/chromeos/power/power_status.h" |
| 9 #include "ash/common/system/chromeos/power/power_status_view.h" | 9 #include "ash/common/system/chromeos/power/power_status_view.h" |
| 10 #include "ash/common/system/tray/actionable_view.h" | 10 #include "ash/common/system/tray/actionable_view.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 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(LoginStatus status) | 34 explicit SettingsDefaultView(LoginStatus status) |
| 35 : login_status_(status), label_(NULL), power_status_view_(NULL) { | 35 : login_status_(status), label_(NULL), power_status_view_(NULL) { |
| 36 PowerStatus::Get()->AddObserver(this); | 36 PowerStatus::Get()->AddObserver(this); |
| 37 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, | 37 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, |
| 38 ash::kTrayPopupPaddingHorizontal, 0, | 38 ash::kTrayPopupPaddingHorizontal, 0, |
| 39 ash::kTrayPopupPaddingBetweenItems)); | 39 ash::kTrayPopupPaddingBetweenItems)); |
| 40 | 40 |
| 41 bool power_view_right_align = false; | 41 bool power_view_right_align = false; |
| 42 if (login_status_ != LoginStatus::NOT_LOGGED_IN && | 42 if (login_status_ != LoginStatus::NOT_LOGGED_IN && |
| 43 login_status_ != LoginStatus::LOCKED && | 43 login_status_ != LoginStatus::LOCKED && |
| 44 !WmShell::Get() | 44 !WmShell::Get() |
| 45 ->GetSessionStateDelegate() | 45 ->GetSessionStateDelegate() |
| 46 ->IsInSecondaryLoginScreen()) { | 46 ->IsInSecondaryLoginScreen()) { |
| 47 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 47 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 48 views::ImageView* icon = | 48 views::ImageView* icon = |
| 49 new ash::FixedSizedImageView(0, ash::kTrayPopupItemHeight); | 49 new ash::FixedSizedImageView(0, ash::kTrayPopupItemHeight); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 void ChildPreferredSizeChanged(views::View* child) override { | 100 void ChildPreferredSizeChanged(views::View* child) override { |
| 101 views::View::ChildPreferredSizeChanged(child); | 101 views::View::ChildPreferredSizeChanged(child); |
| 102 Layout(); | 102 Layout(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 // Overridden from PowerStatus::Observer. | 105 // Overridden from PowerStatus::Observer. |
| 106 void OnPowerStatusChanged() override { | 106 void OnPowerStatusChanged() override { |
| 107 if (!PowerStatus::Get()->IsBatteryPresent()) | 107 if (!PowerStatus::Get()->IsBatteryPresent()) |
| 108 return; | 108 return; |
| 109 | 109 |
| 110 base::string16 accessible_name = label_ ? | 110 base::string16 accessible_name = |
| 111 label_->text() + base::ASCIIToUTF16(", ") + | 111 label_ |
| 112 PowerStatus::Get()->GetAccessibleNameString(true) : | 112 ? label_->text() + base::ASCIIToUTF16(", ") + |
| 113 PowerStatus::Get()->GetAccessibleNameString(true); | 113 PowerStatus::Get()->GetAccessibleNameString(true) |
| 114 : PowerStatus::Get()->GetAccessibleNameString(true); |
| 114 SetAccessibleName(accessible_name); | 115 SetAccessibleName(accessible_name); |
| 115 } | 116 } |
| 116 | 117 |
| 117 private: | 118 private: |
| 118 LoginStatus login_status_; | 119 LoginStatus login_status_; |
| 119 views::Label* label_; | 120 views::Label* label_; |
| 120 ash::PowerStatusView* power_status_view_; | 121 ash::PowerStatusView* power_status_view_; |
| 121 | 122 |
| 122 DISALLOW_COPY_AND_ASSIGN(SettingsDefaultView); | 123 DISALLOW_COPY_AND_ASSIGN(SettingsDefaultView); |
| 123 }; | 124 }; |
| 124 | 125 |
| 125 } // namespace tray | 126 } // namespace tray |
| 126 | 127 |
| 127 TraySettings::TraySettings(SystemTray* system_tray) | 128 TraySettings::TraySettings(SystemTray* system_tray) |
| 128 : SystemTrayItem(system_tray), | 129 : SystemTrayItem(system_tray), default_view_(NULL) {} |
| 129 default_view_(NULL) { | |
| 130 } | |
| 131 | 130 |
| 132 TraySettings::~TraySettings() { | 131 TraySettings::~TraySettings() {} |
| 133 } | |
| 134 | 132 |
| 135 views::View* TraySettings::CreateTrayView(LoginStatus status) { | 133 views::View* TraySettings::CreateTrayView(LoginStatus status) { |
| 136 return NULL; | 134 return NULL; |
| 137 } | 135 } |
| 138 | 136 |
| 139 views::View* TraySettings::CreateDefaultView(LoginStatus status) { | 137 views::View* TraySettings::CreateDefaultView(LoginStatus status) { |
| 140 if ((status == LoginStatus::NOT_LOGGED_IN || status == LoginStatus::LOCKED) && | 138 if ((status == LoginStatus::NOT_LOGGED_IN || status == LoginStatus::LOCKED) && |
| 141 !PowerStatus::Get()->IsBatteryPresent()) | 139 !PowerStatus::Get()->IsBatteryPresent()) |
| 142 return NULL; | 140 return NULL; |
| 143 if (!WmShell::Get()->system_tray_delegate()->ShouldShowSettings()) | 141 if (!WmShell::Get()->system_tray_delegate()->ShouldShowSettings()) |
| 144 return NULL; | 142 return NULL; |
| 145 CHECK(default_view_ == NULL); | 143 CHECK(default_view_ == NULL); |
| 146 default_view_ = new tray::SettingsDefaultView(status); | 144 default_view_ = new tray::SettingsDefaultView(status); |
| 147 return default_view_; | 145 return default_view_; |
| 148 } | 146 } |
| 149 | 147 |
| 150 views::View* TraySettings::CreateDetailedView(LoginStatus status) { | 148 views::View* TraySettings::CreateDetailedView(LoginStatus status) { |
| 151 NOTIMPLEMENTED(); | 149 NOTIMPLEMENTED(); |
| 152 return NULL; | 150 return NULL; |
| 153 } | 151 } |
| 154 | 152 |
| 155 void TraySettings::DestroyTrayView() {} | 153 void TraySettings::DestroyTrayView() {} |
| 156 | 154 |
| 157 void TraySettings::DestroyDefaultView() { | 155 void TraySettings::DestroyDefaultView() { |
| 158 default_view_ = NULL; | 156 default_view_ = NULL; |
| 159 } | 157 } |
| 160 | 158 |
| 161 void TraySettings::DestroyDetailedView() {} | 159 void TraySettings::DestroyDetailedView() {} |
| 162 | 160 |
| 163 void TraySettings::UpdateAfterLoginStatusChange(LoginStatus status) {} | 161 void TraySettings::UpdateAfterLoginStatusChange(LoginStatus status) {} |
| 164 | 162 |
| 165 } // namespace ash | 163 } // namespace ash |
| OLD | NEW |