Index: chrome/browser/ui/blocked_content/popup_blocked_infobar_delegate.cc |
diff --git a/chrome/browser/ui/blocked_content/popup_blocked_infobar_delegate.cc b/chrome/browser/ui/blocked_content/popup_blocked_infobar_delegate.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f332fe99f176032fb4e5727ed7b4cc523419c031 |
--- /dev/null |
+++ b/chrome/browser/ui/blocked_content/popup_blocked_infobar_delegate.cc |
@@ -0,0 +1,63 @@ |
+// Copyright (c) 2013 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/ui/blocked_content/popup_blocked_infobar_delegate.h" |
+ |
+#include "chrome/browser/infobars/infobar_service.h" |
+#include "grit/generated_resources.h" |
+#include "grit/theme_resources.h" |
+#include "ui/base/l10n/l10n_util.h" |
+ |
+PopupBlockedInfoBarDelegate::PopupBlockedInfoBarDelegate( |
+ InfoBarService* infobar_service, |
+ int n_popups) |
+ : ConfirmInfoBarDelegate(infobar_service), n_popups_(n_popups) {} |
+ |
+PopupBlockedInfoBarDelegate::~PopupBlockedInfoBarDelegate() {} |
+ |
+string16 PopupBlockedInfoBarDelegate::GetMessageText() const { |
+ return l10n_util::GetStringFUTF16Int(IDS_POPUPS_BLOCKED_INFOBAR_TEXT, |
+ n_popups_); |
+} |
+ |
+int PopupBlockedInfoBarDelegate::GetButtons() const { return BUTTON_OK; } |
+ |
+string16 PopupBlockedInfoBarDelegate::GetButtonLabel( |
+ InfoBarButton button) const { |
+ return l10n_util::GetStringUTF16(IDS_POPUPS_BLOCKED_INFOBAR_BUTTON_SHOW); |
+} |
+ |
+int PopupBlockedInfoBarDelegate::GetIconID() const { |
+ return IDR_BLOCKED_POPUPS; |
+} |
+ |
+PopupBlockedInfoBarDelegate* |
+PopupBlockedInfoBarDelegate::AsPopupBlockedInfoBarDelegate() { |
+ return this; |
+} |
+ |
+bool PopupBlockedInfoBarDelegate::Accept() { |
+ // TODO(miguelg) implement popup allows. |
+ LOG(WARNING) << "ALLOWING POPUPS IS NOT YET IMPLEMENTED"; |
+ return true; |
+} |
+ |
+// static |
+InfoBarDelegate* PopupBlockedInfoBarDelegate::Create( |
+ InfoBarService* infobar_service, |
+ int n_popups) { |
+ scoped_ptr<InfoBarDelegate> new_delegate( |
+ new PopupBlockedInfoBarDelegate(infobar_service, n_popups)); |
+ |
+ // See if there is an existing popup infobar already. |
+ for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { |
+ if (infobar_service->infobar_at(i)->AsPopupBlockedInfoBarDelegate()) { |
+ return infobar_service->ReplaceInfoBar( |
+ infobar_service->infobar_at(i), |
+ new_delegate.PassAs<InfoBarDelegate>()); |
+ } |
+ } |
+ |
+ return infobar_service->AddInfoBar(new_delegate.PassAs<InfoBarDelegate>()); |
+} |