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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 namespace chromeos { | 106 namespace chromeos { |
107 | 107 |
108 namespace { | 108 namespace { |
109 | 109 |
110 // The minimum session length limit that can be set. | 110 // The minimum session length limit that can be set. |
111 const int kSessionLengthLimitMinMs = 30 * 1000; // 30 seconds. | 111 const int kSessionLengthLimitMinMs = 30 * 1000; // 30 seconds. |
112 | 112 |
113 // The maximum session length limit that can be set. | 113 // The maximum session length limit that can be set. |
114 const int kSessionLengthLimitMaxMs = 24 * 60 * 60 * 1000; // 24 hours. | 114 const int kSessionLengthLimitMaxMs = 24 * 60 * 60 * 1000; // 24 hours. |
115 | 115 |
116 // A pointer so that callers can access the single class instance. | |
117 SystemTrayDelegateChromeOS* g_instance = nullptr; | |
118 | |
116 void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime, | 119 void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime, |
117 const input_method::InputMethodUtil& util, | 120 const input_method::InputMethodUtil& util, |
118 ash::IMEInfo* info) { | 121 ash::IMEInfo* info) { |
119 info->id = ime.id(); | 122 info->id = ime.id(); |
120 info->name = util.GetInputMethodLongName(ime); | 123 info->name = util.GetInputMethodLongName(ime); |
121 info->medium_name = util.GetInputMethodMediumName(ime); | 124 info->medium_name = util.GetInputMethodMediumName(ime); |
122 info->short_name = util.GetInputMethodShortName(ime); | 125 info->short_name = util.GetInputMethodShortName(ime); |
123 info->third_party = extension_ime_util::IsExtensionIME(ime.id()); | 126 info->third_party = extension_ime_util::IsExtensionIME(ime.id()); |
124 } | 127 } |
125 | 128 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 chrome::NOTIFICATION_PROFILE_DESTROYED, | 174 chrome::NOTIFICATION_PROFILE_DESTROYED, |
172 content::NotificationService::AllSources()); | 175 content::NotificationService::AllSources()); |
173 | 176 |
174 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); | 177 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); |
175 CHECK(accessibility_manager); | 178 CHECK(accessibility_manager); |
176 accessibility_subscription_ = accessibility_manager->RegisterCallback( | 179 accessibility_subscription_ = accessibility_manager->RegisterCallback( |
177 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged, | 180 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged, |
178 base::Unretained(this))); | 181 base::Unretained(this))); |
179 | 182 |
180 user_manager::UserManager::Get()->AddSessionStateObserver(this); | 183 user_manager::UserManager::Get()->AddSessionStateObserver(this); |
184 | |
185 g_instance = this; | |
James Cook
2016/11/17 00:43:43
DCHECK(!g_instance) above just to make sure no one
Greg K
2016/11/30 19:30:29
Done.
| |
181 } | 186 } |
182 | 187 |
183 void SystemTrayDelegateChromeOS::Initialize() { | 188 void SystemTrayDelegateChromeOS::Initialize() { |
184 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); | 189 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); |
185 | 190 |
186 input_method::InputMethodManager::Get()->AddObserver(this); | 191 input_method::InputMethodManager::Get()->AddObserver(this); |
187 input_method::InputMethodManager::Get()->AddImeMenuObserver(this); | 192 input_method::InputMethodManager::Get()->AddImeMenuObserver(this); |
188 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); | 193 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); |
189 | 194 |
190 device::BluetoothAdapterFactory::GetAdapter( | 195 device::BluetoothAdapterFactory::GetAdapter( |
(...skipping 28 matching lines...) Expand all Loading... | |
219 | 224 |
220 policy::BrowserPolicyConnectorChromeOS* policy_connector = | 225 policy::BrowserPolicyConnectorChromeOS* policy_connector = |
221 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 226 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
222 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = | 227 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = |
223 policy_connector->GetDeviceCloudPolicyManager(); | 228 policy_connector->GetDeviceCloudPolicyManager(); |
224 if (policy_manager) | 229 if (policy_manager) |
225 policy_manager->core()->store()->AddObserver(this); | 230 policy_manager->core()->store()->AddObserver(this); |
226 UpdateEnterpriseDomain(); | 231 UpdateEnterpriseDomain(); |
227 } | 232 } |
228 | 233 |
229 SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() { | 234 SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() { |
James Cook
2016/11/17 00:43:43
DCHECK_EQ(this, g_instance);
g_instance = nullptr;
Greg K
2016/11/30 19:30:30
Done.
| |
230 // Unregister PrefChangeRegistrars. | 235 // Unregister PrefChangeRegistrars. |
231 local_state_registrar_.reset(); | 236 local_state_registrar_.reset(); |
232 user_pref_registrar_.reset(); | 237 user_pref_registrar_.reset(); |
233 | 238 |
234 // Unregister content notifications before destroying any components. | 239 // Unregister content notifications before destroying any components. |
235 registrar_.reset(); | 240 registrar_.reset(); |
236 | 241 |
237 // Unregister a11y status subscription. | 242 // Unregister a11y status subscription. |
238 accessibility_subscription_.reset(); | 243 accessibility_subscription_.reset(); |
239 | 244 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 return user && user->IsSupervised(); | 318 return user && user->IsSupervised(); |
314 } | 319 } |
315 | 320 |
316 bool SystemTrayDelegateChromeOS::IsUserChild() const { | 321 bool SystemTrayDelegateChromeOS::IsUserChild() const { |
317 return user_manager::UserManager::Get()->IsLoggedInAsChildUser(); | 322 return user_manager::UserManager::Get()->IsLoggedInAsChildUser(); |
318 } | 323 } |
319 | 324 |
320 void SystemTrayDelegateChromeOS::GetSystemUpdateInfo( | 325 void SystemTrayDelegateChromeOS::GetSystemUpdateInfo( |
321 ash::UpdateInfo* info) const { | 326 ash::UpdateInfo* info) const { |
322 GetUpdateInfo(UpgradeDetector::GetInstance(), info); | 327 GetUpdateInfo(UpgradeDetector::GetInstance(), info); |
328 if (!info->factory_reset_required && flash_update_available_) | |
James Cook
2016/11/17 00:43:43
Any particular reason not to set update_required i
Greg K
2016/11/30 19:30:30
Done.
| |
329 info->update_required = true; | |
323 } | 330 } |
324 | 331 |
325 bool SystemTrayDelegateChromeOS::ShouldShowSettings() const { | 332 bool SystemTrayDelegateChromeOS::ShouldShowSettings() const { |
326 // Show setting button only when the user flow allows and it's not in the | 333 // Show setting button only when the user flow allows and it's not in the |
327 // multi-profile login screen. | 334 // multi-profile login screen. |
328 return ChromeUserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings() && | 335 return ChromeUserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings() && |
329 !IsSessionInSecondaryLoginScreen(); | 336 !IsSessionInSecondaryLoginScreen(); |
330 } | 337 } |
331 | 338 |
332 bool SystemTrayDelegateChromeOS::ShouldShowNotificationTray() const { | 339 bool SystemTrayDelegateChromeOS::ShouldShowNotificationTray() const { |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1008 | 1015 |
1009 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " | 1016 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " |
1010 << "ENABLE_SUPERVISED_USERS undefined."; | 1017 << "ENABLE_SUPERVISED_USERS undefined."; |
1011 return base::string16(); | 1018 return base::string16(); |
1012 } | 1019 } |
1013 | 1020 |
1014 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 1021 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
1015 return new SystemTrayDelegateChromeOS(); | 1022 return new SystemTrayDelegateChromeOS(); |
1016 } | 1023 } |
1017 | 1024 |
1025 // static | |
1026 SystemTrayDelegateChromeOS* SystemTrayDelegateChromeOS::Get() { | |
1027 return g_instance; | |
1028 } | |
1029 | |
1030 void SystemTrayDelegateChromeOS::SetFlashUpdateAvailable() { | |
1031 flash_update_available_ = true; | |
1032 | |
1033 ash::UpdateInfo info; | |
James Cook
2016/11/17 00:43:43
Why not call GetSystemUpdateInfo() and use that re
Greg K
2016/11/30 19:30:29
Done.
| |
1034 info.severity = ash::UpdateInfo::UPDATE_ELEVATED; | |
1035 info.update_required = true; | |
1036 info.factory_reset_required = false; | |
1037 | |
1038 GetSystemTrayNotifier()->NotifyUpdateRecommended(info); | |
1039 } | |
James Cook
2016/11/17 00:43:43
Can you add a test for this? It's unlikely that fl
Greg K
2016/11/30 19:30:30
What do you mean by "has a flake problem"? I imagi
James Cook
2016/11/30 23:01:40
A unit test would be nice, but if you look at syst
| |
1040 | |
1018 } // namespace chromeos | 1041 } // namespace chromeos |
OLD | NEW |