OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 // Defines the public interface for the blocked popup notifications. This | 5 // Defines the public interface for the blocked popup notifications. This |
6 // interface should only be used by TabContents. Users and subclasses of | 6 // interface should only be used by TabContents. Users and subclasses of |
7 // TabContents should use the appropriate methods on TabContents to access | 7 // TabContents should use the appropriate methods on TabContents to access |
8 // information about blocked popups. | 8 // information about blocked popups. |
9 | 9 |
10 #ifndef CHROME_BROWSER_BLOCKED_POPUP_CONTAINER_H_ | 10 #ifndef CHROME_BROWSER_BLOCKED_POPUP_CONTAINER_H_ |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 std::string host; | 191 std::string host; |
192 }; | 192 }; |
193 typedef std::vector<BlockedPopup> BlockedPopups; | 193 typedef std::vector<BlockedPopup> BlockedPopups; |
194 | 194 |
195 // TabContents is the popup contents. string is opener hostname. | 195 // TabContents is the popup contents. string is opener hostname. |
196 typedef std::map<TabContents*, std::string> UnblockedPopups; | 196 typedef std::map<TabContents*, std::string> UnblockedPopups; |
197 | 197 |
198 // string is hostname. bool is whitelisted status. | 198 // string is hostname. bool is whitelisted status. |
199 typedef std::map<std::string, bool> PopupHosts; | 199 typedef std::map<std::string, bool> PopupHosts; |
200 | 200 |
| 201 // Creates a BlockedPopupContainer, anchoring the container to the lower |
| 202 // right corner using the given BlockedPopupContainerView. Use only for |
| 203 // testing. |
| 204 static BlockedPopupContainer* Create(TabContents* owner, Profile* profile, |
| 205 BlockedPopupContainerView* view); |
| 206 |
201 // Hides the UI portion of the container. | 207 // Hides the UI portion of the container. |
202 void HideSelf(); | 208 void HideSelf(); |
203 | 209 |
204 // Helper function to convert a host index (which the view uses) into an | 210 // Helper function to convert a host index (which the view uses) into an |
205 // iterator into |popup_hosts_|. Returns popup_hosts_.end() if |index| is | 211 // iterator into |popup_hosts_|. Returns popup_hosts_.end() if |index| is |
206 // invalid. | 212 // invalid. |
207 PopupHosts::const_iterator ConvertHostIndexToIterator(size_t index) const; | 213 PopupHosts::const_iterator ConvertHostIndexToIterator(size_t index) const; |
208 | 214 |
209 // Removes the popup at |i| from the blocked popup list. If this popup's host | 215 // Removes the popup at |i| from the blocked popup list. If this popup's host |
210 // is not otherwised referenced on either popup list, removes the host from | 216 // is not otherwised referenced on either popup list, removes the host from |
211 // the host list. Updates the view's label to match the new state. | 217 // the host list. Updates the view's label to match the new state. |
212 void EraseDataForPopupAndUpdateUI(BlockedPopups::iterator i); | 218 void EraseDataForPopupAndUpdateUI(BlockedPopups::iterator i); |
213 | 219 |
214 // Same as above, but works on the unblocked popup list. | 220 // Same as above, but works on the unblocked popup list. |
215 void EraseDataForPopupAndUpdateUI(UnblockedPopups::iterator i); | 221 void EraseDataForPopupAndUpdateUI(UnblockedPopups::iterator i); |
216 | 222 |
217 private: | 223 private: |
218 friend class BlockedPopupContainerImpl; | 224 friend class BlockedPopupContainerImpl; |
219 friend class BlockedPopupContainerTest; | 225 friend class BlockedPopupContainerTest; |
| 226 friend class BlockedPopupContainerControllerTest; |
220 | 227 |
221 // string is hostname. | 228 // string is hostname. |
222 typedef std::set<std::string> Whitelist; | 229 typedef std::set<std::string> Whitelist; |
223 | 230 |
224 // Creates a container for a certain TabContents: | 231 // Creates a container for a certain TabContents: |
225 BlockedPopupContainer(TabContents* owner, PrefService* prefs); | 232 BlockedPopupContainer(TabContents* owner, PrefService* prefs); |
226 | 233 |
227 // Either hides the view if there are no popups, or updates the label if | 234 // Either hides the view if there are no popups, or updates the label if |
228 // there are. | 235 // there are. |
229 void UpdateView(); | 236 void UpdateView(); |
(...skipping 27 matching lines...) Expand all Loading... |
257 // Information about all popup hosts. | 264 // Information about all popup hosts. |
258 PopupHosts popup_hosts_; | 265 PopupHosts popup_hosts_; |
259 | 266 |
260 // Our platform specific view. | 267 // Our platform specific view. |
261 BlockedPopupContainerView* view_; | 268 BlockedPopupContainerView* view_; |
262 | 269 |
263 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockedPopupContainer); | 270 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockedPopupContainer); |
264 }; | 271 }; |
265 | 272 |
266 #endif // CHROME_BROWSER_BLOCKED_POPUP_CONTAINER_H_ | 273 #endif // CHROME_BROWSER_BLOCKED_POPUP_CONTAINER_H_ |
OLD | NEW |