| OLD | NEW |
| 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 // 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 the | 6 // notifications. This interface should only be used by the |
| 7 // BlockedContentTabHelper. Users and subclasses of WebContents/ | 7 // BlockedContentTabHelper. Users and subclasses of WebContents/TabContents |
| 8 // TabContentsWrapper should use the appropriate methods on | 8 // should use the appropriate methods on BlockedContentTabHelper to access |
| 9 // BlockedContentTabHelper to access information about blocked content. | 9 // information about blocked content. |
| 10 | 10 |
| 11 #ifndef CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_CONTAINER_H_ | 11 #ifndef CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_CONTAINER_H_ |
| 12 #define CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_CONTAINER_H_ | 12 #define CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_CONTAINER_H_ |
| 13 #pragma once | 13 #pragma once |
| 14 | 14 |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 18 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.
h" | 18 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.
h" |
| 19 #include "content/public/browser/web_contents_delegate.h" | 19 #include "content/public/browser/web_contents_delegate.h" |
| 20 | 20 |
| 21 class TabContents; | 21 class TabContents; |
| 22 typedef TabContents TabContentsWrapper; | |
| 23 | 22 |
| 24 // Takes ownership of TabContentsWrappers that are unrequested popup windows. | 23 // Takes ownership of TabContentses that are unrequested popup windows. |
| 25 class BlockedContentContainer : public BlockedContentTabHelperDelegate, | 24 class BlockedContentContainer : public BlockedContentTabHelperDelegate, |
| 26 public content::WebContentsDelegate { | 25 public content::WebContentsDelegate { |
| 27 public: | 26 public: |
| 28 // Creates a container for a certain TabContentsWrapper: | 27 // Creates a container for a certain TabContents: |
| 29 explicit BlockedContentContainer(TabContentsWrapper* owner); | 28 explicit BlockedContentContainer(TabContents* owner); |
| 30 virtual ~BlockedContentContainer(); | 29 virtual ~BlockedContentContainer(); |
| 31 | 30 |
| 32 // Adds a TabContentsWrapper to this container. |bounds| are the window bounds | 31 // Adds a TabContents to this container. |bounds| are the window bounds |
| 33 // requested for the TabContentsWrapper. | 32 // requested for the TabContents. |
| 34 void AddTabContents(TabContentsWrapper* tab_contents, | 33 void AddTabContents(TabContents* tab_contents, |
| 35 WindowOpenDisposition disposition, | 34 WindowOpenDisposition disposition, |
| 36 const gfx::Rect& bounds, | 35 const gfx::Rect& bounds, |
| 37 bool user_gesture); | 36 bool user_gesture); |
| 38 | 37 |
| 39 // Shows the blocked TabContentsWrapper |tab_contents|. | 38 // Shows the blocked TabContents |tab_contents|. |
| 40 void LaunchForContents(TabContentsWrapper* tab_contents); | 39 void LaunchForContents(TabContents* tab_contents); |
| 41 | 40 |
| 42 // Returns the number of blocked contents. | 41 // Returns the number of blocked contents. |
| 43 size_t GetBlockedContentsCount() const; | 42 size_t GetBlockedContentsCount() const; |
| 44 | 43 |
| 45 // Returns the contained TabContentsWrapper pointers. |blocked_contents| must | 44 // Returns the contained TabContents pointers. |blocked_contents| must |
| 46 // be non-NULL. | 45 // be non-NULL. |
| 47 void GetBlockedContents( | 46 void GetBlockedContents(std::vector<TabContents*>* blocked_contents) const; |
| 48 std::vector<TabContentsWrapper*>* blocked_contents) const; | |
| 49 | 47 |
| 50 // Removes all blocked contents. | 48 // Removes all blocked contents. |
| 51 void Clear(); | 49 void Clear(); |
| 52 | 50 |
| 53 // Overridden from BlockedContentTabHelperDelegate: | 51 // Overridden from BlockedContentTabHelperDelegate: |
| 54 virtual TabContentsWrapper* GetConstrainingContentsWrapper( | 52 virtual TabContents* GetConstrainingTabContents(TabContents* source) OVERRIDE; |
| 55 TabContentsWrapper* source) OVERRIDE; | |
| 56 | 53 |
| 57 // Overridden from content::WebContentsDelegate: | 54 // Overridden from content::WebContentsDelegate: |
| 58 | 55 |
| 59 // Forwards OpenURLFromTab to our |owner_|. | 56 // Forwards OpenURLFromTab to our |owner_|. |
| 60 virtual content::WebContents* OpenURLFromTab( | 57 virtual content::WebContents* OpenURLFromTab( |
| 61 content::WebContents* source, | 58 content::WebContents* source, |
| 62 const content::OpenURLParams& params) OVERRIDE; | 59 const content::OpenURLParams& params) OVERRIDE; |
| 63 | 60 |
| 64 // Forwards AddNewContents to our |owner_|. | 61 // Forwards AddNewContents to our |owner_|. |
| 65 virtual void AddNewContents(content::WebContents* source, | 62 virtual void AddNewContents(content::WebContents* source, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 84 // Maximum number of blocked contents we allow. No page should really need | 81 // Maximum number of blocked contents we allow. No page should really need |
| 85 // this many anyway. If reached it typically means there is a compromised | 82 // this many anyway. If reached it typically means there is a compromised |
| 86 // renderer. | 83 // renderer. |
| 87 static const size_t kImpossibleNumberOfPopups; | 84 static const size_t kImpossibleNumberOfPopups; |
| 88 | 85 |
| 89 private: | 86 private: |
| 90 struct BlockedContent; | 87 struct BlockedContent; |
| 91 | 88 |
| 92 typedef std::vector<BlockedContent> BlockedContents; | 89 typedef std::vector<BlockedContent> BlockedContents; |
| 93 | 90 |
| 94 // The TabContentsWrapper that owns and constrains this | 91 // The TabContents that owns and constrains this BlockedContentContainer. |
| 95 // BlockedContentContainer. | 92 TabContents* owner_; |
| 96 TabContentsWrapper* owner_; | |
| 97 | 93 |
| 98 // Information about all blocked contents. | 94 // Information about all blocked contents. |
| 99 BlockedContents blocked_contents_; | 95 BlockedContents blocked_contents_; |
| 100 | 96 |
| 101 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockedContentContainer); | 97 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockedContentContainer); |
| 102 }; | 98 }; |
| 103 | 99 |
| 104 #endif // CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_CONTAINER_H_ | 100 #endif // CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_CONTAINER_H_ |
| OLD | NEW |