| 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/session/session_state_delegate.h" | 8 #include "ash/common/session/session_state_delegate.h" |
| 9 #include "ash/common/shell_window_ids.h" |
| 8 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
| 9 #include "base/bind.h" | 11 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 11 #include "base/logging.h" | 13 #include "base/logging.h" |
| 12 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/browser_process_platform_part.h" | 15 #include "chrome/browser/browser_process_platform_part.h" |
| 14 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 16 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 15 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 17 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 16 #include "chrome/browser/chromeos/options/network_config_view.h" | 18 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 17 #include "chrome/browser/chromeos/system/system_clock.h" | 19 #include "chrome/browser/chromeos/system/system_clock.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
| 19 #include "chrome/browser/ui/ash/ash_util.h" | 21 #include "chrome/browser/ui/ash/ash_util.h" |
| 20 #include "chrome/browser/ui/chrome_pages.h" | 22 #include "chrome/browser/ui/chrome_pages.h" |
| 21 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 23 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 22 #include "chrome/browser/ui/singleton_tabs.h" | 24 #include "chrome/browser/ui/singleton_tabs.h" |
| 23 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
| 24 #include "chrome/grit/generated_resources.h" | 26 #include "chrome/grit/generated_resources.h" |
| 27 #include "chromeos/dbus/dbus_thread_manager.h" |
| 28 #include "chromeos/dbus/session_manager_client.h" |
| 25 #include "chromeos/login/login_state.h" | 29 #include "chromeos/login/login_state.h" |
| 26 #include "content/public/browser/user_metrics.h" | 30 #include "content/public/browser/user_metrics.h" |
| 27 #include "content/public/common/service_manager_connection.h" | 31 #include "content/public/common/service_manager_connection.h" |
| 28 #include "net/base/escape.h" | 32 #include "net/base/escape.h" |
| 29 #include "services/service_manager/public/cpp/connector.h" | 33 #include "services/service_manager/public/cpp/connector.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
| 31 | 35 |
| 36 using chromeos::DBusThreadManager; |
| 32 using chromeos::LoginState; | 37 using chromeos::LoginState; |
| 33 | 38 |
| 34 namespace { | 39 namespace { |
| 35 | 40 |
| 36 const char kDisplaySettingsSubPageName[] = "display"; | 41 const char kDisplaySettingsSubPageName[] = "display"; |
| 37 const char kPaletteSettingsSubPageName[] = "stylus-overlay"; | 42 const char kPaletteSettingsSubPageName[] = "stylus-overlay"; |
| 38 | 43 |
| 39 SystemTrayClient* g_instance = nullptr; | 44 SystemTrayClient* g_instance = nullptr; |
| 40 | 45 |
| 41 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) { | 46 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 59 g_instance = nullptr; | 64 g_instance = nullptr; |
| 60 | 65 |
| 61 g_browser_process->platform_part()->GetSystemClock()->RemoveObserver(this); | 66 g_browser_process->platform_part()->GetSystemClock()->RemoveObserver(this); |
| 62 } | 67 } |
| 63 | 68 |
| 64 // static | 69 // static |
| 65 SystemTrayClient* SystemTrayClient::Get() { | 70 SystemTrayClient* SystemTrayClient::Get() { |
| 66 return g_instance; | 71 return g_instance; |
| 67 } | 72 } |
| 68 | 73 |
| 74 // static |
| 75 ash::LoginStatus SystemTrayClient::GetUserLoginStatus() { |
| 76 if (!LoginState::Get()->IsUserLoggedIn()) |
| 77 return ash::LoginStatus::NOT_LOGGED_IN; |
| 78 |
| 79 // Session manager client owns screen lock status. |
| 80 if (DBusThreadManager::Get()->GetSessionManagerClient()->IsScreenLocked()) |
| 81 return ash::LoginStatus::LOCKED; |
| 82 |
| 83 LoginState::LoggedInUserType user_type = |
| 84 LoginState::Get()->GetLoggedInUserType(); |
| 85 switch (user_type) { |
| 86 case LoginState::LOGGED_IN_USER_NONE: |
| 87 return ash::LoginStatus::NOT_LOGGED_IN; |
| 88 case LoginState::LOGGED_IN_USER_REGULAR: |
| 89 return ash::LoginStatus::USER; |
| 90 case LoginState::LOGGED_IN_USER_OWNER: |
| 91 return ash::LoginStatus::OWNER; |
| 92 case LoginState::LOGGED_IN_USER_GUEST: |
| 93 return ash::LoginStatus::GUEST; |
| 94 case LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT: |
| 95 return ash::LoginStatus::PUBLIC; |
| 96 case LoginState::LOGGED_IN_USER_SUPERVISED: |
| 97 return ash::LoginStatus::SUPERVISED; |
| 98 case LoginState::LOGGED_IN_USER_KIOSK_APP: |
| 99 return ash::LoginStatus::KIOSK_APP; |
| 100 } |
| 101 NOTREACHED(); |
| 102 return ash::LoginStatus::NOT_LOGGED_IN; |
| 103 } |
| 104 |
| 105 // static |
| 106 int SystemTrayClient::GetDialogParentContainerId() { |
| 107 // TODO(mash): Need replacement for SessionStateDelegate. crbug.com/648964 |
| 108 if (chrome::IsRunningInMash()) |
| 109 return ash::kShellWindowId_SystemModalContainer; |
| 110 |
| 111 ash::WmShell* wm_shell = ash::WmShell::Get(); |
| 112 const bool session_started = |
| 113 wm_shell->GetSessionStateDelegate()->IsActiveUserSessionStarted(); |
| 114 const ash::LoginStatus login_status = GetUserLoginStatus(); |
| 115 const bool is_in_secondary_login_screen = |
| 116 wm_shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); |
| 117 |
| 118 if (!session_started || login_status == ash::LoginStatus::NOT_LOGGED_IN || |
| 119 login_status == ash::LoginStatus::LOCKED || is_in_secondary_login_screen) |
| 120 return ash::kShellWindowId_LockSystemModalContainer; |
| 121 |
| 122 return ash::kShellWindowId_SystemModalContainer; |
| 123 } |
| 124 |
| 69 //////////////////////////////////////////////////////////////////////////////// | 125 //////////////////////////////////////////////////////////////////////////////// |
| 70 // ash::mojom::SystemTrayClient: | 126 // ash::mojom::SystemTrayClient: |
| 71 | 127 |
| 72 void SystemTrayClient::ShowSettings() { | 128 void SystemTrayClient::ShowSettings() { |
| 73 ShowSettingsSubPageForActiveUser(std::string()); | 129 ShowSettingsSubPageForActiveUser(std::string()); |
| 74 } | 130 } |
| 75 | 131 |
| 76 void SystemTrayClient::ShowDateSettings() { | 132 void SystemTrayClient::ShowDateSettings() { |
| 77 content::RecordAction(base::UserMetricsAction("ShowDateOptions")); | 133 content::RecordAction(base::UserMetricsAction("ShowDateOptions")); |
| 78 std::string sub_page = | 134 std::string sub_page = |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 connector->ConnectToInterface("service:content_browser", &system_tray_); | 254 connector->ConnectToInterface("service:content_browser", &system_tray_); |
| 199 | 255 |
| 200 // Tolerate ash crashing and coming back up. | 256 // Tolerate ash crashing and coming back up. |
| 201 system_tray_.set_connection_error_handler(base::Bind( | 257 system_tray_.set_connection_error_handler(base::Bind( |
| 202 &SystemTrayClient::OnClientConnectionError, base::Unretained(this))); | 258 &SystemTrayClient::OnClientConnectionError, base::Unretained(this))); |
| 203 } | 259 } |
| 204 | 260 |
| 205 void SystemTrayClient::OnClientConnectionError() { | 261 void SystemTrayClient::OnClientConnectionError() { |
| 206 system_tray_.reset(); | 262 system_tray_.reset(); |
| 207 } | 263 } |
| OLD | NEW |