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

Side by Side Diff: chrome/browser/views/blocked_popup_container.h

Issue 115149: Implement the popup blocking whitelist pref. This makes the whitelist actual... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2008 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_VIEWS_BLOCKED_POPUP_CONTAINER_H_ 10 #ifndef CHROME_BROWSER_VIEWS_BLOCKED_POPUP_CONTAINER_H_
11 #define CHROME_BROWSER_VIEWS_BLOCKED_POPUP_CONTAINER_H_ 11 #define CHROME_BROWSER_VIEWS_BLOCKED_POPUP_CONTAINER_H_
12 12
13 #include <set>
13 #include <utility> 14 #include <utility>
14 #include <vector> 15 #include <vector>
15 16
16 #include "app/animation.h" 17 #include "app/animation.h"
17 #include "base/gfx/rect.h" 18 #include "base/gfx/rect.h"
18 #include "chrome/browser/tab_contents/constrained_window.h" 19 #include "chrome/browser/tab_contents/constrained_window.h"
19 #include "chrome/browser/tab_contents/tab_contents_delegate.h" 20 #include "chrome/browser/tab_contents/tab_contents_delegate.h"
20 #include "chrome/common/notification_registrar.h" 21 #include "chrome/common/notification_registrar.h"
21 #include "views/controls/button/button.h" 22 #include "views/controls/button/button.h"
22 #include "views/controls/button/menu_button.h" 23 #include "views/controls/button/menu_button.h"
23 #include "views/controls/menu/menu.h" 24 #include "views/controls/menu/menu.h"
24 #include "views/view.h" 25 #include "views/view.h"
25 #include "views/widget/widget_win.h" 26 #include "views/widget/widget_win.h"
26 27
27 class BlockedPopupContainer; 28 class BlockedPopupContainer;
29 class PrefService;
28 class Profile; 30 class Profile;
29 class TabContents; 31 class TabContents;
30 class TextButton; 32 class TextButton;
31 33
32 namespace views { 34 namespace views {
33 class ImageButton; 35 class ImageButton;
34 } 36 }
35 37
36 // The view presented to the user notifying them of the number of popups 38 // The view presented to the user notifying them of the number of popups
37 // blocked. This view should only be used inside of BlockedPopupContainer. 39 // blocked. This view should only be used inside of BlockedPopupContainer.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 86
85 // Takes ownership of TabContents that are unrequested popup windows and 87 // Takes ownership of TabContents that are unrequested popup windows and
86 // presents an interface to the user for launching them. (Or never showing them 88 // presents an interface to the user for launching them. (Or never showing them
87 // again). 89 // again).
88 class BlockedPopupContainer : public Animation, 90 class BlockedPopupContainer : public Animation,
89 public ConstrainedWindow, 91 public ConstrainedWindow,
90 public NotificationObserver, 92 public NotificationObserver,
91 public TabContentsDelegate, 93 public TabContentsDelegate,
92 public views::WidgetWin { 94 public views::WidgetWin {
93 public: 95 public:
94 virtual ~BlockedPopupContainer(); 96 static void RegisterUserPrefs(PrefService* prefs);
95 97
96 // Creates a BlockedPopupContainer, anchoring the container to the lower 98 // Creates a BlockedPopupContainer, anchoring the container to the lower
97 // right corner. 99 // right corner.
98 static BlockedPopupContainer* Create( 100 static BlockedPopupContainer* Create(
99 TabContents* owner, Profile* profile, const gfx::Point& initial_anchor); 101 TabContents* owner, Profile* profile, const gfx::Point& initial_anchor);
100 102
103 virtual ~BlockedPopupContainer();
104
101 // Adds a popup to this container. |bounds| are the window bounds requested by 105 // Adds a popup to this container. |bounds| are the window bounds requested by
102 // the popup window. 106 // the popup window.
103 void AddTabContents(TabContents* tab_contents, 107 void AddTabContents(TabContents* tab_contents,
104 const gfx::Rect& bounds, 108 const gfx::Rect& bounds,
105 const std::string& host); 109 const std::string& host);
106 110
107 // Shows the blocked popup at index |index|. 111 // Shows the blocked popup at index |index|.
108 void LaunchPopupAtIndex(size_t index); 112 void LaunchPopupAtIndex(size_t index);
109 113
110 // Returns the number of blocked popups 114 // Returns the number of blocked popups
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 std::string host; 221 std::string host;
218 }; 222 };
219 typedef std::vector<BlockedPopup> BlockedPopups; 223 typedef std::vector<BlockedPopup> BlockedPopups;
220 224
221 // TabContents is the popup contents. string is opener hostname. 225 // TabContents is the popup contents. string is opener hostname.
222 typedef std::map<TabContents*, std::string> UnblockedPopups; 226 typedef std::map<TabContents*, std::string> UnblockedPopups;
223 227
224 // string is hostname. bool is whitelisted status. 228 // string is hostname. bool is whitelisted status.
225 typedef std::map<std::string, bool> PopupHosts; 229 typedef std::map<std::string, bool> PopupHosts;
226 230
231 // string is hostname.
232 typedef std::set<std::string> Whitelist;
233
227 // Creates a container for a certain TabContents. 234 // Creates a container for a certain TabContents.
228 BlockedPopupContainer(TabContents* owner, Profile* profile); 235 BlockedPopupContainer(TabContents* owner, PrefService* prefs);
229 236
230 // Overridden from Animation: 237 // Overridden from Animation:
231 // Changes the visibility percentage of the BlockedPopupContainer. This is 238 // Changes the visibility percentage of the BlockedPopupContainer. This is
232 // called while animating in or out. 239 // called while animating in or out.
233 virtual void AnimateToState(double state); 240 virtual void AnimateToState(double state);
234 241
235 // Overridden from notificationObserver: 242 // Overridden from notificationObserver:
236 virtual void Observe(NotificationType type, 243 virtual void Observe(NotificationType type,
237 const NotificationSource& source, 244 const NotificationSource& source,
238 const NotificationDetails& details); 245 const NotificationDetails& details);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 void EraseDataForPopupAndUpdateUI(BlockedPopups::iterator i); 279 void EraseDataForPopupAndUpdateUI(BlockedPopups::iterator i);
273 280
274 // Same as above, but works on the unblocked popup list, and returns the 281 // Same as above, but works on the unblocked popup list, and returns the
275 // iterator that results from calling erase(). 282 // iterator that results from calling erase().
276 UnblockedPopups::iterator EraseDataForPopupAndUpdateUI( 283 UnblockedPopups::iterator EraseDataForPopupAndUpdateUI(
277 UnblockedPopups::iterator i); 284 UnblockedPopups::iterator i);
278 285
279 // The TabContents that owns and constrains this BlockedPopupContainer. 286 // The TabContents that owns and constrains this BlockedPopupContainer.
280 TabContents* owner_; 287 TabContents* owner_;
281 288
289 // The PrefService we can query to find out what's on the whitelist.
290 PrefService* prefs_;
291
282 // Registrar to handle notifications we care about. 292 // Registrar to handle notifications we care about.
283 NotificationRegistrar registrar_; 293 NotificationRegistrar registrar_;
284 294
295 // The whitelisted hosts, which we allow to open popups directly.
296 Whitelist whitelist_;
297
285 // Information about all blocked popups. 298 // Information about all blocked popups.
286 BlockedPopups blocked_popups_; 299 BlockedPopups blocked_popups_;
287 300
288 // Information about all unblocked popups. 301 // Information about all unblocked popups.
289 UnblockedPopups unblocked_popups_; 302 UnblockedPopups unblocked_popups_;
290 303
291 // Information about all popup hosts. 304 // Information about all popup hosts.
292 PopupHosts popup_hosts_; 305 PopupHosts popup_hosts_;
293 306
294 // Our associated view object. 307 // Our associated view object.
(...skipping 12 matching lines...) Expand all
307 // bounds while animating in or out). 320 // bounds while animating in or out).
308 gfx::Rect bounds_; 321 gfx::Rect bounds_;
309 322
310 // The bottom right corner of where we should appear in our parent window. 323 // The bottom right corner of where we should appear in our parent window.
311 gfx::Point anchor_point_; 324 gfx::Point anchor_point_;
312 325
313 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockedPopupContainer); 326 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockedPopupContainer);
314 }; 327 };
315 328
316 #endif 329 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698