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

Unified Diff: chrome/browser/ui/ash/system_tray_delegate_chromeos.cc

Issue 2568413002: Revert of ash: Use system tray mojo interface to show system update tray icon (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
diff --git a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
index 0b1920ca9e086b761cfa338ad752c0f3c3c2f825..73f5c2e7d161bed10418c448bf1ffc70ab718330 100644
--- a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
+++ b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
@@ -24,6 +24,7 @@
#include "ash/common/system/ime/ime_observer.h"
#include "ash/common/system/tray/system_tray_notifier.h"
#include "ash/common/system/tray_accessibility.h"
+#include "ash/common/system/update/update_observer.h"
#include "ash/common/system/user/user_observer.h"
#include "ash/common/wm_shell.h"
#include "ash/system/chromeos/rotation/tray_rotation_lock.h"
@@ -57,11 +58,13 @@
#include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
#include "chrome/browser/ui/ash/networking_config_delegate_chromeos.h"
#include "chrome/browser/ui/ash/system_tray_client.h"
+#include "chrome/browser/ui/ash/system_tray_delegate_utils.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/browser/ui/singleton_tabs.h"
+#include "chrome/browser/upgrade_detector.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/features.h"
#include "chrome/common/pref_names.h"
@@ -106,6 +109,9 @@
// The maximum session length limit that can be set.
const int kSessionLengthLimitMaxMs = 24 * 60 * 60 * 1000; // 24 hours.
+// A pointer so that callers can access the single class instance.
+SystemTrayDelegateChromeOS* g_instance = nullptr;
+
void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime,
const input_method::InputMethodUtil& util,
ash::IMEInfo* info) {
@@ -145,6 +151,9 @@
// PROFILE_CREATED do not get missed if they happen before Initialize().
registrar_.reset(new content::NotificationRegistrar);
registrar_->Add(this,
+ chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
+ content::NotificationService::AllSources());
+ registrar_->Add(this,
chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
content::NotificationService::AllSources());
if (GetUserLoginStatus() == ash::LoginStatus::NOT_LOGGED_IN) {
@@ -166,6 +175,14 @@
base::Unretained(this)));
user_manager::UserManager::Get()->AddSessionStateObserver(this);
+
+ DCHECK(!g_instance);
+ g_instance = this;
+}
+
+// static
+SystemTrayDelegateChromeOS* SystemTrayDelegateChromeOS::instance() {
+ return g_instance;
}
void SystemTrayDelegateChromeOS::Initialize() {
@@ -215,6 +232,9 @@
}
SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() {
+ DCHECK_EQ(this, g_instance);
+ g_instance = nullptr;
+
// Unregister PrefChangeRegistrars.
local_state_registrar_.reset();
user_pref_registrar_.reset();
@@ -303,6 +323,15 @@
bool SystemTrayDelegateChromeOS::IsUserChild() const {
return user_manager::UserManager::Get()->IsLoggedInAsChildUser();
+}
+
+void SystemTrayDelegateChromeOS::GetSystemUpdateInfo(
+ ash::UpdateInfo* info) const {
+ GetUpdateInfo(UpgradeDetector::GetInstance(), info);
+ // If a flash component update is available, force the tray to show the user
+ // the Restart to Update dialog.
+ if (flash_update_available_)
+ info->update_required = true;
}
bool SystemTrayDelegateChromeOS::ShouldShowSettings() const {
@@ -593,6 +622,18 @@
// At some point profile is not yet fully initiated.
if (session_started_ && user_profile && user_profile_ == user_profile)
ash::WmShell::Get()->UpdateAfterLoginStatusChange(GetUserLoginStatus());
+}
+
+void SystemTrayDelegateChromeOS::SetFlashUpdateAvailable() {
+ flash_update_available_ = true;
+
+ ash::UpdateInfo info;
+ GetSystemUpdateInfo(&info);
+ GetSystemTrayNotifier()->NotifyUpdateRecommended(info);
+}
+
+bool SystemTrayDelegateChromeOS::GetFlashUpdateAvailable() {
+ return flash_update_available_;
}
ash::SystemTrayNotifier* SystemTrayDelegateChromeOS::GetSystemTrayNotifier() {
@@ -762,6 +803,12 @@
const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
+ case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: {
+ ash::UpdateInfo info;
+ GetUpdateInfo(content::Source<UpgradeDetector>(source).ptr(), &info);
+ GetSystemTrayNotifier()->NotifyUpdateRecommended(info);
+ break;
+ }
case chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED: {
// This notification is also sent on login screen when user avatar
// is loaded from file.

Powered by Google App Engine
This is Rietveld 408576698