| 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> |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace | 139 } // namespace |
| 140 | 140 |
| 141 SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS() | 141 SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS() |
| 142 : networking_config_delegate_(new NetworkingConfigDelegateChromeos()), | 142 : networking_config_delegate_(new NetworkingConfigDelegateChromeos()), |
| 143 weak_ptr_factory_(this) { | 143 weak_ptr_factory_(this) { |
| 144 // Register notifications on construction so that events such as | 144 // Register notifications on construction so that events such as |
| 145 // PROFILE_CREATED do not get missed if they happen before Initialize(). | 145 // PROFILE_CREATED do not get missed if they happen before Initialize(). |
| 146 registrar_.reset(new content::NotificationRegistrar); | 146 registrar_.reset(new content::NotificationRegistrar); |
| 147 registrar_->Add(this, | |
| 148 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, | |
| 149 content::NotificationService::AllSources()); | |
| 150 if (GetUserLoginStatus() == ash::LoginStatus::NOT_LOGGED_IN) { | 147 if (GetUserLoginStatus() == ash::LoginStatus::NOT_LOGGED_IN) { |
| 151 registrar_->Add(this, | 148 registrar_->Add(this, |
| 152 chrome::NOTIFICATION_SESSION_STARTED, | 149 chrome::NOTIFICATION_SESSION_STARTED, |
| 153 content::NotificationService::AllSources()); | 150 content::NotificationService::AllSources()); |
| 154 } | 151 } |
| 155 registrar_->Add(this, | 152 registrar_->Add(this, |
| 156 chrome::NOTIFICATION_PROFILE_CREATED, | 153 chrome::NOTIFICATION_PROFILE_CREATED, |
| 157 content::NotificationService::AllSources()); | 154 content::NotificationService::AllSources()); |
| 158 registrar_->Add(this, | 155 registrar_->Add(this, |
| 159 chrome::NOTIFICATION_PROFILE_DESTROYED, | 156 chrome::NOTIFICATION_PROFILE_DESTROYED, |
| 160 content::NotificationService::AllSources()); | 157 content::NotificationService::AllSources()); |
| 161 | 158 |
| 162 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); | 159 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); |
| 163 CHECK(accessibility_manager); | 160 CHECK(accessibility_manager); |
| 164 accessibility_subscription_ = accessibility_manager->RegisterCallback( | 161 accessibility_subscription_ = accessibility_manager->RegisterCallback( |
| 165 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged, | 162 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged, |
| 166 base::Unretained(this))); | 163 base::Unretained(this))); |
| 167 | 164 |
| 165 user_manager::UserManager::Get()->AddObserver(this); |
| 168 user_manager::UserManager::Get()->AddSessionStateObserver(this); | 166 user_manager::UserManager::Get()->AddSessionStateObserver(this); |
| 169 } | 167 } |
| 170 | 168 |
| 171 void SystemTrayDelegateChromeOS::Initialize() { | 169 void SystemTrayDelegateChromeOS::Initialize() { |
| 172 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); | 170 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); |
| 173 | 171 |
| 174 input_method::InputMethodManager::Get()->AddObserver(this); | 172 input_method::InputMethodManager::Get()->AddObserver(this); |
| 175 input_method::InputMethodManager::Get()->AddImeMenuObserver(this); | 173 input_method::InputMethodManager::Get()->AddImeMenuObserver(this); |
| 176 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); | 174 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); |
| 177 | 175 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 StopObservingAppWindowRegistry(); | 235 StopObservingAppWindowRegistry(); |
| 238 StopObservingCustodianInfoChanges(); | 236 StopObservingCustodianInfoChanges(); |
| 239 | 237 |
| 240 policy::BrowserPolicyConnectorChromeOS* connector = | 238 policy::BrowserPolicyConnectorChromeOS* connector = |
| 241 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 239 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 242 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = | 240 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = |
| 243 connector->GetDeviceCloudPolicyManager(); | 241 connector->GetDeviceCloudPolicyManager(); |
| 244 if (policy_manager) | 242 if (policy_manager) |
| 245 policy_manager->core()->store()->RemoveObserver(this); | 243 policy_manager->core()->store()->RemoveObserver(this); |
| 246 | 244 |
| 245 user_manager::UserManager::Get()->RemoveObserver(this); |
| 247 user_manager::UserManager::Get()->RemoveSessionStateObserver(this); | 246 user_manager::UserManager::Get()->RemoveSessionStateObserver(this); |
| 248 } | 247 } |
| 249 | 248 |
| 250 ash::LoginStatus SystemTrayDelegateChromeOS::GetUserLoginStatus() const { | 249 ash::LoginStatus SystemTrayDelegateChromeOS::GetUserLoginStatus() const { |
| 251 return SystemTrayClient::GetUserLoginStatus(); | 250 return SystemTrayClient::GetUserLoginStatus(); |
| 252 } | 251 } |
| 253 | 252 |
| 254 std::string SystemTrayDelegateChromeOS::GetEnterpriseDomain() const { | 253 std::string SystemTrayDelegateChromeOS::GetEnterpriseDomain() const { |
| 255 return enterprise_domain_; | 254 return enterprise_domain_; |
| 256 } | 255 } |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 void SystemTrayDelegateChromeOS::ScreenIsUnlocked() { | 754 void SystemTrayDelegateChromeOS::ScreenIsUnlocked() { |
| 756 ash::WmShell::Get()->UpdateAfterLoginStatusChange(GetUserLoginStatus()); | 755 ash::WmShell::Get()->UpdateAfterLoginStatusChange(GetUserLoginStatus()); |
| 757 } | 756 } |
| 758 | 757 |
| 759 // content::NotificationObserver implementation. | 758 // content::NotificationObserver implementation. |
| 760 void SystemTrayDelegateChromeOS::Observe( | 759 void SystemTrayDelegateChromeOS::Observe( |
| 761 int type, | 760 int type, |
| 762 const content::NotificationSource& source, | 761 const content::NotificationSource& source, |
| 763 const content::NotificationDetails& details) { | 762 const content::NotificationDetails& details) { |
| 764 switch (type) { | 763 switch (type) { |
| 765 case chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED: { | |
| 766 // This notification is also sent on login screen when user avatar | |
| 767 // is loaded from file. | |
| 768 if (GetUserLoginStatus() != ash::LoginStatus::NOT_LOGGED_IN) { | |
| 769 GetSystemTrayNotifier()->NotifyUserUpdate(); | |
| 770 } | |
| 771 break; | |
| 772 } | |
| 773 case chrome::NOTIFICATION_PROFILE_CREATED: { | 764 case chrome::NOTIFICATION_PROFILE_CREATED: { |
| 774 SetProfile(content::Source<Profile>(source).ptr()); | 765 SetProfile(content::Source<Profile>(source).ptr()); |
| 775 registrar_->Remove(this, | 766 registrar_->Remove(this, |
| 776 chrome::NOTIFICATION_PROFILE_CREATED, | 767 chrome::NOTIFICATION_PROFILE_CREATED, |
| 777 content::NotificationService::AllSources()); | 768 content::NotificationService::AllSources()); |
| 778 break; | 769 break; |
| 779 } | 770 } |
| 780 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 771 case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
| 781 if (UnsetProfile(content::Source<Profile>(source).ptr())) { | 772 if (UnsetProfile(content::Source<Profile>(source).ptr())) { |
| 782 registrar_->Remove(this, | 773 registrar_->Remove(this, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 // Overridden from CloudPolicyStore::Observer | 883 // Overridden from CloudPolicyStore::Observer |
| 893 void SystemTrayDelegateChromeOS::OnStoreLoaded( | 884 void SystemTrayDelegateChromeOS::OnStoreLoaded( |
| 894 policy::CloudPolicyStore* store) { | 885 policy::CloudPolicyStore* store) { |
| 895 UpdateEnterpriseDomain(); | 886 UpdateEnterpriseDomain(); |
| 896 } | 887 } |
| 897 | 888 |
| 898 void SystemTrayDelegateChromeOS::OnStoreError(policy::CloudPolicyStore* store) { | 889 void SystemTrayDelegateChromeOS::OnStoreError(policy::CloudPolicyStore* store) { |
| 899 UpdateEnterpriseDomain(); | 890 UpdateEnterpriseDomain(); |
| 900 } | 891 } |
| 901 | 892 |
| 893 void SystemTrayDelegateChromeOS::OnUserImageChanged( |
| 894 const user_manager::User& user) { |
| 895 // This is also invoked on login screen when user avatar is loaded from file. |
| 896 if (GetUserLoginStatus() != ash::LoginStatus::NOT_LOGGED_IN) |
| 897 GetSystemTrayNotifier()->NotifyUserUpdate(); |
| 898 } |
| 899 |
| 902 // Overridden from ash::SessionStateObserver | 900 // Overridden from ash::SessionStateObserver |
| 903 void SystemTrayDelegateChromeOS::UserAddedToSession( | 901 void SystemTrayDelegateChromeOS::UserAddedToSession( |
| 904 const AccountId& /*account_id*/) { | 902 const AccountId& /*account_id*/) { |
| 905 GetSystemTrayNotifier()->NotifyUserAddedToSession(); | 903 GetSystemTrayNotifier()->NotifyUserAddedToSession(); |
| 906 } | 904 } |
| 907 | 905 |
| 908 void SystemTrayDelegateChromeOS::ActiveUserChanged( | 906 void SystemTrayDelegateChromeOS::ActiveUserChanged( |
| 909 const AccountId& /* user_id */) {} | 907 const AccountId& /* user_id */) {} |
| 910 | 908 |
| 911 // Overridden from chrome::BrowserListObserver. | 909 // Overridden from chrome::BrowserListObserver. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " | 976 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " |
| 979 << "ENABLE_SUPERVISED_USERS undefined."; | 977 << "ENABLE_SUPERVISED_USERS undefined."; |
| 980 return base::string16(); | 978 return base::string16(); |
| 981 } | 979 } |
| 982 | 980 |
| 983 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 981 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
| 984 return new SystemTrayDelegateChromeOS(); | 982 return new SystemTrayDelegateChromeOS(); |
| 985 } | 983 } |
| 986 | 984 |
| 987 } // namespace chromeos | 985 } // namespace chromeos |
| OLD | NEW |