blob: 8fbd31a3ca0516856ad91dfcabc0953534b71a50 [file] [log] [blame]
[email protected]8cc8d492010-02-02 10:40:491// 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]66ba4932009-06-04 19:22:134
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]32b76ef2010-07-26 23:08:2412#pragma once
[email protected]66ba4932009-06-04 19:22:1313
[email protected]cba81a7d2010-08-05 21:47:4014#include <vector>
15
[email protected]66ba4932009-06-04 19:22:1316#include "chrome/browser/tab_contents/tab_contents_delegate.h"
[email protected]66ba4932009-06-04 19:22:1317
[email protected]8cc8d492010-02-02 10:40:4918// Takes ownership of TabContents that are unrequested popup windows.
19class BlockedPopupContainer : public TabContentsDelegate {
[email protected]4d4c0b92009-06-08 23:13:0120 public:
[email protected]8cc8d492010-02-02 10:40:4921 typedef std::vector<TabContents*> BlockedContents;
[email protected]4d4c0b92009-06-08 23:13:0122
[email protected]8cc8d492010-02-02 10:40:4923 // Creates a container for a certain TabContents:
24 explicit BlockedPopupContainer(TabContents* owner);
[email protected]4d4c0b92009-06-08 23:13:0125
[email protected]66ba4932009-06-04 19:22:1326 // 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]8cc8d492010-02-02 10:40:4929 const gfx::Rect& bounds);
[email protected]66ba4932009-06-04 19:22:1330
[email protected]8cc8d492010-02-02 10:40:4931 // Shows the blocked popup with TabContents |tab_contents|.
32 void LaunchPopupForContents(TabContents* tab_contents);
[email protected]66ba4932009-06-04 19:22:1333
[email protected]8cc8d492010-02-02 10:40:4934 // Returns the number of blocked popups.
[email protected]66ba4932009-06-04 19:22:1335 size_t GetBlockedPopupCount() const;
36
[email protected]8cc8d492010-02-02 10:40:4937 // Returns the contained TabContents pointers. |blocked_contents| must be
38 // non-NULL.
39 void GetBlockedContents(BlockedContents* blocked_contents) const;
[email protected]66ba4932009-06-04 19:22:1340
41 // Sets this object up to delete itself.
[email protected]4d4c0b92009-06-08 23:13:0142 void Destroy();
[email protected]66ba4932009-06-04 19:22:1343
[email protected]66ba4932009-06-04 19:22:1344 // 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]135fd3b62009-12-16 01:07:0854 unsigned changed_flags) {}
[email protected]66ba4932009-06-04 19:22:1355
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]ea42e7782010-08-23 23:58:1263 // Ignore activation/deactivation requests from the TabContents we're
64 // blocking.
[email protected]135fd3b62009-12-16 01:07:0865 virtual void ActivateContents(TabContents* contents) {}
[email protected]ea42e7782010-08-23 23:58:1266 virtual void DeactivateContents(TabContents* contents) {}
[email protected]66ba4932009-06-04 19:22:1367
68 // Ignored; BlockedPopupContainer doesn't display a throbber.
[email protected]135fd3b62009-12-16 01:07:0869 virtual void LoadingStateChanged(TabContents* source) {}
[email protected]66ba4932009-06-04 19:22:1370
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]be04582b2010-07-26 21:56:5678 virtual bool IsPopup(const TabContents* source) const;
[email protected]66ba4932009-06-04 19:22:1379
80 // Returns our |owner_|.
81 virtual TabContents* GetConstrainingContents(TabContents* source);
82
83 // Ignored; BlockedPopupContainer doesn't display a toolbar.
[email protected]135fd3b62009-12-16 01:07:0884 virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {}
[email protected]66ba4932009-06-04 19:22:1385
86 // Ignored; BlockedPopupContainer doesn't display a bookmarking star.
[email protected]135fd3b62009-12-16 01:07:0887 virtual void URLStarredChanged(TabContents* source, bool starred) {}
[email protected]66ba4932009-06-04 19:22:1388
89 // Ignored; BlockedPopupContainer doesn't display a URL bar.
[email protected]135fd3b62009-12-16 01:07:0890 virtual void UpdateTargetURL(TabContents* source, const GURL& url) {}
[email protected]66ba4932009-06-04 19:22:1391
[email protected]66ba4932009-06-04 19:22:1392 // 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]5f40e112009-10-05 20:51:3595 static const size_t kImpossibleNumberOfPopups;
[email protected]66ba4932009-06-04 19:22:1396
97 protected:
[email protected]ce7f62e32010-08-10 23:43:5998 struct BlockedPopup;
[email protected]66ba4932009-06-04 19:22:1399 typedef std::vector<BlockedPopup> BlockedPopups;
100
[email protected]66ba4932009-06-04 19:22:13101 private:
[email protected]66ba4932009-06-04 19:22:13102 // The TabContents that owns and constrains this BlockedPopupContainer.
103 TabContents* owner_;
104
[email protected]66ba4932009-06-04 19:22:13105 // Information about all blocked popups.
106 BlockedPopups blocked_popups_;
107
[email protected]66ba4932009-06-04 19:22:13108 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockedPopupContainer);
109};
110
111#endif // CHROME_BROWSER_BLOCKED_POPUP_CONTAINER_H_