| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_delegate_chromeos.h" | 5 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <utility> | 13 #include <utility> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "ash/common/login_status.h" | 16 #include "ash/common/login_status.h" |
| 17 #include "ash/common/session/session_state_delegate.h" | |
| 18 #include "ash/common/session/session_state_observer.h" | |
| 19 #include "ash/common/shell_delegate.h" | 17 #include "ash/common/shell_delegate.h" |
| 20 #include "ash/common/system/chromeos/bluetooth/bluetooth_observer.h" | 18 #include "ash/common/system/chromeos/bluetooth/bluetooth_observer.h" |
| 21 #include "ash/common/system/chromeos/power/power_status.h" | 19 #include "ash/common/system/chromeos/power/power_status.h" |
| 22 #include "ash/common/system/chromeos/session/logout_button_observer.h" | 20 #include "ash/common/system/chromeos/session/logout_button_observer.h" |
| 23 #include "ash/common/system/date/clock_observer.h" | 21 #include "ash/common/system/date/clock_observer.h" |
| 24 #include "ash/common/system/ime/ime_observer.h" | 22 #include "ash/common/system/ime/ime_observer.h" |
| 25 #include "ash/common/system/tray/system_tray_notifier.h" | 23 #include "ash/common/system/tray/system_tray_notifier.h" |
| 26 #include "ash/common/system/tray_accessibility.h" | 24 #include "ash/common/system/tray_accessibility.h" |
| 27 #include "ash/common/system/user/user_observer.h" | 25 #include "ash/common/system/user/user_observer.h" |
| 28 #include "ash/common/wm_shell.h" | 26 #include "ash/common/wm_shell.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 #include "chrome/common/url_constants.h" | 66 #include "chrome/common/url_constants.h" |
| 69 #include "chrome/grit/generated_resources.h" | 67 #include "chrome/grit/generated_resources.h" |
| 70 #include "chrome/grit/locale_settings.h" | 68 #include "chrome/grit/locale_settings.h" |
| 71 #include "chromeos/dbus/dbus_thread_manager.h" | 69 #include "chromeos/dbus/dbus_thread_manager.h" |
| 72 #include "chromeos/dbus/session_manager_client.h" | 70 #include "chromeos/dbus/session_manager_client.h" |
| 73 #include "chromeos/login/login_state.h" | 71 #include "chromeos/login/login_state.h" |
| 74 #include "chromeos/network/portal_detector/network_portal_detector.h" | 72 #include "chromeos/network/portal_detector/network_portal_detector.h" |
| 75 #include "components/google/core/browser/google_util.h" | 73 #include "components/google/core/browser/google_util.h" |
| 76 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 74 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 77 #include "components/prefs/pref_service.h" | 75 #include "components/prefs/pref_service.h" |
| 76 #include "components/session_manager/core/session_manager.h" |
| 78 #include "components/user_manager/user.h" | 77 #include "components/user_manager/user.h" |
| 79 #include "components/user_manager/user_manager.h" | 78 #include "components/user_manager/user_manager.h" |
| 80 #include "components/user_manager/user_type.h" | 79 #include "components/user_manager/user_type.h" |
| 81 #include "content/public/browser/notification_observer.h" | 80 #include "content/public/browser/notification_observer.h" |
| 82 #include "content/public/browser/notification_service.h" | 81 #include "content/public/browser/notification_service.h" |
| 83 #include "content/public/browser/user_metrics.h" | 82 #include "content/public/browser/user_metrics.h" |
| 84 #include "device/bluetooth/bluetooth_adapter.h" | 83 #include "device/bluetooth/bluetooth_adapter.h" |
| 85 #include "device/bluetooth/bluetooth_adapter_factory.h" | 84 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 86 #include "device/bluetooth/bluetooth_device.h" | 85 #include "device/bluetooth/bluetooth_device.h" |
| 87 #include "ui/base/ime/chromeos/extension_ime_util.h" | 86 #include "ui/base/ime/chromeos/extension_ime_util.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 device::BluetoothDevice::ConnectErrorCode error_code) { | 123 device::BluetoothDevice::ConnectErrorCode error_code) { |
| 125 } | 124 } |
| 126 | 125 |
| 127 void OnAcceptMultiprofilesIntro(bool no_show_again) { | 126 void OnAcceptMultiprofilesIntro(bool no_show_again) { |
| 128 PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); | 127 PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); |
| 129 prefs->SetBoolean(prefs::kMultiProfileNeverShowIntro, no_show_again); | 128 prefs->SetBoolean(prefs::kMultiProfileNeverShowIntro, no_show_again); |
| 130 UserAddingScreen::Get()->Start(); | 129 UserAddingScreen::Get()->Start(); |
| 131 } | 130 } |
| 132 | 131 |
| 133 bool IsSessionInSecondaryLoginScreen() { | 132 bool IsSessionInSecondaryLoginScreen() { |
| 134 return ash::WmShell::Get() | 133 return session_manager::SessionManager::Get()->IsInSecondaryLoginScreen(); |
| 135 ->GetSessionStateDelegate() | |
| 136 ->IsInSecondaryLoginScreen(); | |
| 137 } | 134 } |
| 138 | 135 |
| 139 } // namespace | 136 } // namespace |
| 140 | 137 |
| 141 SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS() | 138 SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS() |
| 142 : networking_config_delegate_(new NetworkingConfigDelegateChromeos()), | 139 : networking_config_delegate_(new NetworkingConfigDelegateChromeos()), |
| 143 weak_ptr_factory_(this) { | 140 weak_ptr_factory_(this) { |
| 144 // Register notifications on construction so that events such as | 141 // Register notifications on construction so that events such as |
| 145 // PROFILE_CREATED do not get missed if they happen before Initialize(). | 142 // PROFILE_CREATED do not get missed if they happen before Initialize(). |
| 146 registrar_.reset(new content::NotificationRegistrar); | 143 registrar_.reset(new content::NotificationRegistrar); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 170 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); | 167 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); |
| 171 | 168 |
| 172 input_method::InputMethodManager::Get()->AddObserver(this); | 169 input_method::InputMethodManager::Get()->AddObserver(this); |
| 173 input_method::InputMethodManager::Get()->AddImeMenuObserver(this); | 170 input_method::InputMethodManager::Get()->AddImeMenuObserver(this); |
| 174 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); | 171 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); |
| 175 | 172 |
| 176 device::BluetoothAdapterFactory::GetAdapter( | 173 device::BluetoothAdapterFactory::GetAdapter( |
| 177 base::Bind(&SystemTrayDelegateChromeOS::InitializeOnAdapterReady, | 174 base::Bind(&SystemTrayDelegateChromeOS::InitializeOnAdapterReady, |
| 178 weak_ptr_factory_.GetWeakPtr())); | 175 weak_ptr_factory_.GetWeakPtr())); |
| 179 | 176 |
| 180 ash::WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this); | |
| 181 | |
| 182 BrowserList::AddObserver(this); | 177 BrowserList::AddObserver(this); |
| 183 } | 178 } |
| 184 | 179 |
| 185 void SystemTrayDelegateChromeOS::InitializeOnAdapterReady( | 180 void SystemTrayDelegateChromeOS::InitializeOnAdapterReady( |
| 186 scoped_refptr<device::BluetoothAdapter> adapter) { | 181 scoped_refptr<device::BluetoothAdapter> adapter) { |
| 187 bluetooth_adapter_ = adapter; | 182 bluetooth_adapter_ = adapter; |
| 188 CHECK(bluetooth_adapter_); | 183 CHECK(bluetooth_adapter_); |
| 189 bluetooth_adapter_->AddObserver(this); | 184 bluetooth_adapter_->AddObserver(this); |
| 190 | 185 |
| 191 local_state_registrar_.reset(new PrefChangeRegistrar); | 186 local_state_registrar_.reset(new PrefChangeRegistrar); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 221 registrar_.reset(); | 216 registrar_.reset(); |
| 222 | 217 |
| 223 // Unregister a11y status subscription. | 218 // Unregister a11y status subscription. |
| 224 accessibility_subscription_.reset(); | 219 accessibility_subscription_.reset(); |
| 225 | 220 |
| 226 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); | 221 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); |
| 227 input_method::InputMethodManager::Get()->RemoveObserver(this); | 222 input_method::InputMethodManager::Get()->RemoveObserver(this); |
| 228 ui::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this); | 223 ui::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this); |
| 229 if (bluetooth_adapter_) | 224 if (bluetooth_adapter_) |
| 230 bluetooth_adapter_->RemoveObserver(this); | 225 bluetooth_adapter_->RemoveObserver(this); |
| 231 ash::WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver( | |
| 232 this); | |
| 233 | 226 |
| 234 BrowserList::RemoveObserver(this); | 227 BrowserList::RemoveObserver(this); |
| 235 StopObservingAppWindowRegistry(); | 228 StopObservingAppWindowRegistry(); |
| 236 StopObservingCustodianInfoChanges(); | 229 StopObservingCustodianInfoChanges(); |
| 237 | 230 |
| 238 policy::BrowserPolicyConnectorChromeOS* connector = | 231 policy::BrowserPolicyConnectorChromeOS* connector = |
| 239 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 232 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 240 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = | 233 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = |
| 241 connector->GetDeviceCloudPolicyManager(); | 234 connector->GetDeviceCloudPolicyManager(); |
| 242 if (policy_manager) | 235 if (policy_manager) |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 ash::WmShell* wm_shell = ash::WmShell::Get(); | 326 ash::WmShell* wm_shell = ash::WmShell::Get(); |
| 334 if (!wm_shell->delegate()->IsMultiProfilesEnabled()) | 327 if (!wm_shell->delegate()->IsMultiProfilesEnabled()) |
| 335 return; | 328 return; |
| 336 | 329 |
| 337 // Only regular non-supervised users could add other users to current session. | 330 // Only regular non-supervised users could add other users to current session. |
| 338 if (user_manager::UserManager::Get()->GetActiveUser()->GetType() != | 331 if (user_manager::UserManager::Get()->GetActiveUser()->GetType() != |
| 339 user_manager::USER_TYPE_REGULAR) { | 332 user_manager::USER_TYPE_REGULAR) { |
| 340 return; | 333 return; |
| 341 } | 334 } |
| 342 | 335 |
| 343 if (static_cast<int>( | 336 if (user_manager::UserManager::Get()->GetLoggedInUsers().size() >= |
| 344 user_manager::UserManager::Get()->GetLoggedInUsers().size()) >= | 337 session_manager::SessionManager::Get() |
| 345 wm_shell->GetSessionStateDelegate()->GetMaximumNumberOfLoggedInUsers()) { | 338 ->GetMaximumNumberOfUserSessions()) { |
| 346 return; | 339 return; |
| 347 } | 340 } |
| 348 | 341 |
| 349 // Launch sign in screen to add another user to current session. | 342 // Launch sign in screen to add another user to current session. |
| 350 if (user_manager::UserManager::Get() | 343 if (user_manager::UserManager::Get() |
| 351 ->GetUsersAllowedForMultiProfile() | 344 ->GetUsersAllowedForMultiProfile() |
| 352 .size()) { | 345 .size()) { |
| 353 // Don't show dialog if any logged in user in multi-profiles session | 346 // Don't show dialog if any logged in user in multi-profiles session |
| 354 // dismissed it. | 347 // dismissed it. |
| 355 bool show_intro = true; | 348 bool show_intro = true; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 custodian_info_changed_observers_.RemoveObserver(observer); | 557 custodian_info_changed_observers_.RemoveObserver(observer); |
| 565 } | 558 } |
| 566 | 559 |
| 567 std::unique_ptr<ash::SystemTrayItem> | 560 std::unique_ptr<ash::SystemTrayItem> |
| 568 SystemTrayDelegateChromeOS::CreateRotationLockTrayItem(ash::SystemTray* tray) { | 561 SystemTrayDelegateChromeOS::CreateRotationLockTrayItem(ash::SystemTray* tray) { |
| 569 return base::MakeUnique<ash::TrayRotationLock>(tray); | 562 return base::MakeUnique<ash::TrayRotationLock>(tray); |
| 570 } | 563 } |
| 571 | 564 |
| 572 void SystemTrayDelegateChromeOS::UserAddedToSession( | 565 void SystemTrayDelegateChromeOS::UserAddedToSession( |
| 573 const user_manager::User* active_user) { | 566 const user_manager::User* active_user) { |
| 567 GetSystemTrayNotifier()->NotifyUserAddedToSession(); |
| 574 } | 568 } |
| 575 | 569 |
| 576 void SystemTrayDelegateChromeOS::ActiveUserChanged( | 570 void SystemTrayDelegateChromeOS::ActiveUserChanged( |
| 577 const user_manager::User* /* active_user */) { | 571 const user_manager::User* /* active_user */) { |
| 578 } | 572 } |
| 579 | 573 |
| 580 void SystemTrayDelegateChromeOS::UserChangedChildStatus( | 574 void SystemTrayDelegateChromeOS::UserChangedChildStatus( |
| 581 user_manager::User* user) { | 575 user_manager::User* user) { |
| 582 Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(user); | 576 Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(user); |
| 583 | 577 |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 UpdateEnterpriseDomain(); | 878 UpdateEnterpriseDomain(); |
| 885 } | 879 } |
| 886 | 880 |
| 887 void SystemTrayDelegateChromeOS::OnUserImageChanged( | 881 void SystemTrayDelegateChromeOS::OnUserImageChanged( |
| 888 const user_manager::User& user) { | 882 const user_manager::User& user) { |
| 889 // This is also invoked on login screen when user avatar is loaded from file. | 883 // This is also invoked on login screen when user avatar is loaded from file. |
| 890 if (GetUserLoginStatus() != ash::LoginStatus::NOT_LOGGED_IN) | 884 if (GetUserLoginStatus() != ash::LoginStatus::NOT_LOGGED_IN) |
| 891 GetSystemTrayNotifier()->NotifyUserUpdate(); | 885 GetSystemTrayNotifier()->NotifyUserUpdate(); |
| 892 } | 886 } |
| 893 | 887 |
| 894 // Overridden from ash::SessionStateObserver | |
| 895 void SystemTrayDelegateChromeOS::UserAddedToSession( | |
| 896 const AccountId& /*account_id*/) { | |
| 897 GetSystemTrayNotifier()->NotifyUserAddedToSession(); | |
| 898 } | |
| 899 | |
| 900 void SystemTrayDelegateChromeOS::ActiveUserChanged( | |
| 901 const AccountId& /* user_id */) {} | |
| 902 | |
| 903 // Overridden from chrome::BrowserListObserver. | 888 // Overridden from chrome::BrowserListObserver. |
| 904 void SystemTrayDelegateChromeOS::OnBrowserRemoved(Browser* browser) { | 889 void SystemTrayDelegateChromeOS::OnBrowserRemoved(Browser* browser) { |
| 905 NotifyIfLastWindowClosed(); | 890 NotifyIfLastWindowClosed(); |
| 906 } | 891 } |
| 907 | 892 |
| 908 // Overridden from extensions::AppWindowRegistry::Observer. | 893 // Overridden from extensions::AppWindowRegistry::Observer. |
| 909 void SystemTrayDelegateChromeOS::OnAppWindowRemoved( | 894 void SystemTrayDelegateChromeOS::OnAppWindowRemoved( |
| 910 extensions::AppWindow* app_window) { | 895 extensions::AppWindow* app_window) { |
| 911 NotifyIfLastWindowClosed(); | 896 NotifyIfLastWindowClosed(); |
| 912 } | 897 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " | 955 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " |
| 971 << "ENABLE_SUPERVISED_USERS undefined."; | 956 << "ENABLE_SUPERVISED_USERS undefined."; |
| 972 return base::string16(); | 957 return base::string16(); |
| 973 } | 958 } |
| 974 | 959 |
| 975 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 960 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
| 976 return new SystemTrayDelegateChromeOS(); | 961 return new SystemTrayDelegateChromeOS(); |
| 977 } | 962 } |
| 978 | 963 |
| 979 } // namespace chromeos | 964 } // namespace chromeos |
| OLD | NEW |