| 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 // ContentSettingsTabHelper. Users and subclasses of TabContents/ |
| 8 // to access information about blocked content. | 8 // TabContentsWrapper should use the appropriate methods on |
| 9 // ContentSettingsTabHelper to access information about blocked content. |
| 9 | 10 |
| 10 #ifndef CHROME_BROWSER_BLOCKED_CONTENT_CONTAINER_H_ | 11 #ifndef CHROME_BROWSER_UI_CONTENT_SETTINGS_BLOCKED_CONTENT_CONTAINER_H_ |
| 11 #define CHROME_BROWSER_BLOCKED_CONTENT_CONTAINER_H_ | 12 #define CHROME_BROWSER_UI_CONTENT_SETTINGS_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/content_settings/content_settings_tab_helper_delegat
e.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 ContentSettingsTabHelperDelegate, |
| 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 ContentSettingsTabHelperDelegate: |
| 54 |
| 55 // Ignore contents requests from the TabContents we're blocking. |
| 56 virtual void ShowContentSettingsPage(ContentSettingsType content_type) {} |
| 57 virtual void ShowCollectedCookiesDialog(TabContents* tab_contents) {} |
| 58 |
| 59 // Overridden from ContentSettingsTabHelperDelegate, TabContentsDelegate: |
| 60 virtual TabContents* GetConstrainingContents(TabContents* source) OVERRIDE; |
| 61 virtual TabContentsWrapper* GetConstrainingContents( |
| 62 TabContentsWrapper* source) OVERRIDE; |
| 44 | 63 |
| 45 // Overridden from TabContentsDelegate: | 64 // Overridden from TabContentsDelegate: |
| 46 | 65 |
| 47 // Forwards OpenURLFromTab to our |owner_|. | 66 // Forwards OpenURLFromTab to our |owner_|. |
| 48 virtual void OpenURLFromTab(TabContents* source, | 67 virtual void OpenURLFromTab(TabContents* source, |
| 49 const GURL& url, const GURL& referrer, | 68 const GURL& url, const GURL& referrer, |
| 50 WindowOpenDisposition disposition, | 69 WindowOpenDisposition disposition, |
| 51 PageTransition::Type transition); | 70 PageTransition::Type transition); |
| 52 | 71 |
| 53 // Ignored; BlockedContentContainer doesn't display a throbber. | 72 // Ignored; BlockedContentContainer doesn't display a throbber. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 71 | 90 |
| 72 // Removes |source| from our internal list of blocked contents. | 91 // Removes |source| from our internal list of blocked contents. |
| 73 virtual void CloseContents(TabContents* source); | 92 virtual void CloseContents(TabContents* source); |
| 74 | 93 |
| 75 // Changes the opening rectangle associated with |source|. | 94 // Changes the opening rectangle associated with |source|. |
| 76 virtual void MoveContents(TabContents* source, const gfx::Rect& new_bounds); | 95 virtual void MoveContents(TabContents* source, const gfx::Rect& new_bounds); |
| 77 | 96 |
| 78 // Always returns true. | 97 // Always returns true. |
| 79 virtual bool IsPopup(const TabContents* source) const; | 98 virtual bool IsPopup(const TabContents* source) const; |
| 80 | 99 |
| 81 // Returns our |owner_|. | |
| 82 virtual TabContents* GetConstrainingContents(TabContents* source); | |
| 83 | |
| 84 // Ignored; BlockedContentContainer doesn't display a toolbar. | 100 // Ignored; BlockedContentContainer doesn't display a toolbar. |
| 85 virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {} | 101 virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {} |
| 86 | 102 |
| 87 // Ignored; BlockedContentContainer doesn't display a URL bar. | 103 // Ignored; BlockedContentContainer doesn't display a URL bar. |
| 88 virtual void UpdateTargetURL(TabContents* source, const GURL& url) {} | 104 virtual void UpdateTargetURL(TabContents* source, const GURL& url) {} |
| 89 | 105 |
| 90 // Maximum number of blocked contents we allow. No page should really need | 106 // Maximum number of blocked contents we allow. No page should really need |
| 91 // this many anyway. If reached it typically means there is a compromised | 107 // this many anyway. If reached it typically means there is a compromised |
| 92 // renderer. | 108 // renderer. |
| 93 static const size_t kImpossibleNumberOfPopups; | 109 static const size_t kImpossibleNumberOfPopups; |
| 94 | 110 |
| 95 private: | 111 private: |
| 96 struct BlockedContent; | 112 struct BlockedContent; |
| 97 | 113 |
| 98 typedef std::vector<BlockedContent> BlockedContents; | 114 typedef std::vector<BlockedContent> BlockedContents; |
| 99 | 115 |
| 100 // The TabContents that owns and constrains this BlockedContentContainer. | 116 // The TabContents that owns and constrains this BlockedContentContainer. |
| 101 TabContents* owner_; | 117 TabContentsWrapper* owner_; |
| 102 | 118 |
| 103 // Information about all blocked contents. | 119 // Information about all blocked contents. |
| 104 BlockedContents blocked_contents_; | 120 BlockedContents blocked_contents_; |
| 105 | 121 |
| 106 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockedContentContainer); | 122 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockedContentContainer); |
| 107 }; | 123 }; |
| 108 | 124 |
| 109 #endif // CHROME_BROWSER_BLOCKED_CONTENT_CONTAINER_H_ | 125 #endif // CHROME_BROWSER_UI_CONTENT_SETTINGS_BLOCKED_CONTENT_CONTAINER_H_ |
| OLD | NEW |