| 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 TabContents/ | 7 // BlockedContentTabHelper. Users and subclasses of WebContents/ |
| 8 // TabContentsWrapper should use the appropriate methods on | 8 // TabContentsWrapper should use the appropriate methods on |
| 9 // BlockedContentTabHelper to access information about blocked content. | 9 // BlockedContentTabHelper to access 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 TabContentsWrapper; | 21 class TabContentsWrapper; |
| 22 | 22 |
| 23 // Takes ownership of TabContents that are unrequested popup windows. | 23 // Takes ownership of TabContentsWrappers that are unrequested popup windows. |
| 24 class BlockedContentContainer : public BlockedContentTabHelperDelegate, | 24 class BlockedContentContainer : public BlockedContentTabHelperDelegate, |
| 25 public content::WebContentsDelegate { | 25 public content::WebContentsDelegate { |
| 26 public: | 26 public: |
| 27 // Creates a container for a certain TabContents: | 27 // Creates a container for a certain TabContentsWrapper: |
| 28 explicit BlockedContentContainer(TabContentsWrapper* owner); | 28 explicit BlockedContentContainer(TabContentsWrapper* owner); |
| 29 virtual ~BlockedContentContainer(); | 29 virtual ~BlockedContentContainer(); |
| 30 | 30 |
| 31 // Adds a TabContents to this container. |bounds| are the window bounds | 31 // Adds a TabContentsWrapper to this container. |bounds| are the window bounds |
| 32 // requested for the TabContents. | 32 // requested for the TabContentsWrapper. |
| 33 void AddTabContents(TabContentsWrapper* tab_contents, | 33 void AddTabContents(TabContentsWrapper* tab_contents, |
| 34 WindowOpenDisposition disposition, | 34 WindowOpenDisposition disposition, |
| 35 const gfx::Rect& bounds, | 35 const gfx::Rect& bounds, |
| 36 bool user_gesture); | 36 bool user_gesture); |
| 37 | 37 |
| 38 // Shows the blocked TabContents |tab_contents|. | 38 // Shows the blocked TabContentsWrapper |tab_contents|. |
| 39 void LaunchForContents(TabContentsWrapper* tab_contents); | 39 void LaunchForContents(TabContentsWrapper* tab_contents); |
| 40 | 40 |
| 41 // Returns the number of blocked contents. | 41 // Returns the number of blocked contents. |
| 42 size_t GetBlockedContentsCount() const; | 42 size_t GetBlockedContentsCount() const; |
| 43 | 43 |
| 44 // Returns the contained TabContentsWrapper pointers. |blocked_contents| must | 44 // Returns the contained TabContentsWrapper pointers. |blocked_contents| must |
| 45 // be non-NULL. | 45 // be non-NULL. |
| 46 void GetBlockedContents( | 46 void GetBlockedContents( |
| 47 std::vector<TabContentsWrapper*>* blocked_contents) const; | 47 std::vector<TabContentsWrapper*>* blocked_contents) const; |
| 48 | 48 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // Maximum number of blocked contents we allow. No page should really need | 83 // Maximum number of blocked contents we allow. No page should really need |
| 84 // this many anyway. If reached it typically means there is a compromised | 84 // this many anyway. If reached it typically means there is a compromised |
| 85 // renderer. | 85 // renderer. |
| 86 static const size_t kImpossibleNumberOfPopups; | 86 static const size_t kImpossibleNumberOfPopups; |
| 87 | 87 |
| 88 private: | 88 private: |
| 89 struct BlockedContent; | 89 struct BlockedContent; |
| 90 | 90 |
| 91 typedef std::vector<BlockedContent> BlockedContents; | 91 typedef std::vector<BlockedContent> BlockedContents; |
| 92 | 92 |
| 93 // The TabContents that owns and constrains this BlockedContentContainer. | 93 // The TabContentsWrapper that owns and constrains this |
| 94 // BlockedContentContainer. |
| 94 TabContentsWrapper* owner_; | 95 TabContentsWrapper* owner_; |
| 95 | 96 |
| 96 // Information about all blocked contents. | 97 // Information about all blocked contents. |
| 97 BlockedContents blocked_contents_; | 98 BlockedContents blocked_contents_; |
| 98 | 99 |
| 99 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockedContentContainer); | 100 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockedContentContainer); |
| 100 }; | 101 }; |
| 101 | 102 |
| 102 #endif // CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_CONTAINER_H_ | 103 #endif // CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_CONTAINER_H_ |
| OLD | NEW |