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

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

Issue 164312: Make the theme install infobar have an 'undo' button instead of (Closed)
Patch Set: Created 11 years, 4 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
Index: chrome/browser/extensions/theme_preview_infobar_delegate.cc
diff --git a/chrome/browser/extensions/theme_preview_infobar_delegate.cc b/chrome/browser/extensions/theme_preview_infobar_delegate.cc
index a1a179f78e1ddb06c5a5ece98ed473cb916192a0..99617153c2fb6ee8c9381038f9c397736774b739 100644
--- a/chrome/browser/extensions/theme_preview_infobar_delegate.cc
+++ b/chrome/browser/extensions/theme_preview_infobar_delegate.cc
@@ -6,14 +6,18 @@
#include "app/l10n_util.h"
#include "base/string_util.h"
+#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/extensions/extension.h"
#include "grit/generated_resources.h"
ThemePreviewInfobarDelegate::ThemePreviewInfobarDelegate(
- TabContents* tab_contents, const std::string& name)
+ TabContents* tab_contents, const std::string& name,
+ const std::string& previous_theme_id)
: ConfirmInfoBarDelegate(tab_contents),
- profile_(tab_contents->profile()), name_(name) {
+ profile_(tab_contents->profile()), name_(name),
+ previous_theme_id_(previous_theme_id) {
}
void ThemePreviewInfobarDelegate::InfoBarClosed() {
@@ -51,13 +55,17 @@ std::wstring ThemePreviewInfobarDelegate::GetButtonLabel(
}
bool ThemePreviewInfobarDelegate::Cancel() {
- // Blech, this is a total hack.
- //
- // a) We should be uninstalling via ExtensionsService, not
- // Profile::ClearTheme().
- // b) We should be able to view the theme without installing it. This would
- // help in edge cases like the user closing the window or tab before making
- // a decision.
+ if (!previous_theme_id_.empty()) {
+ ExtensionsService* service = profile_->GetExtensionsService();
+ if (service) {
+ Extension* previous_theme = service->GetExtensionById(previous_theme_id_);
+ if (previous_theme) {
+ profile_->SetTheme(previous_theme);
+ return true;
+ }
+ }
+ }
+
profile_->ClearTheme();
return true;
}

Powered by Google App Engine
This is Rietveld 408576698