Chromium Code Reviews| 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; | |
|
stevenjb
2016/10/20 19:42:40
nit: {}
James Cook
2016/10/20 20:10:34
Done.
| |
| 111 | |
| 107 // TODO(mash): Need replacement for SessionStateDelegate. crbug.com/648964 | 112 // TODO(mash): Need replacement for SessionStateDelegate. crbug.com/648964 |
| 108 if (chrome::IsRunningInMash()) | 113 if (chrome::IsRunningInMash()) |
| 109 return ash::kShellWindowId_SystemModalContainer; | 114 return ash::kShellWindowId_SystemModalContainer; |
| 110 | 115 |
| 111 ash::WmShell* wm_shell = ash::WmShell::Get(); | 116 ash::WmShell* wm_shell = ash::WmShell::Get(); |
| 112 const bool session_started = | 117 const bool session_started = |
| 113 wm_shell->GetSessionStateDelegate()->IsActiveUserSessionStarted(); | 118 wm_shell->GetSessionStateDelegate()->IsActiveUserSessionStarted(); |
| 114 const ash::LoginStatus login_status = GetUserLoginStatus(); | |
| 115 const bool is_in_secondary_login_screen = | 119 const bool is_in_secondary_login_screen = |
| 116 wm_shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); | 120 wm_shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); |
| 117 | 121 |
| 118 if (!session_started || login_status == ash::LoginStatus::NOT_LOGGED_IN || | 122 if (!session_started || is_in_secondary_login_screen) |
| 119 login_status == ash::LoginStatus::LOCKED || is_in_secondary_login_screen) | |
| 120 return ash::kShellWindowId_LockSystemModalContainer; | 123 return ash::kShellWindowId_LockSystemModalContainer; |
| 121 | 124 |
| 122 return ash::kShellWindowId_SystemModalContainer; | 125 return ash::kShellWindowId_SystemModalContainer; |
| 123 } | 126 } |
| 124 | 127 |
| 125 //////////////////////////////////////////////////////////////////////////////// | 128 //////////////////////////////////////////////////////////////////////////////// |
| 126 // ash::mojom::SystemTrayClient: | 129 // ash::mojom::SystemTrayClient: |
| 127 | 130 |
| 128 void SystemTrayClient::ShowSettings() { | 131 void SystemTrayClient::ShowSettings() { |
| 129 ShowSettingsSubPageForActiveUser(std::string()); | 132 ShowSettingsSubPageForActiveUser(std::string()); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 ShowSettingsSubPageForActiveUser(kPaletteSettingsSubPageName); | 194 ShowSettingsSubPageForActiveUser(kPaletteSettingsSubPageName); |
| 192 } | 195 } |
| 193 | 196 |
| 194 void SystemTrayClient::ShowPublicAccountInfo() { | 197 void SystemTrayClient::ShowPublicAccountInfo() { |
| 195 chrome::ScopedTabbedBrowserDisplayer displayer( | 198 chrome::ScopedTabbedBrowserDisplayer displayer( |
| 196 ProfileManager::GetActiveUserProfile()); | 199 ProfileManager::GetActiveUserProfile()); |
| 197 chrome::ShowPolicy(displayer.browser()); | 200 chrome::ShowPolicy(displayer.browser()); |
| 198 } | 201 } |
| 199 | 202 |
| 200 void SystemTrayClient::ShowNetworkConfigure(const std::string& network_id) { | 203 void SystemTrayClient::ShowNetworkConfigure(const std::string& network_id) { |
| 201 // TODO(jamescook): Consolidate this with the classic ash version from | 204 // UI is not available at the lock screen. |
| 202 // NetworkConnectDelegateChromeOS. This will require moving the window | 205 // TODO(mash): Need replacement for SessionStateDelegate. crbug.com/648964 |
| 203 // container calculation to this class, then plumbing a container ID through | 206 if (!chrome::IsRunningInMash() && |
| 204 // the dialog code. | 207 ash::WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked()) |
| 205 CHECK(chrome::IsRunningInMash()); | 208 return; |
|
stevenjb
2016/10/20 19:42:40
{}
James Cook
2016/10/20 20:10:34
Done.
| |
| 209 | |
| 210 // Dialog will default to the primary display. | |
| 206 chromeos::NetworkConfigView::ShowByNetworkId(network_id, | 211 chromeos::NetworkConfigView::ShowByNetworkId(network_id, |
| 207 nullptr /* parent */); | 212 GetDialogParentContainerId()); |
| 208 } | 213 } |
| 209 | 214 |
| 210 void SystemTrayClient::ShowNetworkSettings(const std::string& network_id) { | 215 void SystemTrayClient::ShowNetworkSettings(const std::string& network_id) { |
| 211 if (!chrome::IsRunningInMash()) { | 216 if (!chrome::IsRunningInMash()) { |
| 212 // TODO(mash): Need replacement for SessionStateDelegate. crbug.com/648964 | 217 // TODO(mash): Need replacement for SessionStateDelegate. crbug.com/648964 |
| 213 if (!LoginState::Get()->IsUserLoggedIn() || | 218 if (!LoginState::Get()->IsUserLoggedIn() || |
| 214 ash::WmShell::Get() | 219 ash::WmShell::Get() |
| 215 ->GetSessionStateDelegate() | 220 ->GetSessionStateDelegate() |
| 216 ->IsInSecondaryLoginScreen()) | 221 ->IsInSecondaryLoginScreen()) |
| 217 return; | 222 return; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 connector->ConnectToInterface("service:content_browser", &system_tray_); | 260 connector->ConnectToInterface("service:content_browser", &system_tray_); |
| 256 | 261 |
| 257 // Tolerate ash crashing and coming back up. | 262 // Tolerate ash crashing and coming back up. |
| 258 system_tray_.set_connection_error_handler(base::Bind( | 263 system_tray_.set_connection_error_handler(base::Bind( |
| 259 &SystemTrayClient::OnClientConnectionError, base::Unretained(this))); | 264 &SystemTrayClient::OnClientConnectionError, base::Unretained(this))); |
| 260 } | 265 } |
| 261 | 266 |
| 262 void SystemTrayClient::OnClientConnectionError() { | 267 void SystemTrayClient::OnClientConnectionError() { |
| 263 system_tray_.reset(); | 268 system_tray_.reset(); |
| 264 } | 269 } |
| OLD | NEW |