| 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 // Defines the public interface for the blocked content (including popup) | |
| 6 // notifications. This interface should only be used by TabContents. Users and | |
| 7 // subclasses of TabContents should use the appropriate methods on TabContents | |
| 8 // to access information about blocked content. | |
| 9 | |
| 10 #ifndef CHROME_BROWSER_BLOCKED_CONTENT_CONTAINER_H_ | |
| 11 #define CHROME_BROWSER_BLOCKED_CONTENT_CONTAINER_H_ | |
| 12 #pragma once | |
| 13 | |
| 14 #include <vector> | |
| 15 | |
| 16 #include "content/browser/tab_contents/tab_contents_delegate.h" | |
| 17 | |
| 18 // Takes ownership of TabContents that are unrequested popup windows. | |
| 19 class BlockedContentContainer : public TabContentsDelegate { | |
| 20 public: | |
| 21 // Creates a container for a certain TabContents: | |
| 22 explicit BlockedContentContainer(TabContents* owner); | |
| 23 virtual ~BlockedContentContainer(); | |
| 24 | |
| 25 // Adds a TabContents to this container. |bounds| are the window bounds | |
| 26 // requested for the TabContents. | |
| 27 void AddTabContents(TabContents* tab_contents, | |
| 28 WindowOpenDisposition disposition, | |
| 29 const gfx::Rect& bounds, | |
| 30 bool user_gesture); | |
| 31 | |
| 32 // Shows the blocked TabContents |tab_contents|. | |
| 33 void LaunchForContents(TabContents* tab_contents); | |
| 34 | |
| 35 // Returns the number of blocked contents. | |
| 36 size_t GetBlockedContentsCount() const; | |
| 37 | |
| 38 // Returns the contained TabContents pointers. |blocked_contents| must be | |
| 39 // non-NULL. | |
| 40 void GetBlockedContents(std::vector<TabContents*>* blocked_contents) const; | |
| 41 | |
| 42 // Sets this object up to delete itself. | |
| 43 void Destroy(); | |
| 44 | |
| 45 // Overridden from TabContentsDelegate: | |
| 46 | |
| 47 // Forwards OpenURLFromTab to our |owner_|. | |
| 48 virtual void OpenURLFromTab(TabContents* source, | |
| 49 const GURL& url, const GURL& referrer, | |
| 50 WindowOpenDisposition disposition, | |
| 51 PageTransition::Type transition); | |
| 52 | |
| 53 // Ignored; BlockedContentContainer doesn't display a throbber. | |
| 54 virtual void NavigationStateChanged(const TabContents* source, | |
| 55 unsigned changed_flags) {} | |
| 56 | |
| 57 // Forwards AddNewContents to our |owner_|. | |
| 58 virtual void AddNewContents(TabContents* source, | |
| 59 TabContents* new_contents, | |
| 60 WindowOpenDisposition disposition, | |
| 61 const gfx::Rect& initial_position, | |
| 62 bool user_gesture); | |
| 63 | |
| 64 // Ignore activation/deactivation requests from the TabContents we're | |
| 65 // blocking. | |
| 66 virtual void ActivateContents(TabContents* contents) {} | |
| 67 virtual void DeactivateContents(TabContents* contents) {} | |
| 68 | |
| 69 // Ignored; BlockedContentContainer doesn't display a throbber. | |
| 70 virtual void LoadingStateChanged(TabContents* source) {} | |
| 71 | |
| 72 // Removes |source| from our internal list of blocked contents. | |
| 73 virtual void CloseContents(TabContents* source); | |
| 74 | |
| 75 // Changes the opening rectangle associated with |source|. | |
| 76 virtual void MoveContents(TabContents* source, const gfx::Rect& new_bounds); | |
| 77 | |
| 78 // Always returns true. | |
| 79 virtual bool IsPopup(const TabContents* source) const; | |
| 80 | |
| 81 // Returns our |owner_|. | |
| 82 virtual TabContents* GetConstrainingContents(TabContents* source); | |
| 83 | |
| 84 // Ignored; BlockedContentContainer doesn't display a URL bar. | |
| 85 virtual void UpdateTargetURL(TabContents* source, const GURL& url) {} | |
| 86 | |
| 87 // 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 | |
| 89 // renderer. | |
| 90 static const size_t kImpossibleNumberOfPopups; | |
| 91 | |
| 92 private: | |
| 93 struct BlockedContent; | |
| 94 | |
| 95 typedef std::vector<BlockedContent> BlockedContents; | |
| 96 | |
| 97 // The TabContents that owns and constrains this BlockedContentContainer. | |
| 98 TabContents* owner_; | |
| 99 | |
| 100 // Information about all blocked contents. | |
| 101 BlockedContents blocked_contents_; | |
| 102 | |
| 103 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockedContentContainer); | |
| 104 }; | |
| 105 | |
| 106 #endif // CHROME_BROWSER_BLOCKED_CONTENT_CONTAINER_H_ | |
| OLD | NEW |