| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 // Defines the public interface for the blocked content (including popup) | 5 // Defines the public interface for the blocked content (including popup) |
| 6 // notifications. This interface should only be used by TabContents. Users and | 6 // notifications. This interface should only be used by the |
| 7 // subclasses of TabContents should use the appropriate methods on TabContents | 7 // BlockedContentTabHelper. Users and subclasses of TabContents/ |
| 8 // to access information about blocked content. | 8 // TabContentsWrapper should use the appropriate methods on |
| 9 // BlockedContentTabHelper to access information about blocked content. |
| 9 | 10 |
| 10 #ifndef CHROME_BROWSER_BLOCKED_CONTENT_CONTAINER_H_ | 11 #ifndef CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_CONTAINER_H_ |
| 11 #define CHROME_BROWSER_BLOCKED_CONTENT_CONTAINER_H_ | 12 #define CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_CONTAINER_H_ |
| 12 #pragma once | 13 #pragma once |
| 13 | 14 |
| 14 #include <vector> | 15 #include <vector> |
| 15 | 16 |
| 17 #include "base/compiler_specific.h" |
| 18 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.
h" |
| 16 #include "content/browser/tab_contents/tab_contents_delegate.h" | 19 #include "content/browser/tab_contents/tab_contents_delegate.h" |
| 17 | 20 |
| 21 class TabContents; |
| 22 class TabContentsWrapper; |
| 23 |
| 18 // Takes ownership of TabContents that are unrequested popup windows. | 24 // Takes ownership of TabContents that are unrequested popup windows. |
| 19 class BlockedContentContainer : public TabContentsDelegate { | 25 class BlockedContentContainer : public BlockedContentTabHelperDelegate, |
| 26 public TabContentsDelegate { |
| 20 public: | 27 public: |
| 21 // Creates a container for a certain TabContents: | 28 // Creates a container for a certain TabContents: |
| 22 explicit BlockedContentContainer(TabContents* owner); | 29 explicit BlockedContentContainer(TabContentsWrapper* owner); |
| 23 virtual ~BlockedContentContainer(); | 30 virtual ~BlockedContentContainer(); |
| 24 | 31 |
| 25 // Adds a TabContents to this container. |bounds| are the window bounds | 32 // Adds a TabContents to this container. |bounds| are the window bounds |
| 26 // requested for the TabContents. | 33 // requested for the TabContents. |
| 27 void AddTabContents(TabContents* tab_contents, | 34 void AddTabContents(TabContentsWrapper* tab_contents, |
| 28 WindowOpenDisposition disposition, | 35 WindowOpenDisposition disposition, |
| 29 const gfx::Rect& bounds, | 36 const gfx::Rect& bounds, |
| 30 bool user_gesture); | 37 bool user_gesture); |
| 31 | 38 |
| 32 // Shows the blocked TabContents |tab_contents|. | 39 // Shows the blocked TabContents |tab_contents|. |
| 33 void LaunchForContents(TabContents* tab_contents); | 40 void LaunchForContents(TabContentsWrapper* tab_contents); |
| 34 | 41 |
| 35 // Returns the number of blocked contents. | 42 // Returns the number of blocked contents. |
| 36 size_t GetBlockedContentsCount() const; | 43 size_t GetBlockedContentsCount() const; |
| 37 | 44 |
| 38 // Returns the contained TabContents pointers. |blocked_contents| must be | 45 // Returns the contained TabContentsWrapper pointers. |blocked_contents| must |
| 39 // non-NULL. | 46 // be non-NULL. |
| 40 void GetBlockedContents(std::vector<TabContents*>* blocked_contents) const; | 47 void GetBlockedContents( |
| 48 std::vector<TabContentsWrapper*>* blocked_contents) const; |
| 41 | 49 |
| 42 // Sets this object up to delete itself. | 50 // Removes all blocked contents. |
| 43 void Destroy(); | 51 void Clear(); |
| 52 |
| 53 // Overridden from BlockedContentTabHelperDelegate, TabContentsDelegate: |
| 54 virtual TabContents* GetConstrainingContents(TabContents* source) OVERRIDE; |
| 55 virtual TabContentsWrapper* GetConstrainingContents( |
| 56 TabContentsWrapper* source) OVERRIDE; |
| 44 | 57 |
| 45 // Overridden from TabContentsDelegate: | 58 // Overridden from TabContentsDelegate: |
| 46 | 59 |
| 47 // Forwards OpenURLFromTab to our |owner_|. | 60 // Forwards OpenURLFromTab to our |owner_|. |
| 48 virtual void OpenURLFromTab(TabContents* source, | 61 virtual void OpenURLFromTab(TabContents* source, |
| 49 const GURL& url, const GURL& referrer, | 62 const GURL& url, const GURL& referrer, |
| 50 WindowOpenDisposition disposition, | 63 WindowOpenDisposition disposition, |
| 51 PageTransition::Type transition); | 64 PageTransition::Type transition); |
| 52 | 65 |
| 53 // Ignored; BlockedContentContainer doesn't display a throbber. | 66 // Ignored; BlockedContentContainer doesn't display a throbber. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 71 | 84 |
| 72 // Removes |source| from our internal list of blocked contents. | 85 // Removes |source| from our internal list of blocked contents. |
| 73 virtual void CloseContents(TabContents* source); | 86 virtual void CloseContents(TabContents* source); |
| 74 | 87 |
| 75 // Changes the opening rectangle associated with |source|. | 88 // Changes the opening rectangle associated with |source|. |
| 76 virtual void MoveContents(TabContents* source, const gfx::Rect& new_bounds); | 89 virtual void MoveContents(TabContents* source, const gfx::Rect& new_bounds); |
| 77 | 90 |
| 78 // Always returns true. | 91 // Always returns true. |
| 79 virtual bool IsPopup(const TabContents* source) const; | 92 virtual bool IsPopup(const TabContents* source) const; |
| 80 | 93 |
| 81 // Returns our |owner_|. | |
| 82 virtual TabContents* GetConstrainingContents(TabContents* source); | |
| 83 | |
| 84 // Ignored; BlockedContentContainer doesn't display a URL bar. | 94 // Ignored; BlockedContentContainer doesn't display a URL bar. |
| 85 virtual void UpdateTargetURL(TabContents* source, const GURL& url) {} | 95 virtual void UpdateTargetURL(TabContents* source, const GURL& url) {} |
| 86 | 96 |
| 87 // Maximum number of blocked contents we allow. No page should really need | 97 // Maximum number of blocked contents we allow. No page should really need |
| 88 // this many anyway. If reached it typically means there is a compromised | 98 // this many anyway. If reached it typically means there is a compromised |
| 89 // renderer. | 99 // renderer. |
| 90 static const size_t kImpossibleNumberOfPopups; | 100 static const size_t kImpossibleNumberOfPopups; |
| 91 | 101 |
| 92 private: | 102 private: |
| 93 struct BlockedContent; | 103 struct BlockedContent; |
| 94 | 104 |
| 95 typedef std::vector<BlockedContent> BlockedContents; | 105 typedef std::vector<BlockedContent> BlockedContents; |
| 96 | 106 |
| 97 // The TabContents that owns and constrains this BlockedContentContainer. | 107 // The TabContents that owns and constrains this BlockedContentContainer. |
| 98 TabContents* owner_; | 108 TabContentsWrapper* owner_; |
| 99 | 109 |
| 100 // Information about all blocked contents. | 110 // Information about all blocked contents. |
| 101 BlockedContents blocked_contents_; | 111 BlockedContents blocked_contents_; |
| 102 | 112 |
| 103 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockedContentContainer); | 113 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockedContentContainer); |
| 104 }; | 114 }; |
| 105 | 115 |
| 106 #endif // CHROME_BROWSER_BLOCKED_CONTENT_CONTAINER_H_ | 116 #endif // CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_CONTAINER_H_ |
| OLD | NEW |