summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-22 14:41:37 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-22 14:41:37 +0000
commite7cfdbdb27147aa58923eac639fbb13bbcbc3945 (patch)
treee6125a0e6105625ac6a5c677110e173d8ae638cb
parent930837d5e50edbdfe137cb1a72708758fc64b1ef (diff)
downloadchromium_src-e7cfdbdb27147aa58923eac639fbb13bbcbc3945.zip
chromium_src-e7cfdbdb27147aa58923eac639fbb13bbcbc3945.tar.gz
chromium_src-e7cfdbdb27147aa58923eac639fbb13bbcbc3945.tar.bz2
Move blocked content from TabContents to TabContentsWrapper.
BUG=71097 TEST=hammer on popup blocking; should be no visible change Review URL: http://codereview.chromium.org/6854035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82643 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/automation/automation_provider.cc1
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc129
-rw-r--r--chrome/browser/extensions/extension_host.cc2
-rw-r--r--chrome/browser/instant/instant_controller.cc7
-rw-r--r--chrome/browser/instant/instant_controller.h2
-rw-r--r--chrome/browser/instant/instant_loader.cc3
-rw-r--r--chrome/browser/ui/blocked_content/blocked_content_container.cc (renamed from chrome/browser/blocked_content_container.cc)80
-rw-r--r--chrome/browser/ui/blocked_content/blocked_content_container.h (renamed from chrome/browser/blocked_content_container.h)48
-rw-r--r--chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc117
-rw-r--r--chrome/browser/ui/blocked_content/blocked_content_tab_helper.h83
-rw-r--r--chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.cc8
-rw-r--r--chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.h24
-rw-r--r--chrome/browser/ui/browser.cc70
-rw-r--r--chrome/browser/ui/browser.h6
-rw-r--r--chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm5
-rw-r--r--chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa_unittest.mm31
-rw-r--r--chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm15
-rw-r--r--chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm4
-rw-r--r--chrome/browser/ui/content_settings/content_setting_bubble_model.cc (renamed from chrome/browser/content_setting_bubble_model.cc)88
-rw-r--r--chrome/browser/ui/content_settings/content_setting_bubble_model.h (renamed from chrome/browser/content_setting_bubble_model.h)18
-rw-r--r--chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc (renamed from chrome/browser/content_setting_bubble_model_unittest.cc)22
-rw-r--r--chrome/browser/ui/content_settings/content_setting_combo_model.cc (renamed from chrome/browser/content_setting_combo_model.cc)5
-rw-r--r--chrome/browser/ui/content_settings/content_setting_combo_model.h (renamed from chrome/browser/content_setting_combo_model.h)8
-rw-r--r--chrome/browser/ui/content_settings/content_setting_image_model.cc (renamed from chrome/browser/content_setting_image_model.cc)2
-rw-r--r--chrome/browser/ui/content_settings/content_setting_image_model.h (renamed from chrome/browser/content_setting_image_model.h)8
-rw-r--r--chrome/browser/ui/content_settings/content_setting_image_model_unittest.cc (renamed from chrome/browser/content_setting_image_model_unittest.cc)4
-rw-r--r--chrome/browser/ui/gtk/collected_cookies_gtk.h3
-rw-r--r--chrome/browser/ui/gtk/content_setting_bubble_gtk.cc3
-rw-r--r--chrome/browser/ui/gtk/location_bar_view_gtk.cc11
-rw-r--r--chrome/browser/ui/tab_contents/tab_contents_wrapper.cc2
-rw-r--r--chrome/browser/ui/tab_contents/tab_contents_wrapper.h6
-rw-r--r--chrome/browser/ui/views/collected_cookies_win.h3
-rw-r--r--chrome/browser/ui/views/content_setting_bubble_contents.cc3
-rw-r--r--chrome/browser/ui/views/location_bar/content_setting_image_view.cc8
-rw-r--r--chrome/chrome_browser.gypi20
-rw-r--r--chrome/chrome_tests.gypi4
-rw-r--r--content/browser/tab_contents/tab_contents.cc118
-rw-r--r--content/browser/tab_contents/tab_contents.h51
-rw-r--r--content/browser/tab_contents/tab_contents_delegate.h4
-rw-r--r--content/browser/tab_contents/tab_contents_observer.h2
-rw-r--r--content/browser/tab_contents/tab_contents_view.cc2
41 files changed, 621 insertions, 409 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 7e5a97c..0239d65 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -35,7 +35,6 @@
#include "chrome/browser/automation/automation_tab_tracker.h"
#include "chrome/browser/automation/automation_window_tracker.h"
#include "chrome/browser/automation/ui_controls.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_process.h"
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 6e30ce2..08f467c 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -37,7 +37,6 @@
#include "chrome/browser/automation/automation_util.h"
#include "chrome/browser/automation/automation_window_tracker.h"
#include "chrome/browser/automation/ui_controls.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_process.h"
@@ -72,6 +71,7 @@
#include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
#include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h"
#include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
+#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/download/download_tab_helper.h"
#include "chrome/browser/ui/find_bar/find_bar.h"
@@ -2009,17 +2009,13 @@ void TestingAutomationProvider::GetBlockedPopupCount(int handle, int* count) {
*count = -1; // -1 is the error code
if (tab_tracker_->ContainsHandle(handle)) {
NavigationController* nav_controller = tab_tracker_->GetResource(handle);
- TabContents* tab_contents = nav_controller->tab_contents();
+ TabContentsWrapper* tab_contents =
+ TabContentsWrapper::GetCurrentWrapperForContents(
+ nav_controller->tab_contents());
if (tab_contents) {
- BlockedContentContainer* container =
- tab_contents->blocked_content_container();
- if (container) {
- *count = static_cast<int>(container->GetBlockedContentsCount());
- } else {
- // If we don't have a container, we don't have any blocked popups to
- // contain!
- *count = 0;
- }
+ BlockedContentTabHelper* blocked_content =
+ tab_contents->blocked_content_tab_helper();
+ *count = static_cast<int>(blocked_content->GetBlockedContentsCount());
}
}
}
@@ -3544,35 +3540,37 @@ void TestingAutomationProvider::ClearBrowsingData(
namespace {
- // Get the TabContents from a dictionary of arguments.
- TabContents* GetTabContentsFromDict(const Browser* browser,
- const DictionaryValue* args,
- std::string* error_message) {
- int tab_index;
- if (!args->GetInteger("tab_index", &tab_index)) {
- *error_message = "Must include tab_index.";
- return NULL;
- }
-
- TabContents* tab_contents = browser->GetTabContentsAt(tab_index);
- if (!tab_contents) {
- *error_message = StringPrintf("No tab at index %d.", tab_index);
- return NULL;
- }
- return tab_contents;
+// Get the TabContentsWrapper from a dictionary of arguments.
+TabContentsWrapper* GetTabContentsWrapperFromDict(const Browser* browser,
+ const DictionaryValue* args,
+ std::string* error_message) {
+ int tab_index;
+ if (!args->GetInteger("tab_index", &tab_index)) {
+ *error_message = "Must include tab_index.";
+ return NULL;
}
- // Get the TranslateInfoBarDelegate from TabContents.
- TranslateInfoBarDelegate* GetTranslateInfoBarDelegate(
- TabContents* tab_contents) {
- for (size_t i = 0; i < tab_contents->infobar_count(); i++) {
- InfoBarDelegate* infobar = tab_contents->GetInfoBarDelegateAt(i);
- if (infobar->AsTranslateInfoBarDelegate())
- return infobar->AsTranslateInfoBarDelegate();
- }
- // No translate infobar.
+ TabContentsWrapper* tab_contents =
+ browser->GetTabContentsWrapperAt(tab_index);
+ if (!tab_contents) {
+ *error_message = StringPrintf("No tab at index %d.", tab_index);
return NULL;
}
+ return tab_contents;
+}
+
+// Get the TranslateInfoBarDelegate from TabContents.
+TranslateInfoBarDelegate* GetTranslateInfoBarDelegate(
+ TabContents* tab_contents) {
+ for (size_t i = 0; i < tab_contents->infobar_count(); i++) {
+ InfoBarDelegate* infobar = tab_contents->GetInfoBarDelegateAt(i);
+ if (infobar->AsTranslateInfoBarDelegate())
+ return infobar->AsTranslateInfoBarDelegate();
+ }
+ // No translate infobar.
+ return NULL;
+}
+
} // namespace
void TestingAutomationProvider::FindInPage(
@@ -3580,8 +3578,8 @@ void TestingAutomationProvider::FindInPage(
DictionaryValue* args,
IPC::Message* reply_message) {
std::string error_message;
- TabContents* tab_contents = GetTabContentsFromDict(browser, args,
- &error_message);
+ TabContentsWrapper* tab_contents =
+ GetTabContentsWrapperFromDict(browser, args, &error_message);
if (!tab_contents) {
AutomationJSONReply(this, reply_message).SendError(error_message);
return;
@@ -3610,7 +3608,7 @@ void TestingAutomationProvider::FindInPage(
SendError("Must include find_next boolean.");
return;
}
- SendFindRequest(tab_contents,
+ SendFindRequest(tab_contents->tab_contents(),
true,
search_string,
forward,
@@ -3626,13 +3624,14 @@ void TestingAutomationProvider::GetTranslateInfo(
DictionaryValue* args,
IPC::Message* reply_message) {
std::string error_message;
- TabContents* tab_contents = GetTabContentsFromDict(browser, args,
- &error_message);
- if (!tab_contents) {
+ TabContentsWrapper* tab_contents_wrapper =
+ GetTabContentsWrapperFromDict(browser, args, &error_message);
+ if (!tab_contents_wrapper) {
AutomationJSONReply(this, reply_message).SendError(error_message);
return;
}
+ TabContents* tab_contents = tab_contents_wrapper->tab_contents();
// Get the translate bar if there is one and pass it to the observer.
// The observer will check for null and populate the information accordingly.
TranslateInfoBarDelegate* translate_bar =
@@ -3661,13 +3660,14 @@ void TestingAutomationProvider::SelectTranslateOption(
IPC::Message* reply_message) {
std::string option;
std::string error_message;
- TabContents* tab_contents = GetTabContentsFromDict(browser, args,
- &error_message);
- if (!tab_contents) {
+ TabContentsWrapper* tab_contents_wrapper =
+ GetTabContentsWrapperFromDict(browser, args, &error_message);
+ if (!tab_contents_wrapper) {
AutomationJSONReply(this, reply_message).SendError(error_message);
return;
}
+ TabContents* tab_contents = tab_contents_wrapper->tab_contents();
TranslateInfoBarDelegate* translate_bar =
GetTranslateInfoBarDelegate(tab_contents);
if (!translate_bar) {
@@ -3781,26 +3781,24 @@ void TestingAutomationProvider::GetBlockedPopupsInfo(
IPC::Message* reply_message) {
AutomationJSONReply reply(this, reply_message);
std::string error_message;
- TabContents* tab_contents = GetTabContentsFromDict(
+ TabContentsWrapper* tab_contents = GetTabContentsWrapperFromDict(
browser, args, &error_message);
if (!tab_contents) {
reply.SendError(error_message);
return;
}
scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
- BlockedContentContainer* popup_container =
- tab_contents->blocked_content_container();
+ BlockedContentTabHelper* blocked_content =
+ tab_contents->blocked_content_tab_helper();
ListValue* blocked_popups_list = new ListValue;
- if (popup_container) {
- std::vector<TabContents*> blocked_contents;
- popup_container->GetBlockedContents(&blocked_contents);
- 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());
- item->SetString("title", (*it)->GetTitle());
- blocked_popups_list->Append(item);
- }
+ std::vector<TabContentsWrapper*> blocked_contents;
+ blocked_content->GetBlockedContents(&blocked_contents);
+ for (std::vector<TabContentsWrapper*>::const_iterator it =
+ blocked_contents.begin(); it != blocked_contents.end(); ++it) {
+ DictionaryValue* item = new DictionaryValue;
+ item->SetString("url", (*it)->tab_contents()->GetURL().spec());
+ item->SetString("title", (*it)->tab_contents()->GetTitle());
+ blocked_popups_list->Append(item);
}
return_value->Set("blocked_popups", blocked_popups_list);
reply.SendSuccess(return_value.get());
@@ -3813,7 +3811,7 @@ void TestingAutomationProvider::UnblockAndLaunchBlockedPopup(
IPC::Message* reply_message) {
AutomationJSONReply reply(this, reply_message);
std::string error_message;
- TabContents* tab_contents = GetTabContentsFromDict(
+ TabContentsWrapper* tab_contents = GetTabContentsWrapperFromDict(
browser, args, &error_message);
if (!tab_contents) {
reply.SendError(error_message);
@@ -3825,16 +3823,15 @@ void TestingAutomationProvider::UnblockAndLaunchBlockedPopup(
return;
}
scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
- BlockedContentContainer* content_container =
- tab_contents->blocked_content_container();
- if (!content_container ||
- popup_index >= (int)content_container->GetBlockedContentsCount()) {
+ BlockedContentTabHelper* blocked_content =
+ tab_contents->blocked_content_tab_helper();
+ if (popup_index >= (int)blocked_content->GetBlockedContentsCount()) {
reply.SendError(StringPrintf("No popup at index %d", popup_index));
return;
}
- std::vector<TabContents*> blocked_contents;
- content_container->GetBlockedContents(&blocked_contents);
- content_container->LaunchForContents(blocked_contents[popup_index]);
+ std::vector<TabContentsWrapper*> blocked_contents;
+ blocked_content->GetBlockedContents(&blocked_contents);
+ blocked_content->LaunchForContents(blocked_contents[popup_index]);
reply.SendSuccess(NULL);
}
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index 6af23f9..11859e9 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -629,7 +629,7 @@ void ExtensionHost::ShowCreatedWindow(int route_id,
TabContents* associated_contents = associated_tab_contents();
if (associated_contents &&
associated_contents->profile() == contents->profile()) {
- associated_contents->AddOrBlockNewContents(
+ associated_contents->AddNewContents(
contents, disposition, initial_pos, user_gesture);
return;
}
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
index 676b7e0..0c2bb6e 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
@@ -260,7 +261,7 @@ void InstantController::CommitCurrentPreview(InstantCommitType type) {
tab->controller().CopyStateFromAndPrune(
&tab_contents_->controller(), showing_instant);
delegate_->CommitInstant(tab);
- CompleteRelease(tab->tab_contents());
+ CompleteRelease(tab);
}
void InstantController::SetCommitOnMouseUp() {
@@ -382,8 +383,8 @@ TabContentsWrapper* InstantController::ReleasePreviewContents(
return tab;
}
-void InstantController::CompleteRelease(TabContents* tab) {
- tab->SetAllContentsBlocked(false);
+void InstantController::CompleteRelease(TabContentsWrapper* tab) {
+ tab->blocked_content_tab_helper()->SetAllContentsBlocked(false);
}
TabContentsWrapper* InstantController::GetPreviewContents() {
diff --git a/chrome/browser/instant/instant_controller.h b/chrome/browser/instant/instant_controller.h
index da47d11..0352dfe 100644
--- a/chrome/browser/instant/instant_controller.h
+++ b/chrome/browser/instant/instant_controller.h
@@ -130,7 +130,7 @@ class InstantController : public InstantLoaderDelegate {
// Does cleanup after the preview contents has been added to the tabstrip.
// Invoke this if you explicitly invoke ReleasePreviewContents.
- void CompleteRelease(TabContents* tab);
+ void CompleteRelease(TabContentsWrapper* tab);
// TabContents the match is being shown for.
TabContentsWrapper* tab_contents() const { return tab_contents_; }
diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc
index c9ac786..6616b48 100644
--- a/chrome/browser/instant/instant_loader.cc
+++ b/chrome/browser/instant/instant_loader.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/instant/instant_loader_delegate.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
+#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/render_messages.h"
@@ -974,7 +975,7 @@ void InstantLoader::CreatePreviewContents(TabContentsWrapper* tab_contents) {
new TabContents(
tab_contents->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL);
preview_contents_.reset(new TabContentsWrapper(new_contents));
- new_contents->SetAllContentsBlocked(true);
+ preview_contents_->blocked_content_tab_helper()->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/blocked_content_container.cc b/chrome/browser/ui/blocked_content/blocked_content_container.cc
index 5b5ba08..f702aed 100644
--- a/chrome/browser/blocked_content_container.cc
+++ b/chrome/browser/ui/blocked_content/blocked_content_container.cc
@@ -2,8 +2,10 @@
// 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/ui/blocked_content/blocked_content_container.h"
+#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "ui/gfx/rect.h"
@@ -11,7 +13,7 @@
const size_t BlockedContentContainer::kImpossibleNumberOfPopups = 30;
struct BlockedContentContainer::BlockedContent {
- BlockedContent(TabContents* tab_contents,
+ BlockedContent(TabContentsWrapper* tab_contents,
WindowOpenDisposition disposition,
const gfx::Rect& bounds,
bool user_gesture)
@@ -21,19 +23,21 @@ struct BlockedContentContainer::BlockedContent {
user_gesture(user_gesture) {
}
- TabContents* tab_contents;
+ TabContentsWrapper* tab_contents;
WindowOpenDisposition disposition;
gfx::Rect bounds;
bool user_gesture;
};
-BlockedContentContainer::BlockedContentContainer(TabContents* owner)
+BlockedContentContainer::BlockedContentContainer(TabContentsWrapper* owner)
: owner_(owner) {
}
-BlockedContentContainer::~BlockedContentContainer() {}
+BlockedContentContainer::~BlockedContentContainer() {
+ Clear();
+}
-void BlockedContentContainer::AddTabContents(TabContents* tab_contents,
+void BlockedContentContainer::AddTabContents(TabContentsWrapper* tab_contents,
WindowOpenDisposition disposition,
const gfx::Rect& bounds,
bool user_gesture) {
@@ -46,15 +50,17 @@ void BlockedContentContainer::AddTabContents(TabContents* tab_contents,
blocked_contents_.push_back(
BlockedContent(tab_contents, disposition, bounds, user_gesture));
- tab_contents->set_delegate(this);
- // Since the new tab_contents will not be showed, call WasHidden to change
+ // TODO(avi): remove once TabContentsDelegate::GetConstrainingContents goes
+ // away.
+ tab_contents->tab_contents()->set_delegate(this);
+ tab_contents->blocked_content_tab_helper()->set_delegate(this);
+ // Since the new tab_contents will not be shown, call WasHidden to change
// its status on both RenderViewHost and RenderView.
- tab_contents->WasHidden();
- if (blocked_contents_.size() == 1)
- owner_->PopupNotificationVisibilityChanged(true);
+ tab_contents->tab_contents()->WasHidden();
}
-void BlockedContentContainer::LaunchForContents(TabContents* tab_contents) {
+void BlockedContentContainer::LaunchForContents(
+ TabContentsWrapper* tab_contents) {
// Open the popup.
for (BlockedContents::iterator i(blocked_contents_.begin());
i != blocked_contents_.end(); ++i) {
@@ -64,19 +70,20 @@ void BlockedContentContainer::LaunchForContents(TabContents* tab_contents) {
BlockedContent content(*i);
blocked_contents_.erase(i);
i = blocked_contents_.end();
- tab_contents->set_delegate(NULL);
+ // TODO(avi): remove once TabContentsDelegate::GetConstrainingContents
+ // goes away.
+ tab_contents->tab_contents()->set_delegate(NULL);
+ tab_contents->blocked_content_tab_helper()->set_delegate(NULL);
// We needn't call WasRestored to change its status because the
// TabContents::AddNewContents will do it.
- owner_->AddOrBlockNewContents(tab_contents,
- content.disposition,
- content.bounds,
- content.user_gesture);
+ owner_->tab_contents()->AddNewContents(
+ tab_contents->tab_contents(),
+ content.disposition,
+ content.bounds,
+ content.user_gesture);
break;
}
}
-
- if (blocked_contents_.empty())
- Destroy();
}
size_t BlockedContentContainer::GetBlockedContentsCount() const {
@@ -84,23 +91,24 @@ size_t BlockedContentContainer::GetBlockedContentsCount() const {
}
void BlockedContentContainer::GetBlockedContents(
- std::vector<TabContents*>* blocked_contents) const {
+ std::vector<TabContentsWrapper*>* 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() {
+void BlockedContentContainer::Clear() {
for (BlockedContents::iterator i(blocked_contents_.begin());
i != blocked_contents_.end(); ++i) {
- TabContents* tab_contents = i->tab_contents;
- tab_contents->set_delegate(NULL);
+ TabContentsWrapper* tab_contents = i->tab_contents;
+ // TODO(avi): remove once TabContentsDelegate::GetConstrainingContents goes
+ // away.
+ tab_contents->tab_contents()->set_delegate(NULL);
+ tab_contents->blocked_content_tab_helper()->set_delegate(NULL);
delete tab_contents;
}
blocked_contents_.clear();
- owner_->WillCloseBlockedContentContainer(this);
- delete this;
}
// Overridden from TabContentsDelegate:
@@ -109,7 +117,7 @@ void BlockedContentContainer::OpenURLFromTab(TabContents* source,
const GURL& referrer,
WindowOpenDisposition disposition,
PageTransition::Type transition) {
- owner_->OpenURL(url, referrer, disposition, transition);
+ owner_->tab_contents()->OpenURL(url, referrer, disposition, transition);
}
void BlockedContentContainer::AddNewContents(TabContents* source,
@@ -117,16 +125,19 @@ void BlockedContentContainer::AddNewContents(TabContents* source,
WindowOpenDisposition disposition,
const gfx::Rect& initial_position,
bool user_gesture) {
- owner_->AddOrBlockNewContents(
+ owner_->tab_contents()->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);
+ TabContentsWrapper* tab_contents = i->tab_contents;
+ if (tab_contents->tab_contents() == source) {
+ // TODO(avi): remove once TabContentsDelegate::GetConstrainingContents
+ // goes away.
+ tab_contents->tab_contents()->set_delegate(NULL);
+ tab_contents->blocked_content_tab_helper()->set_delegate(NULL);
blocked_contents_.erase(i);
delete tab_contents;
break;
@@ -138,7 +149,7 @@ 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) {
+ if (i->tab_contents->tab_contents() == source) {
i->bounds = new_bounds;
break;
}
@@ -154,5 +165,10 @@ bool BlockedContentContainer::IsPopup(const TabContents* source) const {
TabContents* BlockedContentContainer::GetConstrainingContents(
TabContents* source) {
+ return owner_->tab_contents();
+}
+
+TabContentsWrapper* BlockedContentContainer::GetConstrainingContents(
+ TabContentsWrapper* source) {
return owner_;
}
diff --git a/chrome/browser/blocked_content_container.h b/chrome/browser/ui/blocked_content/blocked_content_container.h
index 4b057cb..7298170 100644
--- a/chrome/browser/blocked_content_container.h
+++ b/chrome/browser/ui/blocked_content/blocked_content_container.h
@@ -3,44 +3,57 @@
// 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.
+// notifications. This interface should only be used by the
+// BlockedContentTabHelper. Users and subclasses of TabContents/
+// TabContentsWrapper should use the appropriate methods on
+// BlockedContentTabHelper to access information about blocked content.
-#ifndef CHROME_BROWSER_BLOCKED_CONTENT_CONTAINER_H_
-#define CHROME_BROWSER_BLOCKED_CONTENT_CONTAINER_H_
+#ifndef CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_CONTAINER_H_
+#define CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_CONTAINER_H_
#pragma once
#include <vector>
+#include "base/compiler_specific.h"
+#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.h"
#include "content/browser/tab_contents/tab_contents_delegate.h"
+class TabContents;
+class TabContentsWrapper;
+
// Takes ownership of TabContents that are unrequested popup windows.
-class BlockedContentContainer : public TabContentsDelegate {
+class BlockedContentContainer : public BlockedContentTabHelperDelegate,
+ public TabContentsDelegate {
public:
// Creates a container for a certain TabContents:
- explicit BlockedContentContainer(TabContents* owner);
+ explicit BlockedContentContainer(TabContentsWrapper* owner);
virtual ~BlockedContentContainer();
// Adds a TabContents to this container. |bounds| are the window bounds
// requested for the TabContents.
- void AddTabContents(TabContents* tab_contents,
+ void AddTabContents(TabContentsWrapper* tab_contents,
WindowOpenDisposition disposition,
const gfx::Rect& bounds,
bool user_gesture);
// Shows the blocked TabContents |tab_contents|.
- void LaunchForContents(TabContents* tab_contents);
+ void LaunchForContents(TabContentsWrapper* 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;
+ // Returns the contained TabContentsWrapper pointers. |blocked_contents| must
+ // be non-NULL.
+ void GetBlockedContents(
+ std::vector<TabContentsWrapper*>* blocked_contents) const;
+
+ // Removes all blocked contents.
+ void Clear();
- // Sets this object up to delete itself.
- void Destroy();
+ // Overridden from BlockedContentTabHelperDelegate, TabContentsDelegate:
+ virtual TabContents* GetConstrainingContents(TabContents* source) OVERRIDE;
+ virtual TabContentsWrapper* GetConstrainingContents(
+ TabContentsWrapper* source) OVERRIDE;
// Overridden from TabContentsDelegate:
@@ -78,9 +91,6 @@ class BlockedContentContainer : public TabContentsDelegate {
// Always returns true.
virtual bool IsPopup(const TabContents* source) const;
- // Returns our |owner_|.
- virtual TabContents* GetConstrainingContents(TabContents* source);
-
// Ignored; BlockedContentContainer doesn't display a URL bar.
virtual void UpdateTargetURL(TabContents* source, const GURL& url) {}
@@ -95,7 +105,7 @@ class BlockedContentContainer : public TabContentsDelegate {
typedef std::vector<BlockedContent> BlockedContents;
// The TabContents that owns and constrains this BlockedContentContainer.
- TabContents* owner_;
+ TabContentsWrapper* owner_;
// Information about all blocked contents.
BlockedContents blocked_contents_;
@@ -103,4 +113,4 @@ class BlockedContentContainer : public TabContentsDelegate {
DISALLOW_IMPLICIT_CONSTRUCTORS(BlockedContentContainer);
};
-#endif // CHROME_BROWSER_BLOCKED_CONTENT_CONTAINER_H_
+#endif // CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_CONTAINER_H_
diff --git a/chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc b/chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc
new file mode 100644
index 0000000..f2a0f52
--- /dev/null
+++ b/chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc
@@ -0,0 +1,117 @@
+// Copyright (c) 2011 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/ui/blocked_content/blocked_content_tab_helper.h"
+
+#include "base/auto_reset.h"
+#include "chrome/browser/content_settings/host_content_settings_map.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/blocked_content/blocked_content_container.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
+#include "content/browser/renderer_host/render_view_host.h"
+#include "content/browser/tab_contents/tab_contents.h"
+#include "content/common/notification_service.h"
+
+BlockedContentTabHelper::BlockedContentTabHelper(
+ TabContentsWrapper* tab_contents)
+ : TabContentsObserver(tab_contents->tab_contents()),
+ blocked_contents_(new BlockedContentContainer(tab_contents)),
+ all_contents_blocked_(false),
+ tab_contents_wrapper_(tab_contents) {
+}
+
+BlockedContentTabHelper::~BlockedContentTabHelper() {
+}
+
+void BlockedContentTabHelper::DidNavigateMainFramePostCommit(
+ const NavigationController::LoadCommittedDetails& details,
+ const ViewHostMsg_FrameNavigate_Params& params) {
+ // 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_->GetBlockedContentsCount()) {
+ blocked_contents_->Clear();
+ PopupNotificationVisibilityChanged(false);
+ }
+ }
+}
+
+void BlockedContentTabHelper::PopupNotificationVisibilityChanged(
+ bool visible) {
+ if (tab_contents()->is_being_destroyed())
+ return;
+ tab_contents()->GetTabSpecificContentSettings()->SetPopupsBlocked(visible);
+}
+
+void BlockedContentTabHelper::SetAllContentsBlocked(bool value) {
+ if (all_contents_blocked_ == value)
+ return;
+
+ all_contents_blocked_ = value;
+ if (!all_contents_blocked_ && blocked_contents_->GetBlockedContentsCount()) {
+ std::vector<TabContentsWrapper*> blocked;
+ blocked_contents_->GetBlockedContents(&blocked);
+ for (size_t i = 0; i < blocked.size(); ++i)
+ blocked_contents_->LaunchForContents(blocked[i]);
+ }
+}
+
+void BlockedContentTabHelper::AddTabContents(TabContentsWrapper* new_contents,
+ WindowOpenDisposition disposition,
+ const gfx::Rect& initial_pos,
+ bool user_gesture) {
+ if (!blocked_contents_->GetBlockedContentsCount())
+ PopupNotificationVisibilityChanged(true);
+ blocked_contents_->AddTabContents(
+ new_contents, disposition, initial_pos, user_gesture);
+}
+
+void BlockedContentTabHelper::AddPopup(TabContentsWrapper* new_contents,
+ const gfx::Rect& initial_pos,
+ bool user_gesture) {
+ // 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 = tab_contents()->controller().GetLastCommittedEntry();
+ GURL creator = entry ? entry->virtual_url() : GURL::EmptyGURL();
+
+ if (creator.is_valid() &&
+ tab_contents()->profile()->GetHostContentSettingsMap()->GetContentSetting(
+ creator, CONTENT_SETTINGS_TYPE_POPUPS, "") == CONTENT_SETTING_ALLOW) {
+ tab_contents()->AddNewContents(new_contents->tab_contents(),
+ NEW_POPUP,
+ initial_pos,
+ true); // user_gesture
+ } else {
+ // Call blocked_contents_->AddTabContents with user_gesture == true
+ // so that the contents will not get blocked again.
+ blocked_contents_->AddTabContents(new_contents,
+ NEW_POPUP,
+ initial_pos,
+ true); // user_gesture
+ tab_contents()->GetContentSettingsDelegate()->OnContentBlocked(
+ CONTENT_SETTINGS_TYPE_POPUPS, std::string());
+ }
+}
+
+void BlockedContentTabHelper::LaunchForContents(
+ TabContentsWrapper* tab_contents) {
+ blocked_contents_->LaunchForContents(tab_contents);
+ if (!blocked_contents_->GetBlockedContentsCount())
+ PopupNotificationVisibilityChanged(false);
+}
+
+size_t BlockedContentTabHelper::GetBlockedContentsCount() const {
+ return blocked_contents_->GetBlockedContentsCount();
+}
+
+void BlockedContentTabHelper::GetBlockedContents(
+ std::vector<TabContentsWrapper*>* blocked_contents) const {
+ blocked_contents_->GetBlockedContents(blocked_contents);
+}
diff --git a/chrome/browser/ui/blocked_content/blocked_content_tab_helper.h b/chrome/browser/ui/blocked_content/blocked_content_tab_helper.h
new file mode 100644
index 0000000..10f7615
--- /dev/null
+++ b/chrome/browser/ui/blocked_content/blocked_content_tab_helper.h
@@ -0,0 +1,83 @@
+// Copyright (c) 2011 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.
+
+#ifndef CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_TAB_HELPER_H_
+#define CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_TAB_HELPER_H_
+#pragma once
+
+#include "chrome/browser/ui/find_bar/find_bar_controller.h"
+#include "chrome/browser/ui/find_bar/find_notification_details.h"
+#include "content/browser/tab_contents/tab_contents_observer.h"
+#include "content/common/notification_registrar.h"
+#include "webkit/glue/window_open_disposition.h"
+
+class BlockedContentContainer;
+class BlockedContentTabHelperDelegate;
+class TabContentsWrapper;
+
+// Per-tab class to manage blocked popups.
+class BlockedContentTabHelper : public TabContentsObserver {
+ public:
+ explicit BlockedContentTabHelper(TabContentsWrapper* tab_contents);
+ virtual ~BlockedContentTabHelper();
+
+ BlockedContentTabHelperDelegate* delegate() const { return delegate_; }
+ void set_delegate(BlockedContentTabHelperDelegate* d) { delegate_ = d; }
+
+ // 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);
+
+ bool all_contents_blocked() const { return all_contents_blocked_; }
+
+ // Adds the incoming |new_contents| to the |blocked_contents_| container.
+ void AddTabContents(TabContentsWrapper* new_contents,
+ WindowOpenDisposition disposition,
+ const gfx::Rect& initial_pos,
+ bool user_gesture);
+
+ // Adds the incoming |new_contents| to the |blocked_contents_| container.
+ void AddPopup(TabContentsWrapper* new_contents,
+ const gfx::Rect& initial_pos,
+ bool user_gesture);
+
+ // Shows the blocked TabContents |tab_contents|.
+ void LaunchForContents(TabContentsWrapper* tab_contents);
+
+ // Returns the number of blocked contents.
+ size_t GetBlockedContentsCount() const;
+
+ // Returns the blocked TabContentsWrappers. |blocked_contents| must
+ // be non-NULL.
+ void GetBlockedContents(
+ std::vector<TabContentsWrapper*>* blocked_contents) const;
+
+ // TabContentsObserver overrides:
+ virtual void DidNavigateMainFramePostCommit(
+ const NavigationController::LoadCommittedDetails& details,
+ const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE;
+
+ private:
+ // Called when the blocked popup notification is shown or hidden.
+ void PopupNotificationVisibilityChanged(bool visible);
+
+ // Object that holds any blocked TabContents spawned from this TabContents.
+ scoped_ptr<BlockedContentContainer> blocked_contents_;
+
+ // Should we block all child TabContents this attempts to spawn.
+ bool all_contents_blocked_;
+
+ // Owning TabContentsWrapper.
+ TabContentsWrapper* tab_contents_wrapper_;
+
+ // Delegate for notifying our owner (usually Browser) about stuff. Not owned
+ // by us.
+ BlockedContentTabHelperDelegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(BlockedContentTabHelper);
+};
+
+#endif // CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_TAB_HELPER_H_
diff --git a/chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.cc b/chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.cc
new file mode 100644
index 0000000..c045995
--- /dev/null
+++ b/chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.cc
@@ -0,0 +1,8 @@
+// Copyright (c) 2011 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/ui/blocked_content/blocked_content_tab_helper_delegate.h"
+
+BlockedContentTabHelperDelegate::~BlockedContentTabHelperDelegate() {
+}
diff --git a/chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.h b/chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.h
new file mode 100644
index 0000000..ab4a4c4
--- /dev/null
+++ b/chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.h
@@ -0,0 +1,24 @@
+// Copyright (c) 2011 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.
+
+#ifndef CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_TAB_HELPER_DELEGATE_H_
+#define CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_TAB_HELPER_DELEGATE_H_
+#pragma once
+
+class TabContentsWrapper;
+
+// Objects implement this interface to get notified about changes in the
+// BlockedContentTabHelper and to provide necessary functionality.
+class BlockedContentTabHelperDelegate {
+ public:
+ // If |source| is constrained, returns the tab containing it. Otherwise
+ // returns |source|.
+ virtual TabContentsWrapper* GetConstrainingContents(
+ TabContentsWrapper* source) = 0;
+
+ protected:
+ virtual ~BlockedContentTabHelperDelegate();
+};
+
+#endif // CHROME_BROWSER_UI_BLOCKED_CONTENT_BLOCKED_CONTENT_TAB_HELPER_DELEGATE_H_
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index f463914..4e35458 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -72,6 +72,7 @@
#include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h"
#include "chrome/browser/tabs/tab_finder.h"
#include "chrome/browser/tabs/tab_strip_model.h"
+#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_tab_restore_service_delegate.h"
#include "chrome/browser/ui/browser_window.h"
@@ -2892,11 +2893,43 @@ void Browser::AddNewContents(TabContents* source,
WindowOpenDisposition disposition,
const gfx::Rect& initial_pos,
bool user_gesture) {
- // No code for this yet
+ // No code for this yet.
DCHECK(disposition != SAVE_TO_DISK);
// Can't create a new contents for the current tab - invalid case.
DCHECK(disposition != CURRENT_TAB);
+ TabContentsWrapper* source_wrapper = NULL;
+ BlockedContentTabHelper* source_blocked_content = NULL;
+ TabContentsWrapper* new_wrapper = new TabContentsWrapper(new_contents);
+ if (source) {
+ source_wrapper = TabContentsWrapper::GetCurrentWrapperForContents(source);
+ source_blocked_content = source_wrapper->blocked_content_tab_helper();
+ }
+
+ if (source_wrapper) {
+ // Handle blocking of all contents.
+ if (source_blocked_content->all_contents_blocked()) {
+ source_blocked_content->AddTabContents(new_wrapper,
+ disposition,
+ initial_pos,
+ user_gesture);
+ return;
+ }
+
+ // Handle blocking of popups.
+ 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.
+ GetConstrainingContents(source_wrapper)->blocked_content_tab_helper()->
+ AddPopup(new_wrapper, initial_pos, user_gesture);
+ return;
+ }
+
+ new_contents->DisassociateFromPopupCount();
+ }
+
// TODO(beng): This belongs behind the platform-specific View interface.
// That's why it's there. http://crbug.com/78853
#if defined(OS_CHROMEOS)
@@ -2915,11 +2948,11 @@ void Browser::AddNewContents(TabContents* source,
}
#endif
- TabContentsWrapper* wrapper = new TabContentsWrapper(new_contents);
- browser::NavigateParams params(this, wrapper);
+ browser::NavigateParams params(this, new_wrapper);
params.source_contents =
- tabstrip_model()->GetTabContentsAt(
- tabstrip_model()->GetWrapperIndex(source));
+ source ? tabstrip_model()->GetTabContentsAt(
+ tabstrip_model()->GetWrapperIndex(source))
+ : NULL;
params.disposition = disposition;
params.window_bounds = initial_pos;
// If we create a popup or panel from a non user-gesture, don't activate
@@ -2929,6 +2962,13 @@ void Browser::AddNewContents(TabContents* source,
else
params.window_action = browser::NavigateParams::SHOW_WINDOW;
browser::Navigate(&params);
+
+ if (source) {
+ NotificationService::current()->Notify(
+ NotificationType::TAB_ADDED,
+ Source<TabContentsDelegate>(source->delegate()),
+ Details<TabContents>(source));
+ }
}
void Browser::ActivateContents(TabContents* contents) {
@@ -3191,9 +3231,11 @@ void Browser::OnStartDownload(DownloadItem* download, TabContents* tab) {
}
#endif
- // If the download occurs in a new tab, close it
+ // If the download occurs in a new tab, close it.
+ TabContentsWrapper* wrapper =
+ TabContentsWrapper::GetCurrentWrapperForContents(tab);
if (tab->controller().IsInitialNavigation() &&
- GetConstrainingContents(tab) == tab && tab_count() > 1) {
+ GetConstrainingContents(wrapper) == wrapper && tab_count() > 1) {
CloseContents(tab);
}
}
@@ -3326,6 +3368,14 @@ void Browser::ConfirmAddSearchProvider(const TemplateURL* template_url,
}
///////////////////////////////////////////////////////////////////////////////
+// Browser, BlockedContentTabHelperDelegate implementation:
+
+TabContentsWrapper* Browser::GetConstrainingContents(
+ TabContentsWrapper* source) {
+ return source;
+}
+
+///////////////////////////////////////////////////////////////////////////////
// Browser, SelectFileDialog::Listener implementation:
void Browser::FileSelected(const FilePath& path, int index, void* params) {
@@ -4188,8 +4238,12 @@ Browser* Browser::GetOrCreateTabbedBrowser(Profile* profile) {
}
void Browser::SetAsDelegate(TabContentsWrapper* tab, Browser* delegate) {
+ // TabContents...
tab->tab_contents()->set_delegate(delegate);
tab->set_delegate(delegate);
+
+ // ...and all the helpers.
+ tab->blocked_content_tab_helper()->set_delegate(delegate);
tab->search_engine_tab_helper()->set_delegate(delegate);
}
@@ -4322,7 +4376,7 @@ bool Browser::OpenInstant(WindowOpenDisposition disposition) {
-1,
instant()->last_transition_type(),
TabStripModel::ADD_ACTIVE);
- instant()->CompleteRelease(preview_contents->tab_contents());
+ instant()->CompleteRelease(preview_contents);
return true;
}
// The omnibox currently doesn't use other dispositions, so we don't attempt
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index aa45879..97f0b75 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -27,6 +27,7 @@
#include "chrome/browser/tabs/tab_handler.h"
#include "chrome/browser/tabs/tab_strip_model_delegate.h" // TODO(beng): remove
#include "chrome/browser/tabs/tab_strip_model_observer.h" // TODO(beng): remove
+#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h"
#include "chrome/browser/ui/shell_dialogs.h"
@@ -62,6 +63,7 @@ class Browser : public TabHandlerDelegate,
public TabContentsDelegate,
public TabContentsWrapperDelegate,
public SearchEngineTabHelperDelegate,
+ public BlockedContentTabHelperDelegate,
public PageNavigator,
public CommandUpdater::CommandUpdaterDelegate,
public NotificationObserver,
@@ -833,6 +835,10 @@ class Browser : public TabHandlerDelegate,
virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
Profile* profile) OVERRIDE;
+ // Overridden from BlockedContentTabHelperDelegate:
+ virtual TabContentsWrapper* GetConstrainingContents(
+ TabContentsWrapper* source) OVERRIDE;
+
// Overridden from SelectFileDialog::Listener:
virtual void FileSelected(const FilePath& path, int index, void* params);
diff --git a/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm b/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm
index 9624dd1..9587ea9 100644
--- a/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm
+++ b/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -8,10 +8,9 @@
#include "base/logging.h"
#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/blocked_content_container.h"
-#include "chrome/browser/content_setting_bubble_model.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/plugin_updater.h"
+#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
#import "chrome/browser/ui/cocoa/hyperlink_button_cell.h"
#import "chrome/browser/ui/cocoa/info_bubble_view.h"
#import "chrome/browser/ui/cocoa/l10n_util.h"
diff --git a/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa_unittest.mm b/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa_unittest.mm
index 1888be3..5fa32d4 100644
--- a/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa_unittest.mm
+++ b/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa_unittest.mm
@@ -8,17 +8,21 @@
#include "base/debug/debugger.h"
#include "base/memory/scoped_nsobject.h"
-#include "chrome/browser/content_setting_bubble_model.h"
#import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
+#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
+#include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h"
#include "chrome/common/content_settings_types.h"
+#include "chrome/test/testing_profile.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
class DummyContentSettingBubbleModel : public ContentSettingBubbleModel {
public:
- DummyContentSettingBubbleModel(ContentSettingsType content_type)
- : ContentSettingBubbleModel(NULL, NULL, content_type) {
+ DummyContentSettingBubbleModel(TabContentsWrapper* tab_contents,
+ Profile* profile,
+ ContentSettingsType content_type)
+ : ContentSettingBubbleModel(tab_contents, profile, content_type) {
RadioGroup radio_group;
radio_group.default_item = 0;
radio_group.radio_items.resize(2);
@@ -26,9 +30,24 @@ class DummyContentSettingBubbleModel : public ContentSettingBubbleModel {
}
};
-class ContentSettingBubbleControllerTest : public CocoaTest {
+class ContentSettingBubbleControllerTest
+ : public TabContentsWrapperTestHarness {
+ public:
+ ContentSettingBubbleControllerTest();
+ virtual ~ContentSettingBubbleControllerTest();
+
+ private:
+ NSAutoreleasePool* pool_;
};
+ContentSettingBubbleControllerTest::ContentSettingBubbleControllerTest()
+ : pool_([[NSAutoreleasePool alloc] init]) {
+}
+
+ContentSettingBubbleControllerTest::~ContentSettingBubbleControllerTest() {
+ [pool_ drain];
+}
+
// Check that the bubble doesn't crash or leak for any settings type
TEST_F(ContentSettingBubbleControllerTest, Init) {
for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
@@ -51,7 +70,9 @@ TEST_F(ContentSettingBubbleControllerTest, Init) {
[parent.get() orderBack:nil];
ContentSettingBubbleController* controller = [ContentSettingBubbleController
- showForModel:new DummyContentSettingBubbleModel(settingsType)
+ showForModel:new DummyContentSettingBubbleModel(contents_wrapper(),
+ profile(),
+ settingsType)
parentWindow:parent
anchoredAt:NSMakePoint(50, 20)];
EXPECT_TRUE(controller != nil);
diff --git a/chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm b/chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm
index efdcff7..d197860 100644
--- a/chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm
+++ b/chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm
@@ -9,13 +9,14 @@
#include "base/command_line.h"
#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/content_setting_bubble_model.h"
-#include "chrome/browser/content_setting_image_model.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_list.h"
#import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h"
#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
+#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
+#include "chrome/browser/ui/content_settings/content_setting_image_model.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "content/browser/tab_contents/tab_contents.h"
@@ -248,8 +249,8 @@ bool ContentSettingDecoration::AcceptsMousePress() {
bool ContentSettingDecoration::OnMousePressed(NSRect frame) {
// Get host. This should be shared on linux/win/osx medium-term.
- TabContents* tabContents =
- BrowserList::GetLastActive()->GetSelectedTabContents();
+ TabContentsWrapper* tabContents =
+ BrowserList::GetLastActive()->GetSelectedTabContentsWrapper();
if (!tabContents)
return true;
@@ -259,7 +260,7 @@ bool ContentSettingDecoration::OnMousePressed(NSRect frame) {
if (content_settings_type == CONTENT_SETTINGS_TYPE_PRERENDER)
return true;
- GURL url = tabContents->GetURL();
+ GURL url = tabContents->tab_contents()->GetURL();
std::wstring displayHost;
net::AppendFormattedHost(
url,
@@ -281,8 +282,8 @@ bool ContentSettingDecoration::OnMousePressed(NSRect frame) {
ContentSettingBubbleModel::CreateContentSettingBubbleModel(
tabContents, profile_, content_settings_type);
[ContentSettingBubbleController showForModel:model
- parentWindow:[field window]
- anchoredAt:anchor];
+ parentWindow:[field window]
+ anchoredAt:anchor];
return true;
}
diff --git a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
index 980ea27..ac9d13b 100644
--- a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
+++ b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
@@ -14,8 +14,6 @@
#import "chrome/browser/autocomplete/autocomplete_edit_view_mac.h"
#import "chrome/browser/autocomplete/autocomplete_popup_model.h"
#include "chrome/browser/command_updater.h"
-#include "chrome/browser/content_setting_bubble_model.h"
-#include "chrome/browser/content_setting_image_model.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/extensions/extension_browser_event_router.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -39,6 +37,8 @@
#import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h"
#import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h"
#import "chrome/browser/ui/cocoa/location_bar/star_decoration.h"
+#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
+#include "chrome/browser/ui/content_settings/content_setting_image_model.h"
#include "chrome/browser/ui/omnibox/location_bar_util.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_action.h"
diff --git a/chrome/browser/content_setting_bubble_model.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc
index d93f379..2b6b06c 100644
--- a/chrome/browser/content_setting_bubble_model.cc
+++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc
@@ -2,18 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/content_setting_bubble_model.h"
+#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
#include "base/command_line.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/blocked_content_container.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/geolocation/geolocation_content_settings_map.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/tab_specific_content_settings.h"
+#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
+#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.h"
#include "chrome/browser/ui/collected_cookies_infobar_delegate.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/pref_names.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/tab_contents.h"
@@ -25,7 +27,7 @@
class ContentSettingTitleAndLinkModel : public ContentSettingBubbleModel {
public:
- ContentSettingTitleAndLinkModel(TabContents* tab_contents,
+ ContentSettingTitleAndLinkModel(TabContentsWrapper* tab_contents,
Profile* profile,
ContentSettingsType content_type)
: ContentSettingBubbleModel(tab_contents, profile, content_type) {
@@ -40,7 +42,7 @@ class ContentSettingTitleAndLinkModel : public ContentSettingBubbleModel {
private:
void SetBlockedResources() {
- TabSpecificContentSettings* settings =
+ TabSpecificContentSettings* settings = tab_contents()->
tab_contents()->GetTabSpecificContentSettings();
const std::set<std::string>& resources = settings->BlockedResourcesForType(
content_type());
@@ -91,10 +93,10 @@ class ContentSettingTitleAndLinkModel : public ContentSettingBubbleModel {
Need_a_setting_for_every_content_settings_type);
const int *title_ids = kBlockedTitleIDs;
if (tab_contents() &&
- tab_contents()->GetTabSpecificContentSettings()->IsContentAccessed(
- content_type()) &&
- !tab_contents()->GetTabSpecificContentSettings()->IsContentBlocked(
- content_type())) {
+ tab_contents()->tab_contents()->GetTabSpecificContentSettings()->
+ IsContentAccessed(content_type()) &&
+ !tab_contents()->tab_contents()->GetTabSpecificContentSettings()->
+ IsContentBlocked(content_type())) {
title_ids = kAccessedTitleIDs;
} else if (!bubble_content().resource_identifiers.empty()) {
title_ids = kResourceSpecificBlockedTitleIDs;
@@ -120,15 +122,17 @@ class ContentSettingTitleAndLinkModel : public ContentSettingBubbleModel {
}
virtual void OnManageLinkClicked() {
- if (tab_contents())
- tab_contents()->delegate()->ShowContentSettingsPage(content_type());
+ if (tab_contents()) {
+ tab_contents()->tab_contents()->delegate()->
+ ShowContentSettingsPage(content_type());
+ }
}
};
class ContentSettingTitleLinkAndCustomModel
: public ContentSettingTitleAndLinkModel {
public:
- ContentSettingTitleLinkAndCustomModel(TabContents* tab_contents,
+ ContentSettingTitleLinkAndCustomModel(TabContentsWrapper* tab_contents,
Profile* profile,
ContentSettingsType content_type)
: ContentSettingTitleAndLinkModel(tab_contents, profile, content_type) {
@@ -162,7 +166,7 @@ class ContentSettingTitleLinkAndCustomModel
class ContentSettingSingleRadioGroup
: public ContentSettingTitleLinkAndCustomModel {
public:
- ContentSettingSingleRadioGroup(TabContents* tab_contents,
+ ContentSettingSingleRadioGroup(TabContentsWrapper* tab_contents,
Profile* profile,
ContentSettingsType content_type)
: ContentSettingTitleLinkAndCustomModel(tab_contents, profile,
@@ -201,7 +205,7 @@ class ContentSettingSingleRadioGroup
// Initialize the radio group by setting the appropriate labels for the
// content type and setting the default value based on the content setting.
void SetRadioGroup() {
- GURL url = tab_contents()->GetURL();
+ GURL url = tab_contents()->tab_contents()->GetURL();
std::wstring display_host_wide;
net::AppendFormattedHost(url,
UTF8ToWide(profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)),
@@ -311,7 +315,7 @@ class ContentSettingSingleRadioGroup
class ContentSettingCookiesBubbleModel : public ContentSettingSingleRadioGroup {
public:
- ContentSettingCookiesBubbleModel(TabContents* tab_contents,
+ ContentSettingCookiesBubbleModel(TabContentsWrapper* tab_contents,
Profile* profile,
ContentSettingsType content_type)
: ContentSettingSingleRadioGroup(tab_contents, profile, content_type) {
@@ -321,8 +325,8 @@ class ContentSettingCookiesBubbleModel : public ContentSettingSingleRadioGroup {
virtual ~ContentSettingCookiesBubbleModel() {
if (settings_changed()) {
- tab_contents()->AddInfoBar(
- new CollectedCookiesInfoBarDelegate(tab_contents()));
+ tab_contents()->tab_contents()->AddInfoBar(
+ new CollectedCookiesInfoBarDelegate(tab_contents()->tab_contents()));
}
}
@@ -332,21 +336,22 @@ class ContentSettingCookiesBubbleModel : public ContentSettingSingleRadioGroup {
NotificationService::current()->Notify(
NotificationType::COLLECTED_COOKIES_SHOWN,
Source<TabSpecificContentSettings>(
- tab_contents()->GetTabSpecificContentSettings()),
+ tab_contents()->tab_contents()->GetTabSpecificContentSettings()),
NotificationService::NoDetails());
- tab_contents()->delegate()->ShowCollectedCookiesDialog(tab_contents());
+ tab_contents()->tab_contents()->delegate()->
+ ShowCollectedCookiesDialog(tab_contents()->tab_contents());
}
}
};
class ContentSettingPluginBubbleModel : public ContentSettingSingleRadioGroup {
public:
- ContentSettingPluginBubbleModel(TabContents* tab_contents,
+ ContentSettingPluginBubbleModel(TabContentsWrapper* tab_contents,
Profile* profile,
ContentSettingsType content_type)
: ContentSettingSingleRadioGroup(tab_contents, profile, content_type) {
DCHECK_EQ(content_type, CONTENT_SETTINGS_TYPE_PLUGINS);
- set_custom_link_enabled(tab_contents && tab_contents->
+ set_custom_link_enabled(tab_contents && tab_contents->tab_contents()->
GetTabSpecificContentSettings()->load_plugins_link_enabled());
}
@@ -358,14 +363,14 @@ class ContentSettingPluginBubbleModel : public ContentSettingSingleRadioGroup {
DCHECK(tab_contents());
tab_contents()->render_view_host()->LoadBlockedPlugins();
set_custom_link_enabled(false);
- tab_contents()->GetTabSpecificContentSettings()->
+ tab_contents()->tab_contents()->GetTabSpecificContentSettings()->
set_load_plugins_link_enabled(false);
}
};
class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup {
public:
- ContentSettingPopupBubbleModel(TabContents* tab_contents,
+ ContentSettingPopupBubbleModel(TabContentsWrapper* tab_contents,
Profile* profile,
ContentSettingsType content_type)
: ContentSettingSingleRadioGroup(tab_contents, profile, content_type) {
@@ -376,31 +381,28 @@ class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup {
private:
void SetPopups() {
- // check for crbug.com/53176
- if (!tab_contents()->blocked_content_container())
- return;
- std::vector<TabContents*> blocked_contents;
- tab_contents()->blocked_content_container()->GetBlockedContents(
- &blocked_contents);
- for (std::vector<TabContents*>::const_iterator
- i(blocked_contents.begin()); i != blocked_contents.end(); ++i) {
- std::string title(UTF16ToUTF8((*i)->GetTitle()));
+ std::vector<TabContentsWrapper*> blocked_contents;
+ tab_contents()->blocked_content_tab_helper()->
+ GetBlockedContents(&blocked_contents);
+ for (std::vector<TabContentsWrapper*>::const_iterator
+ i = blocked_contents.begin(); i != blocked_contents.end(); ++i) {
+ std::string title(UTF16ToUTF8((*i)->tab_contents()->GetTitle()));
// The popup may not have committed a load yet, in which case it won't
// have a URL or title.
if (title.empty())
title = l10n_util::GetStringUTF8(IDS_TAB_LOADING_TITLE);
PopupItem popup_item;
popup_item.title = title;
- popup_item.bitmap = (*i)->GetFavicon();
+ popup_item.bitmap = (*i)->tab_contents()->GetFavicon();
popup_item.tab_contents = (*i);
add_popup(popup_item);
}
}
virtual void OnPopupClicked(int index) {
- if (tab_contents() && tab_contents()->blocked_content_container()) {
- tab_contents()->blocked_content_container()->LaunchForContents(
- bubble_content().popup_items[index].tab_contents);
+ if (tab_contents()) {
+ tab_contents()->blocked_content_tab_helper()->
+ LaunchForContents(bubble_content().popup_items[index].tab_contents);
}
}
};
@@ -408,7 +410,7 @@ class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup {
class ContentSettingDomainListBubbleModel
: public ContentSettingTitleAndLinkModel {
public:
- ContentSettingDomainListBubbleModel(TabContents* tab_contents,
+ ContentSettingDomainListBubbleModel(TabContentsWrapper* tab_contents,
Profile* profile,
ContentSettingsType content_type)
: ContentSettingTitleAndLinkModel(tab_contents, profile, content_type) {
@@ -430,7 +432,7 @@ class ContentSettingDomainListBubbleModel
}
void SetDomainsAndCustomLink() {
TabSpecificContentSettings* content_settings =
- tab_contents()->GetTabSpecificContentSettings();
+ tab_contents()->tab_contents()->GetTabSpecificContentSettings();
const GeolocationSettingsState& settings =
content_settings->geolocation_settings_state();
GeolocationSettingsState::FormattedHostsPerState formatted_hosts_per_state;
@@ -459,9 +461,9 @@ class ContentSettingDomainListBubbleModel
return;
// Reset this embedder's entry to default for each of the requesting
// origins currently on the page.
- const GURL& embedder_url = tab_contents()->GetURL();
+ const GURL& embedder_url = tab_contents()->tab_contents()->GetURL();
TabSpecificContentSettings* content_settings =
- tab_contents()->GetTabSpecificContentSettings();
+ tab_contents()->tab_contents()->GetTabSpecificContentSettings();
const GeolocationSettingsState::StateMap& state_map =
content_settings->geolocation_settings_state().state_map();
GeolocationContentSettingsMap* settings_map =
@@ -477,7 +479,7 @@ class ContentSettingDomainListBubbleModel
// static
ContentSettingBubbleModel*
ContentSettingBubbleModel::CreateContentSettingBubbleModel(
- TabContents* tab_contents,
+ TabContentsWrapper* tab_contents,
Profile* profile,
ContentSettingsType content_type) {
if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) {
@@ -501,14 +503,14 @@ ContentSettingBubbleModel*
}
ContentSettingBubbleModel::ContentSettingBubbleModel(
- TabContents* tab_contents,
+ TabContentsWrapper* tab_contents,
Profile* profile,
ContentSettingsType content_type)
: tab_contents_(tab_contents),
profile_(profile),
content_type_(content_type) {
registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED,
- Source<TabContents>(tab_contents));
+ Source<TabContents>(tab_contents->tab_contents()));
}
ContentSettingBubbleModel::~ContentSettingBubbleModel() {
@@ -538,6 +540,6 @@ void ContentSettingBubbleModel::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
DCHECK(type == NotificationType::TAB_CONTENTS_DESTROYED);
- DCHECK(source == Source<TabContents>(tab_contents_));
+ DCHECK(source == Source<TabContents>(tab_contents_->tab_contents()));
tab_contents_ = NULL;
}
diff --git a/chrome/browser/content_setting_bubble_model.h b/chrome/browser/ui/content_settings/content_setting_bubble_model.h
index d9a2615..460ed0b 100644
--- a/chrome/browser/content_setting_bubble_model.h
+++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_CONTENT_SETTING_BUBBLE_MODEL_H_
-#define CHROME_BROWSER_CONTENT_SETTING_BUBBLE_MODEL_H_
+#ifndef CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_BUBBLE_MODEL_H_
+#define CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_BUBBLE_MODEL_H_
#pragma once
#include <set>
@@ -18,7 +18,7 @@
class Profile;
class SkBitmap;
-class TabContents;
+class TabContentsWrapper;
// This model provides data for ContentSettingBubble, and also controls
// the action triggered when the allow / block radio buttons are triggered.
@@ -27,7 +27,7 @@ class ContentSettingBubbleModel : public NotificationObserver {
virtual ~ContentSettingBubbleModel();
static ContentSettingBubbleModel* CreateContentSettingBubbleModel(
- TabContents* tab_contents,
+ TabContentsWrapper* tab_contents,
Profile* profile,
ContentSettingsType content_type);
@@ -36,7 +36,7 @@ class ContentSettingBubbleModel : public NotificationObserver {
struct PopupItem {
SkBitmap bitmap;
std::string title;
- TabContents* tab_contents;
+ TabContentsWrapper* tab_contents;
};
typedef std::vector<PopupItem> PopupItems;
@@ -89,10 +89,10 @@ class ContentSettingBubbleModel : public NotificationObserver {
virtual void OnManageLinkClicked() {}
protected:
- ContentSettingBubbleModel(TabContents* tab_contents, Profile* profile,
+ ContentSettingBubbleModel(TabContentsWrapper* tab_contents, Profile* profile,
ContentSettingsType content_type);
- TabContents* tab_contents() const { return tab_contents_; }
+ TabContentsWrapper* tab_contents() const { return tab_contents_; }
Profile* profile() const { return profile_; }
void set_title(const std::string& title) { bubble_content_.title = title; }
@@ -117,7 +117,7 @@ class ContentSettingBubbleModel : public NotificationObserver {
void AddBlockedResource(const std::string& resource_identifier);
private:
- TabContents* tab_contents_;
+ TabContentsWrapper* tab_contents_;
Profile* profile_;
ContentSettingsType content_type_;
BubbleContent bubble_content_;
@@ -125,4 +125,4 @@ class ContentSettingBubbleModel : public NotificationObserver {
NotificationRegistrar registrar_;
};
-#endif // CHROME_BROWSER_CONTENT_SETTING_BUBBLE_MODEL_H_
+#endif // CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_BUBBLE_MODEL_H_
diff --git a/chrome/browser/content_setting_bubble_model_unittest.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc
index f2e656c..860501d 100644
--- a/chrome/browser/content_setting_bubble_model_unittest.cc
+++ b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc
@@ -1,22 +1,21 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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/content_setting_bubble_model.h"
-
#include "base/auto_reset.h"
#include "base/command_line.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/geolocation/geolocation_content_settings_map.h"
+#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
+#include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/testing_profile.h"
#include "content/browser/browser_thread.h"
-#include "content/browser/renderer_host/test_render_view_host.h"
#include "content/browser/tab_contents/test_tab_contents.h"
#include "testing/gtest/include/gtest/gtest.h"
-class ContentSettingBubbleModelTest : public RenderViewHostTestHarness {
+class ContentSettingBubbleModelTest : public TabContentsWrapperTestHarness {
protected:
ContentSettingBubbleModelTest()
: ui_thread_(BrowserThread::UI, MessageLoop::current()) {
@@ -27,7 +26,8 @@ class ContentSettingBubbleModelTest : public RenderViewHostTestHarness {
bool expect_reload_hint) {
scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
ContentSettingBubbleModel::CreateContentSettingBubbleModel(
- contents(), profile_.get(), CONTENT_SETTINGS_TYPE_GEOLOCATION));
+ contents_wrapper(), profile_.get(),
+ CONTENT_SETTINGS_TYPE_GEOLOCATION));
const ContentSettingBubbleModel::BubbleContent& bubble_content =
content_setting_bubble_model->bubble_content();
EXPECT_TRUE(bubble_content.title.empty());
@@ -51,7 +51,7 @@ TEST_F(ContentSettingBubbleModelTest, ImageRadios) {
scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
ContentSettingBubbleModel::CreateContentSettingBubbleModel(
- contents(), profile_.get(), CONTENT_SETTINGS_TYPE_IMAGES));
+ contents_wrapper(), profile_.get(), CONTENT_SETTINGS_TYPE_IMAGES));
const ContentSettingBubbleModel::BubbleContent& bubble_content =
content_setting_bubble_model->bubble_content();
EXPECT_FALSE(bubble_content.title.empty());
@@ -69,7 +69,7 @@ TEST_F(ContentSettingBubbleModelTest, Cookies) {
scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
ContentSettingBubbleModel::CreateContentSettingBubbleModel(
- contents(), profile_.get(), CONTENT_SETTINGS_TYPE_COOKIES));
+ contents_wrapper(), profile_.get(), CONTENT_SETTINGS_TYPE_COOKIES));
const ContentSettingBubbleModel::BubbleContent& bubble_content =
content_setting_bubble_model->bubble_content();
EXPECT_FALSE(bubble_content.title.empty());
@@ -87,7 +87,7 @@ TEST_F(ContentSettingBubbleModelTest, Plugins) {
scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
ContentSettingBubbleModel::CreateContentSettingBubbleModel(
- contents(), profile_.get(), CONTENT_SETTINGS_TYPE_PLUGINS));
+ contents_wrapper(), profile_.get(), CONTENT_SETTINGS_TYPE_PLUGINS));
const ContentSettingBubbleModel::BubbleContent& bubble_content =
content_setting_bubble_model->bubble_content();
EXPECT_FALSE(bubble_content.title.empty());
@@ -125,7 +125,7 @@ TEST_F(ContentSettingBubbleModelTest, MultiplePlugins) {
scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
ContentSettingBubbleModel::CreateContentSettingBubbleModel(
- contents(), profile_.get(), CONTENT_SETTINGS_TYPE_PLUGINS));
+ contents_wrapper(), profile_.get(), CONTENT_SETTINGS_TYPE_PLUGINS));
const ContentSettingBubbleModel::BubbleContent& bubble_content =
content_setting_bubble_model->bubble_content();
EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size());
@@ -191,7 +191,7 @@ TEST_F(ContentSettingBubbleModelTest, FileURL) {
NavigateAndCommit(GURL(file_url));
scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
ContentSettingBubbleModel::CreateContentSettingBubbleModel(
- contents(), profile_.get(), CONTENT_SETTINGS_TYPE_IMAGES));
+ contents_wrapper(), profile_.get(), CONTENT_SETTINGS_TYPE_IMAGES));
std::string title =
content_setting_bubble_model->bubble_content().radio_group.radio_items[0];
ASSERT_NE(std::string::npos, title.find(file_url));
diff --git a/chrome/browser/content_setting_combo_model.cc b/chrome/browser/ui/content_settings/content_setting_combo_model.cc
index 8519ecc..a6dd38e 100644
--- a/chrome/browser/content_setting_combo_model.cc
+++ b/chrome/browser/ui/content_settings/content_setting_combo_model.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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/content_setting_combo_model.h"
+#include "chrome/browser/ui/content_settings/content_setting_combo_model.h"
#include "base/command_line.h"
#include "base/string16.h"
@@ -76,4 +76,3 @@ int ContentSettingComboModel::IndexForSetting(ContentSetting setting) {
NOTREACHED();
return 0;
}
-
diff --git a/chrome/browser/content_setting_combo_model.h b/chrome/browser/ui/content_settings/content_setting_combo_model.h
index 274285f..2502188 100644
--- a/chrome/browser/content_setting_combo_model.h
+++ b/chrome/browser/ui/content_settings/content_setting_combo_model.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
-#ifndef CHROME_BROWSER_CONTENT_SETTING_COMBO_MODEL_H_
-#define CHROME_BROWSER_CONTENT_SETTING_COMBO_MODEL_H_
+#ifndef CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_COMBO_MODEL_H_
+#define CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_COMBO_MODEL_H_
#pragma once
#include "base/basictypes.h"
@@ -29,4 +29,4 @@ class ContentSettingComboModel : public ui::ComboboxModel {
DISALLOW_COPY_AND_ASSIGN(ContentSettingComboModel);
};
-#endif // CHROME_BROWSER_CONTENT_SETTING_COMBO_MODEL_H_
+#endif // CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_COMBO_MODEL_H_
diff --git a/chrome/browser/content_setting_image_model.cc b/chrome/browser/ui/content_settings/content_setting_image_model.cc
index e783d00..4343af6 100644
--- a/chrome/browser/content_setting_image_model.cc
+++ b/chrome/browser/ui/content_settings/content_setting_image_model.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/content_setting_image_model.h"
+#include "chrome/browser/ui/content_settings/content_setting_image_model.h"
#include "base/command_line.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
diff --git a/chrome/browser/content_setting_image_model.h b/chrome/browser/ui/content_settings/content_setting_image_model.h
index 3e6d5e8..686ab07 100644
--- a/chrome/browser/content_setting_image_model.h
+++ b/chrome/browser/ui/content_settings/content_setting_image_model.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
-#ifndef CHROME_BROWSER_CONTENT_SETTING_IMAGE_MODEL_H_
-#define CHROME_BROWSER_CONTENT_SETTING_IMAGE_MODEL_H_
+#ifndef CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_IMAGE_MODEL_H_
+#define CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_IMAGE_MODEL_H_
#pragma once
#include <string>
@@ -53,4 +53,4 @@ class ContentSettingImageModel {
std::string tooltip_;
};
-#endif // CHROME_BROWSER_CONTENT_SETTING_IMAGE_MODEL_H_
+#endif // CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_IMAGE_MODEL_H_
diff --git a/chrome/browser/content_setting_image_model_unittest.cc b/chrome/browser/ui/content_settings/content_setting_image_model_unittest.cc
index acef7af..9eed06a 100644
--- a/chrome/browser/content_setting_image_model_unittest.cc
+++ b/chrome/browser/ui/content_settings/content_setting_image_model_unittest.cc
@@ -1,11 +1,11 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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/content_setting_image_model.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/content_settings/content_setting_image_model.h"
#include "chrome/test/testing_profile.h"
#include "content/browser/browser_thread.h"
#include "content/browser/renderer_host/test_render_view_host.h"
diff --git a/chrome/browser/ui/gtk/collected_cookies_gtk.h b/chrome/browser/ui/gtk/collected_cookies_gtk.h
index 10ebded..974e668 100644
--- a/chrome/browser/ui/gtk/collected_cookies_gtk.h
+++ b/chrome/browser/ui/gtk/collected_cookies_gtk.h
@@ -22,7 +22,8 @@ class CookiesTreeModel;
// CollectedCookiesGtk is a dialog that displays the allowed and blocked
// cookies of the current tab contents. To display the dialog, invoke
-// ShowCollectedCookiesDialog() on the delegate of the tab contents.
+// ShowCollectedCookiesDialog() on the delegate of the tab contents wrapper's
+// content settings tab helper.
class CollectedCookiesGtk : public ConstrainedDialogDelegate,
gtk_tree::TreeAdapter::Delegate,
diff --git a/chrome/browser/ui/gtk/content_setting_bubble_gtk.cc b/chrome/browser/ui/gtk/content_setting_bubble_gtk.cc
index a134e80..632a383 100644
--- a/chrome/browser/ui/gtk/content_setting_bubble_gtk.cc
+++ b/chrome/browser/ui/gtk/content_setting_bubble_gtk.cc
@@ -10,10 +10,9 @@
#include "base/i18n/rtl.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/blocked_content_container.h"
-#include "chrome/browser/content_setting_bubble_model.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
#include "chrome/browser/ui/gtk/gtk_chrome_link_button.h"
#include "chrome/browser/ui/gtk/gtk_theme_service.h"
#include "chrome/browser/ui/gtk/gtk_util.h"
diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
index 15abc6e..500626f 100644
--- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
@@ -20,8 +20,6 @@
#include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h"
#include "chrome/browser/autocomplete/autocomplete_popup_model.h"
#include "chrome/browser/command_updater.h"
-#include "chrome/browser/content_setting_bubble_model.h"
-#include "chrome/browser/content_setting_image_model.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/extensions/extension_browser_event_router.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -32,6 +30,8 @@
#include "chrome/browser/search_engines/template_url_model.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
+#include "chrome/browser/ui/content_settings/content_setting_image_model.h"
#include "chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.h"
#include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h"
#include "chrome/browser/ui/gtk/cairo_cached_surface.h"
@@ -44,6 +44,7 @@
#include "chrome/browser/ui/gtk/rounded_window.h"
#include "chrome/browser/ui/gtk/view_id_util.h"
#include "chrome/browser/ui/omnibox/location_bar_util.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_action.h"
@@ -1359,14 +1360,14 @@ void LocationBarViewGtk::ContentSettingImageViewGtk::AnimationCanceled(
gboolean LocationBarViewGtk::ContentSettingImageViewGtk::OnButtonPressed(
GtkWidget* sender, GdkEvent* event) {
- TabContents* tab_contents = parent_->GetTabContents();
+ TabContentsWrapper* tab_contents = parent_->GetTabContentsWrapper();
if (!tab_contents)
return TRUE;
const ContentSettingsType content_settings_type =
content_setting_image_model_->get_content_settings_type();
if (content_settings_type == CONTENT_SETTINGS_TYPE_PRERENDER)
return TRUE;
- GURL url = tab_contents->GetURL();
+ GURL url = tab_contents->tab_contents()->GetURL();
std::wstring display_host;
net::AppendFormattedHost(url,
UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)),
@@ -1377,7 +1378,7 @@ gboolean LocationBarViewGtk::ContentSettingImageViewGtk::OnButtonPressed(
sender, this,
ContentSettingBubbleModel::CreateContentSettingBubbleModel(
tab_contents, profile_, content_settings_type),
- profile_, tab_contents);
+ profile_, tab_contents->tab_contents());
return TRUE;
}
diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
index e602095..d1e59c1 100644
--- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
+++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
@@ -24,6 +24,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h"
#include "chrome/browser/translate/translate_tab_helper.h"
+#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
#include "chrome/browser/ui/download/download_tab_helper.h"
#include "chrome/browser/ui/find_bar/find_tab_helper.h"
#include "chrome/browser/ui/search_engines/search_engine_tab_helper.h"
@@ -59,6 +60,7 @@ TabContentsWrapper::TabContentsWrapper(TabContents* contents)
autocomplete_history_manager_.reset(new AutocompleteHistoryManager(contents));
autofill_manager_.reset(new AutofillManager(contents));
automation_tab_helper_.reset(new AutomationTabHelper(contents));
+ blocked_content_tab_helper_.reset(new BlockedContentTabHelper(this));
download_tab_helper_.reset(new DownloadTabHelper(contents));
extension_tab_helper_.reset(new ExtensionTabHelper(this));
find_tab_helper_.reset(new FindTabHelper(contents));
diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h
index 3affc93..c682c33 100644
--- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h
+++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h
@@ -27,6 +27,7 @@ class PrintPreviewMessageHandler;
class AutocompleteHistoryManager;
class AutofillManager;
class AutomationTabHelper;
+class BlockedContentTabHelper;
class DownloadTabHelper;
class Extension;
class ExtensionTabHelper;
@@ -106,6 +107,10 @@ class TabContentsWrapper : public NotificationObserver,
return automation_tab_helper_.get();
}
+ BlockedContentTabHelper* blocked_content_tab_helper() {
+ return blocked_content_tab_helper_.get();
+ }
+
DownloadTabHelper* download_tab_helper() {
return download_tab_helper_.get();
}
@@ -182,6 +187,7 @@ class TabContentsWrapper : public NotificationObserver,
scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager_;
scoped_ptr<AutofillManager> autofill_manager_;
scoped_ptr<AutomationTabHelper> automation_tab_helper_;
+ scoped_ptr<BlockedContentTabHelper> blocked_content_tab_helper_;
scoped_ptr<DownloadTabHelper> download_tab_helper_;
scoped_ptr<ExtensionTabHelper> extension_tab_helper_;
scoped_ptr<FindTabHelper> find_tab_helper_;
diff --git a/chrome/browser/ui/views/collected_cookies_win.h b/chrome/browser/ui/views/collected_cookies_win.h
index 8e6e61b..b05f8d6 100644
--- a/chrome/browser/ui/views/collected_cookies_win.h
+++ b/chrome/browser/ui/views/collected_cookies_win.h
@@ -30,7 +30,8 @@ class NativeButton;
//
// CollectedCookiesWin is a dialog that displays the allowed and blocked
// cookies of the current tab contents. To display the dialog, invoke
-// ShowCollectedCookiesDialog() on the delegate of the tab contents.
+// ShowCollectedCookiesDialog() on the delegate of the tab contents wrapper's
+// content settings tab helper.
class CollectedCookiesWin : public ConstrainedDialogDelegate,
public NotificationObserver,
public views::ButtonListener,
diff --git a/chrome/browser/ui/views/content_setting_bubble_contents.cc b/chrome/browser/ui/views/content_setting_bubble_contents.cc
index b77b3cf..00d4c93 100644
--- a/chrome/browser/ui/views/content_setting_bubble_contents.cc
+++ b/chrome/browser/ui/views/content_setting_bubble_contents.cc
@@ -9,11 +9,10 @@
#endif
#include "base/utf_string_conversions.h"
-#include "chrome/browser/blocked_content_container.h"
-#include "chrome/browser/content_setting_bubble_model.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/plugin_updater.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
#include "chrome/browser/ui/views/browser_dialogs.h"
#include "chrome/browser/ui/views/bubble/bubble.h"
#include "content/browser/tab_contents/tab_contents.h"
diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
index bdf926e..3d2f2fa 100644
--- a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
+++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
@@ -6,8 +6,8 @@
#include "base/command_line.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/content_setting_bubble_model.h"
-#include "chrome/browser/content_setting_image_model.h"
+#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
+#include "chrome/browser/ui/content_settings/content_setting_image_model.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/views/content_setting_bubble_contents.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
@@ -128,7 +128,7 @@ void ContentSettingImageView::OnMouseReleased(const views::MouseEvent& event) {
if (!HitTest(event.location()))
return;
- TabContents* tab_contents = parent_->GetTabContentsWrapper()->tab_contents();
+ TabContentsWrapper* tab_contents = parent_->GetTabContentsWrapper();
if (!tab_contents)
return;
@@ -146,7 +146,7 @@ void ContentSettingImageView::OnMouseReleased(const views::MouseEvent& event) {
new ContentSettingBubbleContents(
ContentSettingBubbleModel::CreateContentSettingBubbleModel(
tab_contents, profile_, content_settings_type),
- profile_, tab_contents);
+ profile_, tab_contents->tab_contents());
bubble_ = Bubble::Show(GetWidget(), screen_bounds, BubbleBorder::TOP_RIGHT,
bubble_contents, this);
bubble_contents->set_bubble(bubble_);
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 7464c11..97c1920 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -266,8 +266,6 @@
'browser/background_mode_manager_win.cc',
'browser/background_page_tracker.cc',
'browser/background_page_tracker.h',
- 'browser/blocked_content_container.cc',
- 'browser/blocked_content_container.h',
'browser/bookmarks/base_bookmark_model_observer.cc',
'browser/bookmarks/base_bookmark_model_observer.h',
'browser/bookmarks/bookmark_codec.cc',
@@ -729,12 +727,6 @@
'browser/cocoa/scoped_authorizationref.h',
'browser/command_updater.cc',
'browser/command_updater.h',
- 'browser/content_setting_bubble_model.cc',
- 'browser/content_setting_bubble_model.h',
- 'browser/content_setting_combo_model.cc',
- 'browser/content_setting_combo_model.h',
- 'browser/content_setting_image_model.cc',
- 'browser/content_setting_image_model.h',
'browser/content_settings/content_settings_base_provider.cc',
'browser/content_settings/content_settings_base_provider.h',
'browser/content_settings/content_settings_details.h',
@@ -2092,6 +2084,12 @@
'browser/ui/app_modal_dialogs/message_box_handler.cc',
'browser/ui/app_modal_dialogs/message_box_handler.h',
'browser/ui/app_modal_dialogs/native_app_modal_dialog.h',
+ 'browser/ui/blocked_content/blocked_content_container.cc',
+ 'browser/ui/blocked_content/blocked_content_container.h',
+ 'browser/ui/blocked_content/blocked_content_tab_helper.cc',
+ 'browser/ui/blocked_content/blocked_content_tab_helper.h',
+ 'browser/ui/blocked_content/blocked_content_tab_helper_delegate.cc',
+ 'browser/ui/blocked_content/blocked_content_tab_helper_delegate.h',
'browser/ui/browser.cc',
'browser/ui/browser.h',
'browser/ui/browser_dialogs.h',
@@ -2532,6 +2530,12 @@
'browser/ui/cocoa/wrench_menu/wrench_menu_controller.mm',
'browser/ui/collected_cookies_infobar_delegate.h',
'browser/ui/collected_cookies_infobar_delegate.cc',
+ 'browser/ui/content_settings/content_setting_bubble_model.cc',
+ 'browser/ui/content_settings/content_setting_bubble_model.h',
+ 'browser/ui/content_settings/content_setting_combo_model.cc',
+ 'browser/ui/content_settings/content_setting_combo_model.h',
+ 'browser/ui/content_settings/content_setting_image_model.cc',
+ 'browser/ui/content_settings/content_setting_image_model.h',
'browser/ui/crypto_module_password_dialog.h',
'browser/ui/crypto_module_password_dialog_nss.cc',
'browser/ui/crypto_module_password_dialog_openssl.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index d03fabf..92c603c 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1296,8 +1296,6 @@
'browser/chromeos/status/input_method_menu_unittest.cc',
'browser/chromeos/system_access_unittest.cc',
'browser/chromeos/version_loader_unittest.cc',
- 'browser/content_setting_bubble_model_unittest.cc',
- 'browser/content_setting_image_model_unittest.cc',
'browser/cocoa/keystone_glue_unittest.mm',
'browser/command_updater_unittest.cc',
'browser/content_settings/content_settings_pattern_unittest.cc',
@@ -1750,6 +1748,8 @@
'browser/ui/cocoa/wrench_menu/menu_tracked_root_view_unittest.mm',
'browser/ui/cocoa/wrench_menu/wrench_menu_button_cell_unittest.mm',
'browser/ui/cocoa/wrench_menu/wrench_menu_controller_unittest.mm',
+ 'browser/ui/content_settings/content_setting_bubble_model_unittest.cc',
+ 'browser/ui/content_settings/content_setting_image_model_unittest.cc',
'browser/ui/find_bar/find_backend_unittest.cc',
'browser/ui/login/login_prompt_unittest.cc',
'browser/ui/search_engines/keyword_editor_controller_unittest.cc',
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index d4f871b..e5142a5 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,7 +13,6 @@
#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"
@@ -239,8 +237,6 @@ TabContents::TabContents(Profile* profile,
upload_size_(0),
upload_position_(0),
received_page_title_(false),
- blocked_contents_(NULL),
- all_contents_blocked_(false),
displayed_insecure_content_(false),
capturing_contents_(false),
is_being_destroyed_(false),
@@ -331,10 +327,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,
@@ -811,41 +803,15 @@ void TabContents::BlockTabContent(bool blocked) {
delegate_->SetTabContentBlocked(this, blocked);
}
-
-void TabContents::AddOrBlockNewContents(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;
- }
-
+void TabContents::AddNewContents(TabContents* new_contents,
+ WindowOpenDisposition disposition,
+ const gfx::Rect& initial_pos,
+ bool user_gesture) {
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, user_gesture);
- } else {
- AddNewContents(new_contents, disposition, initial_pos, user_gesture);
- }
-
- // 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);
+ delegate_->AddNewContents(this, new_contents, disposition, initial_pos,
+ user_gesture);
}
gfx::NativeView TabContents::GetContentNativeView() const {
@@ -1031,13 +997,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);
@@ -1067,19 +1026,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_.
@@ -1400,52 +1346,6 @@ void TabContents::SetIsLoading(bool is_loading,
det);
}
-void TabContents::AddNewContents(TabContents* new_contents,
- WindowOpenDisposition disposition,
- const gfx::Rect& initial_pos,
- bool user_gesture) {
- 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));
-}
-
-void TabContents::AddPopup(TabContents* new_contents,
- const gfx::Rect& initial_pos,
- bool user_gesture) {
- // 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, user_gesture);
- } else {
- if (!blocked_contents_)
- blocked_contents_ = new BlockedContentContainer(this);
- // Call blocked_contents_->AddTabContents with user_gesture == true
- // so that the contents will not get blocked again.
- // TODO(stevenjb): Remove user_gesture parameter from
- // BlockedContentContainer::AddTabContents()?
- blocked_contents_->AddTabContents(new_contents,
- NEW_POPUP,
- initial_pos,
- true); // user gesture
- 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
@@ -1549,12 +1449,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_) {
- blocked_contents_->Destroy();
- blocked_contents_ = NULL;
- }
-
// Clear "blocked" flags.
content_settings_delegate_->ClearBlockedContentSettingsExceptForCookies();
content_settings_delegate_->GeolocationDidNavigate(details);
diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h
index fe70195..59277fc 100644
--- a/content/browser/tab_contents/tab_contents.h
+++ b/content/browser/tab_contents/tab_contents.h
@@ -55,7 +55,6 @@ namespace safe_browsing {
class ClientSideDetectionHost;
}
-class BlockedContentContainer;
class WebUI;
class DownloadItem;
class Extension;
@@ -348,15 +347,10 @@ class TabContents : public PageNavigator,
ConstrainedWindowDelegate* delegate);
// Adds a new tab or window with the given already-created contents.
- // If disposition is NEW_POPUP and user_gesture is false, contents may
- // be blocked.
- void AddOrBlockNewContents(TabContents* new_contents,
- WindowOpenDisposition disposition,
- const gfx::Rect& initial_pos,
- bool user_gesture);
-
- // Called when the blocked popup notification is shown or hidden.
- virtual void PopupNotificationVisibilityChanged(bool visible);
+ void AddNewContents(TabContents* new_contents,
+ WindowOpenDisposition disposition,
+ const gfx::Rect& initial_pos,
+ bool user_gesture);
// Returns the number of constrained windows in this tab. Used by tests.
size_t constrained_window_count() { return child_windows_.size(); }
@@ -441,9 +435,6 @@ class TabContents : public PageNavigator,
// Called when a ConstrainedWindow we own is about to be closed.
void WillClose(ConstrainedWindow* window);
- // Called when a BlockedContentContainer we own is about to be closed.
- void WillCloseBlockedContentContainer(BlockedContentContainer* container);
-
// Interstitials -------------------------------------------------------------
// Various other systems need to know about our interstitials.
@@ -505,16 +496,6 @@ class TabContents : public PageNavigator,
void WindowMoveOrResizeStarted();
- // 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() {
return &renderer_preferences_;
}
@@ -611,6 +592,9 @@ class TabContents : public PageNavigator,
// Query the WebUIFactory for the TypeID for the current URL.
WebUI::TypeID GetWebUITypeForCurrentState();
+ // From RenderViewHostDelegate.
+ virtual RenderViewHostDelegate::ContentSettings* GetContentSettingsDelegate();
+
protected:
friend class TabContentsObserver;
friend class TabContentsObserver::Registrar;
@@ -622,7 +606,7 @@ class TabContents : public PageNavigator,
void AddObserver(TabContentsObserver* observer);
void RemoveObserver(TabContentsObserver* observer);
- // from RenderViewHostDelegate.
+ // From RenderViewHostDelegate.
virtual bool OnMessageReceived(const IPC::Message& message);
private:
@@ -694,18 +678,6 @@ class TabContents : public PageNavigator,
void SetIsLoading(bool is_loading,
LoadNotificationDetails* details);
- // Adds a new tab or window with the given already-created contents.
- // Called from AddOrBlockNewContents or AddPopup.
- void AddNewContents(TabContents* new_contents,
- WindowOpenDisposition disposition,
- const gfx::Rect& initial_pos,
- bool user_gesture);
-
- // Adds the incoming |new_contents| to the |blocked_contents_| container.
- void AddPopup(TabContents* new_contents,
- const gfx::Rect& initial_pos,
- bool user_gesture);
-
// Called by derived classes to indicate that we're no longer waiting for a
// response. This won't actually update the throbber, but it will get picked
// up at the next animation step if the throbber is going.
@@ -797,7 +769,6 @@ class TabContents : public PageNavigator,
virtual RenderViewHostDelegate::View* GetViewDelegate();
virtual RenderViewHostDelegate::RendererManagement*
GetRendererManagementDelegate();
- virtual RenderViewHostDelegate::ContentSettings* GetContentSettingsDelegate();
virtual RenderViewHostDelegate::SSL* GetSSLDelegate();
virtual AutomationResourceRoutingDelegate*
GetAutomationResourceRoutingDelegate();
@@ -1008,12 +979,6 @@ class TabContents : public PageNavigator,
// Character encoding.
std::string encoding_;
- // 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_;
-
// True if this is a secure page which displayed insecure content.
bool displayed_insecure_content_;
diff --git a/content/browser/tab_contents/tab_contents_delegate.h b/content/browser/tab_contents/tab_contents_delegate.h
index 8995deb..2b40042 100644
--- a/content/browser/tab_contents/tab_contents_delegate.h
+++ b/content/browser/tab_contents/tab_contents_delegate.h
@@ -109,7 +109,9 @@ class TabContentsDelegate : public AutomationResourceRoutingDelegate {
virtual bool IsPopup(const TabContents* source) const;
// If |source| is constrained, returns the tab containing it. Otherwise
- // returns |source|.
+ // returns |source|. TODO(avi): Remove in favor of GetConstrainingContents on
+ // ContentSettingsTabHelperDelegate once uses of it in TabContents are
+ // removed.
virtual TabContents* GetConstrainingContents(TabContents* source);
// Returns true if constrained windows should be focused. Default is true.
diff --git a/content/browser/tab_contents/tab_contents_observer.h b/content/browser/tab_contents/tab_contents_observer.h
index bfe7760..9169cb0 100644
--- a/content/browser/tab_contents/tab_contents_observer.h
+++ b/content/browser/tab_contents/tab_contents_observer.h
@@ -17,7 +17,7 @@ struct ViewHostMsg_FrameNavigate_Params;
class TabContentsObserver : public IPC::Channel::Listener,
public IPC::Message::Sender {
public:
- // Use this as a member variable in a class that uses the emptry constructor
+ // Use this as a member variable in a class that uses the empty constructor
// version of this interface.
class Registrar {
public:
diff --git a/content/browser/tab_contents/tab_contents_view.cc b/content/browser/tab_contents/tab_contents_view.cc
index ab398d7..48d6b62 100644
--- a/content/browser/tab_contents/tab_contents_view.cc
+++ b/content/browser/tab_contents/tab_contents_view.cc
@@ -68,7 +68,7 @@ void TabContentsView::ShowCreatedWindow(int route_id,
bool user_gesture) {
TabContents* contents = delegate_view_helper_.GetCreatedWindow(route_id);
if (contents) {
- tab_contents()->AddOrBlockNewContents(
+ tab_contents()->AddNewContents(
contents, disposition, initial_pos, user_gesture);
}
}