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

Side by Side Diff: chrome/browser/ui/blocked_content/blocked_content_tab_helper.h

Issue 10938033: Switch BlockedContentTabHelper to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_TAB_HELPER_H_ 5 #ifndef CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_TAB_HELPER_H_
6 #define CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_TAB_HELPER_H_ 6 #define CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_TAB_HELPER_H_
7 7
8 #include "chrome/browser/tab_contents/web_contents_user_data.h"
8 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 9 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
9 #include "chrome/browser/ui/find_bar/find_notification_details.h" 10 #include "chrome/browser/ui/find_bar/find_notification_details.h"
10 #include "content/public/browser/notification_registrar.h" 11 #include "content/public/browser/notification_registrar.h"
11 #include "content/public/browser/web_contents_observer.h" 12 #include "content/public/browser/web_contents_observer.h"
12 #include "webkit/glue/window_open_disposition.h" 13 #include "webkit/glue/window_open_disposition.h"
13 14
14 class BlockedContentContainer; 15 class BlockedContentContainer;
15 class BlockedContentTabHelperDelegate; 16 class BlockedContentTabHelperDelegate;
16 class TabContents;
17 17
18 // Per-tab class to manage blocked popups. 18 // Per-tab class to manage blocked popups.
19 class BlockedContentTabHelper : public content::WebContentsObserver { 19 class BlockedContentTabHelper
20 : public content::WebContentsObserver,
21 public WebContentsUserData<BlockedContentTabHelper> {
20 public: 22 public:
21 explicit BlockedContentTabHelper(TabContents* tab_contents);
22 virtual ~BlockedContentTabHelper(); 23 virtual ~BlockedContentTabHelper();
23 24
24 BlockedContentTabHelperDelegate* delegate() const { return delegate_; } 25 BlockedContentTabHelperDelegate* delegate() const { return delegate_; }
25 void set_delegate(BlockedContentTabHelperDelegate* d) { delegate_ = d; } 26 void set_delegate(BlockedContentTabHelperDelegate* d) { delegate_ = d; }
26 27
27 // Sets whether all TabContents added by way of |AddNewContents| should be 28 // Sets whether all WebContents added by way of |AddNewContents| should be
28 // blocked. Transitioning from all blocked to not all blocked results in 29 // blocked. Transitioning from all blocked to not all blocked results in
29 // reevaluating any blocked TabContentses, which may result in unblocking some 30 // reevaluating any blocked WebContentses, which may result in unblocking some
30 // of the blocked TabContentses. 31 // of the blocked WebContentses.
31 void SetAllContentsBlocked(bool value); 32 void SetAllContentsBlocked(bool value);
32 33
33 bool all_contents_blocked() const { return all_contents_blocked_; } 34 bool all_contents_blocked() const { return all_contents_blocked_; }
34 35
35 // Adds the incoming |new_contents| to the |blocked_contents_| container. 36 // Adds the incoming |new_contents| to the |blocked_contents_| container.
36 void AddTabContents(TabContents* new_contents, 37 void AddWebContents(content::WebContents* new_contents,
37 WindowOpenDisposition disposition, 38 WindowOpenDisposition disposition,
38 const gfx::Rect& initial_pos, 39 const gfx::Rect& initial_pos,
39 bool user_gesture); 40 bool user_gesture);
40 41
41 // Adds the incoming |new_contents| to the |blocked_contents_| container. 42 // Adds the incoming |new_contents| to the |blocked_contents_| container.
42 void AddPopup(TabContents* new_contents, 43 void AddPopup(content::WebContents* new_contents,
43 WindowOpenDisposition disposition, 44 WindowOpenDisposition disposition,
44 const gfx::Rect& initial_pos, 45 const gfx::Rect& initial_pos,
45 bool user_gesture); 46 bool user_gesture);
46 47
47 // Shows the blocked TabContents |tab_contents|. 48 // Shows the blocked WebContents |web_contents|.
48 void LaunchForContents(TabContents* tab_contents); 49 void LaunchForContents(content::WebContents* web_contents);
49 50
50 // Returns the number of blocked contents. 51 // Returns the number of blocked contents.
51 size_t GetBlockedContentsCount() const; 52 size_t GetBlockedContentsCount() const;
52 53
53 // Returns the blocked TabContentss. |blocked_contents| must be non-NULL. 54 // Returns the blocked WebContentses. |blocked_contents| must be non-NULL.
54 void GetBlockedContents(std::vector<TabContents*>* blocked_contents) const; 55 void GetBlockedContents(
56 std::vector<content::WebContents*>* blocked_contents) const;
55 57
56 // content::WebContentsObserver overrides: 58 // content::WebContentsObserver overrides:
57 virtual void DidNavigateMainFrame( 59 virtual void DidNavigateMainFrame(
58 const content::LoadCommittedDetails& details, 60 const content::LoadCommittedDetails& details,
59 const content::FrameNavigateParams& params) OVERRIDE; 61 const content::FrameNavigateParams& params) OVERRIDE;
60 62
61 private: 63 private:
64 explicit BlockedContentTabHelper(content::WebContents* web_contents);
65 static int kUserDataKey;
66 friend class WebContentsUserData<BlockedContentTabHelper>;
67
62 // Called when the blocked popup notification is shown or hidden. 68 // Called when the blocked popup notification is shown or hidden.
63 void PopupNotificationVisibilityChanged(bool visible); 69 void PopupNotificationVisibilityChanged(bool visible);
64 70
65 // Called to notify any observers that |contents| is entering or leaving 71 // Called to notify any observers that |contents| is entering or leaving
66 // the blocked state. 72 // the blocked state.
67 void SendNotification(TabContents* contents, bool blocked_state); 73 void SendNotification(content::WebContents* contents, bool blocked_state);
68 74
69 // Object that holds any blocked TabContents spawned from this TabContents. 75 // Object that holds any blocked WebContentses spawned from this WebContents.
70 scoped_ptr<BlockedContentContainer> blocked_contents_; 76 scoped_ptr<BlockedContentContainer> blocked_contents_;
71 77
72 // Should we block all child TabContents this attempts to spawn. 78 // Should we block all child TabContents this attempts to spawn.
73 bool all_contents_blocked_; 79 bool all_contents_blocked_;
74 80
75 // Owning TabContents.
76 TabContents* tab_contents_;
77
78 // Delegate for notifying our owner (usually Browser) about stuff. Not owned 81 // Delegate for notifying our owner (usually Browser) about stuff. Not owned
79 // by us. 82 // by us.
80 BlockedContentTabHelperDelegate* delegate_; 83 BlockedContentTabHelperDelegate* delegate_;
81 84
82 DISALLOW_COPY_AND_ASSIGN(BlockedContentTabHelper); 85 DISALLOW_COPY_AND_ASSIGN(BlockedContentTabHelper);
83 }; 86 };
84 87
85 #endif // CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_TAB_HELPER_H_ 88 #endif // CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_TAB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698