OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/ui/ash/system_tray_client.h" | 5 #include "chrome/browser/ui/ash/system_tray_client.h" |
6 | 6 |
7 #include "ash/common/login_status.h" | 7 #include "ash/common/login_status.h" |
8 #include "ash/common/session/session_state_delegate.h" | 8 #include "ash/common/session/session_state_delegate.h" |
9 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
10 #include "ash/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 return ash::LoginStatus::SUPERVISED; | 97 return ash::LoginStatus::SUPERVISED; |
98 case LoginState::LOGGED_IN_USER_KIOSK_APP: | 98 case LoginState::LOGGED_IN_USER_KIOSK_APP: |
99 return ash::LoginStatus::KIOSK_APP; | 99 return ash::LoginStatus::KIOSK_APP; |
100 } | 100 } |
101 NOTREACHED(); | 101 NOTREACHED(); |
102 return ash::LoginStatus::NOT_LOGGED_IN; | 102 return ash::LoginStatus::NOT_LOGGED_IN; |
103 } | 103 } |
104 | 104 |
105 // static | 105 // static |
106 int SystemTrayClient::GetDialogParentContainerId() { | 106 int SystemTrayClient::GetDialogParentContainerId() { |
| 107 const ash::LoginStatus login_status = GetUserLoginStatus(); |
| 108 if (login_status == ash::LoginStatus::NOT_LOGGED_IN || |
| 109 login_status == ash::LoginStatus::LOCKED) { |
| 110 return ash::kShellWindowId_LockSystemModalContainer; |
| 111 } |
| 112 |
107 // TODO(mash): Need replacement for SessionStateDelegate. crbug.com/648964 | 113 // TODO(mash): Need replacement for SessionStateDelegate. crbug.com/648964 |
108 if (chrome::IsRunningInMash()) | 114 if (chrome::IsRunningInMash()) |
109 return ash::kShellWindowId_SystemModalContainer; | 115 return ash::kShellWindowId_SystemModalContainer; |
110 | 116 |
111 ash::WmShell* wm_shell = ash::WmShell::Get(); | 117 ash::WmShell* wm_shell = ash::WmShell::Get(); |
112 const bool session_started = | 118 const bool session_started = |
113 wm_shell->GetSessionStateDelegate()->IsActiveUserSessionStarted(); | 119 wm_shell->GetSessionStateDelegate()->IsActiveUserSessionStarted(); |
114 const ash::LoginStatus login_status = GetUserLoginStatus(); | |
115 const bool is_in_secondary_login_screen = | 120 const bool is_in_secondary_login_screen = |
116 wm_shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); | 121 wm_shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); |
117 | 122 |
118 if (!session_started || login_status == ash::LoginStatus::NOT_LOGGED_IN || | 123 if (!session_started || is_in_secondary_login_screen) |
119 login_status == ash::LoginStatus::LOCKED || is_in_secondary_login_screen) | |
120 return ash::kShellWindowId_LockSystemModalContainer; | 124 return ash::kShellWindowId_LockSystemModalContainer; |
121 | 125 |
122 return ash::kShellWindowId_SystemModalContainer; | 126 return ash::kShellWindowId_SystemModalContainer; |
123 } | 127 } |
124 | 128 |
125 //////////////////////////////////////////////////////////////////////////////// | 129 //////////////////////////////////////////////////////////////////////////////// |
126 // ash::mojom::SystemTrayClient: | 130 // ash::mojom::SystemTrayClient: |
127 | 131 |
128 void SystemTrayClient::ShowSettings() { | 132 void SystemTrayClient::ShowSettings() { |
129 ShowSettingsSubPageForActiveUser(std::string()); | 133 ShowSettingsSubPageForActiveUser(std::string()); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 ShowSettingsSubPageForActiveUser(kPaletteSettingsSubPageName); | 195 ShowSettingsSubPageForActiveUser(kPaletteSettingsSubPageName); |
192 } | 196 } |
193 | 197 |
194 void SystemTrayClient::ShowPublicAccountInfo() { | 198 void SystemTrayClient::ShowPublicAccountInfo() { |
195 chrome::ScopedTabbedBrowserDisplayer displayer( | 199 chrome::ScopedTabbedBrowserDisplayer displayer( |
196 ProfileManager::GetActiveUserProfile()); | 200 ProfileManager::GetActiveUserProfile()); |
197 chrome::ShowPolicy(displayer.browser()); | 201 chrome::ShowPolicy(displayer.browser()); |
198 } | 202 } |
199 | 203 |
200 void SystemTrayClient::ShowNetworkConfigure(const std::string& network_id) { | 204 void SystemTrayClient::ShowNetworkConfigure(const std::string& network_id) { |
201 // TODO(jamescook): Consolidate this with the classic ash version from | 205 // UI is not available at the lock screen. |
202 // NetworkConnectDelegateChromeOS. This will require moving the window | 206 // TODO(mash): Need replacement for SessionStateDelegate. crbug.com/648964 |
203 // container calculation to this class, then plumbing a container ID through | 207 if (!chrome::IsRunningInMash() && |
204 // the dialog code. | 208 ash::WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked()) { |
205 CHECK(chrome::IsRunningInMash()); | 209 return; |
206 chromeos::NetworkConfigView::ShowByNetworkId(network_id, | 210 } |
207 nullptr /* parent */); | 211 |
| 212 // Dialog will default to the primary display. |
| 213 chromeos::NetworkConfigView::ShowInContainer(network_id, |
| 214 GetDialogParentContainerId()); |
208 } | 215 } |
209 | 216 |
210 void SystemTrayClient::ShowNetworkSettings(const std::string& network_id) { | 217 void SystemTrayClient::ShowNetworkSettings(const std::string& network_id) { |
211 if (!chrome::IsRunningInMash()) { | 218 if (!chrome::IsRunningInMash()) { |
212 // TODO(mash): Need replacement for SessionStateDelegate. crbug.com/648964 | 219 // TODO(mash): Need replacement for SessionStateDelegate. crbug.com/648964 |
213 if (!LoginState::Get()->IsUserLoggedIn() || | 220 if (!LoginState::Get()->IsUserLoggedIn() || |
214 ash::WmShell::Get() | 221 ash::WmShell::Get() |
215 ->GetSessionStateDelegate() | 222 ->GetSessionStateDelegate() |
216 ->IsInSecondaryLoginScreen()) | 223 ->IsInSecondaryLoginScreen()) |
217 return; | 224 return; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 connector->ConnectToInterface("service:content_browser", &system_tray_); | 262 connector->ConnectToInterface("service:content_browser", &system_tray_); |
256 | 263 |
257 // Tolerate ash crashing and coming back up. | 264 // Tolerate ash crashing and coming back up. |
258 system_tray_.set_connection_error_handler(base::Bind( | 265 system_tray_.set_connection_error_handler(base::Bind( |
259 &SystemTrayClient::OnClientConnectionError, base::Unretained(this))); | 266 &SystemTrayClient::OnClientConnectionError, base::Unretained(this))); |
260 } | 267 } |
261 | 268 |
262 void SystemTrayClient::OnClientConnectionError() { | 269 void SystemTrayClient::OnClientConnectionError() { |
263 system_tray_.reset(); | 270 system_tray_.reset(); |
264 } | 271 } |
OLD | NEW |