summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-28 22:57:22 +0000
committerglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-28 22:57:22 +0000
commit7a691a96215f24415dc7e45dd437ff3371ea1225 (patch)
treeb3edbdb8b775f072d9086a636617e88a0352160e
parente7a1f04a389e923439b8f57aa5e02bd392fb1491 (diff)
downloadchromium_src-7a691a96215f24415dc7e45dd437ff3371ea1225.zip
chromium_src-7a691a96215f24415dc7e45dd437ff3371ea1225.tar.gz
chromium_src-7a691a96215f24415dc7e45dd437ff3371ea1225.tar.bz2
Only allow one theme installation infobar to be shown at a time.
BUG=None TEST=Install two themes without closing the infobar - make sure only one infobar is visible. Review URL: http://codereview.chromium.org/160296 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21910 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/theme_preview_infobar_delegate.cc18
-rw-r--r--chrome/browser/extensions/theme_preview_infobar_delegate.h2
-rw-r--r--chrome/browser/tab_contents/infobar_delegate.h7
3 files changed, 27 insertions, 0 deletions
diff --git a/chrome/browser/extensions/theme_preview_infobar_delegate.cc b/chrome/browser/extensions/theme_preview_infobar_delegate.cc
index b55df72..75c1ce8 100644
--- a/chrome/browser/extensions/theme_preview_infobar_delegate.cc
+++ b/chrome/browser/extensions/theme_preview_infobar_delegate.cc
@@ -16,6 +16,19 @@ ThemePreviewInfobarDelegate::ThemePreviewInfobarDelegate(
profile_(tab_contents->profile()), name_(name) {
}
+bool ThemePreviewInfobarDelegate::EqualsDelegate(InfoBarDelegate* delegate)
+ const {
+ // If another infobar of this type is showing, this will prevent us adding
+ // a new one, we only care if they're the same type, as pressing undo always
+ // has the same result each time. This does mean that the text continues
+ // to refer to the old theme, but this is good enough for beta.
+ // http://crbug.com/17932
+ if (delegate->AsThemePreviewInfobarDelegate())
+ return true;
+
+ return false;
+}
+
void ThemePreviewInfobarDelegate::InfoBarClosed() {
delete this;
}
@@ -31,6 +44,11 @@ SkBitmap* ThemePreviewInfobarDelegate::GetIcon() const {
return NULL;
}
+ThemePreviewInfobarDelegate*
+ ThemePreviewInfobarDelegate::AsThemePreviewInfobarDelegate() {
+ return this;
+}
+
int ThemePreviewInfobarDelegate::GetButtons() const {
return BUTTON_CANCEL;
}
diff --git a/chrome/browser/extensions/theme_preview_infobar_delegate.h b/chrome/browser/extensions/theme_preview_infobar_delegate.h
index b688f86..0d2b564 100644
--- a/chrome/browser/extensions/theme_preview_infobar_delegate.h
+++ b/chrome/browser/extensions/theme_preview_infobar_delegate.h
@@ -18,9 +18,11 @@ class ThemePreviewInfobarDelegate : public ConfirmInfoBarDelegate {
public:
ThemePreviewInfobarDelegate(TabContents* tab_contents,
const std::string& name);
+ virtual bool EqualsDelegate(InfoBarDelegate* delegate) const;
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;
diff --git a/chrome/browser/tab_contents/infobar_delegate.h b/chrome/browser/tab_contents/infobar_delegate.h
index f8ce253..569ad1d 100644
--- a/chrome/browser/tab_contents/infobar_delegate.h
+++ b/chrome/browser/tab_contents/infobar_delegate.h
@@ -16,6 +16,7 @@ class AlertInfoBarDelegate;
class ConfirmInfoBarDelegate;
class InfoBar;
class LinkInfoBarDelegate;
+class ThemePreviewInfobarDelegate;
// An interface implemented by objects wishing to control an InfoBar.
// Implementing this interface is not sufficient to use an InfoBar, since it
@@ -95,6 +96,12 @@ class InfoBarDelegate {
return NULL;
}
+ // Returns a pointer to the ThemePreviewInfobarDelegate interface, if
+ // implemented.
+ virtual ThemePreviewInfobarDelegate* AsThemePreviewInfobarDelegate() {
+ return NULL;
+ }
+
// Returns the type of the infobar. The type determines the appearance (such
// as background color) of the infobar.
virtual Type GetInfoBarType() {