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/content_settings/host_content_settings_map_factory.h" | 7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/blocked_content/blocked_window_params.h" | 10 #include "chrome/browser/ui/blocked_content/blocked_window_params.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 AddBlockedPopup(params.CreateNavigateParams(web_contents()), | 100 AddBlockedPopup(params.CreateNavigateParams(web_contents()), |
101 params.features()); | 101 params.features()); |
102 } | 102 } |
103 | 103 |
104 void PopupBlockerTabHelper::AddBlockedPopup( | 104 void PopupBlockerTabHelper::AddBlockedPopup( |
105 const chrome::NavigateParams& params, | 105 const chrome::NavigateParams& params, |
106 const WebWindowFeatures& window_features) { | 106 const WebWindowFeatures& window_features) { |
107 if (blocked_popups_.size() >= kMaximumNumberOfPopups) | 107 if (blocked_popups_.size() >= kMaximumNumberOfPopups) |
108 return; | 108 return; |
109 | 109 |
110 blocked_popups_.Add(new BlockedRequest(params, window_features)); | 110 blocked_popups_.Add( |
| 111 base::MakeUnique<BlockedRequest>(params, window_features)); |
111 TabSpecificContentSettings::FromWebContents(web_contents())-> | 112 TabSpecificContentSettings::FromWebContents(web_contents())-> |
112 OnContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS); | 113 OnContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS); |
113 } | 114 } |
114 | 115 |
115 void PopupBlockerTabHelper::ShowBlockedPopup(int32_t id) { | 116 void PopupBlockerTabHelper::ShowBlockedPopup(int32_t id) { |
116 BlockedRequest* popup = blocked_popups_.Lookup(id); | 117 BlockedRequest* popup = blocked_popups_.Lookup(id); |
117 if (!popup) | 118 if (!popup) |
118 return; | 119 return; |
119 // We set user_gesture to true here, so the new popup gets correctly focused. | 120 // We set user_gesture to true here, so the new popup gets correctly focused. |
120 popup->params.user_gesture = true; | 121 popup->params.user_gesture = true; |
(...skipping 19 matching lines...) Expand all 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 |