summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-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
-rw-r--r--content/common/test_url_constants.cc2
-rw-r--r--content/common/test_url_constants.h4
-rw-r--r--content/content_browser.gypi2
-rw-r--r--content/public/browser/content_browser_client.h4
-rw-r--r--content/public/common/url_constants.cc9
-rw-r--r--content/public/common/url_constants.h10
-rw-r--r--content/renderer/render_view_impl.cc24
-rw-r--r--content/shell/shell_content_browser_client.cc4
-rw-r--r--content/shell/shell_content_browser_client.h1
19 files changed, 137 insertions, 50 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;
diff --git a/content/common/test_url_constants.cc b/content/common/test_url_constants.cc
index 9777124..49a4826 100644
--- a/content/common/test_url_constants.cc
+++ b/content/common/test_url_constants.cc
@@ -7,8 +7,6 @@
namespace chrome {
const char kTestCacheURL[] = "about:cache";
-const char kTestHangURL[] = "about:hang";
-const char kTestGpuCleanURL[] = "about:gpuclean";
const char kTestNewTabURL[] = "chrome://newtab";
const char kTestHistoryURL[] = "chrome://history/";
const char kTestBookmarksURL[] = "chrome://bookmarks/";
diff --git a/content/common/test_url_constants.h b/content/common/test_url_constants.h
index 71f9d2d..b04ace0 100644
--- a/content/common/test_url_constants.h
+++ b/content/common/test_url_constants.h
@@ -18,10 +18,6 @@ namespace chrome {
// Various URLs used in security policy testing.
extern const char kTestCacheURL[];
-extern const char kTestHangURL[];
-
-// One of the few about pages that is not a WebUI page.
-extern const char kTestGpuCleanURL[];
// The NTP is assumed in several tests to have the property that it is WebUI.
extern const char kTestNewTabURL[];
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index 729bfc3..bdbbf88 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -621,6 +621,8 @@
'browser/system_message_window_win.h',
'browser/tab_contents/drag_utils_gtk.cc',
'browser/tab_contents/drag_utils_gtk.h',
+ 'browser/tab_contents/debug_urls.cc',
+ 'browser/tab_contents/debug_urls.h',
'browser/tab_contents/interstitial_page.cc',
'browser/tab_contents/interstitial_page.h',
'browser/tab_contents/navigation_controller_impl.cc',
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
index 3ffb71c..3c2fe1a 100644
--- a/content/public/browser/content_browser_client.h
+++ b/content/public/browser/content_browser_client.h
@@ -110,10 +110,6 @@ class ContentBrowserClient {
virtual bool ShouldUseProcessPerSite(BrowserContext* browser_context,
const GURL& effective_url) = 0;
- // Returns whether a specified URL is to be considered the same as any
- // SiteInstance.
- virtual bool IsURLSameAsAnySiteInstance(const GURL& url) = 0;
-
// Returns whether a specified URL is handled by the embedder's internal
// protocol handlers.
virtual bool IsHandledURL(const GURL& url) = 0;
diff --git a/content/public/common/url_constants.cc b/content/public/common/url_constants.cc
index 2c046d4..30f8ec3 100644
--- a/content/public/common/url_constants.cc
+++ b/content/public/common/url_constants.cc
@@ -44,7 +44,14 @@ const char kViewSourceScheme[] = "view-source";
const char kStandardSchemeSeparator[] = "://";
const char kAboutBlankURL[] = "about:blank";
-const char kAboutCrashURL[] = "about:crash";
+const char kChromeUIBrowserCrashHost[] = "inducebrowsercrashforrealz";
+const char kChromeUICrashURL[] = "chrome://crash/";
+const char kChromeUIGpuCleanURL[] = "chrome://gpuclean";
+const char kChromeUIGpuCrashURL[] = "chrome://gpucrash";
+const char kChromeUIGpuHangURL[] = "chrome://gpuhang";
+const char kChromeUIHangURL[] = "chrome://hang/";
+const char kChromeUIKillURL[] = "chrome://kill/";
+const char kChromeUIShorthangURL[] = "chrome://shorthang/";
const char kUnreachableWebDataURL[] = "chrome://chromewebdata/";
diff --git a/content/public/common/url_constants.h b/content/public/common/url_constants.h
index 2c02972..cf910c0 100644
--- a/content/public/common/url_constants.h
+++ b/content/public/common/url_constants.h
@@ -10,6 +10,7 @@
#include "content/common/content_export.h"
+// TODO(jam): rename this to content.
namespace chrome {
// Null terminated list of schemes that are savable. This function can be
@@ -41,7 +42,14 @@ CONTENT_EXPORT extern const char kStandardSchemeSeparator[];
// About URLs (including schemes).
CONTENT_EXPORT extern const char kAboutBlankURL[];
-CONTENT_EXPORT extern const char kAboutCrashURL[];
+CONTENT_EXPORT extern const char kChromeUIBrowserCrashHost[];
+CONTENT_EXPORT extern const char kChromeUICrashURL[];
+CONTENT_EXPORT extern const char kChromeUIGpuCleanURL[];
+CONTENT_EXPORT extern const char kChromeUIGpuCrashURL[];
+CONTENT_EXPORT extern const char kChromeUIGpuHangURL[];
+CONTENT_EXPORT extern const char kChromeUIHangURL[];
+CONTENT_EXPORT extern const char kChromeUIKillURL[];
+CONTENT_EXPORT extern const char kChromeUIShorthangURL[];
// Special URL used to start a navigation to an error page.
extern const char kUnreachableWebDataURL[];
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 2194dd13..9214d7a 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -325,6 +325,29 @@ static WebReferrerPolicy getReferrerPolicyFromRequest(
WebKit::WebReferrerPolicyDefault;
}
+static void MaybeHandleDebugURL(const GURL& url) {
+ if (!url.SchemeIs(chrome::kChromeUIScheme))
+ return;
+ if (url == GURL(chrome::kChromeUICrashURL)) {
+ // NOTE(shess): Crash directly rather than using NOTREACHED() so
+ // that the signature is easier to triage in crash reports.
+ volatile int* zero = NULL;
+ *zero = 0;
+
+ // Just in case the compiler decides the above is undefined and
+ // optimizes it away.
+ NOTREACHED();
+ } else if (url == GURL(chrome::kChromeUIKillURL)) {
+ base::KillProcess(base::GetCurrentProcessHandle(), 1, false);
+ } else if (url == GURL(chrome::kChromeUIHangURL)) {
+ for (;;) {
+ base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1));
+ }
+ } else if (url == GURL(chrome::kChromeUIShorthangURL)) {
+ base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20));
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////
struct RenderViewImpl::PendingFileChooser {
@@ -791,6 +814,7 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
}
void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) {
+ MaybeHandleDebugURL(params.url);
if (!webview())
return;
diff --git a/content/shell/shell_content_browser_client.cc b/content/shell/shell_content_browser_client.cc
index 27019aa..b8dfbcd 100644
--- a/content/shell/shell_content_browser_client.cc
+++ b/content/shell/shell_content_browser_client.cc
@@ -75,10 +75,6 @@ bool ShellContentBrowserClient::ShouldUseProcessPerSite(
return false;
}
-bool ShellContentBrowserClient::IsURLSameAsAnySiteInstance(const GURL& url) {
- return false;
-}
-
bool ShellContentBrowserClient::IsHandledURL(const GURL& url) {
return false;
}
diff --git a/content/shell/shell_content_browser_client.h b/content/shell/shell_content_browser_client.h
index eeaf5ac..4d265f2 100644
--- a/content/shell/shell_content_browser_client.h
+++ b/content/shell/shell_content_browser_client.h
@@ -38,7 +38,6 @@ class ShellContentBrowserClient : 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;