diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-09 04:30:06 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-09 04:30:06 +0000 |
commit | 1e9ae4b6e18e62ca06f6bb9c7c0c6b56510c9091 (patch) | |
tree | 83d15ae372f65bab0a1e9aa27727b22970e56ef2 | |
parent | dccce12ad336b63071ac90cb252e171e781df9bf (diff) | |
download | chromium_src-1e9ae4b6e18e62ca06f6bb9c7c0c6b56510c9091.zip chromium_src-1e9ae4b6e18e62ca06f6bb9c7c0c6b56510c9091.tar.gz chromium_src-1e9ae4b6e18e62ca06f6bb9c7c0c6b56510c9091.tar.bz2 |
patch from issue 261007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28520 0039d316-1c4b-4281-b951-d872f2087c98
10 files changed, 44 insertions, 212 deletions
diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc index 457dbad..d044bf0 100644 --- a/chrome/browser/extensions/extension_install_ui.cc +++ b/chrome/browser/extensions/extension_install_ui.cc @@ -12,7 +12,7 @@ #include "base/rand_util.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_window.h" -#include "chrome/browser/extensions/theme_preview_infobar_delegate.h" +#include "chrome/browser/extensions/theme_installed_infobar_delegate.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/extensions/extension.h" @@ -27,7 +27,7 @@ #include "base/sys_string_conversions.h" #include <CoreFoundation/CFUserNotification.h> #elif defined(TOOLKIT_GTK) -#include "chrome/browser/extensions/gtk_theme_preview_infobar_delegate.h" +#include "chrome/browser/extensions/gtk_theme_installed_infobar_delegate.h" #include "chrome/browser/gtk/gtk_theme_provider.h" #endif @@ -231,12 +231,12 @@ void ExtensionInstallUI::ShowThemeInfoBar(Extension* new_theme) { // Then either replace that old one or add a new one. InfoBarDelegate* new_delegate = #if defined(TOOLKIT_GTK) - new GtkThemePreviewInfobarDelegate( + new GtkThemeInstalledInfoBarDelegate( tab_contents, new_theme->name(), previous_theme_id_, previous_use_gtk_theme_); #else - new ThemePreviewInfobarDelegate(tab_contents, - new_theme->name(), previous_theme_id_); + new ThemeInstalledInfoBarDelegate(tab_contents, + new_theme->name(), previous_theme_id_); #endif if (old_delegate) diff --git a/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.cc b/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.cc index e577158..9ce137a 100644 --- a/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.cc +++ b/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.cc @@ -6,20 +6,20 @@ #include "chrome/browser/profile.h" -GtkThemePreviewInfobarDelegate::GtkThemePreviewInfobarDelegate( +GtkThemeInstalledInfoBarDelegate::GtkThemeInstalledInfoBarDelegate( TabContents* tab_contents, const std::string& name, const std::string& previous_theme, bool previous_use_gtk_theme) - : ThemePreviewInfobarDelegate(tab_contents, name, previous_theme), + : ThemeInstalledInfoBarDelegate(tab_contents, name, previous_theme), previous_use_gtk_theme_(previous_use_gtk_theme) { } -bool GtkThemePreviewInfobarDelegate::Cancel() { +bool GtkThemeInstalledInfoBarDelegate::Cancel() { if (previous_use_gtk_theme_) { profile()->SetNativeTheme(); return true; } else { - return ThemePreviewInfobarDelegate::Cancel(); + return ThemeInstalledInfoBarDelegate::Cancel(); } } diff --git a/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.h b/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.h index cfc213de..75ea2da 100644 --- a/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.h +++ b/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.h @@ -2,26 +2,28 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_VIEWS_EXTENSIONS_GTK_THEME_PREVIEW_INFOBAR_DELEGATE_H_ -#define CHROME_BROWSER_VIEWS_EXTENSIONS_GTK_THEME_PREVIEW_INFOBAR_DELEGATE_H_ +#ifndef CHROME_BROWSER_VIEWS_EXTENSIONS_GTK_THEME_INSTALLED_INFOBAR_DELEGATE_H_ +#define CHROME_BROWSER_VIEWS_EXTENSIONS_GTK_THEME_INSTALLED_INFOBAR_DELEGATE_H_ -#include "chrome/browser/extensions/theme_preview_infobar_delegate.h" +#include "chrome/browser/extensions/theme_installed_infobar_delegate.h" + +#include <string> class SkBitmap; class TabContents; -// A specialization of ThemePreviewInfobarDelegate to make "Undo" reset to the +// A specialization of ThemeInstalledInfoBarDelegate to make "Undo" reset to the // GTK theme if the user was in GTK theme mode before installing the theme. -class GtkThemePreviewInfobarDelegate : public ThemePreviewInfobarDelegate { +class GtkThemeInstalledInfoBarDelegate : public ThemeInstalledInfoBarDelegate { public: - GtkThemePreviewInfobarDelegate(TabContents* tab_contents, - const std::string& name, - const std::string& previous_theme, - bool previous_use_gtk_theme); + GtkThemeInstalledInfoBarDelegate(TabContents* tab_contents, + const std::string& name, + const std::string& previous_theme, + bool previous_use_gtk_theme); virtual bool Cancel(); private: bool previous_use_gtk_theme_; }; -#endif // CHROME_BROWSER_VIEWS_EXTENSIONS_GTK_THEME_PREVIEW_INFOBAR_DELEGATE_H_ +#endif // CHROME_BROWSER_VIEWS_EXTENSIONS_GTK_THEME_INSTALLED_INFOBAR_DELEGATE_H_ diff --git a/chrome/browser/extensions/gtk_theme_preview_infobar_delegate.cc b/chrome/browser/extensions/gtk_theme_preview_infobar_delegate.cc index e577158..e69de29 100644 --- a/chrome/browser/extensions/gtk_theme_preview_infobar_delegate.cc +++ b/chrome/browser/extensions/gtk_theme_preview_infobar_delegate.cc @@ -1,25 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/extensions/gtk_theme_preview_infobar_delegate.h" - -#include "chrome/browser/profile.h" - -GtkThemePreviewInfobarDelegate::GtkThemePreviewInfobarDelegate( - TabContents* tab_contents, - const std::string& name, - const std::string& previous_theme, - bool previous_use_gtk_theme) - : ThemePreviewInfobarDelegate(tab_contents, name, previous_theme), - previous_use_gtk_theme_(previous_use_gtk_theme) { -} - -bool GtkThemePreviewInfobarDelegate::Cancel() { - if (previous_use_gtk_theme_) { - profile()->SetNativeTheme(); - return true; - } else { - return ThemePreviewInfobarDelegate::Cancel(); - } -} diff --git a/chrome/browser/extensions/gtk_theme_preview_infobar_delegate.h b/chrome/browser/extensions/gtk_theme_preview_infobar_delegate.h index cfc213de..e69de29 100644 --- a/chrome/browser/extensions/gtk_theme_preview_infobar_delegate.h +++ b/chrome/browser/extensions/gtk_theme_preview_infobar_delegate.h @@ -1,27 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_VIEWS_EXTENSIONS_GTK_THEME_PREVIEW_INFOBAR_DELEGATE_H_ -#define CHROME_BROWSER_VIEWS_EXTENSIONS_GTK_THEME_PREVIEW_INFOBAR_DELEGATE_H_ - -#include "chrome/browser/extensions/theme_preview_infobar_delegate.h" - -class SkBitmap; -class TabContents; - -// A specialization of ThemePreviewInfobarDelegate to make "Undo" reset to the -// GTK theme if the user was in GTK theme mode before installing the theme. -class GtkThemePreviewInfobarDelegate : public ThemePreviewInfobarDelegate { - public: - GtkThemePreviewInfobarDelegate(TabContents* tab_contents, - const std::string& name, - const std::string& previous_theme, - bool previous_use_gtk_theme); - virtual bool Cancel(); - - private: - bool previous_use_gtk_theme_; -}; - -#endif // CHROME_BROWSER_VIEWS_EXTENSIONS_GTK_THEME_PREVIEW_INFOBAR_DELEGATE_H_ diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.cc b/chrome/browser/extensions/theme_installed_infobar_delegate.cc index 06b8ed6..2084548 100644 --- a/chrome/browser/extensions/theme_installed_infobar_delegate.cc +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/theme_preview_infobar_delegate.h" +#include "chrome/browser/extensions/theme_installed_infobar_delegate.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" @@ -14,40 +14,41 @@ #include "grit/generated_resources.h" #include "grit/theme_resources.h" -ThemePreviewInfobarDelegate::ThemePreviewInfobarDelegate( +ThemeInstalledInfoBarDelegate::ThemeInstalledInfoBarDelegate( 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() { +void ThemeInstalledInfoBarDelegate::InfoBarClosed() { delete this; } -std::wstring ThemePreviewInfobarDelegate::GetMessageText() const { +std::wstring ThemeInstalledInfoBarDelegate::GetMessageText() const { return l10n_util::GetStringF(IDS_THEME_INSTALL_INFOBAR_LABEL, UTF8ToWide(name_)); } -SkBitmap* ThemePreviewInfobarDelegate::GetIcon() const { +SkBitmap* ThemeInstalledInfoBarDelegate::GetIcon() const { // TODO(aa): Reply with the theme's icon, but this requires reading it // asynchronously from disk. return ResourceBundle::GetSharedInstance().GetBitmapNamed( IDR_INFOBAR_THEME); } -ThemePreviewInfobarDelegate* - ThemePreviewInfobarDelegate::AsThemePreviewInfobarDelegate() { +ThemeInstalledInfoBarDelegate* + ThemeInstalledInfoBarDelegate::AsThemePreviewInfobarDelegate() { return this; } -int ThemePreviewInfobarDelegate::GetButtons() const { +int ThemeInstalledInfoBarDelegate::GetButtons() const { return BUTTON_CANCEL; } -std::wstring ThemePreviewInfobarDelegate::GetButtonLabel( +std::wstring ThemeInstalledInfoBarDelegate::GetButtonLabel( ConfirmInfoBarDelegate::InfoBarButton button) const { switch (button) { case BUTTON_CANCEL: { @@ -58,7 +59,7 @@ std::wstring ThemePreviewInfobarDelegate::GetButtonLabel( } } -bool ThemePreviewInfobarDelegate::Cancel() { +bool ThemeInstalledInfoBarDelegate::Cancel() { if (!previous_theme_id_.empty()) { ExtensionsService* service = profile_->GetExtensionsService(); if (service) { diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.h b/chrome/browser/extensions/theme_installed_infobar_delegate.h index fdffe07..594764a 100644 --- a/chrome/browser/extensions/theme_installed_infobar_delegate.h +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_VIEWS_EXTENSIONS_THEME_PREVIEW_INFOBAR_DELEGATE_H_ -#define CHROME_BROWSER_VIEWS_EXTENSIONS_THEME_PREVIEW_INFOBAR_DELEGATE_H_ +#ifndef CHROME_BROWSER_VIEWS_EXTENSIONS_THEME_INSTALLED_INFOBAR_DELEGATE_H_ +#define CHROME_BROWSER_VIEWS_EXTENSIONS_THEME_INSTALLED_INFOBAR_DELEGATE_H_ #include "chrome/browser/tab_contents/infobar_delegate.h" @@ -12,18 +12,15 @@ class TabContents; // When a user installs a theme, we display it immediately, but provide an // infobar allowing them to cancel. -// -// TODO(aa): Rename this to ThemeInstalledInfoBarDelegate, since it isn't -// used for previewing anymore. -class ThemePreviewInfobarDelegate : public ConfirmInfoBarDelegate { +class ThemeInstalledInfoBarDelegate : public ConfirmInfoBarDelegate { public: - ThemePreviewInfobarDelegate(TabContents* tab_contents, - const std::string& name, - const std::string& previous_theme); + ThemeInstalledInfoBarDelegate(TabContents* tab_contents, + const std::string& name, + const std::string& previous_theme); virtual void InfoBarClosed(); virtual std::wstring GetMessageText() const; virtual SkBitmap* GetIcon() const; - virtual ThemePreviewInfobarDelegate* AsThemePreviewInfobarDelegate(); + virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); virtual int GetButtons() const; virtual std::wstring GetButtonLabel( ConfirmInfoBarDelegate::InfoBarButton button) const; @@ -38,4 +35,4 @@ class ThemePreviewInfobarDelegate : public ConfirmInfoBarDelegate { std::string previous_theme_id_; // used to undo theme install }; -#endif // CHROME_BROWSER_VIEWS_EXTENSIONS_THEME_PREVIEW_INFOBAR_DELEGATE_H_ +#endif // CHROME_BROWSER_VIEWS_EXTENSIONS_THEME_INSTALLED_INFOBAR_DELEGATE_H_ diff --git a/chrome/browser/extensions/theme_preview_infobar_delegate.cc b/chrome/browser/extensions/theme_preview_infobar_delegate.cc index 06b8ed6..e69de29 100644 --- a/chrome/browser/extensions/theme_preview_infobar_delegate.cc +++ b/chrome/browser/extensions/theme_preview_infobar_delegate.cc @@ -1,75 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/extensions/theme_preview_infobar_delegate.h" - -#include "app/l10n_util.h" -#include "app/resource_bundle.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" -#include "grit/theme_resources.h" - -ThemePreviewInfobarDelegate::ThemePreviewInfobarDelegate( - TabContents* tab_contents, const std::string& name, - const std::string& previous_theme_id) - : ConfirmInfoBarDelegate(tab_contents), - profile_(tab_contents->profile()), name_(name), - previous_theme_id_(previous_theme_id) { -} - -void ThemePreviewInfobarDelegate::InfoBarClosed() { - delete this; -} - -std::wstring ThemePreviewInfobarDelegate::GetMessageText() const { - return l10n_util::GetStringF(IDS_THEME_INSTALL_INFOBAR_LABEL, - UTF8ToWide(name_)); -} - -SkBitmap* ThemePreviewInfobarDelegate::GetIcon() const { - // TODO(aa): Reply with the theme's icon, but this requires reading it - // asynchronously from disk. - return ResourceBundle::GetSharedInstance().GetBitmapNamed( - IDR_INFOBAR_THEME); -} - -ThemePreviewInfobarDelegate* - ThemePreviewInfobarDelegate::AsThemePreviewInfobarDelegate() { - return this; -} - -int ThemePreviewInfobarDelegate::GetButtons() const { - return BUTTON_CANCEL; -} - -std::wstring ThemePreviewInfobarDelegate::GetButtonLabel( - ConfirmInfoBarDelegate::InfoBarButton button) const { - switch (button) { - case BUTTON_CANCEL: { - return l10n_util::GetString(IDS_THEME_INSTALL_INFOBAR_UNDO_BUTTON); - } - default: - return L""; - } -} - -bool ThemePreviewInfobarDelegate::Cancel() { - 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; -} diff --git a/chrome/browser/extensions/theme_preview_infobar_delegate.h b/chrome/browser/extensions/theme_preview_infobar_delegate.h index fdffe07..e69de29 100644 --- a/chrome/browser/extensions/theme_preview_infobar_delegate.h +++ b/chrome/browser/extensions/theme_preview_infobar_delegate.h @@ -1,41 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_VIEWS_EXTENSIONS_THEME_PREVIEW_INFOBAR_DELEGATE_H_ -#define CHROME_BROWSER_VIEWS_EXTENSIONS_THEME_PREVIEW_INFOBAR_DELEGATE_H_ - -#include "chrome/browser/tab_contents/infobar_delegate.h" - -class SkBitmap; -class TabContents; - -// When a user installs a theme, we display it immediately, but provide an -// infobar allowing them to cancel. -// -// TODO(aa): Rename this to ThemeInstalledInfoBarDelegate, since it isn't -// used for previewing anymore. -class ThemePreviewInfobarDelegate : public ConfirmInfoBarDelegate { - public: - ThemePreviewInfobarDelegate(TabContents* tab_contents, - const std::string& name, - const std::string& previous_theme); - virtual void InfoBarClosed(); - virtual std::wstring GetMessageText() const; - virtual SkBitmap* GetIcon() const; - virtual ThemePreviewInfobarDelegate* AsThemePreviewInfobarDelegate(); - virtual int GetButtons() const; - virtual std::wstring GetButtonLabel( - ConfirmInfoBarDelegate::InfoBarButton button) const; - virtual bool Cancel(); - - protected: - Profile* profile() { return profile_; } - - private: - Profile* profile_; - std::string name_; // name of theme to install - std::string previous_theme_id_; // used to undo theme install -}; - -#endif // CHROME_BROWSER_VIEWS_EXTENSIONS_THEME_PREVIEW_INFOBAR_DELEGATE_H_ diff --git a/chrome/browser/tab_contents/infobar_delegate.h b/chrome/browser/tab_contents/infobar_delegate.h index 569ad1d..8079fba 100644 --- a/chrome/browser/tab_contents/infobar_delegate.h +++ b/chrome/browser/tab_contents/infobar_delegate.h @@ -16,7 +16,7 @@ class AlertInfoBarDelegate; class ConfirmInfoBarDelegate; class InfoBar; class LinkInfoBarDelegate; -class ThemePreviewInfobarDelegate; +class ThemeInstalledInfoBarDelegate; // An interface implemented by objects wishing to control an InfoBar. // Implementing this interface is not sufficient to use an InfoBar, since it @@ -96,9 +96,9 @@ class InfoBarDelegate { return NULL; } - // Returns a pointer to the ThemePreviewInfobarDelegate interface, if + // Returns a pointer to the ThemeInstalledInfoBarDelegate interface, if // implemented. - virtual ThemePreviewInfobarDelegate* AsThemePreviewInfobarDelegate() { + virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate() { return NULL; } |