summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-28 01:31:42 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-28 01:31:42 +0000
commit5dcaf8ec918ad9caa97218b7921eb7946911248e (patch)
tree20f1a270d45b6f099fdf25e0ac9706db4caf1f74
parentc5eb493a7014001fb05fd923f6d976fefafa0559 (diff)
downloadchromium_src-5dcaf8ec918ad9caa97218b7921eb7946911248e.zip
chromium_src-5dcaf8ec918ad9caa97218b7921eb7946911248e.tar.gz
chromium_src-5dcaf8ec918ad9caa97218b7921eb7946911248e.tar.bz2
Replace the GetAssociatedRenderView call with GetAssociatedRenderFrame in InterceptNavigationResourceThrottle.
BUG=304341 Review URL: https://codereview.chromium.org/106203003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242655 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/apps/app_url_redirector.cc8
-rw-r--r--chrome/browser/apps/ephemeral_app_throttle.cc12
-rw-r--r--chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc4
-rw-r--r--chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_unittest.cc6
-rw-r--r--chrome/browser/extensions/api/web_request/web_request_permissions_unittest.cc5
-rw-r--r--chrome/browser/extensions/extension_protocols_unittest.cc1
-rw-r--r--chrome/browser/prerender/prerender_tracker_unittest.cc9
-rw-r--r--chrome/browser/search/iframe_source_unittest.cc2
-rw-r--r--chrome/browser/task_manager/guest_resource_provider.cc5
-rw-r--r--chrome/browser/ui/blocked_content/blocked_window_params.cc5
-rw-r--r--components/navigation_interception/intercept_navigation_delegate.cc7
-rw-r--r--components/navigation_interception/intercept_navigation_resource_throttle.cc30
-rw-r--r--components/navigation_interception/intercept_navigation_resource_throttle.h4
-rw-r--r--components/navigation_interception/intercept_navigation_resource_throttle_unittest.cc29
-rw-r--r--content/browser/browser_plugin/browser_plugin_guest.cc5
-rw-r--r--content/browser/browser_plugin/browser_plugin_guest_manager.cc4
-rw-r--r--content/browser/frame_host/navigator_impl.cc2
-rw-r--r--content/browser/loader/resource_loader_unittest.cc3
-rw-r--r--content/browser/loader/resource_request_info_impl.cc3
-rw-r--r--content/browser/renderer_host/render_process_host_impl.cc51
-rw-r--r--content/browser/renderer_host/render_process_host_impl.h4
-rw-r--r--content/browser/renderer_host/render_view_host_impl.cc95
-rw-r--r--content/browser/renderer_host/render_view_host_impl.h23
-rw-r--r--content/browser/web_contents/web_contents_impl.cc20
-rw-r--r--content/browser/web_contents/web_contents_impl.h5
-rw-r--r--content/public/browser/render_process_host.h5
-rw-r--r--content/public/browser/render_view_host.h12
-rw-r--r--content/public/browser/resource_request_info.h1
-rw-r--r--content/public/browser/web_contents.h4
-rw-r--r--content/public/test/mock_render_process_host.cc4
-rw-r--r--content/public/test/mock_render_process_host.h1
31 files changed, 176 insertions, 193 deletions
diff --git a/chrome/browser/apps/app_url_redirector.cc b/chrome/browser/apps/app_url_redirector.cc
index cfa5ce2..5a87e75 100644
--- a/chrome/browser/apps/app_url_redirector.cc
+++ b/chrome/browser/apps/app_url_redirector.cc
@@ -35,7 +35,7 @@ namespace {
bool LaunchAppWithUrl(
const scoped_refptr<const Extension> app,
const std::string& handler_id,
- content::RenderViewHost* source,
+ content::WebContents* source,
const navigation_interception::NavigationParams& params) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -50,12 +50,8 @@ bool LaunchAppWithUrl(
DCHECK(!params.is_post());
DCHECK(UrlHandlers::CanExtensionHandleUrl(app, params.url()));
- WebContents* web_contents = WebContents::FromRenderViewHost(source);
- if (!web_contents)
- return false;
-
Profile* profile =
- Profile::FromBrowserContext(web_contents->GetBrowserContext());
+ Profile::FromBrowserContext(source->GetBrowserContext());
DVLOG(1) << "Launching app handler with URL: "
<< params.url().spec() << " -> "
diff --git a/chrome/browser/apps/ephemeral_app_throttle.cc b/chrome/browser/apps/ephemeral_app_throttle.cc
index fafda3f..ec19909 100644
--- a/chrome/browser/apps/ephemeral_app_throttle.cc
+++ b/chrome/browser/apps/ephemeral_app_throttle.cc
@@ -30,7 +30,7 @@ namespace {
bool LaunchEphemeralApp(
const std::string& app_id,
- content::RenderViewHost* source,
+ content::WebContents* source,
const navigation_interception::NavigationParams& params) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -38,12 +38,8 @@ bool LaunchEphemeralApp(
if (source->IsSubframe())
return false;
- WebContents* web_contents = WebContents::FromRenderViewHost(source);
- if (!web_contents)
- return false;
-
Profile* profile =
- Profile::FromBrowserContext(web_contents->GetBrowserContext());
+ Profile::FromBrowserContext(source->GetBrowserContext());
if (!profile)
return false;
@@ -56,7 +52,7 @@ bool LaunchEphemeralApp(
// If the app is already installed, launch it.
AppLaunchParams params(profile, extension, NEW_FOREGROUND_TAB);
params.desktop_type = chrome::GetHostDesktopTypeForNativeView(
- web_contents->GetView()->GetNativeView());
+ source->GetView()->GetNativeView());
OpenApplication(params);
return true;
}
@@ -64,7 +60,7 @@ bool LaunchEphemeralApp(
if (!extension) {
// Install ephemeral app and launch.
scoped_refptr<EphemeralAppLauncher> installer =
- EphemeralAppLauncher::CreateForLink(app_id, web_contents);
+ EphemeralAppLauncher::CreateForLink(app_id, source);
installer->Start();
return true;
}
diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc
index ab8c843..b350afc 100644
--- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc
+++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc
@@ -92,14 +92,14 @@ TEST(WebRequestConditionAttributeTest, ResourceType) {
net::TestURLRequest url_request_ok(
GURL("http://www.example.com"), net::DEFAULT_PRIORITY, NULL, &context);
content::ResourceRequestInfo::AllocateForTesting(
- &url_request_ok, ResourceType::SUB_FRAME, NULL, -1, -1, false);
+ &url_request_ok, ResourceType::SUB_FRAME, NULL, -1, -1, -1, false);
EXPECT_TRUE(attribute->IsFulfilled(WebRequestData(&url_request_ok,
ON_BEFORE_REQUEST)));
net::TestURLRequest url_request_fail(
GURL("http://www.example.com"), net::DEFAULT_PRIORITY, NULL, &context);
content::ResourceRequestInfo::AllocateForTesting(
- &url_request_fail, ResourceType::MAIN_FRAME, NULL, -1, -1, false);
+ &url_request_fail, ResourceType::MAIN_FRAME, NULL, -1, -1, -1, false);
EXPECT_FALSE(attribute->IsFulfilled(WebRequestData(&url_request_fail,
ON_BEFORE_REQUEST)));
}
diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_unittest.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_unittest.cc
index 8531a15..d49a32d 100644
--- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_unittest.cc
+++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_unittest.cc
@@ -84,7 +84,7 @@ TEST(WebRequestConditionTest, CreateCondition) {
request_data.url_match_ids = matcher.MatchURL(http_url);
EXPECT_EQ(1u, request_data.url_match_ids.size());
content::ResourceRequestInfo::AllocateForTesting(
- &match_request, ResourceType::MAIN_FRAME, NULL, -1, -1, false);
+ &match_request, ResourceType::MAIN_FRAME, NULL, -1, -1, -1, false);
EXPECT_TRUE(result->IsFulfilled(request_data));
const GURL https_url("https://www.example.com");
@@ -95,7 +95,7 @@ TEST(WebRequestConditionTest, CreateCondition) {
// Make sure IsFulfilled does not fail because of URL matching.
EXPECT_EQ(1u, request_data.url_match_ids.size());
content::ResourceRequestInfo::AllocateForTesting(
- &wrong_resource_type, ResourceType::SUB_FRAME, NULL, -1, -1, false);
+ &wrong_resource_type, ResourceType::SUB_FRAME, NULL, -1, -1, -1, false);
EXPECT_FALSE(result->IsFulfilled(request_data));
}
@@ -135,7 +135,7 @@ TEST(WebRequestConditionTest, CreateConditionFirstPartyForCookies) {
request_data.first_party_url_match_ids = matcher.MatchURL(first_party_url);
EXPECT_EQ(1u, request_data.first_party_url_match_ids.size());
content::ResourceRequestInfo::AllocateForTesting(
- &match_request, ResourceType::MAIN_FRAME, NULL, -1, -1, false);
+ &match_request, ResourceType::MAIN_FRAME, NULL, -1, -1, -1, false);
EXPECT_TRUE(result->IsFulfilled(request_data));
}
diff --git a/chrome/browser/extensions/api/web_request/web_request_permissions_unittest.cc b/chrome/browser/extensions/api/web_request/web_request_permissions_unittest.cc
index c9e03b0..4d0a4b57 100644
--- a/chrome/browser/extensions/api/web_request/web_request_permissions_unittest.cc
+++ b/chrome/browser/extensions/api/web_request/web_request_permissions_unittest.cc
@@ -11,6 +11,7 @@
#include "content/public/browser/resource_request_info.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "extensions/browser/info_map.h"
+#include "ipc/ipc_message.h"
#include "net/base/request_priority.h"
#include "net/url_request/url_request_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -128,7 +129,7 @@ TEST_F(ExtensionWebRequestHelpersTestWithThreadsTest, TestHideRequestForURL) {
non_sensitive_url, net::DEFAULT_PRIORITY, NULL, &context);
ResourceRequestInfo::AllocateForTesting(
&sensitive_request, ResourceType::SCRIPT, NULL,
- process_id, frame_id, false);
+ process_id, frame_id, MSG_ROUTING_NONE, false);
extension_info_map_->RegisterExtensionProcess(
extension_misc::kWebStoreAppId, process_id, site_instance_id);
EXPECT_TRUE(WebRequestPermissions::HideRequest(extension_info_map_.get(),
@@ -142,7 +143,7 @@ TEST_F(ExtensionWebRequestHelpersTestWithThreadsTest, TestHideRequestForURL) {
non_sensitive_url, net::DEFAULT_PRIORITY, NULL, &context);
ResourceRequestInfo::AllocateForTesting(
&sensitive_request, ResourceType::SCRIPT, NULL,
- process_id, frame_id, false);
+ process_id, frame_id, MSG_ROUTING_NONE, false);
EXPECT_TRUE(WebRequestPermissions::HideRequest(extension_info_map_.get(),
&sensitive_request));
}
diff --git a/chrome/browser/extensions/extension_protocols_unittest.cc b/chrome/browser/extensions/extension_protocols_unittest.cc
index 74e52bc..a39a89a 100644
--- a/chrome/browser/extensions/extension_protocols_unittest.cc
+++ b/chrome/browser/extensions/extension_protocols_unittest.cc
@@ -122,6 +122,7 @@ class ExtensionProtocolTest : public testing::Test {
&resource_context_,
-1,
-1,
+ -1,
false);
request->Start();
base::MessageLoop::current()->Run();
diff --git a/chrome/browser/prerender/prerender_tracker_unittest.cc b/chrome/browser/prerender/prerender_tracker_unittest.cc
index b96159a..9293d69 100644
--- a/chrome/browser/prerender/prerender_tracker_unittest.cc
+++ b/chrome/browser/prerender/prerender_tracker_unittest.cc
@@ -20,6 +20,7 @@
#include "content/public/browser/resource_request_info.h"
#include "content/public/test/test_browser_thread.h"
#include "content/test/net/url_request_mock_http_job.h"
+#include "ipc/ipc_message.h"
#include "net/base/request_priority.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_test_util.h"
@@ -534,7 +535,7 @@ TEST_F(PrerenderTrackerTest, PrerenderThrottledRedirectResume) {
&url_request_context);
content::ResourceRequestInfo::AllocateForTesting(
&request, ResourceType::IMAGE, NULL,
- kDefaultChildId, kDefaultRouteId, true);
+ kDefaultChildId, kDefaultRouteId, MSG_ROUTING_NONE, true);
// Install a prerender throttle.
PrerenderResourceThrottle throttle(&request, prerender_tracker());
@@ -574,7 +575,7 @@ TEST_F(PrerenderTrackerTest, PrerenderThrottledRedirectCancel) {
&url_request_context);
content::ResourceRequestInfo::AllocateForTesting(
&request, ResourceType::IMAGE, NULL,
- kDefaultChildId, kDefaultRouteId, true);
+ kDefaultChildId, kDefaultRouteId, MSG_ROUTING_NONE, true);
// Install a prerender throttle.
PrerenderResourceThrottle throttle(&request, prerender_tracker());
@@ -614,7 +615,7 @@ TEST_F(PrerenderTrackerTest, PrerenderThrottledRedirectMainFrame) {
&url_request_context);
content::ResourceRequestInfo::AllocateForTesting(
&request, ResourceType::MAIN_FRAME, NULL,
- kDefaultChildId, kDefaultRouteId, true);
+ kDefaultChildId, kDefaultRouteId, MSG_ROUTING_NONE, true);
// Install a prerender throttle.
PrerenderResourceThrottle throttle(&request, prerender_tracker());
@@ -653,7 +654,7 @@ TEST_F(PrerenderTrackerTest, PrerenderThrottledRedirectSyncXHR) {
&url_request_context);
content::ResourceRequestInfo::AllocateForTesting(
&request, ResourceType::XHR, NULL,
- kDefaultChildId, kDefaultRouteId, false);
+ kDefaultChildId, kDefaultRouteId, MSG_ROUTING_NONE, false);
// Install a prerender throttle.
PrerenderResourceThrottle throttle(&request, prerender_tracker());
diff --git a/chrome/browser/search/iframe_source_unittest.cc b/chrome/browser/search/iframe_source_unittest.cc
index cf40af7..899b168 100644
--- a/chrome/browser/search/iframe_source_unittest.cc
+++ b/chrome/browser/search/iframe_source_unittest.cc
@@ -14,6 +14,7 @@
#include "content/public/test/mock_resource_context.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "grit/browser_resources.h"
+#include "ipc/ipc_message.h"
#include "net/base/request_priority.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
@@ -107,6 +108,7 @@ class IframeSourceTest : public testing::Test {
&resource_context_,
render_process_id,
render_view_id,
+ MSG_ROUTING_NONE,
false);
}
return request;
diff --git a/chrome/browser/task_manager/guest_resource_provider.cc b/chrome/browser/task_manager/guest_resource_provider.cc
index 787029a..b27678b 100644
--- a/chrome/browser/task_manager/guest_resource_provider.cc
+++ b/chrome/browser/task_manager/guest_resource_provider.cc
@@ -138,7 +138,8 @@ void GuestResourceProvider::StartUpdating() {
while (content::RenderWidgetHost* widget = widgets->GetNextHost()) {
if (widget->IsRenderView()) {
RenderViewHost* rvh = RenderViewHost::From(widget);
- if (rvh->IsSubframe())
+ WebContents* web_contents = WebContents::FromRenderViewHost(rvh);
+ if (web_contents->IsSubframe())
Add(rvh);
}
}
@@ -190,7 +191,7 @@ void GuestResourceProvider::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
WebContents* web_contents = content::Source<WebContents>(source).ptr();
- if (!web_contents || !web_contents->GetRenderViewHost()->IsSubframe())
+ if (!web_contents || !web_contents->IsSubframe())
return;
switch (type) {
diff --git a/chrome/browser/ui/blocked_content/blocked_window_params.cc b/chrome/browser/ui/blocked_content/blocked_window_params.cc
index f05f8e8..69fdaea 100644
--- a/chrome/browser/ui/blocked_content/blocked_window_params.cc
+++ b/chrome/browser/ui/blocked_content/blocked_window_params.cc
@@ -6,7 +6,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
-#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "third_party/WebKit/public/web/WebWindowFeatures.h"
@@ -34,8 +34,7 @@ BlockedWindowParams::BlockedWindowParams(
chrome::NavigateParams BlockedWindowParams::CreateNavigateParams(
content::WebContents* web_contents) const {
GURL popup_url(target_url_);
- content::RenderViewHost::FilterURL(
- web_contents->GetRenderProcessHost(), false, &popup_url);
+ web_contents->GetRenderProcessHost()->FilterURL(false, &popup_url);
chrome::NavigateParams nav_params(
Profile::FromBrowserContext(web_contents->GetBrowserContext()),
popup_url,
diff --git a/components/navigation_interception/intercept_navigation_delegate.cc b/components/navigation_interception/intercept_navigation_delegate.cc
index 2b126af..bf6dbab 100644
--- a/components/navigation_interception/intercept_navigation_delegate.cc
+++ b/components/navigation_interception/intercept_navigation_delegate.cc
@@ -30,16 +30,13 @@ namespace {
const void* kInterceptNavigationDelegateUserDataKey =
&kInterceptNavigationDelegateUserDataKey;
-bool CheckIfShouldIgnoreNavigationOnUIThread(RenderViewHost* source,
+bool CheckIfShouldIgnoreNavigationOnUIThread(WebContents* source,
const NavigationParams& params) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(source);
- WebContents* web_contents = WebContents::FromRenderViewHost(source);
- if (!web_contents)
- return false;
InterceptNavigationDelegate* intercept_navigation_delegate =
- InterceptNavigationDelegate::Get(web_contents);
+ InterceptNavigationDelegate::Get(source);
if (!intercept_navigation_delegate)
return false;
diff --git a/components/navigation_interception/intercept_navigation_resource_throttle.cc b/components/navigation_interception/intercept_navigation_resource_throttle.cc
index 3cbdad6..5a3d9d4 100644
--- a/components/navigation_interception/intercept_navigation_resource_throttle.cc
+++ b/components/navigation_interception/intercept_navigation_resource_throttle.cc
@@ -7,10 +7,11 @@
#include "components/navigation_interception/navigation_params.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
+#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
-#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_controller.h"
#include "content/public/browser/resource_request_info.h"
+#include "content/public/browser/web_contents.h"
#include "content/public/common/page_transition_types.h"
#include "content/public/common/referrer.h"
#include "net/http/http_response_headers.h"
@@ -20,7 +21,7 @@ using content::BrowserThread;
using content::ChildProcessSecurityPolicy;
using content::PageTransition;
using content::Referrer;
-using content::RenderViewHost;
+using content::RenderProcessHost;
using content::ResourceRequestInfo;
namespace navigation_interception {
@@ -29,22 +30,23 @@ namespace {
void CheckIfShouldIgnoreNavigationOnUIThread(
int render_process_id,
- int render_view_id,
+ int render_frame_id,
const NavigationParams& navigation_params,
InterceptNavigationResourceThrottle::CheckOnUIThreadCallback
should_ignore_callback,
base::Callback<void(bool)> callback) {
-
bool should_ignore_navigation = false;
- RenderViewHost* rvh =
- RenderViewHost::FromID(render_process_id, render_view_id);
-
- if (rvh) {
+ RenderProcessHost* rph = RenderProcessHost::FromID(render_process_id);
+ if (rph) {
NavigationParams validated_params(navigation_params);
- RenderViewHost::FilterURL(
- rvh->GetProcess(), false, &validated_params.url());
+ rph->FilterURL(false, &validated_params.url());
+
+ content::RenderFrameHost* render_frame_host =
+ content::RenderFrameHost::FromID(render_process_id, render_frame_id);
+ content::WebContents* web_contents =
+ content::WebContents::FromRenderFrameHost(render_frame_host);
- should_ignore_navigation = should_ignore_callback.Run(rvh,
+ should_ignore_navigation = should_ignore_callback.Run(web_contents,
validated_params);
}
@@ -100,8 +102,8 @@ bool InterceptNavigationResourceThrottle::CheckIfShouldIgnoreNavigation(
if (!info)
return false;
- int render_process_id, render_view_id;
- if (!info->GetAssociatedRenderView(&render_process_id, &render_view_id))
+ int render_process_id, render_frame_id;
+ if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_id))
return false;
NavigationParams navigation_params(url,
@@ -118,7 +120,7 @@ bool InterceptNavigationResourceThrottle::CheckIfShouldIgnoreNavigation(
base::Bind(
&CheckIfShouldIgnoreNavigationOnUIThread,
render_process_id,
- render_view_id,
+ render_frame_id,
navigation_params,
should_ignore_callback_,
base::Bind(
diff --git a/components/navigation_interception/intercept_navigation_resource_throttle.h b/components/navigation_interception/intercept_navigation_resource_throttle.h
index f4d2bf7..2e80ca0 100644
--- a/components/navigation_interception/intercept_navigation_resource_throttle.h
+++ b/components/navigation_interception/intercept_navigation_resource_throttle.h
@@ -14,7 +14,7 @@
class GURL;
namespace content {
-class RenderViewHost;
+class WebContents;
}
namespace net {
@@ -30,7 +30,7 @@ class NavigationParams;
class InterceptNavigationResourceThrottle : public content::ResourceThrottle {
public:
typedef base::Callback<bool(
- content::RenderViewHost* /* source */,
+ content::WebContents* /* source */,
const NavigationParams& /* navigation_params */)>
CheckOnUIThreadCallback;
diff --git a/components/navigation_interception/intercept_navigation_resource_throttle_unittest.cc b/components/navigation_interception/intercept_navigation_resource_throttle_unittest.cc
index 86970564..fd6f9da 100644
--- a/components/navigation_interception/intercept_navigation_resource_throttle_unittest.cc
+++ b/components/navigation_interception/intercept_navigation_resource_throttle_unittest.cc
@@ -10,6 +10,7 @@
#include "components/navigation_interception/intercept_navigation_resource_throttle.h"
#include "components/navigation_interception/navigation_params.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/resource_controller.h"
@@ -65,7 +66,7 @@ MATCHER(NavigationParamsUrlIsSafe, "") {
class MockInterceptCallbackReceiver {
public:
MOCK_METHOD2(ShouldIgnoreNavigation,
- bool(content::RenderViewHost* source,
+ bool(content::WebContents* source,
const NavigationParams& navigation_params));
};
@@ -114,7 +115,7 @@ class TestIOThreadState {
public:
TestIOThreadState(const GURL& url,
int render_process_id,
- int render_view_id,
+ int render_frame_id,
const std::string& request_method,
RedirectMode redirect_mode,
MockInterceptCallbackReceiver* callback_receiver)
@@ -125,13 +126,14 @@ class TestIOThreadState {
resource_context_.GetRequestContext()) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
if (render_process_id != MSG_ROUTING_NONE &&
- render_view_id != MSG_ROUTING_NONE) {
+ render_frame_id != MSG_ROUTING_NONE) {
content::ResourceRequestInfo::AllocateForTesting(
&request_,
ResourceType::MAIN_FRAME,
&resource_context_,
render_process_id,
- render_view_id,
+ MSG_ROUTING_NONE,
+ render_frame_id,
false);
}
throttle_.reset(new InterceptNavigationResourceThrottle(
@@ -210,11 +212,11 @@ class InterceptNavigationResourceThrottleTest
const std::string& request_method,
RedirectMode redirect_mode,
int render_process_id,
- int render_view_id,
+ int render_frame_id,
bool* defer) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
TestIOThreadState* io_thread_state =
- new TestIOThreadState(url, render_process_id, render_view_id,
+ new TestIOThreadState(url, render_process_id, render_frame_id,
request_method, redirect_mode,
mock_callback_receiver_.get());
@@ -238,7 +240,8 @@ class InterceptNavigationResourceThrottleTest
ON_CALL(*mock_callback_receiver_, ShouldIgnoreNavigation(_, _))
.WillByDefault(Return(callback_action == IgnoreNavigation));
EXPECT_CALL(*mock_callback_receiver_,
- ShouldIgnoreNavigation(rvh(), NavigationParamsUrlIsTest()))
+ ShouldIgnoreNavigation(web_contents(),
+ NavigationParamsUrlIsTest()))
.Times(1);
content::BrowserThread::PostTask(
@@ -252,7 +255,7 @@ class InterceptNavigationResourceThrottleTest
"GET",
REDIRECT_MODE_NO_REDIRECT,
web_contents()->GetRenderViewHost()->GetProcess()->GetID(),
- web_contents()->GetRenderViewHost()->GetRoutingID(),
+ web_contents()->GetMainFrame()->GetRoutingID(),
base::Unretained(defer)));
// Wait for the request to finish processing.
@@ -317,7 +320,7 @@ TEST_F(InterceptNavigationResourceThrottleTest,
"GET",
REDIRECT_MODE_NO_REDIRECT,
web_contents()->GetRenderViewHost()->GetProcess()->GetID(),
- web_contents()->GetRenderViewHost()->GetRoutingID(),
+ web_contents()->GetMainFrame()->GetRoutingID(),
base::Unretained(&defer)));
content::BrowserThread::PostTask(
@@ -382,7 +385,7 @@ TEST_F(InterceptNavigationResourceThrottleTest,
"GET",
REDIRECT_MODE_NO_REDIRECT,
web_contents()->GetRenderViewHost()->GetProcess()->GetID(),
- web_contents()->GetRenderViewHost()->GetRoutingID(),
+ web_contents()->GetMainFrame()->GetRoutingID(),
base::Unretained(&defer)));
// Wait for the request to finish processing.
@@ -410,7 +413,7 @@ TEST_F(InterceptNavigationResourceThrottleTest,
"GET",
REDIRECT_MODE_NO_REDIRECT,
web_contents()->GetRenderViewHost()->GetProcess()->GetID(),
- web_contents()->GetRenderViewHost()->GetRoutingID(),
+ web_contents()->GetMainFrame()->GetRoutingID(),
base::Unretained(&defer)));
// Wait for the request to finish processing.
@@ -438,7 +441,7 @@ TEST_F(InterceptNavigationResourceThrottleTest,
"POST",
REDIRECT_MODE_NO_REDIRECT,
web_contents()->GetRenderViewHost()->GetProcess()->GetID(),
- web_contents()->GetRenderViewHost()->GetRoutingID(),
+ web_contents()->GetMainFrame()->GetRoutingID(),
base::Unretained(&defer)));
// Wait for the request to finish processing.
@@ -466,7 +469,7 @@ TEST_F(InterceptNavigationResourceThrottleTest,
"POST",
REDIRECT_MODE_302,
web_contents()->GetRenderViewHost()->GetProcess()->GetID(),
- web_contents()->GetRenderViewHost()->GetRoutingID(),
+ web_contents()->GetMainFrame()->GetRoutingID(),
base::Unretained(&defer)));
// Wait for the request to finish processing.
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc
index 065dcec..0e6ba06 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.cc
+++ b/content/browser/browser_plugin/browser_plugin_guest.cc
@@ -1452,10 +1452,7 @@ void BrowserPluginGuest::OnNavigateGuest(
}
GURL validated_url(url);
- RenderViewHost::FilterURL(
- GetWebContents()->GetRenderProcessHost(),
- false,
- &validated_url);
+ GetWebContents()->GetRenderProcessHost()->FilterURL(false, &validated_url);
// As guests do not swap processes on navigation, only navigations to
// normal web URLs are supported. No protocol handlers are installed for
// other schemes (e.g., WebUI or extensions), and no permissions or bindings
diff --git a/content/browser/browser_plugin/browser_plugin_guest_manager.cc b/content/browser/browser_plugin/browser_plugin_guest_manager.cc
index 82d0565..d16d11a 100644
--- a/content/browser/browser_plugin/browser_plugin_guest_manager.cc
+++ b/content/browser/browser_plugin/browser_plugin_guest_manager.cc
@@ -11,6 +11,7 @@
#include "content/common/browser_plugin/browser_plugin_constants.h"
#include "content/common/browser_plugin/browser_plugin_messages.h"
#include "content/common/content_export.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/common/result_codes.h"
#include "content/public/common/url_constants.h"
@@ -62,8 +63,7 @@ BrowserPluginGuest* BrowserPluginGuestManager::CreateGuest(
// iframe's URL to determine the extension.
const GURL& embedder_site_url = embedder_site_instance->GetSiteURL();
GURL validated_frame_url(params.embedder_frame_url);
- RenderViewHost::FilterURL(
- embedder_process_host, false, &validated_frame_url);
+ embedder_process_host->FilterURL(false, &validated_frame_url);
const std::string& host = content::HasWebUIScheme(embedder_site_url) ?
validated_frame_url.host() : embedder_site_url.host();
diff --git a/content/browser/frame_host/navigator_impl.cc b/content/browser/frame_host/navigator_impl.cc
index f1ee1c9..362f64c 100644
--- a/content/browser/frame_host/navigator_impl.cc
+++ b/content/browser/frame_host/navigator_impl.cc
@@ -38,7 +38,7 @@ void NavigatorImpl::DidStartProvisionalLoad(
bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL);
GURL validated_url(url);
RenderProcessHost* render_process_host = render_frame_host->GetProcess();
- RenderViewHost::FilterURL(render_process_host, false, &validated_url);
+ render_process_host->FilterURL(false, &validated_url);
// TODO(creis): This is a hack for now, until we mirror the frame tree and do
// cross-process subframe navigations in actual subframes. As a result, we
diff --git a/content/browser/loader/resource_loader_unittest.cc b/content/browser/loader/resource_loader_unittest.cc
index 8f96211..0132d5d 100644
--- a/content/browser/loader/resource_loader_unittest.cc
+++ b/content/browser/loader/resource_loader_unittest.cc
@@ -11,6 +11,7 @@
#include "content/public/test/mock_resource_context.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "content/test/test_content_browser_client.h"
+#include "ipc/ipc_message.h"
#include "net/base/request_priority.h"
#include "net/cert/x509_certificate.h"
#include "net/ssl/client_cert_store.h"
@@ -222,6 +223,7 @@ TEST_F(ResourceLoaderTest, ClientCertStoreLookup) {
&resource_context_,
kRenderProcessId,
kRenderViewId,
+ MSG_ROUTING_NONE,
false);
// Set up the test client cert store.
@@ -287,6 +289,7 @@ TEST_F(ResourceLoaderTest, ClientCertStoreNull) {
&resource_context_,
kRenderProcessId,
kRenderViewId,
+ MSG_ROUTING_NONE,
false);
// Ownership of the |request| is about to be turned over to ResourceLoader. We
diff --git a/content/browser/loader/resource_request_info_impl.cc b/content/browser/loader/resource_request_info_impl.cc
index c1ccc91..71e748f 100644
--- a/content/browser/loader/resource_request_info_impl.cc
+++ b/content/browser/loader/resource_request_info_impl.cc
@@ -29,6 +29,7 @@ void ResourceRequestInfo::AllocateForTesting(
ResourceContext* context,
int render_process_id,
int render_view_id,
+ int render_frame_id,
bool is_async) {
ResourceRequestInfoImpl* info =
new ResourceRequestInfoImpl(
@@ -37,7 +38,7 @@ void ResourceRequestInfo::AllocateForTesting(
render_view_id, // route_id
0, // origin_pid
0, // request_id
- MSG_ROUTING_NONE, // render_frame_id
+ render_frame_id, // render_frame_id
resource_type == ResourceType::MAIN_FRAME, // is_main_frame
0, // frame_id
false, // parent_is_main_frame
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index c058bbc..c841640 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -1498,6 +1498,10 @@ void RenderProcessHostImpl::ResumeRequestsForView(int route_id) {
widget_helper_->ResumeRequestsForView(route_id);
}
+void RenderProcessHostImpl::FilterURL(bool empty_allowed, GURL* url) {
+ FilterURL(this, empty_allowed, url);
+}
+
#if defined(ENABLE_WEBRTC)
void RenderProcessHostImpl::EnableAecDump(const base::FilePath& file) {
BrowserThread::PostTaskAndReplyWithResult(
@@ -1559,6 +1563,53 @@ void RenderProcessHostImpl::UnregisterHost(int host_id) {
}
// static
+void RenderProcessHostImpl::FilterURL(RenderProcessHost* rph,
+ bool empty_allowed,
+ GURL* url) {
+ ChildProcessSecurityPolicyImpl* policy =
+ ChildProcessSecurityPolicyImpl::GetInstance();
+
+ if (empty_allowed && url->is_empty())
+ return;
+
+ // The browser process should never hear the swappedout:// URL from any
+ // of the renderer's messages. Check for this in debug builds, but don't
+ // let it crash a release browser.
+ DCHECK(GURL(kSwappedOutURL) != *url);
+
+ if (!url->is_valid()) {
+ // Have to use about:blank for the denied case, instead of an empty GURL.
+ // This is because the browser treats navigation to an empty GURL as a
+ // navigation to the home page. This is often a privileged page
+ // (chrome://newtab/) which is exactly what we don't want.
+ *url = GURL(kAboutBlankURL);
+ RecordAction(UserMetricsAction("FilterURLTermiate_Invalid"));
+ return;
+ }
+
+ if (url->SchemeIs(chrome::kAboutScheme)) {
+ // The renderer treats all URLs in the about: scheme as being about:blank.
+ // Canonicalize about: URLs to about:blank.
+ *url = GURL(kAboutBlankURL);
+ RecordAction(UserMetricsAction("FilterURLTermiate_About"));
+ }
+
+ // Do not allow browser plugin guests to navigate to non-web URLs, since they
+ // cannot swap processes or grant bindings.
+ bool non_web_url_in_guest = rph->IsGuest() &&
+ !(url->is_valid() && policy->IsWebSafeScheme(url->scheme()));
+
+ if (non_web_url_in_guest || !policy->CanRequestURL(rph->GetID(), *url)) {
+ // If this renderer is not permitted to request this URL, we invalidate the
+ // URL. This prevents us from storing the blocked URL and becoming confused
+ // later.
+ VLOG(1) << "Blocked URL " << url->spec();
+ *url = GURL(kAboutBlankURL);
+ RecordAction(UserMetricsAction("FilterURLTermiate_Blocked"));
+ }
+}
+
+// static
bool RenderProcessHostImpl::IsSuitableHost(
RenderProcessHost* host,
BrowserContext* browser_context,
diff --git a/content/browser/renderer_host/render_process_host_impl.h b/content/browser/renderer_host/render_process_host_impl.h
index 63d0522..cb8a35f 100644
--- a/content/browser/renderer_host/render_process_host_impl.h
+++ b/content/browser/renderer_host/render_process_host_impl.h
@@ -121,6 +121,7 @@ class CONTENT_EXPORT RenderProcessHostImpl
virtual base::TimeDelta GetChildProcessIdleTime() const OVERRIDE;
virtual void SurfaceUpdated(int32 surface_id) OVERRIDE;
virtual void ResumeRequestsForView(int route_id) OVERRIDE;
+ virtual void FilterURL(bool empty_allowed, GURL* url) OVERRIDE;
#if defined(ENABLE_WEBRTC)
virtual void EnableAecDump(const base::FilePath& file) OVERRIDE;
virtual void DisableAecDump() OVERRIDE;
@@ -170,6 +171,9 @@ class CONTENT_EXPORT RenderProcessHostImpl
static void RegisterHost(int host_id, RenderProcessHost* host);
static void UnregisterHost(int host_id);
+ // Implementation of FilterURL below that can be shared with the mock class.
+ static void FilterURL(RenderProcessHost* rph, bool empty_allowed, GURL* url);
+
// Returns true if |host| is suitable for launching a new view with |site_url|
// in the given |browser_context|.
static bool IsSuitableHost(RenderProcessHost* host,
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc
index fcdf375..27ebdd6 100644
--- a/content/browser/renderer_host/render_view_host_impl.cc
+++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -157,14 +157,6 @@ RenderViewHost* RenderViewHost::From(RenderWidgetHost* rwh) {
return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(rwh));
}
-// static
-void RenderViewHost::FilterURL(const RenderProcessHost* process,
- bool empty_allowed,
- GURL* url) {
- RenderViewHostImpl::FilterURL(ChildProcessSecurityPolicyImpl::GetInstance(),
- process, empty_allowed, url);
-}
-
///////////////////////////////////////////////////////////////////////////////
// RenderViewHostImpl, public:
@@ -197,7 +189,6 @@ RenderViewHostImpl::RenderViewHostImpl(
navigations_suspended_(false),
has_accessed_initial_document_(false),
is_swapped_out_(swapped_out),
- is_subframe_(false),
main_frame_id_(-1),
main_frame_routing_id_(main_frame_routing_id),
run_modal_reply_msg_(NULL),
@@ -323,10 +314,6 @@ bool RenderViewHostImpl::IsRenderViewLive() const {
return GetProcess()->HasConnection() && renderer_initialized_;
}
-bool RenderViewHostImpl::IsSubframe() const {
- return is_subframe_;
-}
-
void RenderViewHostImpl::SyncRendererPrefs() {
Send(new ViewMsg_SetRendererPrefs(GetRoutingID(),
delegate_->GetRendererPrefs(
@@ -891,7 +878,7 @@ void RenderViewHostImpl::DragTargetDragEnter(
// The URL could have been cobbled together from any highlighted text string,
// and can't be interpreted as a capability.
DropData filtered_data(drop_data);
- FilterURL(policy, GetProcess(), true, &filtered_data.url);
+ GetProcess()->FilterURL(true, &filtered_data.url);
// The filenames vector, on the other hand, does represent a capability to
// access the given files.
@@ -1340,12 +1327,9 @@ void RenderViewHostImpl::CreateNewWindow(
const ViewHostMsg_CreateWindow_Params& params,
SessionStorageNamespace* session_storage_namespace) {
ViewHostMsg_CreateWindow_Params validated_params(params);
- ChildProcessSecurityPolicyImpl* policy =
- ChildProcessSecurityPolicyImpl::GetInstance();
- FilterURL(policy, GetProcess(), false, &validated_params.target_url);
- FilterURL(policy, GetProcess(), false, &validated_params.opener_url);
- FilterURL(policy, GetProcess(), true,
- &validated_params.opener_security_origin);
+ GetProcess()->FilterURL(false, &validated_params.target_url);
+ GetProcess()->FilterURL(false, &validated_params.opener_url);
+ GetProcess()->FilterURL(true, &validated_params.opener_security_origin);
delegate_->CreateNewWindow(
GetProcess()->GetID(), route_id, main_frame_route_id, validated_params,
@@ -1521,8 +1505,6 @@ void RenderViewHostImpl::OnNavigate(const IPC::Message& msg) {
// initial page has been accessed.
has_accessed_initial_document_ = false;
- ChildProcessSecurityPolicyImpl* policy =
- ChildProcessSecurityPolicyImpl::GetInstance();
// Without this check, an evil renderer can trick the browser into creating
// a navigation entry for a banned URL. If the user clicks the back button
// followed by the forward button (or clicks reload, or round-trips through
@@ -1530,13 +1512,13 @@ void RenderViewHostImpl::OnNavigate(const IPC::Message& msg) {
// renderer to load the URL and grant the renderer the privileges to request
// the URL. To prevent this attack, we block the renderer from inserting
// banned URLs into the navigation controller in the first place.
- FilterURL(policy, process, false, &validated_params.url);
- FilterURL(policy, process, true, &validated_params.referrer.url);
+ process->FilterURL(false, &validated_params.url);
+ process->FilterURL(true, &validated_params.referrer.url);
for (std::vector<GURL>::iterator it(validated_params.redirects.begin());
it != validated_params.redirects.end(); ++it) {
- FilterURL(policy, process, false, &(*it));
+ process->FilterURL(false, &(*it));
}
- FilterURL(policy, process, true, &validated_params.searchable_form_url);
+ process->FilterURL(true, &validated_params.searchable_form_url);
// Without this check, the renderer can trick the browser into using
// filenames it can't access in a future session restore.
@@ -1634,15 +1616,13 @@ void RenderViewHostImpl::OnContextMenu(const ContextMenuParams& params) {
// directly, don't show them in the context menu.
ContextMenuParams validated_params(params);
RenderProcessHost* process = GetProcess();
- ChildProcessSecurityPolicyImpl* policy =
- ChildProcessSecurityPolicyImpl::GetInstance();
// We don't validate |unfiltered_link_url| so that this field can be used
// when users want to copy the original link URL.
- FilterURL(policy, process, true, &validated_params.link_url);
- FilterURL(policy, process, true, &validated_params.src_url);
- FilterURL(policy, process, false, &validated_params.page_url);
- FilterURL(policy, process, true, &validated_params.frame_url);
+ process->FilterURL(true, &validated_params.link_url);
+ process->FilterURL(true, &validated_params.src_url);
+ process->FilterURL(false, &validated_params.page_url);
+ process->FilterURL(true, &validated_params.frame_url);
delegate_->ShowContextMenu(validated_params);
}
@@ -1658,8 +1638,7 @@ void RenderViewHostImpl::OnToggleFullscreen(bool enter_fullscreen) {
void RenderViewHostImpl::OnOpenURL(
const ViewHostMsg_OpenURL_Params& params) {
GURL validated_url(params.url);
- FilterURL(ChildProcessSecurityPolicyImpl::GetInstance(),
- GetProcess(), false, &validated_url);
+ GetProcess()->FilterURL(false, &validated_url);
delegate_->RequestOpenURL(
this, validated_url, params.referrer, params.disposition, params.frame_id,
@@ -1763,8 +1742,8 @@ void RenderViewHostImpl::OnStartDragging(
// Allow drag of Javascript URLs to enable bookmarklet drag to bookmark bar.
if (!filtered_data.url.SchemeIs(kJavaScriptScheme))
- FilterURL(policy, process, true, &filtered_data.url);
- FilterURL(policy, process, false, &filtered_data.html_base_url);
+ process->FilterURL(true, &filtered_data.url);
+ process->FilterURL(false, &filtered_data.html_base_url);
// Filter out any paths that the renderer didn't have access to. This prevents
// the following attack on a malicious renderer:
// 1. StartDragging IPC sent with renderer-specified filesystem paths that it
@@ -2010,50 +1989,6 @@ bool RenderViewHostImpl::CanCommitURL(const GURL& url) {
return GetContentClient()->browser()->CanCommitURL(GetProcess(), url);
}
-void RenderViewHostImpl::FilterURL(ChildProcessSecurityPolicyImpl* policy,
- const RenderProcessHost* process,
- bool empty_allowed,
- GURL* url) {
- if (empty_allowed && url->is_empty())
- return;
-
- // The browser process should never hear the swappedout:// URL from any
- // of the renderer's messages. Check for this in debug builds, but don't
- // let it crash a release browser.
- DCHECK(GURL(kSwappedOutURL) != *url);
-
- if (!url->is_valid()) {
- // Have to use about:blank for the denied case, instead of an empty GURL.
- // This is because the browser treats navigation to an empty GURL as a
- // navigation to the home page. This is often a privileged page
- // (chrome://newtab/) which is exactly what we don't want.
- *url = GURL(kAboutBlankURL);
- RecordAction(UserMetricsAction("FilterURLTermiate_Invalid"));
- return;
- }
-
- if (url->SchemeIs(chrome::kAboutScheme)) {
- // The renderer treats all URLs in the about: scheme as being about:blank.
- // Canonicalize about: URLs to about:blank.
- *url = GURL(kAboutBlankURL);
- RecordAction(UserMetricsAction("FilterURLTermiate_About"));
- }
-
- // Do not allow browser plugin guests to navigate to non-web URLs, since they
- // cannot swap processes or grant bindings.
- bool non_web_url_in_guest = process->IsGuest() &&
- !(url->is_valid() && policy->IsWebSafeScheme(url->scheme()));
-
- if (non_web_url_in_guest || !policy->CanRequestURL(process->GetID(), *url)) {
- // If this renderer is not permitted to request this URL, we invalidate the
- // URL. This prevents us from storing the blocked URL and becoming confused
- // later.
- VLOG(1) << "Blocked URL " << url->spec();
- *url = GURL(kAboutBlankURL);
- RecordAction(UserMetricsAction("FilterURLTermiate_Blocked"));
- }
-}
-
void RenderViewHostImpl::SetAltErrorPageURL(const GURL& url) {
Send(new ViewMsg_SetAltErrorPageURL(GetRoutingID(), url));
}
diff --git a/content/browser/renderer_host/render_view_host_impl.h b/content/browser/renderer_host/render_view_host_impl.h
index 18c643f..aed517b 100644
--- a/content/browser/renderer_host/render_view_host_impl.h
+++ b/content/browser/renderer_host/render_view_host_impl.h
@@ -195,7 +195,6 @@ class CONTENT_EXPORT RenderViewHostImpl
virtual void InsertCSS(const base::string16& frame_xpath,
const std::string& css) OVERRIDE;
virtual bool IsRenderViewLive() const OVERRIDE;
- virtual bool IsSubframe() const OVERRIDE;
virtual void NotifyContextMenuClosed(
const CustomContextMenuContext& context) OVERRIDE;
virtual void NotifyMoveOrResizeStarted() OVERRIDE;
@@ -423,12 +422,6 @@ class CONTENT_EXPORT RenderViewHostImpl
// User rotated the screen. Calls the "onorientationchange" Javascript hook.
void SendOrientationChangeEvent(int orientation);
- // Sets a bit indicating whether the RenderView is responsible for displaying
- // a subframe in a different process from its parent page.
- void set_is_subframe(bool is_subframe) {
- is_subframe_ = is_subframe;
- }
-
// TODO(creis): Remove this when we replace frame IDs with RenderFrameHost
// routing IDs.
int64 main_frame_id() const {
@@ -470,18 +463,10 @@ class CONTENT_EXPORT RenderViewHostImpl
}
// Returns whether the given URL is allowed to commit in the current process.
- // This is a more conservative check than FilterURL, since it will be used to
- // kill processes that commit unauthorized URLs.
+ // This is a more conservative check than RenderProcessHost::FilterURL, since
+ // it will be used to kill processes that commit unauthorized URLs.
bool CanCommitURL(const GURL& url);
- // Checks that the given renderer can request |url|, if not it sets it to
- // about:blank.
- // empty_allowed must be set to false for navigations for security reasons.
- static void FilterURL(ChildProcessSecurityPolicyImpl* policy,
- const RenderProcessHost* process,
- bool empty_allowed,
- GURL* url);
-
// Update the FrameTree to use this RenderViewHost's main frame
// RenderFrameHost. Called when the RenderViewHost is committed.
//
@@ -662,10 +647,6 @@ class CONTENT_EXPORT RenderViewHostImpl
// being rendered by another process.
bool is_swapped_out_;
- // Whether this RenderView is responsible for displaying a subframe in a
- // different process from its parent page.
- bool is_subframe_;
-
// The frame id of the main (top level) frame. This value is set on the
// initial navigation of a RenderView and reset when the RenderView's
// process is terminated (in RenderProcessGone).
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index aa5193d..1178bf9 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -395,7 +395,8 @@ WebContentsImpl::WebContentsImpl(
temporary_zoom_settings_(false),
color_chooser_identifier_(0),
render_view_message_source_(NULL),
- fullscreen_widget_routing_id_(MSG_ROUTING_NONE) {
+ fullscreen_widget_routing_id_(MSG_ROUTING_NONE),
+ is_subframe_(false) {
for (size_t i = 0; i < g_created_callbacks.Get().size(); i++)
g_created_callbacks.Get().at(i).Run(this);
frame_tree_.SetFrameRemoveListener(
@@ -490,8 +491,7 @@ BrowserPluginGuest* WebContentsImpl::CreateGuest(
// We are instantiating a WebContents for browser plugin. Set its subframe bit
// to true.
- static_cast<RenderViewHostImpl*>(
- new_contents->GetRenderViewHost())->set_is_subframe(true);
+ new_contents->is_subframe_ = true;
return new_contents->browser_plugin_guest_.get();
}
@@ -2122,6 +2122,10 @@ int WebContentsImpl::DownloadImage(const GURL& url,
return id;
}
+bool WebContentsImpl::IsSubframe() const {
+ return is_subframe_;
+}
+
bool WebContentsImpl::FocusLocationBarByDefault() {
NavigationEntry* entry = controller_.GetVisibleEntry();
if (entry && entry->GetURL() == GURL(kAboutBlankURL))
@@ -2177,8 +2181,8 @@ void WebContentsImpl::DidRedirectProvisionalLoad(
GURL validated_target_url(target_url);
RenderProcessHost* render_process_host =
render_view_host->GetProcess();
- RenderViewHost::FilterURL(render_process_host, false, &validated_source_url);
- RenderViewHost::FilterURL(render_process_host, false, &validated_target_url);
+ render_process_host->FilterURL(false, &validated_source_url);
+ render_process_host->FilterURL(false, &validated_target_url);
NavigationEntry* entry;
if (page_id == -1) {
entry = controller_.GetPendingEntry();
@@ -2208,7 +2212,7 @@ void WebContentsImpl::DidFailProvisionalLoadWithError(
GURL validated_url(params.url);
RenderProcessHost* render_process_host =
render_view_host->GetProcess();
- RenderViewHost::FilterURL(render_process_host, false, &validated_url);
+ render_process_host->FilterURL(false, &validated_url);
if (net::ERR_ABORTED == params.error_code) {
// EVIL HACK ALERT! Ignore failed loads when we're showing interstitials.
@@ -2343,7 +2347,7 @@ void WebContentsImpl::OnDidFinishLoad(
RenderProcessHost* render_process_host =
render_view_message_source_->GetProcess();
- RenderViewHost::FilterURL(render_process_host, false, &validated_url);
+ render_process_host->FilterURL(false, &validated_url);
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
DidFinishLoad(frame_id, validated_url, is_main_frame,
render_view_message_source_));
@@ -2358,7 +2362,7 @@ void WebContentsImpl::OnDidFailLoadWithError(
GURL validated_url(url);
RenderProcessHost* render_process_host =
render_view_message_source_->GetProcess();
- RenderViewHost::FilterURL(render_process_host, false, &validated_url);
+ render_process_host->FilterURL(false, &validated_url);
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
DidFailLoad(frame_id, validated_url, is_main_frame,
error_code, error_description,
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
index 94f7507..5a377a2 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
@@ -282,6 +282,7 @@ class CONTENT_EXPORT WebContentsImpl
bool is_favicon,
uint32_t max_bitmap_size,
const ImageDownloadCallback& callback) OVERRIDE;
+ virtual bool IsSubframe() const OVERRIDE;
#if defined(OS_ANDROID)
virtual base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents()
OVERRIDE;
@@ -1035,6 +1036,10 @@ class CONTENT_EXPORT WebContentsImpl
typedef std::map<int, ImageDownloadCallback> ImageDownloadMap;
ImageDownloadMap image_download_map_;
+ // Whether this RenderView is responsible for displaying a subframe in a
+ // different process from its parent page.
+ bool is_subframe_;
+
DISALLOW_COPY_AND_ASSIGN(WebContentsImpl);
};
diff --git a/content/public/browser/render_process_host.h b/content/public/browser/render_process_host.h
index 6ddf375..16f0141 100644
--- a/content/public/browser/render_process_host.h
+++ b/content/public/browser/render_process_host.h
@@ -210,6 +210,11 @@ class CONTENT_EXPORT RenderProcessHost : public IPC::Sender,
// were initially blocked.
virtual void ResumeRequestsForView(int route_id) = 0;
+ // Checks that the given renderer can request |url|, if not it sets it to
+ // about:blank.
+ // |empty_allowed| must be set to false for navigations for security reasons.
+ virtual void FilterURL(bool empty_allowed, GURL* url) = 0;
+
#if defined(ENABLE_WEBRTC)
virtual void EnableAecDump(const base::FilePath& file) = 0;
virtual void DisableAecDump() = 0;
diff --git a/content/public/browser/render_view_host.h b/content/public/browser/render_view_host.h
index 366ad0d..e074441 100644
--- a/content/public/browser/render_view_host.h
+++ b/content/public/browser/render_view_host.h
@@ -44,7 +44,6 @@ struct WebPluginAction;
namespace content {
class ChildProcessSecurityPolicy;
-class RenderProcessHost;
class RenderViewHostDelegate;
class SessionStorageNamespace;
class SiteInstance;
@@ -72,13 +71,6 @@ class CONTENT_EXPORT RenderViewHost : virtual public RenderWidgetHost {
// because RenderWidgetHost is a virtual base class.
static RenderViewHost* From(RenderWidgetHost* rwh);
- // Checks that the given renderer can request |url|, if not it sets it to
- // about:blank.
- // |empty_allowed| must be set to false for navigations for security reasons.
- static void FilterURL(const RenderProcessHost* process,
- bool empty_allowed,
- GURL* url);
-
virtual ~RenderViewHost() {}
// Tell the render view to enable a set of javascript bindings. The argument
@@ -230,10 +222,6 @@ class CONTENT_EXPORT RenderViewHost : virtual public RenderWidgetHost {
// because it is overridden by TestRenderViewHost.
virtual bool IsRenderViewLive() const = 0;
- // Returns true if the RenderView is responsible for displaying a subframe
- // in a different process from its parent page.
- virtual bool IsSubframe() const = 0;
-
// Let the renderer know that the menu has been closed.
virtual void NotifyContextMenuClosed(
const CustomContextMenuContext& context) = 0;
diff --git a/content/public/browser/resource_request_info.h b/content/public/browser/resource_request_info.h
index d564082..e5ab6c6 100644
--- a/content/public/browser/resource_request_info.h
+++ b/content/public/browser/resource_request_info.h
@@ -35,6 +35,7 @@ class ResourceRequestInfo {
ResourceContext* context,
int render_process_id,
int render_view_id,
+ int render_frame_id,
bool is_async);
// Returns the associated RenderFrame for a given process. Returns false, if
diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h
index bf28b8c..6beb47f 100644
--- a/content/public/browser/web_contents.h
+++ b/content/public/browser/web_contents.h
@@ -476,6 +476,10 @@ class WebContents : public PageNavigator,
uint32_t max_bitmap_size,
const ImageDownloadCallback& callback) = 0;
+ // Returns true if the WebContents is responsible for displaying a subframe
+ // in a different process from its parent page.
+ virtual bool IsSubframe() const = 0;
+
#if defined(OS_ANDROID)
CONTENT_EXPORT static WebContents* FromJavaWebContents(
jobject jweb_contents_android);
diff --git a/content/public/test/mock_render_process_host.cc b/content/public/test/mock_render_process_host.cc
index c579b66..7989dbc 100644
--- a/content/public/test/mock_render_process_host.cc
+++ b/content/public/test/mock_render_process_host.cc
@@ -256,6 +256,10 @@ void MockRenderProcessHost::SurfaceUpdated(int32 surface_id) {
void MockRenderProcessHost::ResumeRequestsForView(int route_id) {
}
+void MockRenderProcessHost::FilterURL(bool empty_allowed, GURL* url) {
+ RenderProcessHostImpl::FilterURL(this, empty_allowed, url);
+}
+
#if defined(ENABLE_WEBRTC)
void MockRenderProcessHost::EnableAecDump(const base::FilePath& file) {
}
diff --git a/content/public/test/mock_render_process_host.h b/content/public/test/mock_render_process_host.h
index c9f20fa..b3d2cad 100644
--- a/content/public/test/mock_render_process_host.h
+++ b/content/public/test/mock_render_process_host.h
@@ -75,6 +75,7 @@ class MockRenderProcessHost : public RenderProcessHost {
virtual base::TimeDelta GetChildProcessIdleTime() const OVERRIDE;
virtual void SurfaceUpdated(int32 surface_id) OVERRIDE;
virtual void ResumeRequestsForView(int route_id) OVERRIDE;
+ virtual void FilterURL(bool empty_allowed, GURL* url) OVERRIDE;
#if defined(ENABLE_WEBRTC)
virtual void EnableAecDump(const base::FilePath& file) OVERRIDE;
virtual void DisableAecDump() OVERRIDE;