[email protected] | 8cc8d49 | 2010-02-02 10:40:49 | [diff] [blame] | 1 | // Copyright (c) 2010 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. |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 4 | |
| 5 | // Defines the public interface for the blocked popup notifications. This |
| 6 | // interface should only be used by TabContents. Users and subclasses of |
| 7 | // TabContents should use the appropriate methods on TabContents to access |
| 8 | // information about blocked popups. |
| 9 | |
| 10 | #ifndef CHROME_BROWSER_BLOCKED_POPUP_CONTAINER_H_ |
| 11 | #define CHROME_BROWSER_BLOCKED_POPUP_CONTAINER_H_ |
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 12 | #pragma once |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 13 | |
[email protected] | cba81a7d | 2010-08-05 21:47:40 | [diff] [blame] | 14 | #include <vector> |
| 15 | |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 16 | #include "chrome/browser/tab_contents/tab_contents_delegate.h" |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 17 | |
[email protected] | 8cc8d49 | 2010-02-02 10:40:49 | [diff] [blame] | 18 | // Takes ownership of TabContents that are unrequested popup windows. |
| 19 | class BlockedPopupContainer : public TabContentsDelegate { |
[email protected] | 4d4c0b9 | 2009-06-08 23:13:01 | [diff] [blame] | 20 | public: |
[email protected] | 8cc8d49 | 2010-02-02 10:40:49 | [diff] [blame] | 21 | typedef std::vector<TabContents*> BlockedContents; |
[email protected] | 4d4c0b9 | 2009-06-08 23:13:01 | [diff] [blame] | 22 | |
[email protected] | 8cc8d49 | 2010-02-02 10:40:49 | [diff] [blame] | 23 | // Creates a container for a certain TabContents: |
| 24 | explicit BlockedPopupContainer(TabContents* owner); |
[email protected] | 4d4c0b9 | 2009-06-08 23:13:01 | [diff] [blame] | 25 | |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 26 | // Adds a popup to this container. |bounds| are the window bounds requested by |
| 27 | // the popup window. |
| 28 | void AddTabContents(TabContents* tab_contents, |
[email protected] | 8cc8d49 | 2010-02-02 10:40:49 | [diff] [blame] | 29 | const gfx::Rect& bounds); |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 30 | |
[email protected] | 8cc8d49 | 2010-02-02 10:40:49 | [diff] [blame] | 31 | // Shows the blocked popup with TabContents |tab_contents|. |
| 32 | void LaunchPopupForContents(TabContents* tab_contents); |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 33 | |
[email protected] | 8cc8d49 | 2010-02-02 10:40:49 | [diff] [blame] | 34 | // Returns the number of blocked popups. |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 35 | size_t GetBlockedPopupCount() const; |
| 36 | |
[email protected] | 8cc8d49 | 2010-02-02 10:40:49 | [diff] [blame] | 37 | // Returns the contained TabContents pointers. |blocked_contents| must be |
| 38 | // non-NULL. |
| 39 | void GetBlockedContents(BlockedContents* blocked_contents) const; |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 40 | |
| 41 | // Sets this object up to delete itself. |
[email protected] | 4d4c0b9 | 2009-06-08 23:13:01 | [diff] [blame] | 42 | void Destroy(); |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 43 | |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 44 | // Overridden from TabContentsDelegate: |
| 45 | |
| 46 | // Forwards OpenURLFromTab to our |owner_|. |
| 47 | virtual void OpenURLFromTab(TabContents* source, |
| 48 | const GURL& url, const GURL& referrer, |
| 49 | WindowOpenDisposition disposition, |
| 50 | PageTransition::Type transition); |
| 51 | |
| 52 | // Ignored; BlockedPopupContainer doesn't display a throbber. |
| 53 | virtual void NavigationStateChanged(const TabContents* source, |
[email protected] | 135fd3b6 | 2009-12-16 01:07:08 | [diff] [blame] | 54 | unsigned changed_flags) {} |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 55 | |
| 56 | // Forwards AddNewContents to our |owner_|. |
| 57 | virtual void AddNewContents(TabContents* source, |
| 58 | TabContents* new_contents, |
| 59 | WindowOpenDisposition disposition, |
| 60 | const gfx::Rect& initial_position, |
| 61 | bool user_gesture); |
| 62 | |
[email protected] | ea42e778 | 2010-08-23 23:58:12 | [diff] [blame] | 63 | // Ignore activation/deactivation requests from the TabContents we're |
| 64 | // blocking. |
[email protected] | 135fd3b6 | 2009-12-16 01:07:08 | [diff] [blame] | 65 | virtual void ActivateContents(TabContents* contents) {} |
[email protected] | ea42e778 | 2010-08-23 23:58:12 | [diff] [blame] | 66 | virtual void DeactivateContents(TabContents* contents) {} |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 67 | |
| 68 | // Ignored; BlockedPopupContainer doesn't display a throbber. |
[email protected] | 135fd3b6 | 2009-12-16 01:07:08 | [diff] [blame] | 69 | virtual void LoadingStateChanged(TabContents* source) {} |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 70 | |
| 71 | // Removes |source| from our internal list of blocked popups. |
| 72 | virtual void CloseContents(TabContents* source); |
| 73 | |
| 74 | // Changes the opening rectangle associated with |source|. |
| 75 | virtual void MoveContents(TabContents* source, const gfx::Rect& new_bounds); |
| 76 | |
| 77 | // Always returns true. |
[email protected] | be04582b | 2010-07-26 21:56:56 | [diff] [blame] | 78 | virtual bool IsPopup(const TabContents* source) const; |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 79 | |
| 80 | // Returns our |owner_|. |
| 81 | virtual TabContents* GetConstrainingContents(TabContents* source); |
| 82 | |
| 83 | // Ignored; BlockedPopupContainer doesn't display a toolbar. |
[email protected] | 135fd3b6 | 2009-12-16 01:07:08 | [diff] [blame] | 84 | virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {} |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 85 | |
| 86 | // Ignored; BlockedPopupContainer doesn't display a bookmarking star. |
[email protected] | 135fd3b6 | 2009-12-16 01:07:08 | [diff] [blame] | 87 | virtual void URLStarredChanged(TabContents* source, bool starred) {} |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 88 | |
| 89 | // Ignored; BlockedPopupContainer doesn't display a URL bar. |
[email protected] | 135fd3b6 | 2009-12-16 01:07:08 | [diff] [blame] | 90 | virtual void UpdateTargetURL(TabContents* source, const GURL& url) {} |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 91 | |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 92 | // A number larger than the internal popup count on the Renderer; meant for |
| 93 | // preventing a compromised renderer from exhausting GDI memory by spawning |
| 94 | // infinite windows. |
[email protected] | 5f40e11 | 2009-10-05 20:51:35 | [diff] [blame] | 95 | static const size_t kImpossibleNumberOfPopups; |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 96 | |
| 97 | protected: |
[email protected] | ce7f62e3 | 2010-08-10 23:43:59 | [diff] [blame] | 98 | struct BlockedPopup; |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 99 | typedef std::vector<BlockedPopup> BlockedPopups; |
| 100 | |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 101 | private: |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 102 | // The TabContents that owns and constrains this BlockedPopupContainer. |
| 103 | TabContents* owner_; |
| 104 | |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 105 | // Information about all blocked popups. |
| 106 | BlockedPopups blocked_popups_; |
| 107 | |
[email protected] | 66ba493 | 2009-06-04 19:22:13 | [diff] [blame] | 108 | DISALLOW_IMPLICIT_CONSTRUCTORS(BlockedPopupContainer); |
| 109 | }; |
| 110 | |
| 111 | #endif // CHROME_BROWSER_BLOCKED_POPUP_CONTAINER_H_ |