diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-11 18:37:38 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-11 18:37:38 +0000 |
commit | 1e09a50056d013f04f980855e8c0c5a424070985 (patch) | |
tree | 1b86f0df4c12e0098be5790b26c56cf23571d943 /chrome/browser/extensions/theme_preview_infobar_delegate.cc | |
parent | 601298ebd4745c16d156c0a85fcf800acf110997 (diff) | |
download | chromium_src-1e09a50056d013f04f980855e8c0c5a424070985.zip chromium_src-1e09a50056d013f04f980855e8c0c5a424070985.tar.gz chromium_src-1e09a50056d013f04f980855e8c0c5a424070985.tar.bz2 |
Make the theme install infobar have an 'undo' button instead
of a 'back to default' button.
BUG=18986
TEST=none
Review URL: http://codereview.chromium.org/164312
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23055 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/theme_preview_infobar_delegate.cc')
-rw-r--r-- | chrome/browser/extensions/theme_preview_infobar_delegate.cc | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/chrome/browser/extensions/theme_preview_infobar_delegate.cc b/chrome/browser/extensions/theme_preview_infobar_delegate.cc index a1a179f..ac71aa9 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() { @@ -44,20 +48,27 @@ std::wstring ThemePreviewInfobarDelegate::GetButtonLabel( ConfirmInfoBarDelegate::InfoBarButton button) const { switch (button) { case BUTTON_CANCEL: - return l10n_util::GetString(IDS_THEME_INSTALL_INFOBAR_UNDO_BUTTON); + // TODO(aa): Reusing IDS_UNDO is hack to get around string freeze. This + // should be changed back to IDS_THEME_INSTALL_INFOBAR_UNDO_BUTTON at some + // point. + return l10n_util::GetString(IDS_UNDO); default: return L""; } } 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; } |