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

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

Issue 136763014: Merge r250184: [Android] Remove the "Always show" button for blocked popups if the setting is... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: x Created 6 years, 10 months 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
« no previous file with comments | « chrome/browser/ui/android/content_settings/popup_blocked_infobar_delegate.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/android/content_settings/popup_blocked_infobar_delegate.cc
diff --git a/chrome/browser/ui/android/content_settings/popup_blocked_infobar_delegate.cc b/chrome/browser/ui/android/content_settings/popup_blocked_infobar_delegate.cc
index 7283eadebb42ea96a7969bbdac1a65faf1a97974..62a594066747d9cfc24a7b66cb7ca501f862bc94 100644
--- a/chrome/browser/ui/android/content_settings/popup_blocked_infobar_delegate.cc
+++ b/chrome/browser/ui/android/content_settings/popup_blocked_infobar_delegate.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h"
+#include "chrome/common/content_settings.h"
#include "chrome/common/content_settings_types.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -17,12 +18,18 @@
// static
-void PopupBlockedInfoBarDelegate::Create(InfoBarService* infobar_service,
+void PopupBlockedInfoBarDelegate::Create(content::WebContents* web_contents,
int num_popups) {
+ const GURL& url = web_contents->GetURL();
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents->GetBrowserContext());
scoped_ptr<InfoBar> infobar(ConfirmInfoBarDelegate::CreateInfoBar(
scoped_ptr<ConfirmInfoBarDelegate>(
- new PopupBlockedInfoBarDelegate(num_popups))));
+ new PopupBlockedInfoBarDelegate(
+ num_popups, url, profile->GetHostContentSettingsMap()))));
+ InfoBarService* infobar_service =
+ InfoBarService::FromWebContents(web_contents);
// See if there is an existing popup infobar already.
// TODO(dfalcantara) When triggering more than one popup the infobar
// will be shown once, then hide then be shown again.
@@ -50,9 +57,21 @@ PopupBlockedInfoBarDelegate*
return this;
}
-PopupBlockedInfoBarDelegate::PopupBlockedInfoBarDelegate(int num_popups)
- : ConfirmInfoBarDelegate(),
- num_popups_(num_popups) {
+PopupBlockedInfoBarDelegate::PopupBlockedInfoBarDelegate(
+ int num_popups,
+ const GURL& url,
+ HostContentSettingsMap* map)
+ : ConfirmInfoBarDelegate(), num_popups_(num_popups), url_(url), map_(map) {
+ content_settings::SettingInfo setting_info;
+ scoped_ptr<base::Value> setting(
+ map->GetWebsiteSetting(
+ url,
+ url,
+ CONTENT_SETTINGS_TYPE_POPUPS,
+ std::string(),
+ &setting_info));
+ can_show_popups_ =
+ setting_info.source != content_settings::SETTING_SOURCE_POLICY;
}
base::string16 PopupBlockedInfoBarDelegate::GetMessageText() const {
@@ -61,6 +80,9 @@ base::string16 PopupBlockedInfoBarDelegate::GetMessageText() const {
}
int PopupBlockedInfoBarDelegate::GetButtons() const {
+ if (!can_show_popups_)
+ return 0;
+
return BUTTON_OK;
}
@@ -70,12 +92,11 @@ base::string16 PopupBlockedInfoBarDelegate::GetButtonLabel(
}
bool PopupBlockedInfoBarDelegate::Accept() {
+ DCHECK(can_show_popups_);
+
// Create exceptions.
- const GURL& url = web_contents()->GetURL();
- Profile* profile = Profile::FromBrowserContext(
- web_contents()->GetBrowserContext());
- profile->GetHostContentSettingsMap()->AddExceptionForURL(
- url, url, CONTENT_SETTINGS_TYPE_POPUPS, CONTENT_SETTING_ALLOW);
+ map_->AddExceptionForURL(
+ url_, url_, CONTENT_SETTINGS_TYPE_POPUPS, CONTENT_SETTING_ALLOW);
// Launch popups.
PopupBlockerTabHelper* popup_blocker_helper =
« no previous file with comments | « chrome/browser/ui/android/content_settings/popup_blocked_infobar_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698