Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: chrome/browser/ui/ash/system_tray_delegate_chromeos.cc

Issue 2493973003: Display "Restart to update" dialog to Chrome OS users. (Closed)
Patch Set: Display "Restart to update" dialog to Chrome OS users. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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;
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
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;
176 } 182 }
177 183
178 void SystemTrayDelegateChromeOS::Initialize() { 184 void SystemTrayDelegateChromeOS::Initialize() {
179 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); 185 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this);
180 186
181 input_method::InputMethodManager::Get()->AddObserver(this); 187 input_method::InputMethodManager::Get()->AddObserver(this);
182 input_method::InputMethodManager::Get()->AddImeMenuObserver(this); 188 input_method::InputMethodManager::Get()->AddImeMenuObserver(this);
183 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); 189 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this);
184 190
185 device::BluetoothAdapterFactory::GetAdapter( 191 device::BluetoothAdapterFactory::GetAdapter(
(...skipping 29 matching lines...) Expand all
215 policy::BrowserPolicyConnectorChromeOS* policy_connector = 221 policy::BrowserPolicyConnectorChromeOS* policy_connector =
216 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 222 g_browser_process->platform_part()->browser_policy_connector_chromeos();
217 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 223 policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
218 policy_connector->GetDeviceCloudPolicyManager(); 224 policy_connector->GetDeviceCloudPolicyManager();
219 if (policy_manager) 225 if (policy_manager)
220 policy_manager->core()->store()->AddObserver(this); 226 policy_manager->core()->store()->AddObserver(this);
221 UpdateEnterpriseDomain(); 227 UpdateEnterpriseDomain();
222 } 228 }
223 229
224 SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() { 230 SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() {
231 DCHECK_EQ(this, g_instance);
232 g_instance = nullptr;
233
225 // Unregister PrefChangeRegistrars. 234 // Unregister PrefChangeRegistrars.
226 local_state_registrar_.reset(); 235 local_state_registrar_.reset();
227 user_pref_registrar_.reset(); 236 user_pref_registrar_.reset();
228 237
229 // Unregister content notifications before destroying any components. 238 // Unregister content notifications before destroying any components.
230 registrar_.reset(); 239 registrar_.reset();
231 240
232 // Unregister a11y status subscription. 241 // Unregister a11y status subscription.
233 accessibility_subscription_.reset(); 242 accessibility_subscription_.reset();
234 243
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 return user && user->IsSupervised(); 317 return user && user->IsSupervised();
309 } 318 }
310 319
311 bool SystemTrayDelegateChromeOS::IsUserChild() const { 320 bool SystemTrayDelegateChromeOS::IsUserChild() const {
312 return user_manager::UserManager::Get()->IsLoggedInAsChildUser(); 321 return user_manager::UserManager::Get()->IsLoggedInAsChildUser();
313 } 322 }
314 323
315 void SystemTrayDelegateChromeOS::GetSystemUpdateInfo( 324 void SystemTrayDelegateChromeOS::GetSystemUpdateInfo(
316 ash::UpdateInfo* info) const { 325 ash::UpdateInfo* info) const {
317 GetUpdateInfo(UpgradeDetector::GetInstance(), info); 326 GetUpdateInfo(UpgradeDetector::GetInstance(), info);
327 // If a flash component update is available, force the tray to show the user
328 // the Restart to Update dialog.
329 if (flash_update_available_)
330 info->update_required = true;
318 } 331 }
319 332
320 bool SystemTrayDelegateChromeOS::ShouldShowSettings() const { 333 bool SystemTrayDelegateChromeOS::ShouldShowSettings() const {
321 // Show setting button only when the user flow allows and it's not in the 334 // Show setting button only when the user flow allows and it's not in the
322 // multi-profile login screen. 335 // multi-profile login screen.
323 return ChromeUserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings() && 336 return ChromeUserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings() &&
324 !IsSessionInSecondaryLoginScreen(); 337 !IsSessionInSecondaryLoginScreen();
325 } 338 }
326 339
327 bool SystemTrayDelegateChromeOS::ShouldShowNotificationTray() const { 340 bool SystemTrayDelegateChromeOS::ShouldShowNotificationTray() const {
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 1012
1000 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " 1013 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while "
1001 << "ENABLE_SUPERVISED_USERS undefined."; 1014 << "ENABLE_SUPERVISED_USERS undefined.";
1002 return base::string16(); 1015 return base::string16();
1003 } 1016 }
1004 1017
1005 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 1018 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
1006 return new SystemTrayDelegateChromeOS(); 1019 return new SystemTrayDelegateChromeOS();
1007 } 1020 }
1008 1021
1022 // static
1023 SystemTrayDelegateChromeOS* SystemTrayDelegateChromeOS::Get() {
James Cook 2016/12/01 20:41:13 nit: reorder this function (and the ones below) to
Greg K 2016/12/02 01:07:32 Done.
1024 return g_instance;
1025 }
1026
1027 void SystemTrayDelegateChromeOS::SetFlashUpdateAvailable() {
1028 flash_update_available_ = true;
1029
1030 ash::UpdateInfo info;
1031 GetSystemUpdateInfo(&info);
1032 GetSystemTrayNotifier()->NotifyUpdateRecommended(info);
1033 }
1034
1035 bool SystemTrayDelegateChromeOS::GetFlashUpdateAvailable() {
1036 return flash_update_available_;
1037 }
1038
1009 } // namespace chromeos 1039 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698