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

Unified Diff: chrome/browser/ui/android/content_settings/popup_blocked_infobar_delegate.cc

Issue 22694006: Infobar system refactor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years 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/ui/android/content_settings/popup_blocked_infobar_delegate.cc
===================================================================
--- chrome/browser/ui/android/content_settings/popup_blocked_infobar_delegate.cc (revision 238220)
+++ chrome/browser/ui/android/content_settings/popup_blocked_infobar_delegate.cc (working copy)
@@ -6,6 +6,7 @@
#include "base/prefs/pref_service.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
+#include "chrome/browser/infobars/infobar.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h"
@@ -18,8 +19,9 @@
// static
void PopupBlockedInfoBarDelegate::Create(InfoBarService* infobar_service,
int num_popups) {
- scoped_ptr<InfoBarDelegate> infobar(
- new PopupBlockedInfoBarDelegate(infobar_service, num_popups));
+ scoped_ptr<InfoBar> infobar(ConfirmInfoBarDelegate::CreateInfoBar(
+ scoped_ptr<ConfirmInfoBarDelegate>(
+ new PopupBlockedInfoBarDelegate(num_popups))));
// See if there is an existing popup infobar already.
// TODO(dfalcantara) When triggering more than one popup the infobar
@@ -26,8 +28,8 @@
// will be shown once, then hide then be shown again.
// This will be fixed once we have an in place replace infobar mechanism.
for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
- InfoBarDelegate* existing_infobar = infobar_service->infobar_at(i);
- if (existing_infobar->AsPopupBlockedInfoBarDelegate()) {
+ InfoBar* existing_infobar = infobar_service->infobar_at(i);
+ if (existing_infobar->delegate()->AsPopupBlockedInfoBarDelegate()) {
infobar_service->ReplaceInfoBar(existing_infobar, infobar.Pass());
return;
}
@@ -48,10 +50,8 @@
return this;
}
-PopupBlockedInfoBarDelegate::PopupBlockedInfoBarDelegate(
- InfoBarService* infobar_service,
- int num_popups)
- : ConfirmInfoBarDelegate(infobar_service),
+PopupBlockedInfoBarDelegate::PopupBlockedInfoBarDelegate(int num_popups)
+ : ConfirmInfoBarDelegate(),
num_popups_(num_popups) {
}
@@ -71,10 +71,9 @@
bool PopupBlockedInfoBarDelegate::Accept() {
// Create exceptions.
- content::WebContents* web_contents = owner()->web_contents();
- const GURL& url = web_contents->GetURL();
+ const GURL& url = web_contents()->GetURL();
Profile* profile = Profile::FromBrowserContext(
- web_contents->GetBrowserContext());
+ web_contents()->GetBrowserContext());
profile->GetHostContentSettingsMap()->AddExceptionForURL(
url, url, CONTENT_SETTINGS_TYPE_POPUPS, std::string(),
CONTENT_SETTING_ALLOW);
@@ -81,7 +80,7 @@
// Launch popups.
PopupBlockerTabHelper* popup_blocker_helper =
- PopupBlockerTabHelper::FromWebContents(web_contents);
+ PopupBlockerTabHelper::FromWebContents(web_contents());
DCHECK(popup_blocker_helper);
PopupBlockerTabHelper::PopupIdMap blocked_popups =
popup_blocker_helper->GetBlockedPopupRequests();

Powered by Google App Engine
This is Rietveld 408576698