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

Unified Diff: chrome/browser/ui/views/toolbar/toolbar_view.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/ui/views/toolbar/toolbar_view.h ('k') | chrome/browser/ui/webui/help/help_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/toolbar/toolbar_view.cc
diff --git a/chrome/browser/ui/views/toolbar/toolbar_view.cc b/chrome/browser/ui/views/toolbar/toolbar_view.cc
index 72eaaa1052dd5d3725ec18ba285151d3fafba304..df3e48bf4f5f9c19280c9b5f6b1269383c8e63c9 100644
--- a/chrome/browser/ui/views/toolbar/toolbar_view.cc
+++ b/chrome/browser/ui/views/toolbar/toolbar_view.cc
@@ -14,7 +14,6 @@
#include "build/build_config.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/app/vector_icons/vector_icons.h"
-#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/command_updater.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/profiles/profile.h"
@@ -45,6 +44,7 @@
#include "chrome/browser/ui/views/toolbar/toolbar_button.h"
#include "chrome/browser/ui/views/translate/translate_bubble_view.h"
#include "chrome/browser/ui/views/translate/translate_icon_view.h"
+#include "chrome/browser/upgrade_detector.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/chromium_strings.h"
@@ -53,7 +53,6 @@
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/browser_accessibility_state.h"
-#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "ui/accessibility/ax_node_data.h"
@@ -135,19 +134,12 @@ ToolbarView::ToolbarView(Browser* browser)
chrome::AddCommandObserver(browser_, IDC_HOME, this);
chrome::AddCommandObserver(browser_, IDC_LOAD_NEW_TAB_PAGE, this);
- if (OutdatedUpgradeBubbleView::IsAvailable()) {
- registrar_.Add(this, chrome::NOTIFICATION_OUTDATED_INSTALL,
- content::NotificationService::AllSources());
- registrar_.Add(this, chrome::NOTIFICATION_OUTDATED_INSTALL_NO_AU,
- content::NotificationService::AllSources());
- }
-#if defined(OS_WIN)
- registrar_.Add(this, chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED,
- content::NotificationService::AllSources());
-#endif
+ UpgradeDetector::GetInstance()->AddObserver(this);
}
ToolbarView::~ToolbarView() {
+ UpgradeDetector::GetInstance()->RemoveObserver(this);
+
// NOTE: Don't remove the command observers here. This object gets destroyed
// after the Browser (which owns the CommandUpdater), so the CommandUpdater is
// already gone.
@@ -451,26 +443,21 @@ void ToolbarView::ButtonPressed(views::Button* sender,
}
////////////////////////////////////////////////////////////////////////////////
-// ToolbarView, content::NotificationObserver implementation:
-
-void ToolbarView::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- switch (type) {
- case chrome::NOTIFICATION_OUTDATED_INSTALL:
- ShowOutdatedInstallNotification(true);
- break;
- case chrome::NOTIFICATION_OUTDATED_INSTALL_NO_AU:
- ShowOutdatedInstallNotification(false);
- break;
+// ToolbarView, UpgradeObserver implementation:
+void ToolbarView::OnOutdatedInstall() {
+ if (OutdatedUpgradeBubbleView::IsAvailable())
+ ShowOutdatedInstallNotification(true);
+}
+
+void ToolbarView::OnOutdatedInstallNoAutoUpdate() {
+ if (OutdatedUpgradeBubbleView::IsAvailable())
+ ShowOutdatedInstallNotification(false);
+}
+
+void ToolbarView::OnCriticalUpgradeInstalled() {
#if defined(OS_WIN)
- case chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED:
- ShowCriticalNotification();
- break;
+ ShowCriticalNotification();
#endif
- default:
- NOTREACHED();
- }
}
////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_view.h ('k') | chrome/browser/ui/webui/help/help_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698