summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/automation/automation_provider.cc2
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc30
-rw-r--r--chrome/browser/blocked_content_container.cc149
-rw-r--r--chrome/browser/blocked_content_container.h (renamed from chrome/browser/blocked_popup_container.h)72
-rw-r--r--chrome/browser/blocked_popup_container.cc131
-rw-r--r--chrome/browser/browser.cc1
-rw-r--r--chrome/browser/cocoa/content_setting_bubble_cocoa.mm2
-rw-r--r--chrome/browser/content_setting_bubble_model.cc14
-rw-r--r--chrome/browser/gtk/content_setting_bubble_gtk.cc2
-rw-r--r--chrome/browser/instant/instant_controller.cc8
-rw-r--r--chrome/browser/instant/instant_controller.h6
-rw-r--r--chrome/browser/instant/instant_loader.cc1
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc55
-rw-r--r--chrome/browser/tab_contents/tab_contents.h25
-rw-r--r--chrome/browser/views/content_setting_bubble_contents.cc2
-rw-r--r--chrome/chrome_browser.gypi4
16 files changed, 284 insertions, 220 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index ec635a9..7deaefe 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -38,7 +38,7 @@
#include "chrome/browser/automation/automation_window_tracker.h"
#include "chrome/browser/automation/extension_port_container.h"
#include "chrome/browser/autocomplete/autocomplete_edit.h"
-#include "chrome/browser/blocked_popup_container.h"
+#include "chrome/browser/blocked_content_container.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_storage.h"
#include "chrome/browser/browser_list.h"
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 4b28aad..109c13b 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -27,7 +27,7 @@
#include "chrome/browser/automation/ui_controls.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_storage.h"
-#include "chrome/browser/blocked_popup_container.h"
+#include "chrome/browser/blocked_content_container.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/browser_window.h"
@@ -1956,10 +1956,10 @@ void TestingAutomationProvider::GetBlockedPopupCount(int handle, int* count) {
NavigationController* nav_controller = tab_tracker_->GetResource(handle);
TabContents* tab_contents = nav_controller->tab_contents();
if (tab_contents) {
- BlockedPopupContainer* container =
- tab_contents->blocked_popup_container();
+ BlockedContentContainer* container =
+ tab_contents->blocked_content_container();
if (container) {
- *count = static_cast<int>(container->GetBlockedPopupCount());
+ *count = static_cast<int>(container->GetBlockedContentsCount());
} else {
// If we don't have a container, we don't have any blocked popups to
// contain!
@@ -3598,13 +3598,13 @@ void TestingAutomationProvider::GetBlockedPopupsInfo(
return;
}
scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
- BlockedPopupContainer* popup_container =
- tab_contents->blocked_popup_container();
+ BlockedContentContainer* popup_container =
+ tab_contents->blocked_content_container();
ListValue* blocked_popups_list = new ListValue;
if (popup_container) {
- BlockedPopupContainer::BlockedContents blocked_contents;
+ std::vector<TabContents*> blocked_contents;
popup_container->GetBlockedContents(&blocked_contents);
- for (BlockedPopupContainer::BlockedContents::const_iterator it =
+ for (std::vector<TabContents*>::const_iterator it =
blocked_contents.begin(); it != blocked_contents.end(); ++it) {
DictionaryValue* item = new DictionaryValue;
item->SetString("url", (*it)->GetURL().spec());
@@ -3635,16 +3635,16 @@ void TestingAutomationProvider::UnblockAndLaunchBlockedPopup(
return;
}
scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
- BlockedPopupContainer* popup_container =
- tab_contents->blocked_popup_container();
- if (!popup_container ||
- popup_index >= (int)popup_container->GetBlockedPopupCount()) {
+ BlockedContentContainer* content_container =
+ tab_contents->blocked_content_container();
+ if (!content_container ||
+ popup_index >= (int)content_container->GetBlockedContentsCount()) {
reply.SendError(StringPrintf("No popup at index %d", popup_index));
return;
}
- BlockedPopupContainer::BlockedContents blocked_contents;
- popup_container->GetBlockedContents(&blocked_contents);
- popup_container->LaunchPopupForContents(blocked_contents[popup_index]);
+ std::vector<TabContents*> blocked_contents;
+ content_container->GetBlockedContents(&blocked_contents);
+ content_container->LaunchForContents(blocked_contents[popup_index]);
reply.SendSuccess(NULL);
}
diff --git a/chrome/browser/blocked_content_container.cc b/chrome/browser/blocked_content_container.cc
new file mode 100644
index 0000000..58897c4
--- /dev/null
+++ b/chrome/browser/blocked_content_container.cc
@@ -0,0 +1,149 @@
+// 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.
+
+#include "chrome/browser/blocked_content_container.h"
+
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "gfx/rect.h"
+
+// static
+const size_t BlockedContentContainer::kImpossibleNumberOfPopups = 30;
+
+struct BlockedContentContainer::BlockedContent {
+ BlockedContent(TabContents* tab_contents,
+ WindowOpenDisposition disposition,
+ const gfx::Rect& bounds,
+ bool user_gesture)
+ : tab_contents(tab_contents),
+ disposition(disposition),
+ bounds(bounds),
+ user_gesture(user_gesture) {
+ }
+
+ TabContents* tab_contents;
+ WindowOpenDisposition disposition;
+ gfx::Rect bounds;
+ bool user_gesture;
+};
+
+BlockedContentContainer::BlockedContentContainer(TabContents* owner)
+ : owner_(owner) {
+}
+
+void BlockedContentContainer::AddTabContents(TabContents* tab_contents,
+ WindowOpenDisposition disposition,
+ const gfx::Rect& bounds,
+ bool user_gesture) {
+ if (blocked_contents_.size() == (kImpossibleNumberOfPopups - 1)) {
+ delete tab_contents;
+ LOG(INFO) << "Warning: Renderer is sending more popups to us than should "
+ "be possible. Renderer compromised?";
+ return;
+ }
+
+ blocked_contents_.push_back(
+ BlockedContent(tab_contents, disposition, bounds, user_gesture));
+ tab_contents->set_delegate(this);
+ if (blocked_contents_.size() == 1)
+ owner_->PopupNotificationVisibilityChanged(true);
+}
+
+void BlockedContentContainer::LaunchForContents(TabContents* tab_contents) {
+ // Open the popup.
+ for (BlockedContents::iterator i(blocked_contents_.begin());
+ i != blocked_contents_.end(); ++i) {
+ if (i->tab_contents == tab_contents) {
+ // To support the owner blocking the content again we copy and erase
+ // before attempting to add.
+ BlockedContent content(*i);
+ blocked_contents_.erase(i);
+ i = blocked_contents_.end();
+ tab_contents->set_delegate(NULL);
+ owner_->AddNewContents(tab_contents, content.disposition, content.bounds,
+ content.user_gesture);
+ break;
+ }
+ }
+
+ if (blocked_contents_.empty())
+ Destroy();
+}
+
+size_t BlockedContentContainer::GetBlockedContentsCount() const {
+ return blocked_contents_.size();
+}
+
+void BlockedContentContainer::GetBlockedContents(
+ std::vector<TabContents*>* blocked_contents) const {
+ DCHECK(blocked_contents);
+ for (BlockedContents::const_iterator i(blocked_contents_.begin());
+ i != blocked_contents_.end(); ++i)
+ blocked_contents->push_back(i->tab_contents);
+}
+
+void BlockedContentContainer::Destroy() {
+ for (BlockedContents::iterator i(blocked_contents_.begin());
+ i != blocked_contents_.end(); ++i) {
+ TabContents* tab_contents = i->tab_contents;
+ tab_contents->set_delegate(NULL);
+ delete tab_contents;
+ }
+ blocked_contents_.clear();
+ owner_->WillCloseBlockedContentContainer(this);
+ delete this;
+}
+
+// Overridden from TabContentsDelegate:
+void BlockedContentContainer::OpenURLFromTab(TabContents* source,
+ const GURL& url,
+ const GURL& referrer,
+ WindowOpenDisposition disposition,
+ PageTransition::Type transition) {
+ owner_->OpenURL(url, referrer, disposition, transition);
+}
+
+void BlockedContentContainer::AddNewContents(TabContents* source,
+ TabContents* new_contents,
+ WindowOpenDisposition disposition,
+ const gfx::Rect& initial_position,
+ bool user_gesture) {
+ owner_->AddNewContents(new_contents, disposition, initial_position,
+ user_gesture);
+}
+
+void BlockedContentContainer::CloseContents(TabContents* source) {
+ for (BlockedContents::iterator i(blocked_contents_.begin());
+ i != blocked_contents_.end(); ++i) {
+ TabContents* tab_contents = i->tab_contents;
+ if (tab_contents == source) {
+ tab_contents->set_delegate(NULL);
+ blocked_contents_.erase(i);
+ delete tab_contents;
+ break;
+ }
+ }
+}
+
+void BlockedContentContainer::MoveContents(TabContents* source,
+ const gfx::Rect& new_bounds) {
+ for (BlockedContents::iterator i(blocked_contents_.begin());
+ i != blocked_contents_.end(); ++i) {
+ if (i->tab_contents == source) {
+ i->bounds = new_bounds;
+ break;
+ }
+ }
+}
+
+bool BlockedContentContainer::IsPopup(const TabContents* source) const {
+ // Assume everything added is a popup. This may turn out to be wrong, but
+ // callers don't cache this information so it should be fine if the value ends
+ // up changing.
+ return true;
+}
+
+TabContents* BlockedContentContainer::GetConstrainingContents(
+ TabContents* source) {
+ return owner_;
+}
diff --git a/chrome/browser/blocked_popup_container.h b/chrome/browser/blocked_content_container.h
index 8fbd31a..29fc467 100644
--- a/chrome/browser/blocked_popup_container.h
+++ b/chrome/browser/blocked_content_container.h
@@ -2,13 +2,13 @@
// 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 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 popups.
+// 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_POPUP_CONTAINER_H_
-#define CHROME_BROWSER_BLOCKED_POPUP_CONTAINER_H_
+#ifndef CHROME_BROWSER_BLOCKED_CONTENT_CONTAINER_H_
+#define CHROME_BROWSER_BLOCKED_CONTENT_CONTAINER_H_
#pragma once
#include <vector>
@@ -16,27 +16,27 @@
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
// Takes ownership of TabContents that are unrequested popup windows.
-class BlockedPopupContainer : public TabContentsDelegate {
+class BlockedContentContainer : public TabContentsDelegate {
public:
- typedef std::vector<TabContents*> BlockedContents;
-
// Creates a container for a certain TabContents:
- explicit BlockedPopupContainer(TabContents* owner);
+ explicit BlockedContentContainer(TabContents* owner);
- // Adds a popup to this container. |bounds| are the window bounds requested by
- // the popup window.
+ // Adds a TabContents to this container. |bounds| are the window bounds
+ // requested for the TabContents.
void AddTabContents(TabContents* tab_contents,
- const gfx::Rect& bounds);
+ WindowOpenDisposition disposition,
+ const gfx::Rect& bounds,
+ bool user_gesture);
- // Shows the blocked popup with TabContents |tab_contents|.
- void LaunchPopupForContents(TabContents* tab_contents);
+ // Shows the blocked TabContents |tab_contents|.
+ void LaunchForContents(TabContents* tab_contents);
- // Returns the number of blocked popups.
- size_t GetBlockedPopupCount() const;
+ // Returns the number of blocked contents.
+ size_t GetBlockedContentsCount() const;
// Returns the contained TabContents pointers. |blocked_contents| must be
// non-NULL.
- void GetBlockedContents(BlockedContents* blocked_contents) const;
+ void GetBlockedContents(std::vector<TabContents*>* blocked_contents) const;
// Sets this object up to delete itself.
void Destroy();
@@ -49,7 +49,7 @@ class BlockedPopupContainer : public TabContentsDelegate {
WindowOpenDisposition disposition,
PageTransition::Type transition);
- // Ignored; BlockedPopupContainer doesn't display a throbber.
+ // Ignored; BlockedContentContainer doesn't display a throbber.
virtual void NavigationStateChanged(const TabContents* source,
unsigned changed_flags) {}
@@ -65,10 +65,10 @@ class BlockedPopupContainer : public TabContentsDelegate {
virtual void ActivateContents(TabContents* contents) {}
virtual void DeactivateContents(TabContents* contents) {}
- // Ignored; BlockedPopupContainer doesn't display a throbber.
+ // Ignored; BlockedContentContainer doesn't display a throbber.
virtual void LoadingStateChanged(TabContents* source) {}
- // Removes |source| from our internal list of blocked popups.
+ // Removes |source| from our internal list of blocked contents.
virtual void CloseContents(TabContents* source);
// Changes the opening rectangle associated with |source|.
@@ -80,32 +80,32 @@ class BlockedPopupContainer : public TabContentsDelegate {
// Returns our |owner_|.
virtual TabContents* GetConstrainingContents(TabContents* source);
- // Ignored; BlockedPopupContainer doesn't display a toolbar.
+ // Ignored; BlockedContentContainer doesn't display a toolbar.
virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {}
- // Ignored; BlockedPopupContainer doesn't display a bookmarking star.
+ // Ignored; BlockedContentContainer doesn't display a bookmarking star.
virtual void URLStarredChanged(TabContents* source, bool starred) {}
- // Ignored; BlockedPopupContainer doesn't display a URL bar.
+ // Ignored; BlockedContentContainer doesn't display a URL bar.
virtual void UpdateTargetURL(TabContents* source, const GURL& url) {}
- // A number larger than the internal popup count on the Renderer; meant for
- // preventing a compromised renderer from exhausting GDI memory by spawning
- // infinite windows.
+ // 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;
- protected:
- struct BlockedPopup;
- typedef std::vector<BlockedPopup> BlockedPopups;
-
private:
- // The TabContents that owns and constrains this BlockedPopupContainer.
+ struct BlockedContent;
+
+ typedef std::vector<BlockedContent> BlockedContents;
+
+ // The TabContents that owns and constrains this BlockedContentContainer.
TabContents* owner_;
- // Information about all blocked popups.
- BlockedPopups blocked_popups_;
+ // Information about all blocked contents.
+ BlockedContents blocked_contents_;
- DISALLOW_IMPLICIT_CONSTRUCTORS(BlockedPopupContainer);
+ DISALLOW_IMPLICIT_CONSTRUCTORS(BlockedContentContainer);
};
-#endif // CHROME_BROWSER_BLOCKED_POPUP_CONTAINER_H_
+#endif // CHROME_BROWSER_BLOCKED_CONTENT_CONTAINER_H_
diff --git a/chrome/browser/blocked_popup_container.cc b/chrome/browser/blocked_popup_container.cc
deleted file mode 100644
index d349314..0000000
--- a/chrome/browser/blocked_popup_container.cc
+++ /dev/null
@@ -1,131 +0,0 @@
-// 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.
-
-#include "chrome/browser/blocked_popup_container.h"
-
-#include "chrome/browser/tab_contents/tab_contents.h"
-#include "gfx/rect.h"
-
-// static
-const size_t BlockedPopupContainer::kImpossibleNumberOfPopups = 30;
-
-struct BlockedPopupContainer::BlockedPopup {
- BlockedPopup(TabContents* tab_contents,
- const gfx::Rect& bounds)
- : tab_contents(tab_contents), bounds(bounds) {
- }
-
- TabContents* tab_contents;
- gfx::Rect bounds;
-};
-
-BlockedPopupContainer::BlockedPopupContainer(TabContents* owner)
- : owner_(owner) {
-}
-
-void BlockedPopupContainer::AddTabContents(TabContents* tab_contents,
- const gfx::Rect& bounds) {
- if (blocked_popups_.size() == (kImpossibleNumberOfPopups - 1)) {
- delete tab_contents;
- LOG(INFO) << "Warning: Renderer is sending more popups to us than should "
- "be possible. Renderer compromised?";
- return;
- }
-
- blocked_popups_.push_back(BlockedPopup(tab_contents, bounds));
- tab_contents->set_delegate(this);
- if (blocked_popups_.size() == 1)
- owner_->PopupNotificationVisibilityChanged(true);
-}
-
-void BlockedPopupContainer::LaunchPopupForContents(TabContents* tab_contents) {
- // Open the popup.
- for (BlockedPopups::iterator i(blocked_popups_.begin());
- i != blocked_popups_.end(); ++i) {
- if (i->tab_contents == tab_contents) {
- tab_contents->set_delegate(NULL);
- owner_->AddNewContents(tab_contents, NEW_POPUP, i->bounds, true);
- blocked_popups_.erase(i);
- break;
- }
- }
-
- if (blocked_popups_.empty())
- Destroy();
-}
-
-size_t BlockedPopupContainer::GetBlockedPopupCount() const {
- return blocked_popups_.size();
-}
-
-void BlockedPopupContainer::GetBlockedContents(
- BlockedContents* blocked_contents) const {
- DCHECK(blocked_contents);
- for (BlockedPopups::const_iterator i(blocked_popups_.begin());
- i != blocked_popups_.end(); ++i)
- blocked_contents->push_back(i->tab_contents);
-}
-
-void BlockedPopupContainer::Destroy() {
- for (BlockedPopups::iterator i(blocked_popups_.begin());
- i != blocked_popups_.end(); ++i) {
- TabContents* tab_contents = i->tab_contents;
- tab_contents->set_delegate(NULL);
- delete tab_contents;
- }
- blocked_popups_.clear();
- owner_->WillCloseBlockedPopupContainer(this);
- delete this;
-}
-
-// Overridden from TabContentsDelegate:
-void BlockedPopupContainer::OpenURLFromTab(TabContents* source,
- const GURL& url,
- const GURL& referrer,
- WindowOpenDisposition disposition,
- PageTransition::Type transition) {
- owner_->OpenURL(url, referrer, disposition, transition);
-}
-
-void BlockedPopupContainer::AddNewContents(TabContents* source,
- TabContents* new_contents,
- WindowOpenDisposition disposition,
- const gfx::Rect& initial_position,
- bool user_gesture) {
- owner_->AddNewContents(new_contents, disposition, initial_position,
- user_gesture);
-}
-
-void BlockedPopupContainer::CloseContents(TabContents* source) {
- for (BlockedPopups::iterator i(blocked_popups_.begin());
- i != blocked_popups_.end(); ++i) {
- TabContents* tab_contents = i->tab_contents;
- if (tab_contents == source) {
- tab_contents->set_delegate(NULL);
- blocked_popups_.erase(i);
- delete tab_contents;
- break;
- }
- }
-}
-
-void BlockedPopupContainer::MoveContents(TabContents* source,
- const gfx::Rect& new_bounds) {
- for (BlockedPopups::iterator i(blocked_popups_.begin());
- i != blocked_popups_.end(); ++i) {
- if (i->tab_contents == source) {
- i->bounds = new_bounds;
- break;
- }
- }
-}
-
-bool BlockedPopupContainer::IsPopup(const TabContents* source) const {
- return true;
-}
-
-TabContents* BlockedPopupContainer::GetConstrainingContents(
- TabContents* source) {
- return owner_;
-}
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index c4f0b2a..23ead52 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -4211,6 +4211,7 @@ bool Browser::OpenInstant(WindowOpenDisposition disposition) {
instant()->last_transition_type(),
disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_SELECTED :
TabStripModel::ADD_NONE);
+ instant()->CompleteRelease(preview_contents);
return true;
}
// The omnibox currently doesn't use other dispositions, so we don't attempt
diff --git a/chrome/browser/cocoa/content_setting_bubble_cocoa.mm b/chrome/browser/cocoa/content_setting_bubble_cocoa.mm
index ea26ebc..f5e7e93 100644
--- a/chrome/browser/cocoa/content_setting_bubble_cocoa.mm
+++ b/chrome/browser/cocoa/content_setting_bubble_cocoa.mm
@@ -9,7 +9,7 @@
#include "base/logging.h"
#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/blocked_popup_container.h"
+#include "chrome/browser/blocked_content_container.h"
#import "chrome/browser/cocoa/content_settings_dialog_controller.h"
#import "chrome/browser/cocoa/hyperlink_button_cell.h"
#import "chrome/browser/cocoa/info_bubble_view.h"
diff --git a/chrome/browser/content_setting_bubble_model.cc b/chrome/browser/content_setting_bubble_model.cc
index 7b13dcd..65f1baa 100644
--- a/chrome/browser/content_setting_bubble_model.cc
+++ b/chrome/browser/content_setting_bubble_model.cc
@@ -7,7 +7,7 @@
#include "app/l10n_util.h"
#include "base/command_line.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/blocked_popup_container.h"
+#include "chrome/browser/blocked_content_container.h"
#include "chrome/browser/geolocation/geolocation_content_settings_map.h"
#include "chrome/browser/host_content_settings_map.h"
#include "chrome/browser/metrics/user_metrics.h"
@@ -329,12 +329,12 @@ class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup {
private:
void SetPopups() {
// check for crbug.com/53176
- if (!tab_contents()->blocked_popup_container())
+ if (!tab_contents()->blocked_content_container())
return;
- BlockedPopupContainer::BlockedContents blocked_contents;
- tab_contents()->blocked_popup_container()->GetBlockedContents(
+ std::vector<TabContents*> blocked_contents;
+ tab_contents()->blocked_content_container()->GetBlockedContents(
&blocked_contents);
- for (BlockedPopupContainer::BlockedContents::const_iterator
+ for (std::vector<TabContents*>::const_iterator
i(blocked_contents.begin()); i != blocked_contents.end(); ++i) {
std::string title(UTF16ToUTF8((*i)->GetTitle()));
// The popup may not have committed a load yet, in which case it won't
@@ -350,8 +350,8 @@ class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup {
}
virtual void OnPopupClicked(int index) {
- if (tab_contents() && tab_contents()->blocked_popup_container()) {
- tab_contents()->blocked_popup_container()->LaunchPopupForContents(
+ if (tab_contents() && tab_contents()->blocked_content_container()) {
+ tab_contents()->blocked_content_container()->LaunchForContents(
bubble_content().popup_items[index].tab_contents);
}
}
diff --git a/chrome/browser/gtk/content_setting_bubble_gtk.cc b/chrome/browser/gtk/content_setting_bubble_gtk.cc
index 7d4b011..21331f8 100644
--- a/chrome/browser/gtk/content_setting_bubble_gtk.cc
+++ b/chrome/browser/gtk/content_setting_bubble_gtk.cc
@@ -7,7 +7,7 @@
#include "app/l10n_util.h"
#include "base/i18n/rtl.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/blocked_popup_container.h"
+#include "chrome/browser/blocked_content_container.h"
#include "chrome/browser/content_setting_bubble_model.h"
#include "chrome/browser/gtk/gtk_chrome_link_button.h"
#include "chrome/browser/gtk/gtk_theme_provider.h"
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
index ac0cbfd..5afaca7 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -116,7 +116,9 @@ bool InstantController::IsCurrent() {
void InstantController::CommitCurrentPreview(InstantCommitType type) {
DCHECK(loader_manager_.get());
DCHECK(loader_manager_->current_loader());
- delegate_->CommitInstant(ReleasePreviewContents(type));
+ TabContents* tab = ReleasePreviewContents(type);
+ delegate_->CommitInstant(tab);
+ CompleteRelease(tab);
}
void InstantController::SetCommitOnMouseUp() {
@@ -145,6 +147,10 @@ TabContents* InstantController::ReleasePreviewContents(InstantCommitType type) {
return tab;
}
+void InstantController::CompleteRelease(TabContents* tab) {
+ tab->SetAllContentsBlocked(false);
+}
+
TabContents* InstantController::GetPreviewContents() {
return loader_manager_.get() ?
loader_manager_->current_loader()->preview_contents() : NULL;
diff --git a/chrome/browser/instant/instant_controller.h b/chrome/browser/instant/instant_controller.h
index dd4631a..d06bde6 100644
--- a/chrome/browser/instant/instant_controller.h
+++ b/chrome/browser/instant/instant_controller.h
@@ -87,8 +87,14 @@ class InstantController : public InstantLoaderDelegate {
// Releases the preview TabContents passing ownership to the caller. This is
// intended to be called when the preview TabContents is committed. This does
// not notify the delegate.
+ // WARNING: be sure and invoke CompleteRelease after adding the returned
+ // TabContents to a tabstrip.
TabContents* ReleasePreviewContents(InstantCommitType type);
+ // Does cleanup after the preview contents has been added to the tabstrip.
+ // Invoke this if you explicitly invoke ReleasePreviewContents.
+ void CompleteRelease(TabContents* tab);
+
// TabContents the match is being shown for.
TabContents* tab_contents() const { return tab_contents_; }
diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc
index f1e7dd3..ed0f59e 100644
--- a/chrome/browser/instant/instant_loader.cc
+++ b/chrome/browser/instant/instant_loader.cc
@@ -536,6 +536,7 @@ void InstantLoader::Update(TabContents* tab_contents,
preview_contents_.reset(
new TabContents(tab_contents->profile(), NULL, MSG_ROUTING_NONE,
NULL, NULL));
+ preview_contents_->SetAllContentsBlocked(true);
// Propagate the max page id. That way if we end up merging the two
// NavigationControllers (which happens if we commit) none of the page ids
// will overlap.
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 0ed29a0..5bceee9 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -23,8 +23,8 @@
#include "base/time.h"
#include "chrome/browser/autocomplete_history_manager.h"
#include "chrome/browser/autofill/autofill_manager.h"
+#include "chrome/browser/blocked_content_container.h"
#include "chrome/browser/blocked_plugin_manager.h"
-#include "chrome/browser/blocked_popup_container.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_shutdown.h"
@@ -345,7 +345,8 @@ TabContents::TabContents(Profile* profile,
is_starred_(false),
contents_mime_type_(),
encoding_(),
- blocked_popups_(NULL),
+ blocked_contents_(NULL),
+ all_contents_blocked_(false),
dont_notify_render_view_(false),
displayed_insecure_content_(false),
infobar_delegates_(),
@@ -457,9 +458,9 @@ TabContents::~TabContents() {
// twice before it runs.
CloseConstrainedWindows();
- // Close all blocked popups.
- if (blocked_popups_)
- blocked_popups_->Destroy();
+ // Close all blocked contents.
+ if (blocked_contents_)
+ blocked_contents_->Destroy();
// Notify any observer that have a reference on this tab contents.
NotificationService::current()->Notify(
@@ -971,6 +972,14 @@ void TabContents::AddNewContents(TabContents* new_contents,
WindowOpenDisposition disposition,
const gfx::Rect& initial_pos,
bool user_gesture) {
+ if (all_contents_blocked_) {
+ if (!blocked_contents_)
+ blocked_contents_ = new BlockedContentContainer(this);
+ blocked_contents_->AddTabContents(
+ new_contents, disposition, initial_pos, user_gesture);
+ return;
+ }
+
if (!delegate_)
return;
@@ -992,7 +1001,7 @@ void TabContents::AddNewContents(TabContents* new_contents,
}
// TODO(pkasting): Why is this necessary?
- PopupNotificationVisibilityChanged(blocked_popups_ != NULL);
+ PopupNotificationVisibilityChanged(blocked_contents_ != NULL);
}
bool TabContents::ExecuteCode(int request_id, const std::string& extension_id,
@@ -1221,10 +1230,10 @@ void TabContents::WillClose(ConstrainedWindow* window) {
}
}
-void TabContents::WillCloseBlockedPopupContainer(
- BlockedPopupContainer* container) {
- DCHECK(blocked_popups_ == container);
- blocked_popups_ = NULL;
+void TabContents::WillCloseBlockedContentContainer(
+ BlockedContentContainer* container) {
+ DCHECK(blocked_contents_ == container);
+ blocked_contents_ = NULL;
PopupNotificationVisibilityChanged(false);
}
@@ -1379,6 +1388,19 @@ void TabContents::WindowMoveOrResizeStarted() {
render_view_host()->WindowMoveOrResizeStarted();
}
+void TabContents::SetAllContentsBlocked(bool value) {
+ if (all_contents_blocked_ == value)
+ return;
+
+ all_contents_blocked_ = value;
+ if (!all_contents_blocked_ && blocked_contents_) {
+ std::vector<TabContents*> blocked;
+ blocked_contents_->GetBlockedContents(&blocked);
+ for (size_t i = 0; i < blocked.size(); ++i)
+ blocked_contents_->LaunchForContents(blocked[i]);
+ }
+}
+
void TabContents::LogNewTabTime(const std::string& event_name) {
// Not all new tab pages get timed. In those cases, we don't have a
// new_tab_start_time_.
@@ -1515,9 +1537,10 @@ void TabContents::AddPopup(TabContents* new_contents,
creator, CONTENT_SETTINGS_TYPE_POPUPS, "") == CONTENT_SETTING_ALLOW) {
AddNewContents(new_contents, NEW_POPUP, initial_pos, true);
} else {
- if (!blocked_popups_)
- blocked_popups_ = new BlockedPopupContainer(this);
- blocked_popups_->AddTabContents(new_contents, initial_pos);
+ if (!blocked_contents_)
+ blocked_contents_ = new BlockedContentContainer(this);
+ blocked_contents_->AddTabContents(new_contents, NEW_POPUP, initial_pos,
+ true);
content_settings_delegate_->OnContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS,
std::string());
}
@@ -1657,10 +1680,10 @@ void TabContents::DidNavigateMainFramePostCommit(
}
// Close blocked popups.
- if (blocked_popups_) {
+ if (blocked_contents_) {
AutoReset<bool> auto_reset(&dont_notify_render_view_, true);
- blocked_popups_->Destroy();
- blocked_popups_ = NULL;
+ blocked_contents_->Destroy();
+ blocked_contents_ = NULL;
}
// Clear "blocked" flags.
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index 1f16a74..b78a83b 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -65,8 +65,8 @@ struct PasswordForm;
class AutocompleteHistoryManager;
class AutoFillManager;
+class BlockedContentContainer;
class BlockedPluginManager;
-class BlockedPopupContainer;
class DOMUI;
class DownloadItem;
class Extension;
@@ -485,8 +485,8 @@ class TabContents : public PageNavigator,
// Called when a ConstrainedWindow we own is about to be closed.
void WillClose(ConstrainedWindow* window);
- // Called when a BlockedPopupContainer we own is about to be closed.
- void WillCloseBlockedPopupContainer(BlockedPopupContainer* container);
+ // Called when a BlockedContentContainer we own is about to be closed.
+ void WillCloseBlockedContentContainer(BlockedContentContainer* container);
// Called when a ConstrainedWindow we own is moved or resized.
void DidMoveOrResize(ConstrainedWindow* window);
@@ -620,8 +620,14 @@ class TabContents : public PageNavigator,
void WindowMoveOrResizeStarted();
- BlockedPopupContainer* blocked_popup_container() const {
- return blocked_popups_;
+ // Sets whether all TabContents added by way of |AddNewContents| should be
+ // blocked. Transitioning from all blocked to not all blocked results in
+ // reevaluating any blocked TabContents, which may result in unblocking some
+ // of the blocked TabContents.
+ void SetAllContentsBlocked(bool value);
+
+ BlockedContentContainer* blocked_content_container() const {
+ return blocked_contents_;
}
RendererPreferences* GetMutableRendererPrefs() {
@@ -745,7 +751,7 @@ class TabContents : public PageNavigator,
void SetIsLoading(bool is_loading,
LoadNotificationDetails* details);
- // Adds the incoming |new_contents| to the |blocked_popups_| container.
+ // Adds the incoming |new_contents| to the |blocked_contents_| container.
void AddPopup(TabContents* new_contents,
const gfx::Rect& initial_pos);
@@ -1155,8 +1161,11 @@ class TabContents : public PageNavigator,
// Character encoding. TODO(jungshik) : convert to std::string
std::string encoding_;
- // Object that holds any blocked popups frmo the current page.
- BlockedPopupContainer* blocked_popups_;
+ // Object that holds any blocked TabContents spawned from this TabContents.
+ BlockedContentContainer* blocked_contents_;
+
+ // Should we block all child TabContents this attempts to spawn.
+ bool all_contents_blocked_;
// TODO(pkasting): Hack to try and fix Linux browser tests.
bool dont_notify_render_view_;
diff --git a/chrome/browser/views/content_setting_bubble_contents.cc b/chrome/browser/views/content_setting_bubble_contents.cc
index f285212..240fbcf 100644
--- a/chrome/browser/views/content_setting_bubble_contents.cc
+++ b/chrome/browser/views/content_setting_bubble_contents.cc
@@ -10,7 +10,7 @@
#include "app/l10n_util.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/blocked_popup_container.h"
+#include "chrome/browser/blocked_content_container.h"
#include "chrome/browser/content_setting_bubble_model.h"
#include "chrome/browser/host_content_settings_map.h"
#include "chrome/browser/plugin_updater.h"
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 82d8823..50cac0e 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -260,10 +260,10 @@
'browser/background_mode_manager.cc',
'browser/background_contents_service.h',
'browser/background_contents_service.cc',
+ 'browser/blocked_content_container.cc',
+ 'browser/blocked_content_container.h',
'browser/blocked_plugin_manager.cc',
'browser/blocked_plugin_manager.h',
- 'browser/blocked_popup_container.cc',
- 'browser/blocked_popup_container.h',
'browser/bookmarks/bookmark_codec.cc',
'browser/bookmarks/bookmark_codec.h',
'browser/bookmarks/bookmark_context_menu_controller.cc',