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

Unified Diff: ios/chrome/browser/web/blocked_popup_tab_helper.mm

Issue 2717613006: Moved ios popup opening code from Tab to BlockedPopupTabHelper. (Closed)
Patch Set: Rebased Created 3 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 | « ios/chrome/browser/tabs/tab.mm ('k') | ios/chrome/browser/web/blocked_popup_tab_helper_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/web/blocked_popup_tab_helper.mm
diff --git a/ios/chrome/browser/web/blocked_popup_tab_helper.mm b/ios/chrome/browser/web/blocked_popup_tab_helper.mm
index 364434eeb3cdce51414fd3369fd94b0ccb30d49a..23e330142b8092ea6d068459b2233fb06172be44 100644
--- a/ios/chrome/browser/web/blocked_popup_tab_helper.mm
+++ b/ios/chrome/browser/web/blocked_popup_tab_helper.mm
@@ -32,8 +32,9 @@ namespace {
class BlockPopupInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
BlockPopupInfoBarDelegate(ios::ChromeBrowserState* browser_state,
+ web::WebState* web_state,
const std::vector<web::BlockedPopupInfo>& popups)
- : browser_state_(browser_state), popups_(popups) {}
+ : browser_state_(browser_state), web_state_(web_state), popups_(popups) {}
~BlockPopupInfoBarDelegate() override {}
@@ -67,10 +68,13 @@ class BlockPopupInfoBarDelegate : public ConfirmInfoBarDelegate {
std::vector<web::BlockedPopupInfo>::iterator it;
scoped_refptr<HostContentSettingsMap> host_content_map_settings(
ios::HostContentSettingsMapFactory::GetForBrowserState(browser_state_));
- for (auto& it : popups_) {
- it.ShowPopup();
+ for (auto& popup : popups_) {
+ web::WebState::OpenURLParams params(
+ popup.url(), popup.referrer(), WindowOpenDisposition::NEW_POPUP,
+ ui::PAGE_TRANSITION_LINK, true /* is_renderer_initiated */);
+ web_state_->OpenURL(params);
host_content_map_settings->SetContentSettingCustomScope(
- ContentSettingsPattern::FromURL(it.referrer().url),
+ ContentSettingsPattern::FromURL(popup.referrer().url),
ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_POPUPS,
std::string(), CONTENT_SETTING_ALLOW);
}
@@ -80,8 +84,8 @@ class BlockPopupInfoBarDelegate : public ConfirmInfoBarDelegate {
int GetButtons() const override { return BUTTON_OK; }
private:
- // The browser state to access user preferences.
ios::ChromeBrowserState* browser_state_;
+ web::WebState* web_state_;
// The popups to open.
std::vector<web::BlockedPopupInfo> popups_;
// The icon to display.
@@ -104,6 +108,7 @@ bool BlockedPopupTabHelper::ShouldBlockPopup(const GURL& source_url) {
void BlockedPopupTabHelper::HandlePopup(
const web::BlockedPopupInfo& blocked_popup_info) {
+ DCHECK(ShouldBlockPopup(blocked_popup_info.referrer().url));
popups_.push_back(blocked_popup_info);
ShowInfoBar();
}
@@ -131,7 +136,8 @@ void BlockedPopupTabHelper::ShowInfoBar() {
RegisterAsInfoBarManagerObserverIfNeeded(infobar_manager);
std::unique_ptr<BlockPopupInfoBarDelegate> delegate(
- base::MakeUnique<BlockPopupInfoBarDelegate>(GetBrowserState(), popups_));
+ base::MakeUnique<BlockPopupInfoBarDelegate>(GetBrowserState(), web_state_,
+ popups_));
std::unique_ptr<infobars::InfoBar> infobar =
infobar_manager->CreateConfirmInfoBar(std::move(delegate));
if (infobar_) {
« no previous file with comments | « ios/chrome/browser/tabs/tab.mm ('k') | ios/chrome/browser/web/blocked_popup_tab_helper_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698