summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-10 19:22:00 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-10 19:22:00 +0000
commit1c7b206c9a57a1878cf004c02666505d55b1745c (patch)
treeca20faf29c471f57882bf48c821a19fc6cc2c720
parenta164c1c728da3900206957e5362868d3b5f46f20 (diff)
downloadchromium_src-1c7b206c9a57a1878cf004c02666505d55b1745c.zip
chromium_src-1c7b206c9a57a1878cf004c02666505d55b1745c.tar.gz
chromium_src-1c7b206c9a57a1878cf004c02666505d55b1745c.tar.bz2
Revert 117067 - Split RenderViewHostDelegateViewHelper in two.
BUG=93804, 95573 TEST=no visible change Review URL: http://codereview.chromium.org/9008079 TBR=avi@chromium.org Review URL: http://codereview.chromium.org/9168015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117074 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chrome_content_browser_client.cc2
-rw-r--r--chrome/browser/external_tab_container_win.cc7
-rw-r--r--chrome/browser/external_tab_container_win.h7
-rw-r--r--chrome/browser/prerender/prerender_contents.cc28
-rw-r--r--chrome/browser/tab_contents/render_view_host_delegate_helper.cc192
-rw-r--r--chrome/browser/tab_contents/render_view_host_delegate_helper.h47
-rw-r--r--chrome/browser/ui/browser.cc89
-rw-r--r--chrome/browser/ui/browser.h17
-rw-r--r--content/public/browser/notification_types.h6
-rw-r--r--content/public/browser/web_contents_delegate.cc8
-rw-r--r--content/public/browser/web_contents_delegate.h16
11 files changed, 219 insertions, 200 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 0d46782..301377c 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -51,6 +51,7 @@
#include "chrome/browser/spellchecker/spellcheck_message_filter.h"
#include "chrome/browser/ssl/ssl_add_cert_handler.h"
#include "chrome/browser/ssl/ssl_blocking_page.h"
+#include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
#include "chrome/browser/tab_contents/tab_contents_ssl_helper.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
@@ -88,7 +89,6 @@
#include "net/base/network_change_notifier.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
-#include "webkit/glue/webpreferences.h"
#if defined(OS_WIN)
#include "chrome/browser/chrome_browser_main_win.h"
diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc
index edb9f24..2e887d2 100644
--- a/chrome/browser/external_tab_container_win.cc
+++ b/chrome/browser/external_tab_container_win.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 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.
@@ -488,10 +488,7 @@ void ExternalTabContainer::AddNewContents(WebContents* source,
}
}
-void ExternalTabContainer::WebContentsCreated(WebContents* source_contents,
- int64 source_frame_id,
- const GURL& target_url,
- WebContents* new_contents) {
+void ExternalTabContainer::WebContentsCreated(WebContents* new_contents) {
RenderViewHost* rvh = new_contents->GetRenderViewHost();
DCHECK(rvh != NULL);
diff --git a/chrome/browser/external_tab_container_win.h b/chrome/browser/external_tab_container_win.h
index 3873fce..5b6eb8b 100644
--- a/chrome/browser/external_tab_container_win.h
+++ b/chrome/browser/external_tab_container_win.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 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.
@@ -138,10 +138,7 @@ class ExternalTabContainer : public content::WebContentsDelegate,
const GURL& url) OVERRIDE;
virtual void ContentsZoomChange(bool zoom_in) OVERRIDE;
virtual gfx::NativeWindow GetFrameNativeWindow() OVERRIDE;
- virtual void WebContentsCreated(content::WebContents* source_contents,
- int64 source_frame_id,
- const GURL& target_url,
- content::WebContents* new_contents) OVERRIDE;
+ virtual void WebContentsCreated(content::WebContents* new_contents);
virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
bool* is_keyboard_shortcut) OVERRIDE;
virtual void HandleKeyboardEvent(
diff --git a/chrome/browser/prerender/prerender_contents.cc b/chrome/browser/prerender/prerender_contents.cc
index cdcea39..81e7d35 100644
--- a/chrome/browser/prerender/prerender_contents.cc
+++ b/chrome/browser/prerender/prerender_contents.cc
@@ -127,18 +127,6 @@ class PrerenderContents::TabContentsDelegateImpl
NOTREACHED();
}
- virtual bool ShouldCreateWebContents(
- WebContents* web_contents,
- int route_id,
- WindowContainerType window_container_type,
- const string16& frame_name) OVERRIDE {
- // Since we don't want to permit child windows that would have a
- // window.opener property, terminate prerendering.
- prerender_contents_->Destroy(FINAL_STATUS_CREATE_NEW_WINDOW);
- // Cancel the popup.
- return false;
- }
-
virtual bool OnGoToEntryOffset(int offset) OVERRIDE {
// This isn't allowed because the history merge operation
// does not work if there are renderer issued challenges.
@@ -346,6 +334,11 @@ void PrerenderContents::StartPrerendering(
this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT,
content::Source<WebContents>(GetWebContents()));
+ // Register for new windows from any source.
+ notification_registrar_.Add(
+ this, content::NOTIFICATION_CREATING_NEW_WINDOW_CANCELLED,
+ content::Source<WebContents>(new_contents));
+
DCHECK(load_start_time_.is_null());
load_start_time_ = base::TimeTicks::Now();
@@ -474,6 +467,17 @@ void PrerenderContents::Observe(int type,
break;
}
+ case content::NOTIFICATION_CREATING_NEW_WINDOW_CANCELLED: {
+ if (prerender_contents_.get()) {
+ CHECK(content::Source<WebContents>(source).ptr() ==
+ prerender_contents_->web_contents());
+ // Since we don't want to permit child windows that would have a
+ // window.opener property, terminate prerendering.
+ Destroy(FINAL_STATUS_CREATE_NEW_WINDOW);
+ }
+ break;
+ }
+
default:
NOTREACHED() << "Unexpected notification sent.";
break;
diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc
index 451e7b9..b4301a3 100644
--- a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc
+++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc
@@ -4,24 +4,32 @@
#include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/background/background_contents_service.h"
+#include "chrome/browser/background/background_contents_service_factory.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/process_map.h"
+#include "chrome/browser/prerender/prerender_manager.h"
+#include "chrome/browser/prerender/prerender_manager_factory.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/tab_contents/background_contents.h"
+#include "chrome/browser/tab_contents/retargeting_details.h"
+#include "chrome/common/chrome_notification_types.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/renderer_host/render_widget_host.h"
#include "content/browser/renderer_host/render_widget_host_view.h"
+#include "content/browser/site_instance.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_view.h"
#include "content/common/view_messages.h"
#include "content/public/browser/notification_service.h"
-#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_delegate.h"
using content::WebContents;
RenderViewHostDelegateViewHelper::RenderViewHostDelegateViewHelper() {
- registrar_.Add(this,
- content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
- content::NotificationService::AllBrowserContextsAndSources());
+ registrar_.Add(this, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
+ content::NotificationService::AllSources());
}
RenderViewHostDelegateViewHelper::~RenderViewHostDelegateViewHelper() {}
@@ -41,47 +49,107 @@ void RenderViewHostDelegateViewHelper::Observe(
}
}
-TabContents* RenderViewHostDelegateViewHelper::CreateNewWindow(
- WebContents* web_contents,
+BackgroundContents*
+RenderViewHostDelegateViewHelper::MaybeCreateBackgroundContents(
int route_id,
- const ViewHostMsg_CreateWindow_Params& params) {
- bool should_create = true;
- if (web_contents->GetDelegate()) {
- should_create = web_contents->GetDelegate()->ShouldCreateWebContents(
- web_contents,
+ Profile* profile,
+ SiteInstance* site,
+ const GURL& opener_url,
+ const string16& frame_name) {
+ ExtensionService* extensions_service = profile->GetExtensionService();
+
+ if (!opener_url.is_valid() ||
+ frame_name.empty() ||
+ !extensions_service ||
+ !extensions_service->is_ready())
+ return NULL;
+
+ // Only hosted apps have web extents, so this ensures that only hosted apps
+ // can create BackgroundContents. We don't have to check for background
+ // permission as that is checked in RenderMessageFilter when the CreateWindow
+ // message is processed.
+ const Extension* extension =
+ extensions_service->extensions()->GetHostedAppByURL(
+ ExtensionURLInfo(opener_url));
+ if (!extension)
+ return NULL;
+
+ // No BackgroundContents allowed if BackgroundContentsService doesn't exist.
+ BackgroundContentsService* service =
+ BackgroundContentsServiceFactory::GetForProfile(profile);
+ if (!service)
+ return NULL;
+
+ // Ensure that we're trying to open this from the extension's process.
+ extensions::ProcessMap* process_map = extensions_service->process_map();
+ if (!site->GetProcess() ||
+ !process_map->Contains(extension->id(), site->GetProcess()->GetID())) {
+ return NULL;
+ }
+
+ // Only allow a single background contents per app. If one already exists,
+ // close it (even if it was specified in the manifest).
+ BackgroundContents* existing =
+ service->GetAppBackgroundContents(ASCIIToUTF16(extension->id()));
+ if (existing) {
+ DLOG(INFO) << "Closing existing BackgroundContents for " << opener_url;
+ delete existing;
+ }
+
+ // Passed all the checks, so this should be created as a BackgroundContents.
+ return service->CreateBackgroundContents(site, route_id, profile, frame_name,
+ ASCIIToUTF16(extension->id()));
+}
+
+TabContents* RenderViewHostDelegateViewHelper::CreateNewWindowImpl(
+ int route_id,
+ Profile* profile,
+ SiteInstance* site,
+ WebUI::TypeID webui_type,
+ RenderViewHostDelegate* opener,
+ WindowContainerType window_container_type,
+ const string16& frame_name) {
+ if (window_container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
+ BackgroundContents* contents = MaybeCreateBackgroundContents(
route_id,
- params.window_container_type,
- params.frame_name);
+ profile,
+ site,
+ opener->GetURL(),
+ frame_name);
+ if (contents) {
+ pending_contents_[route_id] =
+ contents->web_contents()->GetRenderViewHost();
+ return NULL;
+ }
}
- if (!should_create)
+ TabContents* base_tab_contents = opener->GetAsTabContents();
+
+ // Do not create the new TabContents if the opener is a prerender TabContents.
+ prerender::PrerenderManager* prerender_manager =
+ prerender::PrerenderManagerFactory::GetForProfile(profile);
+ if (prerender_manager &&
+ prerender_manager->IsWebContentsPrerendering(base_tab_contents)) {
return NULL;
+ }
// Create the new web contents. This will automatically create the new
// TabContentsView. In the future, we may want to create the view separately.
TabContents* new_contents =
- new TabContents(web_contents->GetBrowserContext(),
- web_contents->GetSiteInstance(),
+ new TabContents(profile,
+ site,
route_id,
- static_cast<TabContents*>(web_contents),
+ base_tab_contents,
NULL);
- new_contents->set_opener_web_ui_type(
- web_contents->GetWebUITypeForCurrentState());
+ new_contents->set_opener_web_ui_type(webui_type);
TabContentsView* new_view = new_contents->GetView();
- // TODO(brettw): It seems bogus that we have to call this function on the
+ // TODO(brettw) it seems bogus that we have to call this function on the
// newly created object and give it one of its own member variables.
new_view->CreateViewForWidget(new_contents->GetRenderViewHost());
// Save the created window associated with the route so we can show it later.
- pending_contents_[route_id] = new_contents;
-
- if (web_contents->GetDelegate())
- web_contents->GetDelegate()->WebContentsCreated(web_contents,
- params.opener_frame_id,
- params.target_url,
- new_contents);
-
+ pending_contents_[route_id] = new_contents->GetRenderViewHost();
return new_contents;
}
@@ -91,7 +159,8 @@ RenderWidgetHostView* RenderViewHostDelegateViewHelper::CreateNewWidget(
bool is_fullscreen,
WebKit::WebPopupType popup_type) {
content::RenderProcessHost* process = web_contents->GetRenderProcessHost();
- RenderWidgetHost* widget_host = new RenderWidgetHost(process, route_id);
+ RenderWidgetHost* widget_host =
+ new RenderWidgetHost(process, route_id);
RenderWidgetHostView* widget_view =
RenderWidgetHostView::CreateViewForWidget(widget_host);
if (!is_fullscreen) {
@@ -112,16 +181,17 @@ TabContents* RenderViewHostDelegateViewHelper::GetCreatedWindow(int route_id) {
return NULL;
}
- TabContents* new_contents = iter->second;
+ RenderViewHost* new_rvh = iter->second;
pending_contents_.erase(route_id);
- if (!new_contents->GetRenderProcessHost()->HasConnection() ||
- !new_contents->GetRenderViewHost()->view())
+ // The renderer crashed or it is a TabContents and has no view.
+ if (!new_rvh->process()->HasConnection() ||
+ (new_rvh->delegate()->GetAsTabContents() && !new_rvh->view()))
return NULL;
- // TODO(brettw): It seems bogus to reach into here and initialize the host.
- new_contents->GetRenderViewHost()->Init();
- return new_contents;
+ // TODO(brettw) this seems bogus to reach into here and initialize the host.
+ new_rvh->Init();
+ return new_rvh->delegate()->GetAsTabContents();
}
RenderWidgetHostView* RenderViewHostDelegateViewHelper::GetCreatedWidget(
@@ -144,20 +214,56 @@ RenderWidgetHostView* RenderViewHostDelegateViewHelper::GetCreatedWidget(
return widget_host_view;
}
+TabContents* RenderViewHostDelegateViewHelper::CreateNewWindow(
+ WebContents* web_contents,
+ int route_id,
+ const ViewHostMsg_CreateWindow_Params& params) {
+ TabContents* new_contents = CreateNewWindowImpl(
+ route_id,
+ Profile::FromBrowserContext(web_contents->GetBrowserContext()),
+ web_contents->GetSiteInstance(),
+ web_contents->GetWebUITypeForCurrentState(),
+ static_cast<TabContents*>(web_contents),
+ params.window_container_type,
+ params.frame_name);
+
+ if (new_contents) {
+ if (web_contents->GetDelegate())
+ web_contents->GetDelegate()->WebContentsCreated(new_contents);
+
+ RetargetingDetails details;
+ details.source_web_contents = web_contents;
+ details.source_frame_id = params.opener_frame_id;
+ details.target_url = params.target_url;
+ details.target_web_contents = new_contents;
+ details.not_yet_in_tabstrip = true;
+ content::NotificationService::current()->Notify(
+ chrome::NOTIFICATION_RETARGETING,
+ content::Source<Profile>(
+ Profile::FromBrowserContext(web_contents->GetBrowserContext())),
+ content::Details<RetargetingDetails>(&details));
+ } else {
+ content::NotificationService::current()->Notify(
+ content::NOTIFICATION_CREATING_NEW_WINDOW_CANCELLED,
+ content::Source<WebContents>(web_contents),
+ content::Details<const ViewHostMsg_CreateWindow_Params>(&params));
+ }
+
+ return new_contents;
+}
+
TabContents* RenderViewHostDelegateViewHelper::ShowCreatedWindow(
WebContents* web_contents,
int route_id,
WindowOpenDisposition disposition,
const gfx::Rect& initial_pos,
bool user_gesture) {
- TabContents* contents = GetCreatedWindow(route_id);
+ WebContents* contents = GetCreatedWindow(route_id);
if (contents) {
- web_contents->AddNewContents(contents,
- disposition,
- initial_pos,
- user_gesture);
+ web_contents->AddNewContents(
+ contents, disposition, initial_pos, user_gesture);
}
- return contents;
+ return static_cast<TabContents*>(contents);
}
RenderWidgetHostView* RenderViewHostDelegateViewHelper::ShowCreatedWidget(
diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.h b/chrome/browser/tab_contents/render_view_host_delegate_helper.h
index 1d38de4..7959e0f 100644
--- a/chrome/browser/tab_contents/render_view_host_delegate_helper.h
+++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.h
@@ -7,19 +7,30 @@
#pragma once
#include <map>
+#include <string>
#include "base/basictypes.h"
-#include "base/compiler_specific.h"
+#include "content/browser/webui/web_ui.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
+#include "content/public/common/window_container_type.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h"
+#include "webkit/glue/webpreferences.h"
#include "webkit/glue/window_open_disposition.h"
+class BackgroundContents;
+class Profile;
+class RenderViewHost;
+class RenderViewHostDelegate;
+class RenderWidgetHost;
class RenderWidgetHostView;
+class SiteInstance;
class TabContents;
struct ViewHostMsg_CreateWindow_Params;
namespace content {
+class BrowserContext;
+class RenderProcessHost;
class WebContents;
}
@@ -27,10 +38,6 @@ namespace gfx {
class Rect;
}
-// TODO(avi): Once all the TabContentsViews implementations are in content (I'm
-// looking at you, TabContentsViewViews...) then change the parameters to take
-// WebContentsImpl rather than WebContents.
-
// Provides helper methods that provide common implementations of some
// TabContentsView methods.
class RenderViewHostDelegateViewHelper : public content::NotificationObserver {
@@ -71,18 +78,40 @@ class RenderViewHostDelegateViewHelper : public content::NotificationObserver {
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
+ // Creates a new renderer for window.open. This will either be a
+ // BackgroundContents (if the window_container_type ==
+ // WINDOW_CONTAINER_TYPE_BACKGROUND and permissions allow) or a TabContents.
+ // If a TabContents is created, it is returned. Otherwise NULL is returned.
+ TabContents* CreateNewWindowImpl(
+ int route_id,
+ Profile* profile,
+ SiteInstance* site,
+ WebUI::TypeID webui_type,
+ RenderViewHostDelegate* opener,
+ WindowContainerType window_container_type,
+ const string16& frame_name);
+
+ BackgroundContents* MaybeCreateBackgroundContents(
+ int route_id,
+ Profile* profile,
+ SiteInstance* site,
+ const GURL& opener_url,
+ const string16& frame_name);
+
// Finds the new RenderWidgetHost and returns it. Note that this can only be
// called once as this call also removes it from the internal map.
RenderWidgetHostView* GetCreatedWidget(int route_id);
- // Finds the new TabContents by route_id, initializes it for
- // renderer-initiated creation, and returns it. Note that this can only be
- // called once as this call also removes it from the internal map.
+ // Finds the new RenderViewHost/Delegate by route_id, initializes it for
+ // for renderer-initiated creation, and returns the TabContents that needs
+ // to be shown, if there is one (i.e. not a BackgroundContents). Note that
+ // this can only be called once as this call also removes it from the internal
+ // map.
TabContents* GetCreatedWindow(int route_id);
// Tracks created RenderViewHost objects that have not been shown yet.
// They are identified by the route ID passed to CreateNewWindow.
- typedef std::map<int, TabContents*> PendingContents;
+ typedef std::map<int, RenderViewHost*> PendingContents;
PendingContents pending_contents_;
// These maps hold on to the widgets that we created on behalf of the
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 2fa326e..234af50 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -29,7 +29,6 @@
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/background/background_contents_service.h"
-#include "chrome/browser/background/background_contents_service_factory.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/browser_process.h"
@@ -70,8 +69,6 @@
#include "chrome/browser/platform_util.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/prerender/prerender_manager.h"
-#include "chrome/browser/prerender/prerender_manager_factory.h"
#include "chrome/browser/prerender/prerender_tab_helper.h"
#include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h"
#include "chrome/browser/printing/print_preview_tab_controller.h"
@@ -90,7 +87,6 @@
#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/browser/tab_closeable_state_watcher.h"
#include "chrome/browser/tab_contents/background_contents.h"
-#include "chrome/browser/tab_contents/retargeting_details.h"
#include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/browser/tabs/tab_finder.h"
@@ -2139,55 +2135,6 @@ void Browser::OpenBookmarkManagerEditNode(int64 node_id) {
OpenBookmarkManagerWithHash("e=", node_id);
}
-bool Browser::MaybeCreateBackgroundContents(int route_id,
- SiteInstance* site,
- const GURL& opener_url,
- const string16& frame_name) {
- ExtensionService* extensions_service = profile_->GetExtensionService();
-
- if (!opener_url.is_valid() ||
- frame_name.empty() ||
- !extensions_service ||
- !extensions_service->is_ready())
- return false;
-
- // Only hosted apps have web extents, so this ensures that only hosted apps
- // can create BackgroundContents. We don't have to check for background
- // permission as that is checked in RenderMessageFilter when the CreateWindow
- // message is processed.
- const Extension* extension =
- extensions_service->extensions()->GetHostedAppByURL(
- ExtensionURLInfo(opener_url));
- if (!extension)
- return false;
-
- // No BackgroundContents allowed if BackgroundContentsService doesn't exist.
- BackgroundContentsService* service =
- BackgroundContentsServiceFactory::GetForProfile(profile_);
- if (!service)
- return false;
-
- // Ensure that we're trying to open this from the extension's process.
- extensions::ProcessMap* process_map = extensions_service->process_map();
- if (!site->GetProcess() ||
- !process_map->Contains(extension->id(), site->GetProcess()->GetID())) {
- return false;
- }
-
- // Only allow a single background contents per app. If one already exists,
- // close it (even if it was specified in the manifest).
- BackgroundContents* existing =
- service->GetAppBackgroundContents(ASCIIToUTF16(extension->id()));
- if (existing) {
- DLOG(INFO) << "Closing existing BackgroundContents for " << opener_url;
- delete existing;
- }
-
- // Passed all the checks, so this should be created as a BackgroundContents.
- return service->CreateBackgroundContents(site, route_id, profile_, frame_name,
- ASCIIToUTF16(extension->id()));
-}
-
void Browser::ShowAppMenu() {
// We record the user metric for this event in WrenchMenu::RunMenu.
window_->ShowAppMenu();
@@ -3871,7 +3818,7 @@ void Browser::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {
window()->HandleKeyboardEvent(event);
}
-void Browser::ShowRepostFormWarningDialog(WebContents* source) {
+void Browser:: ShowRepostFormWarningDialog(WebContents* source) {
browser::ShowTabModalConfirmDialog(
new RepostFormWarningController(source),
TabContentsWrapper::GetCurrentWrapperForContents(source));
@@ -3894,45 +3841,13 @@ bool Browser::ShouldAddNavigationToHistory(
return !IsApplication();
}
-bool Browser::ShouldCreateWebContents(
- WebContents* web_contents,
- int route_id,
- WindowContainerType window_container_type,
- const string16& frame_name) {
- if (window_container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
- // If a BackgroundContents is created, suppress the normal WebContents.
- return !MaybeCreateBackgroundContents(
- route_id,
- web_contents->GetSiteInstance(),
- web_contents->GetURL(),
- frame_name);
- }
-
- return true;
-}
-
-void Browser::WebContentsCreated(WebContents* source_contents,
- int64 source_frame_id,
- const GURL& target_url,
- WebContents* new_contents) {
+void Browser::WebContentsCreated(WebContents* new_contents) {
// Create a TabContentsWrapper now, so all observers are in place, as the
// network requests for its initial navigation will start immediately. The
// TabContents will later be inserted into this browser using
// Browser::Navigate via AddNewContents. The latter will retrieve the newly
// created TabContentsWrapper from TabContents object.
new TabContentsWrapper(new_contents);
-
- // Notify.
- RetargetingDetails details;
- details.source_web_contents = source_contents;
- details.source_frame_id = source_frame_id;
- details.target_url = target_url;
- details.target_web_contents = new_contents;
- details.not_yet_in_tabstrip = true;
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_RETARGETING,
- content::Source<Profile>(profile_),
- content::Details<RetargetingDetails>(&details));
}
void Browser::ContentRestrictionsChanged(WebContents* source) {
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index a44067a..fceb89d 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -972,15 +972,7 @@ class Browser : public TabHandlerDelegate,
virtual bool ShouldAddNavigationToHistory(
const history::HistoryAddPageArgs& add_page_args,
content::NavigationType navigation_type) OVERRIDE;
- virtual bool ShouldCreateWebContents(
- content::WebContents* web_contents,
- int route_id,
- WindowContainerType window_container_type,
- const string16& frame_name) OVERRIDE;
- virtual void WebContentsCreated(content::WebContents* source_contents,
- int64 source_frame_id,
- const GURL& target_url,
- content::WebContents* new_contents) OVERRIDE;
+ virtual void WebContentsCreated(content::WebContents* new_contents) OVERRIDE;
virtual void ContentRestrictionsChanged(
content::WebContents* source) OVERRIDE;
virtual void RendererUnresponsive(content::WebContents* source) OVERRIDE;
@@ -1289,13 +1281,6 @@ class Browser : public TabHandlerDelegate,
// Open the bookmark manager with a defined hash action.
void OpenBookmarkManagerWithHash(const std::string& action, int64 node_id);
- // Creates a BackgroundContents if appropriate; return true if one was
- // created.
- bool MaybeCreateBackgroundContents(int route_id,
- SiteInstance* site,
- const GURL& opener_url,
- const string16& frame_name);
-
// Data members /////////////////////////////////////////////////////////////
content::NotificationRegistrar registrar_;
diff --git a/content/public/browser/notification_types.h b/content/public/browser/notification_types.h
index c3f1381..5edef45 100644
--- a/content/public/browser/notification_types.h
+++ b/content/public/browser/notification_types.h
@@ -119,6 +119,12 @@ enum NotificationType {
// issued. Details in the form of a ResourceRedirectDetails are provided.
NOTIFICATION_RESOURCE_RECEIVED_REDIRECT,
+ // A new window was requested but was not created. The source will be a
+ // Source<WebContents> corresponding to the tab the request originated from.
+ // Details are the ViewHostMsg_CreateWindow_Params object that were used in
+ // the request.
+ NOTIFICATION_CREATING_NEW_WINDOW_CANCELLED,
+
// SSL ---------------------------------------------------------------------
// Updating the SSL security indicators (the lock icon and such) proceeds
diff --git a/content/public/browser/web_contents_delegate.cc b/content/public/browser/web_contents_delegate.cc
index 2078164..fbedef6 100644
--- a/content/public/browser/web_contents_delegate.cc
+++ b/content/public/browser/web_contents_delegate.cc
@@ -111,14 +111,6 @@ gfx::NativeWindow WebContentsDelegate::GetFrameNativeWindow() {
return NULL;
}
-bool WebContentsDelegate::ShouldCreateWebContents(
- WebContents* web_contents,
- int route_id,
- WindowContainerType window_container_type,
- const string16& frame_name) {
- return true;
-}
-
// A stubbed-out version of JavaScriptDialogCreator that doesn't do anything.
class JavaScriptDialogCreatorStub : public JavaScriptDialogCreator {
public:
diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h
index 53584dc..1426c65 100644
--- a/content/public/browser/web_contents_delegate.h
+++ b/content/public/browser/web_contents_delegate.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 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.
@@ -14,7 +14,6 @@
#include "content/common/content_export.h"
#include "content/public/browser/navigation_type.h"
#include "content/public/common/page_transition_types.h"
-#include "content/public/common/window_container_type.h"
#include "ui/gfx/native_widget_types.h"
#include "webkit/glue/window_open_disposition.h"
@@ -272,20 +271,9 @@ class CONTENT_EXPORT WebContentsDelegate {
// Returns the native window framing the view containing the tab contents.
virtual gfx::NativeWindow GetFrameNativeWindow();
- // Allows delegate to control whether a WebContents will be created. Returns
- // true to allow the creation. Default is to allow it.
- virtual bool ShouldCreateWebContents(
- WebContents* web_contents,
- int route_id,
- WindowContainerType window_container_type,
- const string16& frame_name);
-
// Notifies the delegate about the creation of a new WebContents. This
// typically happens when popups are created.
- virtual void WebContentsCreated(WebContents* source_contents,
- int64 source_frame_id,
- const GURL& target_url,
- WebContents* new_contents) {}
+ virtual void WebContentsCreated(WebContents* new_contents) {}
// Notifies the delegate that the content restrictions for this tab has
// changed.