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

Unified Diff: chrome/browser/upgrade_detector.cc

Issue 2925973002: Migrate upgrade notifications to observer (Closed)
Patch Set: Add DISALLOW_COPY_AND_ASSIGN Created 3 years, 6 months 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
« no previous file with comments | « chrome/browser/upgrade_detector.h ('k') | chrome/browser/upgrade_detector_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/upgrade_detector.cc
diff --git a/chrome/browser/upgrade_detector.cc b/chrome/browser/upgrade_detector.cc
index 68215d240a6d08fcd005d3093f3069c3dc9c19b6..3a0763d602c122674d94434e09daa8eaeed2e11e 100644
--- a/chrome/browser/upgrade_detector.cc
+++ b/chrome/browser/upgrade_detector.cc
@@ -7,13 +7,11 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "chrome/app/vector_icons/vector_icons.h"
-#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/ui/browser_otr_state.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_registry_simple.h"
-#include "content/public/browser/notification_service.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/paint_vector_icon.h"
@@ -73,20 +71,40 @@ UpgradeDetector::UpgradeDetector()
UpgradeDetector::~UpgradeDetector() {
}
-void UpgradeDetector::NotifyUpgradeRecommended() {
+void UpgradeDetector::NotifyOutdatedInstall() {
+ for (auto& observer : observer_list_)
+ observer.OnOutdatedInstall();
+}
+
+void UpgradeDetector::NotifyOutdatedInstallNoAutoUpdate() {
+ for (auto& observer : observer_list_)
+ observer.OnOutdatedInstallNoAutoUpdate();
+}
+
+void UpgradeDetector::NotifyUpgrade() {
notify_upgrade_ = true;
- TriggerNotification(chrome::NOTIFICATION_UPGRADE_RECOMMENDED);
+ NotifyUpgradeRecommended();
if (upgrade_available_ == UPGRADE_NEEDED_OUTDATED_INSTALL) {
- TriggerNotification(chrome::NOTIFICATION_OUTDATED_INSTALL);
+ NotifyOutdatedInstall();
} else if (upgrade_available_ == UPGRADE_NEEDED_OUTDATED_INSTALL_NO_AU) {
- TriggerNotification(chrome::NOTIFICATION_OUTDATED_INSTALL_NO_AU);
+ NotifyOutdatedInstallNoAutoUpdate();
} else if (upgrade_available_ == UPGRADE_AVAILABLE_CRITICAL ||
critical_experiment_updates_available_) {
TriggerCriticalUpdate();
}
}
+void UpgradeDetector::NotifyUpgradeRecommended() {
+ for (auto& observer : observer_list_)
+ observer.OnUpgradeRecommended();
+}
+
+void UpgradeDetector::NotifyCriticalUpgradeInstalled() {
+ for (auto& observer : observer_list_)
+ observer.OnCriticalUpgradeInstalled();
+}
+
void UpgradeDetector::NotifyUpdateOverCellularAvailable() {
for (auto& observer : observer_list_)
observer.OnUpdateOverCellularAvailable();
@@ -110,13 +128,6 @@ void UpgradeDetector::CheckIdle() {
base::Unretained(this)));
}
-void UpgradeDetector::TriggerNotification(chrome::NotificationType type) {
- content::NotificationService::current()->Notify(
- type,
- content::Source<UpgradeDetector>(this),
- content::NotificationService::NoDetails());
-}
-
void UpgradeDetector::IdleCallback(ui::IdleState state) {
// Don't proceed while an incognito window is open. The timer will still
// keep firing, so this function will get a chance to re-evaluate this.
@@ -132,7 +143,7 @@ void UpgradeDetector::IdleCallback(ui::IdleState state) {
case ui::IDLE_STATE_IDLE:
// Computer has been idle for long enough, show warning.
idle_check_timer_.Stop();
- TriggerNotification(chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED);
+ NotifyCriticalUpgradeInstalled();
break;
case ui::IDLE_STATE_ACTIVE:
case ui::IDLE_STATE_UNKNOWN:
« no previous file with comments | « chrome/browser/upgrade_detector.h ('k') | chrome/browser/upgrade_detector_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698