| 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" | |
| 9 #include "ash/common/wm_shell.h" | 8 #include "ash/common/wm_shell.h" |
| 10 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
| 11 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 12 #include "base/logging.h" | 11 #include "base/logging.h" |
| 13 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/browser_process_platform_part.h" | 13 #include "chrome/browser/browser_process_platform_part.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 15 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 17 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 16 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 18 #include "chrome/browser/chromeos/options/network_config_view.h" | 17 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 19 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 18 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 20 #include "chrome/browser/chromeos/set_time_dialog.h" | 19 #include "chrome/browser/chromeos/set_time_dialog.h" |
| 21 #include "chrome/browser/chromeos/system/system_clock.h" | 20 #include "chrome/browser/chromeos/system/system_clock.h" |
| 22 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" | 21 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" |
| 23 #include "chrome/browser/lifetime/application_lifetime.h" | 22 #include "chrome/browser/lifetime/application_lifetime.h" |
| 24 #include "chrome/browser/profiles/profile_manager.h" | 23 #include "chrome/browser/profiles/profile_manager.h" |
| 25 #include "chrome/browser/ui/ash/ash_util.h" | 24 #include "chrome/browser/ui/ash/ash_util.h" |
| 26 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" | 25 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" |
| 27 #include "chrome/browser/ui/chrome_pages.h" | 26 #include "chrome/browser/ui/chrome_pages.h" |
| 28 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 27 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 29 #include "chrome/browser/ui/singleton_tabs.h" | 28 #include "chrome/browser/ui/singleton_tabs.h" |
| 30 #include "chrome/browser/upgrade_detector.h" | 29 #include "chrome/browser/upgrade_detector.h" |
| 31 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 32 #include "chromeos/dbus/dbus_thread_manager.h" | 31 #include "chromeos/dbus/dbus_thread_manager.h" |
| 33 #include "chromeos/dbus/session_manager_client.h" | 32 #include "chromeos/dbus/session_manager_client.h" |
| 34 #include "chromeos/login/login_state.h" | 33 #include "chromeos/login/login_state.h" |
| 34 #include "components/session_manager/core/session_manager.h" |
| 35 #include "components/user_manager/user_manager.h" | 35 #include "components/user_manager/user_manager.h" |
| 36 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
| 37 #include "content/public/browser/user_metrics.h" | 37 #include "content/public/browser/user_metrics.h" |
| 38 #include "content/public/common/service_manager_connection.h" | 38 #include "content/public/common/service_manager_connection.h" |
| 39 #include "extensions/browser/api/vpn_provider/vpn_service.h" | 39 #include "extensions/browser/api/vpn_provider/vpn_service.h" |
| 40 #include "extensions/browser/api/vpn_provider/vpn_service_factory.h" | 40 #include "extensions/browser/api/vpn_provider/vpn_service_factory.h" |
| 41 #include "net/base/escape.h" | 41 #include "net/base/escape.h" |
| 42 #include "services/service_manager/public/cpp/connector.h" | 42 #include "services/service_manager/public/cpp/connector.h" |
| 43 #include "services/ui/public/cpp/property_type_converters.h" | 43 #include "services/ui/public/cpp/property_type_converters.h" |
| 44 #include "services/ui/public/interfaces/window_manager.mojom.h" | 44 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } | 152 } |
| 153 | 153 |
| 154 // static | 154 // static |
| 155 int SystemTrayClient::GetDialogParentContainerId() { | 155 int SystemTrayClient::GetDialogParentContainerId() { |
| 156 const ash::LoginStatus login_status = GetUserLoginStatus(); | 156 const ash::LoginStatus login_status = GetUserLoginStatus(); |
| 157 if (login_status == ash::LoginStatus::NOT_LOGGED_IN || | 157 if (login_status == ash::LoginStatus::NOT_LOGGED_IN || |
| 158 login_status == ash::LoginStatus::LOCKED) { | 158 login_status == ash::LoginStatus::LOCKED) { |
| 159 return ash::kShellWindowId_LockSystemModalContainer; | 159 return ash::kShellWindowId_LockSystemModalContainer; |
| 160 } | 160 } |
| 161 | 161 |
| 162 // TODO(mash): Need replacement for SessionStateDelegate. crbug.com/648964 | 162 session_manager::SessionManager* const session_manager = |
| 163 if (chrome::IsRunningInMash()) | 163 session_manager::SessionManager::Get(); |
| 164 return ash::kShellWindowId_SystemModalContainer; | 164 const bool session_started = session_manager->IsSessionStarted(); |
| 165 | |
| 166 ash::WmShell* wm_shell = ash::WmShell::Get(); | |
| 167 const bool session_started = | |
| 168 wm_shell->GetSessionStateDelegate()->IsActiveUserSessionStarted(); | |
| 169 const bool is_in_secondary_login_screen = | 165 const bool is_in_secondary_login_screen = |
| 170 wm_shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); | 166 session_manager->IsInSecondaryLoginScreen(); |
| 171 | 167 |
| 172 if (!session_started || is_in_secondary_login_screen) | 168 if (!session_started || is_in_secondary_login_screen) |
| 173 return ash::kShellWindowId_LockSystemModalContainer; | 169 return ash::kShellWindowId_LockSystemModalContainer; |
| 174 | 170 |
| 175 return ash::kShellWindowId_SystemModalContainer; | 171 return ash::kShellWindowId_SystemModalContainer; |
| 176 } | 172 } |
| 177 | 173 |
| 178 // static | 174 // static |
| 179 Widget* SystemTrayClient::CreateUnownedDialogWidget( | 175 Widget* SystemTrayClient::CreateUnownedDialogWidget( |
| 180 views::WidgetDelegate* widget_delegate) { | 176 views::WidgetDelegate* widget_delegate) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 } | 266 } |
| 271 | 267 |
| 272 void SystemTrayClient::ShowPublicAccountInfo() { | 268 void SystemTrayClient::ShowPublicAccountInfo() { |
| 273 chrome::ScopedTabbedBrowserDisplayer displayer( | 269 chrome::ScopedTabbedBrowserDisplayer displayer( |
| 274 ProfileManager::GetActiveUserProfile()); | 270 ProfileManager::GetActiveUserProfile()); |
| 275 chrome::ShowPolicy(displayer.browser()); | 271 chrome::ShowPolicy(displayer.browser()); |
| 276 } | 272 } |
| 277 | 273 |
| 278 void SystemTrayClient::ShowNetworkConfigure(const std::string& network_id) { | 274 void SystemTrayClient::ShowNetworkConfigure(const std::string& network_id) { |
| 279 // UI is not available at the lock screen. | 275 // UI is not available at the lock screen. |
| 280 // TODO(mash): Need replacement for SessionStateDelegate. crbug.com/648964 | 276 if (session_manager::SessionManager::Get()->IsScreenLocked()) |
| 281 if (!chrome::IsRunningInMash() && | |
| 282 ash::WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked()) { | |
| 283 return; | 277 return; |
| 284 } | |
| 285 | 278 |
| 286 // Dialog will default to the primary display. | 279 // Dialog will default to the primary display. |
| 287 chromeos::NetworkConfigView::ShowForNetworkId(network_id, | 280 chromeos::NetworkConfigView::ShowForNetworkId(network_id, |
| 288 nullptr /* parent */); | 281 nullptr /* parent */); |
| 289 } | 282 } |
| 290 | 283 |
| 291 void SystemTrayClient::ShowNetworkCreate(const std::string& type) { | 284 void SystemTrayClient::ShowNetworkCreate(const std::string& type) { |
| 292 int container_id = GetDialogParentContainerId(); | 285 int container_id = GetDialogParentContainerId(); |
| 293 if (type == shill::kTypeCellular) { | 286 if (type == shill::kTypeCellular) { |
| 294 chromeos::ChooseMobileNetworkDialog::ShowDialogInContainer(container_id); | 287 chromeos::ChooseMobileNetworkDialog::ShowDialogInContainer(container_id); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 308 chromeos::ProfileHelper::Get()->GetProfileByUser(primary_user); | 301 chromeos::ProfileHelper::Get()->GetProfileByUser(primary_user); |
| 309 if (!profile) | 302 if (!profile) |
| 310 return; | 303 return; |
| 311 | 304 |
| 312 // Request that the third-party VPN provider show its "add network" dialog. | 305 // Request that the third-party VPN provider show its "add network" dialog. |
| 313 chromeos::VpnServiceFactory::GetForBrowserContext(profile) | 306 chromeos::VpnServiceFactory::GetForBrowserContext(profile) |
| 314 ->SendShowAddDialogToExtension(extension_id); | 307 ->SendShowAddDialogToExtension(extension_id); |
| 315 } | 308 } |
| 316 | 309 |
| 317 void SystemTrayClient::ShowNetworkSettings(const std::string& network_id) { | 310 void SystemTrayClient::ShowNetworkSettings(const std::string& network_id) { |
| 318 if (!chrome::IsRunningInMash()) { | 311 if (!LoginState::Get()->IsUserLoggedIn() || |
| 319 // TODO(mash): Need replacement for SessionStateDelegate. crbug.com/648964 | 312 session_manager::SessionManager::Get()->IsInSecondaryLoginScreen()) { |
| 320 if (!LoginState::Get()->IsUserLoggedIn() || | 313 return; |
| 321 ash::WmShell::Get() | |
| 322 ->GetSessionStateDelegate() | |
| 323 ->IsInSecondaryLoginScreen()) | |
| 324 return; | |
| 325 } | 314 } |
| 326 | 315 |
| 327 std::string page = chrome::kInternetOptionsSubPage; | 316 std::string page = chrome::kInternetOptionsSubPage; |
| 328 if (!network_id.empty()) | 317 if (!network_id.empty()) |
| 329 page += "?guid=" + net::EscapeUrlEncodedData(network_id, true); | 318 page += "?guid=" + net::EscapeUrlEncodedData(network_id, true); |
| 330 content::RecordAction(base::UserMetricsAction("OpenInternetOptionsDialog")); | 319 content::RecordAction(base::UserMetricsAction("OpenInternetOptionsDialog")); |
| 331 ShowSettingsSubPageForActiveUser(page); | 320 ShowSettingsSubPageForActiveUser(page); |
| 332 } | 321 } |
| 333 | 322 |
| 334 void SystemTrayClient::ShowProxySettings() { | 323 void SystemTrayClient::ShowProxySettings() { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 chromeos::system::SystemClock* clock) { | 363 chromeos::system::SystemClock* clock) { |
| 375 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); | 364 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); |
| 376 } | 365 } |
| 377 | 366 |
| 378 void SystemTrayClient::Observe(int type, | 367 void SystemTrayClient::Observe(int type, |
| 379 const content::NotificationSource& source, | 368 const content::NotificationSource& source, |
| 380 const content::NotificationDetails& details) { | 369 const content::NotificationDetails& details) { |
| 381 DCHECK_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED, type); | 370 DCHECK_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED, type); |
| 382 HandleUpdateAvailable(); | 371 HandleUpdateAvailable(); |
| 383 } | 372 } |
| OLD | NEW |