summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/browser_url_handler.cc11
-rw-r--r--content/browser/child_process_security_policy_unittest.cc15
-rw-r--r--content/browser/mock_content_browser_client.cc4
-rw-r--r--content/browser/mock_content_browser_client.h1
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host_uitest.cc2
-rw-r--r--content/browser/site_instance_impl.cc6
-rw-r--r--content/browser/site_instance_impl_unittest.cc13
-rw-r--r--content/browser/tab_contents/debug_urls.cc50
-rw-r--r--content/browser/tab_contents/debug_urls.h21
-rw-r--r--content/browser/tab_contents/navigation_controller_impl.cc4
10 files changed, 94 insertions, 33 deletions
diff --git a/content/browser/browser_url_handler.cc b/content/browser/browser_url_handler.cc
index c42024d..8bcb2d6 100644
--- a/content/browser/browser_url_handler.cc
+++ b/content/browser/browser_url_handler.cc
@@ -59,6 +59,15 @@ static bool ReverseViewSource(GURL* url,
return true;
}
+static bool HandleDebugUrl(GURL* url,
+ content::BrowserContext* browser_context) {
+ // Circumvent processing URLs that the renderer process will handle.
+ return *url == GURL(chrome::kChromeUICrashURL) ||
+ *url == GURL(chrome::kChromeUIHangURL) ||
+ *url == GURL(chrome::kChromeUIKillURL) ||
+ *url == GURL(chrome::kChromeUIShorthangURL);
+}
+
// static
BrowserURLHandler* BrowserURLHandler::GetInstance() {
return Singleton<BrowserURLHandler>::get();
@@ -77,6 +86,8 @@ BrowserURLHandler::URLHandler BrowserURLHandler::null_handler() {
}
BrowserURLHandler::BrowserURLHandler() {
+ AddHandlerPair(&HandleDebugUrl, BrowserURLHandler::null_handler());
+
content::GetContentClient()->browser()->BrowserURLHandlerCreated(this);
// view-source:
diff --git a/content/browser/child_process_security_policy_unittest.cc b/content/browser/child_process_security_policy_unittest.cc
index 032978f..02ebfa2 100644
--- a/content/browser/child_process_security_policy_unittest.cc
+++ b/content/browser/child_process_security_policy_unittest.cc
@@ -163,18 +163,9 @@ TEST_F(ChildProcessSecurityPolicyTest, AboutTest) {
EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:CrASh")));
EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("abOuT:cAChe")));
- // These requests for about: pages should be denied.
- p->GrantRequestURL(kRendererID, GURL(chrome::kTestGpuCleanURL));
- EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kTestGpuCleanURL)));
-
- p->GrantRequestURL(kRendererID, GURL(chrome::kAboutCrashURL));
- EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kAboutCrashURL)));
-
- p->GrantRequestURL(kRendererID, GURL(chrome::kTestCacheURL));
- EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kTestCacheURL)));
-
- p->GrantRequestURL(kRendererID, GURL(chrome::kTestHangURL));
- EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kTestHangURL)));
+ // Requests for about: pages should be denied.
+ p->GrantRequestURL(kRendererID, GURL("about:crash"));
+ EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:crash")));
// These requests for chrome:// pages should be granted.
p->GrantRequestURL(kRendererID, GURL(chrome::kTestNewTabURL));
diff --git a/content/browser/mock_content_browser_client.cc b/content/browser/mock_content_browser_client.cc
index 6b6bb9d..d5b8547 100644
--- a/content/browser/mock_content_browser_client.cc
+++ b/content/browser/mock_content_browser_client.cc
@@ -53,10 +53,6 @@ bool MockContentBrowserClient::ShouldUseProcessPerSite(
return false;
}
-bool MockContentBrowserClient::IsURLSameAsAnySiteInstance(const GURL& url) {
- return false;
-}
-
bool MockContentBrowserClient::IsHandledURL(const GURL& url) {
return false;
}
diff --git a/content/browser/mock_content_browser_client.h b/content/browser/mock_content_browser_client.h
index f0a960f..4a0aaf3 100644
--- a/content/browser/mock_content_browser_client.h
+++ b/content/browser/mock_content_browser_client.h
@@ -34,7 +34,6 @@ class MockContentBrowserClient : public ContentBrowserClient {
const GURL& url) OVERRIDE;
virtual bool ShouldUseProcessPerSite(BrowserContext* browser_context,
const GURL& effective_url) OVERRIDE;
- virtual bool IsURLSameAsAnySiteInstance(const GURL& url) OVERRIDE;
virtual bool IsHandledURL(const GURL& url) OVERRIDE;
virtual bool IsSuitableHost(RenderProcessHost* process_host,
const GURL& site_url) OVERRIDE;
diff --git a/content/browser/renderer_host/resource_dispatcher_host_uitest.cc b/content/browser/renderer_host/resource_dispatcher_host_uitest.cc
index 8fbb16d..a049b37 100644
--- a/content/browser/renderer_host/resource_dispatcher_host_uitest.cc
+++ b/content/browser/renderer_host/resource_dispatcher_host_uitest.cc
@@ -285,7 +285,7 @@ TEST_F(ResourceDispatcherTest, FAILS_CrossSiteAfterCrash) {
#if defined(OS_WIN) || defined(USE_LINUX_BREAKPAD)
expected_crashes_ = 1;
#endif
- ASSERT_TRUE(tab->NavigateToURLAsync(GURL(chrome::kAboutCrashURL)));
+ ASSERT_TRUE(tab->NavigateToURLAsync(GURL(chrome::kChromeUICrashURL)));
// Wait for browser to notice the renderer crash.
base::PlatformThread::Sleep(TestTimeouts::action_timeout());
diff --git a/content/browser/site_instance_impl.cc b/content/browser/site_instance_impl.cc
index feb5402..1212c17 100644
--- a/content/browser/site_instance_impl.cc
+++ b/content/browser/site_instance_impl.cc
@@ -27,8 +27,10 @@ static bool IsURLSameAsAnySiteInstance(const GURL& url) {
if (url.SchemeIs(chrome::kJavaScriptScheme))
return true;
- return
- content::GetContentClient()->browser()->IsURLSameAsAnySiteInstance(url);
+ return url == GURL(chrome::kChromeUICrashURL) ||
+ url == GURL(chrome::kChromeUIKillURL) ||
+ url == GURL(chrome::kChromeUIHangURL) ||
+ url == GURL(chrome::kChromeUIShorthangURL);
}
int32 SiteInstanceImpl::next_site_instance_id_ = 1;
diff --git a/content/browser/site_instance_impl_unittest.cc b/content/browser/site_instance_impl_unittest.cc
index 77ae33c..c04b819 100644
--- a/content/browser/site_instance_impl_unittest.cc
+++ b/content/browser/site_instance_impl_unittest.cc
@@ -82,11 +82,6 @@ class SiteInstanceTestBrowserClient : public content::MockContentBrowserClient {
return false;
}
- virtual bool IsURLSameAsAnySiteInstance(const GURL& url) OVERRIDE {
- return url == GURL(kSameAsAnyInstanceURL) ||
- url == GURL(chrome::kAboutCrashURL);
- }
-
virtual bool IsSuitableHost(content::RenderProcessHost* process_host,
const GURL& site_url) OVERRIDE {
return (privileged_process_id_ == process_host->GetID()) ==
@@ -366,8 +361,6 @@ TEST_F(SiteInstanceTest, IsSameWebSite) {
GURL url_foo_https = GURL("https://foo/a.html");
GURL url_foo_port = GURL("http://foo:8080/a.html");
GURL url_javascript = GURL("javascript:alert(1);");
- GURL url_crash = GURL(chrome::kAboutCrashURL);
- GURL url_browser_specified = GURL(kSameAsAnyInstanceURL);
// Same scheme and port -> same site.
EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_foo, url_foo2));
@@ -383,12 +376,6 @@ TEST_F(SiteInstanceTest, IsSameWebSite) {
EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_javascript, url_foo));
EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_javascript, url_foo_https));
EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_javascript, url_foo_port));
-
- // The URLs specified by the ContentBrowserClient should also be treated as
- // same site.
- EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_crash, url_foo));
- EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_browser_specified,
- url_foo));
}
// Test to ensure that there is only one SiteInstance per site in a given
diff --git a/content/browser/tab_contents/debug_urls.cc b/content/browser/tab_contents/debug_urls.cc
new file mode 100644
index 0000000..17d4403
--- /dev/null
+++ b/content/browser/tab_contents/debug_urls.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2012 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 "content/browser/tab_contents/debug_urls.h"
+
+#include "content/browser/gpu/gpu_process_host_ui_shim.h"
+#include "content/public/common/url_constants.h"
+#include "googleurl/src/gurl.h"
+
+namespace content {
+
+bool HandleDebugURL(const GURL& url, content::PageTransition transition) {
+ content::PageTransition base_transition =
+ content::PageTransitionStripQualifier(transition);
+ if (base_transition != content::PAGE_TRANSITION_TYPED)
+ return false;
+
+ // Handle URLs to crash the browser or wreck the gpu process.
+ if (url.host() == chrome::kChromeUIBrowserCrashHost) {
+ // Induce an intentional crash in the browser process.
+ CHECK(false);
+ return true;
+ }
+
+ if (url == GURL(chrome::kChromeUIGpuCleanURL)) {
+ GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance();
+ if (shim)
+ shim->SimulateRemoveAllContext();
+ return true;
+ }
+
+ if (url == GURL(chrome::kChromeUIGpuCrashURL)) {
+ GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance();
+ if (shim)
+ shim->SimulateCrash();
+ return true;
+ }
+
+ if (url == GURL(chrome::kChromeUIGpuHangURL)) {
+ GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance();
+ if (shim)
+ shim->SimulateHang();
+ return true;
+ }
+
+ return false;
+}
+
+} // namespace content
diff --git a/content/browser/tab_contents/debug_urls.h b/content/browser/tab_contents/debug_urls.h
new file mode 100644
index 0000000..a54a056
--- /dev/null
+++ b/content/browser/tab_contents/debug_urls.h
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 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 CONTENT_BROWSER_TAB_CONTENTS_DEBUG_URLS_H_
+#define CONTENT_BROWSER_TAB_CONTENTS_DEBUG_URLS_H_
+#pragma once
+
+#include "content/public/common/page_transition_types.h"
+
+class GURL;
+
+namespace content {
+
+// Checks if the given url is a url used for debugging purposes, and if so
+// handles it and returns true.
+bool HandleDebugURL(const GURL& url, content::PageTransition transition);
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_TAB_CONTENTS_DEBUG_URLS_H_
diff --git a/content/browser/tab_contents/navigation_controller_impl.cc b/content/browser/tab_contents/navigation_controller_impl.cc
index a7baf9f..eba3157 100644
--- a/content/browser/tab_contents/navigation_controller_impl.cc
+++ b/content/browser/tab_contents/navigation_controller_impl.cc
@@ -15,6 +15,7 @@
#include "content/browser/in_process_webkit/session_storage_namespace.h"
#include "content/browser/renderer_host/render_view_host.h" // Temporary
#include "content/browser/site_instance_impl.h"
+#include "content/browser/tab_contents/debug_urls.h"
#include "content/browser/tab_contents/interstitial_page.h"
#include "content/browser/tab_contents/navigation_entry_impl.h"
#include "content/browser/tab_contents/tab_contents.h"
@@ -565,6 +566,9 @@ void NavigationControllerImpl::LoadURL(
const content::Referrer& referrer,
content::PageTransition transition,
const std::string& extra_headers) {
+ if (content::HandleDebugURL(url, transition))
+ return;
+
// The user initiated a load, we don't need to reload anymore.
needs_reload_ = false;