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

Unified Diff: chrome/browser/extensions/theme_installed_infobar_delegate.cc

Issue 1600030: Select and close previous theme info bars when resetting to default theme via... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 8 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/extensions/theme_installed_infobar_delegate.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/theme_installed_infobar_delegate.cc
===================================================================
--- chrome/browser/extensions/theme_installed_infobar_delegate.cc (revision 44838)
+++ chrome/browser/extensions/theme_installed_infobar_delegate.cc (working copy)
@@ -14,20 +14,28 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/extensions/extension.h"
+#include "chrome/common/notification_service.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
ThemeInstalledInfoBarDelegate::ThemeInstalledInfoBarDelegate(
TabContents* tab_contents, const Extension* new_theme,
const std::string& previous_theme_id)
- : ConfirmInfoBarDelegate(tab_contents),
- profile_(tab_contents->profile()),
- name_(new_theme->name()),
- previous_theme_id_(previous_theme_id) {
+ : ConfirmInfoBarDelegate(tab_contents),
+ profile_(tab_contents->profile()),
+ name_(new_theme->name()),
+ theme_id_(new_theme->id()),
+ previous_theme_id_(previous_theme_id),
+ tab_contents_(tab_contents) {
profile_->GetThemeProvider()->OnInfobarDisplayed();
+ registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
+ NotificationService::AllSources());
}
ThemeInstalledInfoBarDelegate::~ThemeInstalledInfoBarDelegate() {
+ // We don't want any notifications while we're running our destructor.
+ registrar_.RemoveAll();
+
profile_->GetThemeProvider()->OnInfobarDestroyed();
}
@@ -85,3 +93,22 @@
profile_->ClearTheme();
return true;
}
+
+void ThemeInstalledInfoBarDelegate::Observe(
+ NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ switch (type.value) {
+ case NotificationType::BROWSER_THEME_CHANGED: {
+ // If the new theme is different from what this info bar is associated
+ // with, close this info bar since it is no longer relevant.
+ Extension* extension = Details<Extension>(details).ptr();
+ if (!extension || theme_id_ != extension->id())
+ tab_contents_->RemoveInfoBar(this);
+ break;
+ }
+
+ default:
+ NOTREACHED();
+ }
+}
« no previous file with comments | « chrome/browser/extensions/theme_installed_infobar_delegate.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698