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

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: Rebased CL 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 <memory> 10 #include <memory>
(...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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 chrome::NOTIFICATION_PROFILE_DESTROYED, 168 chrome::NOTIFICATION_PROFILE_DESTROYED,
166 content::NotificationService::AllSources()); 169 content::NotificationService::AllSources());
167 170
168 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); 171 AccessibilityManager* accessibility_manager = AccessibilityManager::Get();
169 CHECK(accessibility_manager); 172 CHECK(accessibility_manager);
170 accessibility_subscription_ = accessibility_manager->RegisterCallback( 173 accessibility_subscription_ = accessibility_manager->RegisterCallback(
171 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged, 174 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged,
172 base::Unretained(this))); 175 base::Unretained(this)));
173 176
174 user_manager::UserManager::Get()->AddSessionStateObserver(this); 177 user_manager::UserManager::Get()->AddSessionStateObserver(this);
178
179 DCHECK(!g_instance);
180 g_instance = this;
181 }
182
183 // static
184 SystemTrayDelegateChromeOS* SystemTrayDelegateChromeOS::instance() {
185 return g_instance;
175 } 186 }
176 187
177 void SystemTrayDelegateChromeOS::Initialize() { 188 void SystemTrayDelegateChromeOS::Initialize() {
178 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); 189 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this);
179 190
180 input_method::InputMethodManager::Get()->AddObserver(this); 191 input_method::InputMethodManager::Get()->AddObserver(this);
181 input_method::InputMethodManager::Get()->AddImeMenuObserver(this); 192 input_method::InputMethodManager::Get()->AddImeMenuObserver(this);
182 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); 193 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this);
183 194
184 device::BluetoothAdapterFactory::GetAdapter( 195 device::BluetoothAdapterFactory::GetAdapter(
(...skipping 29 matching lines...) Expand all
214 policy::BrowserPolicyConnectorChromeOS* policy_connector = 225 policy::BrowserPolicyConnectorChromeOS* policy_connector =
215 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 226 g_browser_process->platform_part()->browser_policy_connector_chromeos();
216 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 227 policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
217 policy_connector->GetDeviceCloudPolicyManager(); 228 policy_connector->GetDeviceCloudPolicyManager();
218 if (policy_manager) 229 if (policy_manager)
219 policy_manager->core()->store()->AddObserver(this); 230 policy_manager->core()->store()->AddObserver(this);
220 UpdateEnterpriseDomain(); 231 UpdateEnterpriseDomain();
221 } 232 }
222 233
223 SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() { 234 SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() {
235 DCHECK_EQ(this, g_instance);
236 g_instance = nullptr;
237
224 // Unregister PrefChangeRegistrars. 238 // Unregister PrefChangeRegistrars.
225 local_state_registrar_.reset(); 239 local_state_registrar_.reset();
226 user_pref_registrar_.reset(); 240 user_pref_registrar_.reset();
227 241
228 // Unregister content notifications before destroying any components. 242 // Unregister content notifications before destroying any components.
229 registrar_.reset(); 243 registrar_.reset();
230 244
231 // Unregister a11y status subscription. 245 // Unregister a11y status subscription.
232 accessibility_subscription_.reset(); 246 accessibility_subscription_.reset();
233 247
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 return user && user->IsSupervised(); 321 return user && user->IsSupervised();
308 } 322 }
309 323
310 bool SystemTrayDelegateChromeOS::IsUserChild() const { 324 bool SystemTrayDelegateChromeOS::IsUserChild() const {
311 return user_manager::UserManager::Get()->IsLoggedInAsChildUser(); 325 return user_manager::UserManager::Get()->IsLoggedInAsChildUser();
312 } 326 }
313 327
314 void SystemTrayDelegateChromeOS::GetSystemUpdateInfo( 328 void SystemTrayDelegateChromeOS::GetSystemUpdateInfo(
315 ash::UpdateInfo* info) const { 329 ash::UpdateInfo* info) const {
316 GetUpdateInfo(UpgradeDetector::GetInstance(), info); 330 GetUpdateInfo(UpgradeDetector::GetInstance(), info);
331 // If a flash component update is available, force the tray to show the user
332 // the Restart to Update dialog.
333 if (flash_update_available_)
334 info->update_required = true;
James Cook 2016/12/09 00:11:40 Hey, I just thought of something. If the only upda
317 } 335 }
318 336
319 bool SystemTrayDelegateChromeOS::ShouldShowSettings() const { 337 bool SystemTrayDelegateChromeOS::ShouldShowSettings() const {
320 // Show setting button only when the user flow allows and it's not in the 338 // Show setting button only when the user flow allows and it's not in the
321 // multi-profile login screen. 339 // multi-profile login screen.
322 return ChromeUserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings() && 340 return ChromeUserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings() &&
323 !IsSessionInSecondaryLoginScreen(); 341 !IsSessionInSecondaryLoginScreen();
324 } 342 }
325 343
326 bool SystemTrayDelegateChromeOS::ShouldShowNotificationTray() const { 344 bool SystemTrayDelegateChromeOS::ShouldShowNotificationTray() const {
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 void SystemTrayDelegateChromeOS::UserChangedChildStatus( 617 void SystemTrayDelegateChromeOS::UserChangedChildStatus(
600 user_manager::User* user) { 618 user_manager::User* user) {
601 Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(user); 619 Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(user);
602 620
603 // Returned user_profile might be NULL on restoring Users on browser start. 621 // Returned user_profile might be NULL on restoring Users on browser start.
604 // At some point profile is not yet fully initiated. 622 // At some point profile is not yet fully initiated.
605 if (session_started_ && user_profile && user_profile_ == user_profile) 623 if (session_started_ && user_profile && user_profile_ == user_profile)
606 ash::WmShell::Get()->UpdateAfterLoginStatusChange(GetUserLoginStatus()); 624 ash::WmShell::Get()->UpdateAfterLoginStatusChange(GetUserLoginStatus());
607 } 625 }
608 626
627 void SystemTrayDelegateChromeOS::SetFlashUpdateAvailable() {
628 flash_update_available_ = true;
629
630 ash::UpdateInfo info;
631 GetSystemUpdateInfo(&info);
632 GetSystemTrayNotifier()->NotifyUpdateRecommended(info);
633 }
634
635 bool SystemTrayDelegateChromeOS::GetFlashUpdateAvailable() {
636 return flash_update_available_;
637 }
638
609 ash::SystemTrayNotifier* SystemTrayDelegateChromeOS::GetSystemTrayNotifier() { 639 ash::SystemTrayNotifier* SystemTrayDelegateChromeOS::GetSystemTrayNotifier() {
610 return ash::WmShell::Get()->system_tray_notifier(); 640 return ash::WmShell::Get()->system_tray_notifier();
611 } 641 }
612 642
613 void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) { 643 void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) {
614 // Stop observing the AppWindowRegistry of the current |user_profile_|. 644 // Stop observing the AppWindowRegistry of the current |user_profile_|.
615 StopObservingAppWindowRegistry(); 645 StopObservingAppWindowRegistry();
616 646
617 // Stop observing custodian info changes of the current |user_profile_|. 647 // Stop observing custodian info changes of the current |user_profile_|.
618 StopObservingCustodianInfoChanges(); 648 StopObservingCustodianInfoChanges();
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " 1025 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while "
996 << "ENABLE_SUPERVISED_USERS undefined."; 1026 << "ENABLE_SUPERVISED_USERS undefined.";
997 return base::string16(); 1027 return base::string16();
998 } 1028 }
999 1029
1000 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 1030 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
1001 return new SystemTrayDelegateChromeOS(); 1031 return new SystemTrayDelegateChromeOS();
1002 } 1032 }
1003 1033
1004 } // namespace chromeos 1034 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698