| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" | 5 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/blocked_content/blocked_window_params.h" | 11 #include "chrome/browser/ui/blocked_content/blocked_window_params.h" |
| 11 #include "chrome/browser/ui/browser_navigator.h" | 12 #include "chrome/browser/ui/browser_navigator.h" |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 13 #include "chrome/common/render_messages.h" | 14 #include "chrome/common/render_messages.h" |
| 14 #include "components/content_settings/core/browser/host_content_settings_map.h" | 15 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 15 #include "content/public/browser/navigation_controller.h" | 16 #include "content/public/browser/navigation_controller.h" |
| 16 #include "content/public/browser/navigation_details.h" | 17 #include "content/public/browser/navigation_details.h" |
| 17 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // entry is the page to be loaded as we navigate away from the unloading | 81 // entry is the page to be loaded as we navigate away from the unloading |
| 81 // page. For this reason, we can't use GetURL() to get the opener URL, | 82 // page. For this reason, we can't use GetURL() to get the opener URL, |
| 82 // because it returns the active entry. | 83 // because it returns the active entry. |
| 83 content::NavigationEntry* entry = | 84 content::NavigationEntry* entry = |
| 84 web_contents()->GetController().GetLastCommittedEntry(); | 85 web_contents()->GetController().GetLastCommittedEntry(); |
| 85 GURL creator = entry ? entry->GetVirtualURL() : GURL(); | 86 GURL creator = entry ? entry->GetVirtualURL() : GURL(); |
| 86 Profile* profile = | 87 Profile* profile = |
| 87 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 88 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 88 | 89 |
| 89 if (creator.is_valid() && | 90 if (creator.is_valid() && |
| 90 profile->GetHostContentSettingsMap()->GetContentSetting( | 91 HostContentSettingsMapFactory::GetForProfile(profile)->GetContentSetting( |
| 91 creator, creator, CONTENT_SETTINGS_TYPE_POPUPS, std::string()) == | 92 creator, creator, CONTENT_SETTINGS_TYPE_POPUPS, std::string()) == |
| 92 CONTENT_SETTING_ALLOW) { | 93 CONTENT_SETTING_ALLOW) { |
| 93 return false; | 94 return false; |
| 94 } else { | 95 } else { |
| 95 if (blocked_popups_.size() < kMaximumNumberOfPopups) { | 96 if (blocked_popups_.size() < kMaximumNumberOfPopups) { |
| 96 blocked_popups_.Add(new BlockedRequest(params, window_features)); | 97 blocked_popups_.Add(new BlockedRequest(params, window_features)); |
| 97 TabSpecificContentSettings::FromWebContents(web_contents())-> | 98 TabSpecificContentSettings::FromWebContents(web_contents())-> |
| 98 OnContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS); | 99 OnContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS); |
| 99 } | 100 } |
| 100 return true; | 101 return true; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 PopupBlockerTabHelper::GetBlockedPopupRequests() { | 141 PopupBlockerTabHelper::GetBlockedPopupRequests() { |
| 141 PopupIdMap result; | 142 PopupIdMap result; |
| 142 for (IDMap<BlockedRequest, IDMapOwnPointer>::const_iterator iter( | 143 for (IDMap<BlockedRequest, IDMapOwnPointer>::const_iterator iter( |
| 143 &blocked_popups_); | 144 &blocked_popups_); |
| 144 !iter.IsAtEnd(); | 145 !iter.IsAtEnd(); |
| 145 iter.Advance()) { | 146 iter.Advance()) { |
| 146 result[iter.GetCurrentKey()] = iter.GetCurrentValue()->params.url; | 147 result[iter.GetCurrentKey()] = iter.GetCurrentValue()->params.url; |
| 147 } | 148 } |
| 148 return result; | 149 return result; |
| 149 } | 150 } |
| OLD | NEW |