| 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.h" | 8 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 if (creator.is_valid() && | 90 if (creator.is_valid() && |
| 91 profile->GetHostContentSettingsMap()->GetContentSetting( | 91 profile->GetHostContentSettingsMap()->GetContentSetting( |
| 92 creator, creator, CONTENT_SETTINGS_TYPE_POPUPS, std::string()) == | 92 creator, creator, CONTENT_SETTINGS_TYPE_POPUPS, std::string()) == |
| 93 CONTENT_SETTING_ALLOW) { | 93 CONTENT_SETTING_ALLOW) { |
| 94 return false; | 94 return false; |
| 95 } else { | 95 } else { |
| 96 if (blocked_popups_.size() < kMaximumNumberOfPopups) { | 96 if (blocked_popups_.size() < kMaximumNumberOfPopups) { |
| 97 blocked_popups_.Add(new BlockedRequest(params, window_features)); | 97 blocked_popups_.Add(new BlockedRequest(params, window_features)); |
| 98 TabSpecificContentSettings::FromWebContents(web_contents())-> | 98 TabSpecificContentSettings::FromWebContents(web_contents())-> |
| 99 OnContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS, std::string()); | 99 OnContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS); |
| 100 } | 100 } |
| 101 return true; | 101 return true; |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 void PopupBlockerTabHelper::AddBlockedPopup(const BlockedWindowParams& params) { | 105 void PopupBlockerTabHelper::AddBlockedPopup(const BlockedWindowParams& params) { |
| 106 chrome::NavigateParams nav_params = | 106 chrome::NavigateParams nav_params = |
| 107 params.CreateNavigateParams(web_contents()); | 107 params.CreateNavigateParams(web_contents()); |
| 108 | 108 |
| 109 if (blocked_popups_.size() < kMaximumNumberOfPopups) { | 109 if (blocked_popups_.size() < kMaximumNumberOfPopups) { |
| 110 blocked_popups_.Add(new BlockedRequest(nav_params, params.features())); | 110 blocked_popups_.Add(new BlockedRequest(nav_params, params.features())); |
| 111 TabSpecificContentSettings::FromWebContents(web_contents())-> | 111 TabSpecificContentSettings::FromWebContents(web_contents())-> |
| 112 OnContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS, std::string()); | 112 OnContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 void PopupBlockerTabHelper::ShowBlockedPopup(int32 id) { | 116 void PopupBlockerTabHelper::ShowBlockedPopup(int32 id) { |
| 117 BlockedRequest* popup = blocked_popups_.Lookup(id); | 117 BlockedRequest* popup = blocked_popups_.Lookup(id); |
| 118 if (!popup) | 118 if (!popup) |
| 119 return; | 119 return; |
| 120 #if defined(OS_ANDROID) | 120 #if defined(OS_ANDROID) |
| 121 TabModelList::HandlePopupNavigation(&popup->params); | 121 TabModelList::HandlePopupNavigation(&popup->params); |
| 122 #else | 122 #else |
| (...skipping 16 matching lines...) Expand all Loading... |
| 139 PopupBlockerTabHelper::GetBlockedPopupRequests() { | 139 PopupBlockerTabHelper::GetBlockedPopupRequests() { |
| 140 PopupIdMap result; | 140 PopupIdMap result; |
| 141 for (IDMap<BlockedRequest, IDMapOwnPointer>::const_iterator iter( | 141 for (IDMap<BlockedRequest, IDMapOwnPointer>::const_iterator iter( |
| 142 &blocked_popups_); | 142 &blocked_popups_); |
| 143 !iter.IsAtEnd(); | 143 !iter.IsAtEnd(); |
| 144 iter.Advance()) { | 144 iter.Advance()) { |
| 145 result[iter.GetCurrentKey()] = iter.GetCurrentValue()->params.url; | 145 result[iter.GetCurrentKey()] = iter.GetCurrentValue()->params.url; |
| 146 } | 146 } |
| 147 return result; | 147 return result; |
| 148 } | 148 } |
| OLD | NEW |