Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(937)

Unified Diff: content/browser/tab_contents/tab_contents.cc

Issue 6854035: Move blocked content from TabContents to TabContentsWrapper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/tab_contents/tab_contents.cc
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index 6ed1c389131c44b57d6467566e307bc345eddc13..8e4df17ffe1104964d1b783094018006ccb11c32 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -6,7 +6,6 @@
#include <cmath>
-#include "base/auto_reset.h"
#include "base/command_line.h"
#include "base/metrics/histogram.h"
#include "base/metrics/stats_counters.h"
@@ -14,12 +13,9 @@
#include "base/string_util.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/blocked_content_container.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/character_encoding.h"
-#include "chrome/browser/content_settings/content_settings_details.h"
-#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/debugger/devtools_manager.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/dom_operation_notification_details.h"
@@ -238,9 +234,6 @@ TabContents::TabContents(Profile* profile,
upload_size_(0),
upload_position_(0),
received_page_title_(false),
- blocked_contents_(NULL),
- all_contents_blocked_(false),
- dont_notify_render_view_(false),
displayed_insecure_content_(false),
capturing_contents_(false),
is_being_destroyed_(false),
@@ -297,10 +290,6 @@ TabContents::TabContents(Profile* profile,
registrar_.Add(this, NotificationType::USER_STYLE_SHEET_UPDATED,
NotificationService::AllSources());
- // Register for notifications about content setting changes.
- registrar_.Add(this, NotificationType::CONTENT_SETTINGS_CHANGED,
- NotificationService::AllSources());
-
// Listen for Google URL changes.
registrar_.Add(this, NotificationType::GOOGLE_URL_UPDATED,
NotificationService::AllSources());
@@ -331,10 +320,6 @@ TabContents::~TabContents() {
// twice before it runs.
CloseConstrainedWindows();
- // Close all blocked contents.
- if (blocked_contents_)
- blocked_contents_->Destroy();
-
// Notify any observer that have a reference on this tab contents.
NotificationService::current()->Notify(
NotificationType::TAB_CONTENTS_DESTROYED,
@@ -809,44 +794,11 @@ 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;
- if ((disposition == NEW_POPUP) && !user_gesture &&
- !CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kDisablePopupBlocking)) {
- // Unrequested popups from normal pages are constrained unless they're in
- // the whitelist. The popup owner will handle checking this.
- delegate_->GetConstrainingContents(this)->AddPopup(
- new_contents, initial_pos);
- } else {
- new_contents->DisassociateFromPopupCount();
- delegate_->AddNewContents(this, new_contents, disposition, initial_pos,
- user_gesture);
- NotificationService::current()->Notify(
- NotificationType::TAB_ADDED,
- Source<TabContentsDelegate>(delegate_),
- Details<TabContents>(this));
- }
-
- // TODO(pkasting): Why is this necessary?
- PopupNotificationVisibilityChanged(blocked_contents_ != NULL);
-}
-
-void TabContents::PopupNotificationVisibilityChanged(bool visible) {
- if (is_being_destroyed_)
- return;
- content_settings_delegate_->SetPopupsBlocked(visible);
- if (!dont_notify_render_view_)
- render_view_host()->AllowScriptToClose(!visible);
+ delegate_->AddNewContents(this, new_contents, disposition, initial_pos,
+ user_gesture);
}
gfx::NativeView TabContents::GetContentNativeView() const {
@@ -1038,13 +990,6 @@ void TabContents::WillClose(ConstrainedWindow* window) {
}
}
-void TabContents::WillCloseBlockedContentContainer(
- BlockedContentContainer* container) {
- DCHECK(blocked_contents_ == container);
- blocked_contents_ = NULL;
- PopupNotificationVisibilityChanged(false);
-}
-
void TabContents::EmailPageLocation() {
std::string title = EscapeQueryParamValue(UTF16ToUTF8(GetTitle()), false);
std::string page_url = EscapeQueryParamValue(GetURL().spec(), false);
@@ -1082,19 +1027,6 @@ 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_.
@@ -1415,32 +1347,6 @@ void TabContents::SetIsLoading(bool is_loading,
det);
}
-void TabContents::AddPopup(TabContents* new_contents,
- const gfx::Rect& initial_pos) {
- // A page can't spawn popups (or do anything else, either) until its load
- // commits, so when we reach here, the popup was spawned by the
- // NavigationController's last committed entry, not the active entry. For
- // example, if a page opens a popup in an onunload() handler, then the active
- // entry is the page to be loaded as we navigate away from the unloading
- // page. For this reason, we can't use GetURL() to get the opener URL,
- // because it returns the active entry.
- NavigationEntry* entry = controller_.GetLastCommittedEntry();
- GURL creator = entry ? entry->virtual_url() : GURL::EmptyGURL();
-
- if (creator.is_valid() &&
- profile()->GetHostContentSettingsMap()->GetContentSetting(
- creator, CONTENT_SETTINGS_TYPE_POPUPS, "") == CONTENT_SETTING_ALLOW) {
- AddNewContents(new_contents, NEW_POPUP, initial_pos, true);
- } else {
- 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());
- }
-}
-
void TabContents::ExpireInfoBars(
const NavigationController::LoadCommittedDetails& details) {
// Only hide InfoBars when the user has done something that makes the main
@@ -1544,13 +1450,6 @@ void TabContents::DidNavigateMainFramePostCommit(
// Clear all page actions, blocked content notifications and browser actions
// for this tab, unless this is an in-page navigation.
if (!details.is_in_page) {
- // Close blocked popups.
- if (blocked_contents_) {
- AutoReset<bool> auto_reset(&dont_notify_render_view_, true);
- blocked_contents_->Destroy();
- blocked_contents_ = NULL;
- }
-
// Clear "blocked" flags.
content_settings_delegate_->ClearBlockedContentSettingsExceptForCookies();
content_settings_delegate_->GeolocationDidNavigate(details);
@@ -2471,21 +2370,6 @@ void TabContents::Observe(NotificationType type,
UpdateWebPreferences();
break;
- case NotificationType::CONTENT_SETTINGS_CHANGED: {
- Details<const ContentSettingsDetails> settings_details(details);
- NavigationEntry* entry = controller_.GetActiveEntry();
- GURL entry_url;
- if (entry)
- entry_url = entry->url();
- if (settings_details.ptr()->update_all() ||
- settings_details.ptr()->pattern().Matches(entry_url)) {
- render_view_host()->SendContentSettings(entry_url,
- profile()->GetHostContentSettingsMap()->
- GetContentSettings(entry_url));
- }
- break;
- }
-
case NotificationType::GOOGLE_URL_UPDATED:
UpdateAlternateErrorPageURL();
break;

Powered by Google App Engine
This is Rietveld 408576698