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 <set> | 10 #include <set> |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 namespace chromeos { | 102 namespace chromeos { |
103 | 103 |
104 namespace { | 104 namespace { |
105 | 105 |
106 // The minimum session length limit that can be set. | 106 // The minimum session length limit that can be set. |
107 const int kSessionLengthLimitMinMs = 30 * 1000; // 30 seconds. | 107 const int kSessionLengthLimitMinMs = 30 * 1000; // 30 seconds. |
108 | 108 |
109 // The maximum session length limit that can be set. | 109 // The maximum session length limit that can be set. |
110 const int kSessionLengthLimitMaxMs = 24 * 60 * 60 * 1000; // 24 hours. | 110 const int kSessionLengthLimitMaxMs = 24 * 60 * 60 * 1000; // 24 hours. |
111 | 111 |
112 // A pointer so that callers can access the single class instance. | |
113 SystemTrayDelegateChromeOS* g_instance = nullptr; | |
Nico
2016/12/02 01:20:07
If you hadn't seen it, there's also base/memory/si
Greg K
2016/12/03 00:05:42
Acknowledged.
| |
114 | |
112 void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime, | 115 void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime, |
113 const input_method::InputMethodUtil& util, | 116 const input_method::InputMethodUtil& util, |
114 ash::IMEInfo* info) { | 117 ash::IMEInfo* info) { |
115 info->id = ime.id(); | 118 info->id = ime.id(); |
116 info->name = util.GetInputMethodLongName(ime); | 119 info->name = util.GetInputMethodLongName(ime); |
117 info->medium_name = util.GetInputMethodMediumName(ime); | 120 info->medium_name = util.GetInputMethodMediumName(ime); |
118 info->short_name = util.GetInputMethodShortName(ime); | 121 info->short_name = util.GetInputMethodShortName(ime); |
119 info->third_party = extension_ime_util::IsExtensionIME(ime.id()); | 122 info->third_party = extension_ime_util::IsExtensionIME(ime.id()); |
120 } | 123 } |
121 | 124 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 chrome::NOTIFICATION_PROFILE_DESTROYED, | 169 chrome::NOTIFICATION_PROFILE_DESTROYED, |
167 content::NotificationService::AllSources()); | 170 content::NotificationService::AllSources()); |
168 | 171 |
169 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); | 172 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); |
170 CHECK(accessibility_manager); | 173 CHECK(accessibility_manager); |
171 accessibility_subscription_ = accessibility_manager->RegisterCallback( | 174 accessibility_subscription_ = accessibility_manager->RegisterCallback( |
172 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged, | 175 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged, |
173 base::Unretained(this))); | 176 base::Unretained(this))); |
174 | 177 |
175 user_manager::UserManager::Get()->AddSessionStateObserver(this); | 178 user_manager::UserManager::Get()->AddSessionStateObserver(this); |
179 | |
180 DCHECK(!g_instance); | |
181 g_instance = this; | |
182 } | |
183 | |
184 // static | |
185 SystemTrayDelegateChromeOS* SystemTrayDelegateChromeOS::Get() { | |
186 return g_instance; | |
176 } | 187 } |
177 | 188 |
178 void SystemTrayDelegateChromeOS::Initialize() { | 189 void SystemTrayDelegateChromeOS::Initialize() { |
179 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); | 190 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); |
180 | 191 |
181 input_method::InputMethodManager::Get()->AddObserver(this); | 192 input_method::InputMethodManager::Get()->AddObserver(this); |
182 input_method::InputMethodManager::Get()->AddImeMenuObserver(this); | 193 input_method::InputMethodManager::Get()->AddImeMenuObserver(this); |
183 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); | 194 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); |
184 | 195 |
185 device::BluetoothAdapterFactory::GetAdapter( | 196 device::BluetoothAdapterFactory::GetAdapter( |
(...skipping 29 matching lines...) Expand all Loading... | |
215 policy::BrowserPolicyConnectorChromeOS* policy_connector = | 226 policy::BrowserPolicyConnectorChromeOS* policy_connector = |
216 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 227 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
217 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = | 228 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = |
218 policy_connector->GetDeviceCloudPolicyManager(); | 229 policy_connector->GetDeviceCloudPolicyManager(); |
219 if (policy_manager) | 230 if (policy_manager) |
220 policy_manager->core()->store()->AddObserver(this); | 231 policy_manager->core()->store()->AddObserver(this); |
221 UpdateEnterpriseDomain(); | 232 UpdateEnterpriseDomain(); |
222 } | 233 } |
223 | 234 |
224 SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() { | 235 SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() { |
236 DCHECK_EQ(this, g_instance); | |
237 g_instance = nullptr; | |
Nico
2016/12/02 01:20:07
oh, i guess in this case Singleton isn't an option
Greg K
2016/12/03 00:05:42
Acknowledged.
| |
238 | |
225 // Unregister PrefChangeRegistrars. | 239 // Unregister PrefChangeRegistrars. |
226 local_state_registrar_.reset(); | 240 local_state_registrar_.reset(); |
227 user_pref_registrar_.reset(); | 241 user_pref_registrar_.reset(); |
228 | 242 |
229 // Unregister content notifications before destroying any components. | 243 // Unregister content notifications before destroying any components. |
230 registrar_.reset(); | 244 registrar_.reset(); |
231 | 245 |
232 // Unregister a11y status subscription. | 246 // Unregister a11y status subscription. |
233 accessibility_subscription_.reset(); | 247 accessibility_subscription_.reset(); |
234 | 248 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 return user && user->IsSupervised(); | 322 return user && user->IsSupervised(); |
309 } | 323 } |
310 | 324 |
311 bool SystemTrayDelegateChromeOS::IsUserChild() const { | 325 bool SystemTrayDelegateChromeOS::IsUserChild() const { |
312 return user_manager::UserManager::Get()->IsLoggedInAsChildUser(); | 326 return user_manager::UserManager::Get()->IsLoggedInAsChildUser(); |
313 } | 327 } |
314 | 328 |
315 void SystemTrayDelegateChromeOS::GetSystemUpdateInfo( | 329 void SystemTrayDelegateChromeOS::GetSystemUpdateInfo( |
316 ash::UpdateInfo* info) const { | 330 ash::UpdateInfo* info) const { |
317 GetUpdateInfo(UpgradeDetector::GetInstance(), info); | 331 GetUpdateInfo(UpgradeDetector::GetInstance(), info); |
332 // If a flash component update is available, force the tray to show the user | |
333 // the Restart to Update dialog. | |
334 if (flash_update_available_) | |
335 info->update_required = true; | |
318 } | 336 } |
319 | 337 |
320 bool SystemTrayDelegateChromeOS::ShouldShowSettings() const { | 338 bool SystemTrayDelegateChromeOS::ShouldShowSettings() const { |
321 // Show setting button only when the user flow allows and it's not in the | 339 // Show setting button only when the user flow allows and it's not in the |
322 // multi-profile login screen. | 340 // multi-profile login screen. |
323 return ChromeUserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings() && | 341 return ChromeUserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings() && |
324 !IsSessionInSecondaryLoginScreen(); | 342 !IsSessionInSecondaryLoginScreen(); |
325 } | 343 } |
326 | 344 |
327 bool SystemTrayDelegateChromeOS::ShouldShowNotificationTray() const { | 345 bool SystemTrayDelegateChromeOS::ShouldShowNotificationTray() const { |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
604 void SystemTrayDelegateChromeOS::UserChangedChildStatus( | 622 void SystemTrayDelegateChromeOS::UserChangedChildStatus( |
605 user_manager::User* user) { | 623 user_manager::User* user) { |
606 Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(user); | 624 Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(user); |
607 | 625 |
608 // Returned user_profile might be NULL on restoring Users on browser start. | 626 // Returned user_profile might be NULL on restoring Users on browser start. |
609 // At some point profile is not yet fully initiated. | 627 // At some point profile is not yet fully initiated. |
610 if (session_started_ && user_profile && user_profile_ == user_profile) | 628 if (session_started_ && user_profile && user_profile_ == user_profile) |
611 ash::WmShell::Get()->UpdateAfterLoginStatusChange(GetUserLoginStatus()); | 629 ash::WmShell::Get()->UpdateAfterLoginStatusChange(GetUserLoginStatus()); |
612 } | 630 } |
613 | 631 |
632 void SystemTrayDelegateChromeOS::SetFlashUpdateAvailable() { | |
633 flash_update_available_ = true; | |
634 | |
635 ash::UpdateInfo info; | |
636 GetSystemUpdateInfo(&info); | |
637 GetSystemTrayNotifier()->NotifyUpdateRecommended(info); | |
638 } | |
639 | |
640 bool SystemTrayDelegateChromeOS::GetFlashUpdateAvailable() { | |
641 return flash_update_available_; | |
642 } | |
643 | |
614 ash::SystemTrayNotifier* SystemTrayDelegateChromeOS::GetSystemTrayNotifier() { | 644 ash::SystemTrayNotifier* SystemTrayDelegateChromeOS::GetSystemTrayNotifier() { |
615 return ash::WmShell::Get()->system_tray_notifier(); | 645 return ash::WmShell::Get()->system_tray_notifier(); |
616 } | 646 } |
617 | 647 |
618 void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) { | 648 void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) { |
619 // Stop observing the AppWindowRegistry of the current |user_profile_|. | 649 // Stop observing the AppWindowRegistry of the current |user_profile_|. |
620 StopObservingAppWindowRegistry(); | 650 StopObservingAppWindowRegistry(); |
621 | 651 |
622 // Stop observing custodian info changes of the current |user_profile_|. | 652 // Stop observing custodian info changes of the current |user_profile_|. |
623 StopObservingCustodianInfoChanges(); | 653 StopObservingCustodianInfoChanges(); |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1000 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " | 1030 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " |
1001 << "ENABLE_SUPERVISED_USERS undefined."; | 1031 << "ENABLE_SUPERVISED_USERS undefined."; |
1002 return base::string16(); | 1032 return base::string16(); |
1003 } | 1033 } |
1004 | 1034 |
1005 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 1035 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
1006 return new SystemTrayDelegateChromeOS(); | 1036 return new SystemTrayDelegateChromeOS(); |
1007 } | 1037 } |
1008 | 1038 |
1009 } // namespace chromeos | 1039 } // namespace chromeos |
OLD | NEW |