Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_TAB_HELPER_H_ | |
| 6 #define CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_TAB_HELPER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | |
| 10 #include "chrome/browser/ui/find_bar/find_notification_details.h" | |
| 11 #include "content/browser/tab_contents/tab_contents_observer.h" | |
| 12 #include "content/common/notification_registrar.h" | |
| 13 #include "webkit/glue/window_open_disposition.h" | |
| 14 | |
| 15 class BlockedContentContainer; | |
| 16 class BlockedContentTabHelperDelegate; | |
| 17 class TabContentsWrapper; | |
| 18 | |
| 19 // Per-tab class to manage blocked popups. | |
| 20 class BlockedContentTabHelper : public TabContentsObserver { | |
| 21 public: | |
| 22 explicit BlockedContentTabHelper(TabContentsWrapper* tab_contents); | |
| 23 virtual ~BlockedContentTabHelper(); | |
| 24 | |
| 25 BlockedContentTabHelperDelegate* delegate() const { return delegate_; } | |
| 26 void set_delegate(BlockedContentTabHelperDelegate* d) { delegate_ = d; } | |
| 27 | |
| 28 // Sets whether all TabContents added by way of |AddNewContents| should be | |
| 29 // blocked. Transitioning from all blocked to not all blocked results in | |
| 30 // reevaluating any blocked TabContents, which may result in unblocking some | |
| 31 // of the blocked TabContents. | |
| 32 void SetAllContentsBlocked(bool value); | |
| 33 | |
| 34 bool all_contents_blocked() const { return all_contents_blocked_; } | |
| 35 | |
| 36 // Adds the incoming |new_contents| to the |blocked_contents_| container. | |
| 37 void AddTabContents(TabContentsWrapper* new_contents, | |
| 38 WindowOpenDisposition disposition, | |
| 39 const gfx::Rect& initial_pos, | |
| 40 bool user_gesture); | |
| 41 | |
| 42 // Adds the incoming |new_contents| to the |blocked_contents_| container. | |
| 43 void AddPopup(TabContentsWrapper* new_contents, | |
| 44 const gfx::Rect& initial_pos, | |
| 45 bool user_gesture); | |
| 46 | |
| 47 // Shows the blocked TabContents |tab_contents|. | |
| 48 void LaunchForContents(TabContentsWrapper* tab_contents); | |
| 49 | |
| 50 // Returns the number of blocked contents. | |
| 51 size_t GetBlockedContentsCount() const; | |
| 52 | |
| 53 // Returns the blocked TabContentsWrappers. |blocked_contents| must | |
| 54 // be non-NULL. | |
| 55 void GetBlockedContents( | |
| 56 std::vector<TabContentsWrapper*>* blocked_contents) const; | |
|
stevenjb
2011/04/21 19:03:00
This is confusing - it's the same function name as
Avi (use Gerrit)
2011/04/21 20:06:02
Nononono. It used to be that way. The problem was
stevenjb
2011/04/21 21:06:44
Yeah, this makes more sense after doing the entire
| |
| 57 | |
| 58 // TabContentsObserver overrides: | |
| 59 virtual void DidNavigateMainFramePostCommit( | |
| 60 const NavigationController::LoadCommittedDetails& details, | |
| 61 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE; | |
| 62 | |
| 63 private: | |
| 64 // Called when the blocked popup notification is shown or hidden. | |
| 65 void PopupNotificationVisibilityChanged(bool visible); | |
| 66 | |
| 67 // Object that holds any blocked TabContents spawned from this TabContents. | |
| 68 scoped_ptr<BlockedContentContainer> blocked_contents_; | |
| 69 | |
| 70 // Should we block all child TabContents this attempts to spawn. | |
| 71 bool all_contents_blocked_; | |
| 72 | |
| 73 // Owning TabContentsWrapper. | |
| 74 TabContentsWrapper* tab_contents_wrapper_; | |
| 75 | |
| 76 // Delegate for notifying our owner about stuff. Not owned by us. | |
| 77 BlockedContentTabHelperDelegate* delegate_; | |
|
stevenjb
2011/04/21 19:03:00
This confused me for a while since delegate_ is un
Avi (use Gerrit)
2011/04/21 20:06:02
Sure. In general, the Browser is always the delega
| |
| 78 | |
| 79 DISALLOW_COPY_AND_ASSIGN(BlockedContentTabHelper); | |
| 80 }; | |
| 81 | |
| 82 #endif // CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_TAB_HELPER_H_ | |
| OLD | NEW |