| Index: chrome/browser/ui/browser.cc
|
| diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
|
| index 8a13c8dc975fd1d41bb0886d319a3efb0206f265..8e49501ada4bd6f06119391264f3cf77c7dc2185 100644
|
| --- a/chrome/browser/ui/browser.cc
|
| +++ b/chrome/browser/ui/browser.cc
|
| @@ -75,6 +75,7 @@
|
| #include "chrome/browser/ui/browser_list.h"
|
| #include "chrome/browser/ui/browser_tab_restore_service_delegate.h"
|
| #include "chrome/browser/ui/browser_window.h"
|
| +#include "chrome/browser/ui/content_settings/content_settings_tab_helper.h"
|
| #include "chrome/browser/ui/download/download_tab_helper.h"
|
| #include "chrome/browser/ui/find_bar/find_bar.h"
|
| #include "chrome/browser/ui/find_bar/find_bar_controller.h"
|
| @@ -2893,11 +2894,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;
|
| + ContentSettingsTabHelper* source_content_settings = NULL;
|
| + TabContentsWrapper* new_wrapper = new TabContentsWrapper(new_contents);
|
| + if (source) {
|
| + source_wrapper = TabContentsWrapper::GetCurrentWrapperForContents(source);
|
| + source_content_settings = source_wrapper->content_settings_tab_helper();
|
| + }
|
| +
|
| + if (source_wrapper) {
|
| + // Handle blocking of all contents.
|
| + if (source_content_settings->all_contents_blocked()) {
|
| + source_content_settings->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)->content_settings_tab_helper()->
|
| + AddPopup(new_wrapper, initial_pos);
|
| + 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)
|
| @@ -2916,15 +2949,22 @@ 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;
|
| params.show_window = true;
|
| browser::Navigate(¶ms);
|
| +
|
| + if (source) {
|
| + NotificationService::current()->Notify(
|
| + NotificationType::TAB_ADDED,
|
| + Source<TabContentsDelegate>(source->delegate()),
|
| + Details<TabContents>(source));
|
| + }
|
| }
|
|
|
| void Browser::ActivateContents(TabContents* contents) {
|
| @@ -3200,9 +3240,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);
|
| }
|
| }
|
| @@ -3243,16 +3285,6 @@ void Browser::ShowRepostFormWarningDialog(TabContents *tab_contents) {
|
| window()->ShowRepostFormWarningDialog(tab_contents);
|
| }
|
|
|
| -void Browser::ShowContentSettingsPage(ContentSettingsType content_type) {
|
| - ShowOptionsTab(
|
| - chrome::kContentSettingsExceptionsSubPage + std::string(kHashMark) +
|
| - ContentSettingsHandler::ContentSettingsTypeToGroupName(content_type));
|
| -}
|
| -
|
| -void Browser::ShowCollectedCookiesDialog(TabContents *tab_contents) {
|
| - window()->ShowCollectedCookiesDialog(tab_contents);
|
| -}
|
| -
|
| bool Browser::ShouldAddNavigationToHistory(
|
| const history::HistoryAddPageArgs& add_page_args,
|
| NavigationType::Type navigation_type) {
|
| @@ -3336,6 +3368,24 @@ void Browser::ConfirmAddSearchProvider(const TemplateURL* template_url,
|
| }
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
| +// Browser, ContentSettingsTabHelperDelegate implementation:
|
| +
|
| +TabContentsWrapper* Browser::GetConstrainingContents(
|
| + TabContentsWrapper* source) {
|
| + return source;
|
| +}
|
| +
|
| +void Browser::ShowContentSettingsPage(ContentSettingsType content_type) {
|
| + ShowOptionsTab(
|
| + chrome::kContentSettingsExceptionsSubPage + std::string(kHashMark) +
|
| + ContentSettingsHandler::ContentSettingsTypeToGroupName(content_type));
|
| +}
|
| +
|
| +void Browser::ShowCollectedCookiesDialog(TabContents *tab_contents) {
|
| + window()->ShowCollectedCookiesDialog(tab_contents);
|
| +}
|
| +
|
| +///////////////////////////////////////////////////////////////////////////////
|
| // Browser, SelectFileDialog::Listener implementation:
|
|
|
| void Browser::FileSelected(const FilePath& path, int index, void* params) {
|
| @@ -4214,8 +4264,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->content_settings_tab_helper()->set_delegate(delegate);
|
| tab->search_engine_tab_helper()->set_delegate(delegate);
|
| }
|
|
|
| @@ -4348,7 +4402,7 @@ bool Browser::OpenInstant(WindowOpenDisposition disposition) {
|
| -1,
|
| instant()->last_transition_type(),
|
| TabStripModel::ADD_SELECTED);
|
| - 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
|
|
|