diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-14 15:30:40 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-14 15:30:40 +0000 |
commit | c65e2f15891448a06a89c7a2e0e9aa74d1a44c67 (patch) | |
tree | 0a8f6b8d60b332a9d4c60f85046f8a3f7ba3e96d /chrome/browser/blocked_content_container.h | |
parent | 87996f6636dd308b649e38e7b83df05045e62b81 (diff) | |
download | chromium_src-c65e2f15891448a06a89c7a2e0e9aa74d1a44c67.zip chromium_src-c65e2f15891448a06a89c7a2e0e9aa74d1a44c67.tar.gz chromium_src-c65e2f15891448a06a89c7a2e0e9aa74d1a44c67.tar.bz2 |
Fixes instant so that it correctly deals with child contents. I've
changed around BlockedPopupContainer so that it can handle any types
and made TabContents offer a mode to block all child content.
BUG=58927
TEST=enable instant, go to a site that would normally show a popup on
entering (or explicitly enable all popups). While typing in
the omnibox the popup shouldn't appear, but as soon as you
commit the instant result it should appear.
Review URL: http://codereview.chromium.org/3694005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62553 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/blocked_content_container.h')
-rw-r--r-- | chrome/browser/blocked_content_container.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/chrome/browser/blocked_content_container.h b/chrome/browser/blocked_content_container.h new file mode 100644 index 0000000..29fc467 --- /dev/null +++ b/chrome/browser/blocked_content_container.h @@ -0,0 +1,111 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Defines the public interface for the blocked content (including popup) +// notifications. This interface should only be used by TabContents. Users and +// subclasses of TabContents should use the appropriate methods on TabContents +// to access information about blocked content. + +#ifndef CHROME_BROWSER_BLOCKED_CONTENT_CONTAINER_H_ +#define CHROME_BROWSER_BLOCKED_CONTENT_CONTAINER_H_ +#pragma once + +#include <vector> + +#include "chrome/browser/tab_contents/tab_contents_delegate.h" + +// Takes ownership of TabContents that are unrequested popup windows. +class BlockedContentContainer : public TabContentsDelegate { + public: + // Creates a container for a certain TabContents: + explicit BlockedContentContainer(TabContents* owner); + + // Adds a TabContents to this container. |bounds| are the window bounds + // requested for the TabContents. + void AddTabContents(TabContents* tab_contents, + WindowOpenDisposition disposition, + const gfx::Rect& bounds, + bool user_gesture); + + // Shows the blocked TabContents |tab_contents|. + void LaunchForContents(TabContents* tab_contents); + + // Returns the number of blocked contents. + size_t GetBlockedContentsCount() const; + + // Returns the contained TabContents pointers. |blocked_contents| must be + // non-NULL. + void GetBlockedContents(std::vector<TabContents*>* blocked_contents) const; + + // Sets this object up to delete itself. + void Destroy(); + + // Overridden from TabContentsDelegate: + + // Forwards OpenURLFromTab to our |owner_|. + virtual void OpenURLFromTab(TabContents* source, + const GURL& url, const GURL& referrer, + WindowOpenDisposition disposition, + PageTransition::Type transition); + + // Ignored; BlockedContentContainer doesn't display a throbber. + virtual void NavigationStateChanged(const TabContents* source, + unsigned changed_flags) {} + + // Forwards AddNewContents to our |owner_|. + virtual void AddNewContents(TabContents* source, + TabContents* new_contents, + WindowOpenDisposition disposition, + const gfx::Rect& initial_position, + bool user_gesture); + + // Ignore activation/deactivation requests from the TabContents we're + // blocking. + virtual void ActivateContents(TabContents* contents) {} + virtual void DeactivateContents(TabContents* contents) {} + + // Ignored; BlockedContentContainer doesn't display a throbber. + virtual void LoadingStateChanged(TabContents* source) {} + + // Removes |source| from our internal list of blocked contents. + virtual void CloseContents(TabContents* source); + + // Changes the opening rectangle associated with |source|. + virtual void MoveContents(TabContents* source, const gfx::Rect& new_bounds); + + // Always returns true. + virtual bool IsPopup(const TabContents* source) const; + + // Returns our |owner_|. + virtual TabContents* GetConstrainingContents(TabContents* source); + + // Ignored; BlockedContentContainer doesn't display a toolbar. + virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {} + + // Ignored; BlockedContentContainer doesn't display a bookmarking star. + virtual void URLStarredChanged(TabContents* source, bool starred) {} + + // Ignored; BlockedContentContainer doesn't display a URL bar. + virtual void UpdateTargetURL(TabContents* source, const GURL& url) {} + + // Maximum number of blocked contents we allow. No page should really need + // this many anyway. If reached it typically means there is a compromised + // renderer. + static const size_t kImpossibleNumberOfPopups; + + private: + struct BlockedContent; + + typedef std::vector<BlockedContent> BlockedContents; + + // The TabContents that owns and constrains this BlockedContentContainer. + TabContents* owner_; + + // Information about all blocked contents. + BlockedContents blocked_contents_; + + DISALLOW_IMPLICIT_CONSTRUCTORS(BlockedContentContainer); +}; + +#endif // CHROME_BROWSER_BLOCKED_CONTENT_CONTAINER_H_ |