| 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/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/session/session_state_delegate.h" | 8 #include "ash/common/session/session_state_delegate.h" |
| 9 #include "ash/common/system/chromeos/power/power_status.h" | 9 #include "ash/common/system/chromeos/power/power_status.h" |
| 10 #include "ash/common/system/chromeos/power/power_status_view.h" | 10 #include "ash/common/system/chromeos/power/power_status_view.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "ui/views/layout/box_layout.h" | 27 #include "ui/views/layout/box_layout.h" |
| 28 #include "ui/views/layout/fill_layout.h" | 28 #include "ui/views/layout/fill_layout.h" |
| 29 #include "ui/views/view.h" | 29 #include "ui/views/view.h" |
| 30 | 30 |
| 31 namespace ash { | 31 namespace ash { |
| 32 namespace tray { | 32 namespace tray { |
| 33 | 33 |
| 34 class SettingsDefaultView : public ActionableView, | 34 class SettingsDefaultView : public ActionableView, |
| 35 public PowerStatus::Observer { | 35 public PowerStatus::Observer { |
| 36 public: | 36 public: |
| 37 explicit SettingsDefaultView(LoginStatus status) | 37 SettingsDefaultView(SystemTrayItem* owner, LoginStatus status) |
| 38 : login_status_(status), label_(NULL), power_status_view_(NULL) { | 38 : ActionableView(owner), |
| 39 login_status_(status), |
| 40 label_(nullptr), |
| 41 power_status_view_(nullptr) { |
| 39 PowerStatus::Get()->AddObserver(this); | 42 PowerStatus::Get()->AddObserver(this); |
| 40 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, | 43 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, |
| 41 ash::kTrayPopupPaddingHorizontal, 0, | 44 ash::kTrayPopupPaddingHorizontal, 0, |
| 42 ash::kTrayPopupPaddingBetweenItems)); | 45 ash::kTrayPopupPaddingBetweenItems)); |
| 43 | 46 |
| 44 bool power_view_right_align = false; | 47 bool power_view_right_align = false; |
| 45 if (login_status_ != LoginStatus::NOT_LOGGED_IN && | 48 if (login_status_ != LoginStatus::NOT_LOGGED_IN && |
| 46 login_status_ != LoginStatus::LOCKED && | 49 login_status_ != LoginStatus::LOCKED && |
| 47 !WmShell::Get() | 50 !WmShell::Get() |
| 48 ->GetSessionStateDelegate() | 51 ->GetSessionStateDelegate() |
| (...skipping 30 matching lines...) Expand all Loading... |
| 79 | 82 |
| 80 // Overridden from ash::ActionableView. | 83 // Overridden from ash::ActionableView. |
| 81 bool PerformAction(const ui::Event& event) override { | 84 bool PerformAction(const ui::Event& event) override { |
| 82 if (login_status_ == LoginStatus::NOT_LOGGED_IN || | 85 if (login_status_ == LoginStatus::NOT_LOGGED_IN || |
| 83 login_status_ == LoginStatus::LOCKED || | 86 login_status_ == LoginStatus::LOCKED || |
| 84 WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen()) { | 87 WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen()) { |
| 85 return false; | 88 return false; |
| 86 } | 89 } |
| 87 | 90 |
| 88 WmShell::Get()->system_tray_delegate()->ShowSettings(); | 91 WmShell::Get()->system_tray_delegate()->ShowSettings(); |
| 92 CloseSystemBubble(); |
| 89 return true; | 93 return true; |
| 90 } | 94 } |
| 91 | 95 |
| 92 // Overridden from views::View. | 96 // Overridden from views::View. |
| 93 void Layout() override { | 97 void Layout() override { |
| 94 views::View::Layout(); | 98 views::View::Layout(); |
| 95 | 99 |
| 96 if (label_ && power_status_view_) { | 100 if (label_ && power_status_view_) { |
| 97 // Let the box-layout do the layout first. Then move power_status_view_ | 101 // Let the box-layout do the layout first. Then move power_status_view_ |
| 98 // to right align if it is created. | 102 // to right align if it is created. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 }; | 136 }; |
| 133 | 137 |
| 134 } // namespace tray | 138 } // namespace tray |
| 135 | 139 |
| 136 TraySettings::TraySettings(SystemTray* system_tray) | 140 TraySettings::TraySettings(SystemTray* system_tray) |
| 137 : SystemTrayItem(system_tray, UMA_SETTINGS), default_view_(nullptr) {} | 141 : SystemTrayItem(system_tray, UMA_SETTINGS), default_view_(nullptr) {} |
| 138 | 142 |
| 139 TraySettings::~TraySettings() {} | 143 TraySettings::~TraySettings() {} |
| 140 | 144 |
| 141 views::View* TraySettings::CreateTrayView(LoginStatus status) { | 145 views::View* TraySettings::CreateTrayView(LoginStatus status) { |
| 142 return NULL; | 146 return nullptr; |
| 143 } | 147 } |
| 144 | 148 |
| 145 views::View* TraySettings::CreateDefaultView(LoginStatus status) { | 149 views::View* TraySettings::CreateDefaultView(LoginStatus status) { |
| 146 if ((status == LoginStatus::NOT_LOGGED_IN || status == LoginStatus::LOCKED) && | 150 if ((status == LoginStatus::NOT_LOGGED_IN || status == LoginStatus::LOCKED) && |
| 147 !PowerStatus::Get()->IsBatteryPresent()) | 151 !PowerStatus::Get()->IsBatteryPresent()) |
| 148 return NULL; | 152 return nullptr; |
| 149 if (!WmShell::Get()->system_tray_delegate()->ShouldShowSettings()) | 153 if (!WmShell::Get()->system_tray_delegate()->ShouldShowSettings()) |
| 150 return NULL; | 154 return nullptr; |
| 151 CHECK(default_view_ == NULL); | 155 CHECK(default_view_ == nullptr); |
| 152 default_view_ = new tray::SettingsDefaultView(status); | 156 default_view_ = new tray::SettingsDefaultView(this, status); |
| 153 return default_view_; | 157 return default_view_; |
| 154 } | 158 } |
| 155 | 159 |
| 156 views::View* TraySettings::CreateDetailedView(LoginStatus status) { | 160 views::View* TraySettings::CreateDetailedView(LoginStatus status) { |
| 157 NOTIMPLEMENTED(); | 161 NOTIMPLEMENTED(); |
| 158 return NULL; | 162 return nullptr; |
| 159 } | 163 } |
| 160 | 164 |
| 161 void TraySettings::DestroyTrayView() {} | 165 void TraySettings::DestroyTrayView() {} |
| 162 | 166 |
| 163 void TraySettings::DestroyDefaultView() { | 167 void TraySettings::DestroyDefaultView() { |
| 164 default_view_ = NULL; | 168 default_view_ = nullptr; |
| 165 } | 169 } |
| 166 | 170 |
| 167 void TraySettings::DestroyDetailedView() {} | 171 void TraySettings::DestroyDetailedView() {} |
| 168 | 172 |
| 169 void TraySettings::UpdateAfterLoginStatusChange(LoginStatus status) {} | 173 void TraySettings::UpdateAfterLoginStatusChange(LoginStatus status) {} |
| 170 | 174 |
| 171 } // namespace ash | 175 } // namespace ash |
| OLD | NEW |