blob: 4e9d49d32a3d7be43ab7cb5b882f1cfd17c3d0d7 [file] [log] [blame]
[email protected]d4a8ca482013-10-30 21:06:401// Copyright 2013 The Chromium Authors. All rights reserved.
[email protected]8bf1048012012-02-08 01:22:182// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]d4a8ca482013-10-30 21:06:405#include "content/browser/frame_host/debug_urls.h"
[email protected]8bf1048012012-02-08 01:22:186
[email protected]029bd942013-01-22 08:30:337#include <vector>
8
[email protected]74ebfb12013-06-07 20:48:009#include "base/strings/utf_string_conversions.h"
[email protected]8bf1048012012-02-08 01:22:1810#include "content/browser/gpu/gpu_process_host_ui_shim.h"
[email protected]029bd942013-01-22 08:30:3311#include "content/browser/ppapi_plugin_process_host.h"
12#include "content/public/browser/browser_thread.h"
[email protected]73270292013-08-09 03:48:0713#include "content/public/common/content_constants.h"
[email protected]8bf1048012012-02-08 01:22:1814#include "content/public/common/url_constants.h"
[email protected]029bd942013-01-22 08:30:3315#include "ppapi/proxy/ppapi_messages.h"
[email protected]707e1c42013-07-09 21:18:5816#include "url/gurl.h"
[email protected]8bf1048012012-02-08 01:22:1817
18namespace content {
19
[email protected]029bd942013-01-22 08:30:3320namespace {
21
22void HandlePpapiFlashDebugURL(const GURL& url) {
23#if defined(ENABLE_PLUGINS)
[email protected]f8a6d732013-03-02 22:46:0324 bool crash = url == GURL(kChromeUIPpapiFlashCrashURL);
[email protected]029bd942013-01-22 08:30:3325
26 std::vector<PpapiPluginProcessHost*> hosts;
[email protected]32956122013-12-25 07:29:2427 PpapiPluginProcessHost::FindByName(
28 base::UTF8ToUTF16(kFlashPluginName), &hosts);
[email protected]029bd942013-01-22 08:30:3329 for (std::vector<PpapiPluginProcessHost*>::iterator iter = hosts.begin();
30 iter != hosts.end(); ++iter) {
31 if (crash)
32 (*iter)->Send(new PpapiMsg_Crash());
33 else
34 (*iter)->Send(new PpapiMsg_Hang());
35 }
36#endif
37}
38
39} // namespace
40
[email protected]91a4ff82012-10-29 20:29:4841bool HandleDebugURL(const GURL& url, PageTransition transition) {
[email protected]425a7472012-04-30 22:09:1042 // Ensure that the user explicitly navigated to this URL.
[email protected]91a4ff82012-10-29 20:29:4843 if (!(transition & PAGE_TRANSITION_FROM_ADDRESS_BAR))
[email protected]8bf1048012012-02-08 01:22:1844 return false;
45
[email protected]46ed0862013-04-14 02:47:5646 if (url.host() == kChromeUIBrowserCrashHost) {
[email protected]8bf1048012012-02-08 01:22:1847 // Induce an intentional crash in the browser process.
48 CHECK(false);
49 return true;
50 }
51
[email protected]f8a6d732013-03-02 22:46:0352 if (url == GURL(kChromeUIGpuCleanURL)) {
[email protected]8bf1048012012-02-08 01:22:1853 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance();
54 if (shim)
55 shim->SimulateRemoveAllContext();
56 return true;
57 }
58
[email protected]f8a6d732013-03-02 22:46:0359 if (url == GURL(kChromeUIGpuCrashURL)) {
[email protected]8bf1048012012-02-08 01:22:1860 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance();
61 if (shim)
62 shim->SimulateCrash();
63 return true;
64 }
65
[email protected]f8a6d732013-03-02 22:46:0366 if (url == GURL(kChromeUIGpuHangURL)) {
[email protected]8bf1048012012-02-08 01:22:1867 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance();
68 if (shim)
69 shim->SimulateHang();
70 return true;
71 }
72
[email protected]f8a6d732013-03-02 22:46:0373 if (url == GURL(kChromeUIPpapiFlashCrashURL) ||
74 url == GURL(kChromeUIPpapiFlashHangURL)) {
[email protected]029bd942013-01-22 08:30:3375 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
76 base::Bind(&HandlePpapiFlashDebugURL, url));
77 return true;
78 }
79
[email protected]8bf1048012012-02-08 01:22:1880 return false;
81}
82
[email protected]c02f1ba2014-02-03 06:53:5383bool IsRendererDebugURL(const GURL& url) {
84 if (!url.is_valid())
85 return false;
86
87 if (url.SchemeIs(kJavaScriptScheme))
88 return true;
89
90 return url == GURL(kChromeUICrashURL) ||
91 url == GURL(kChromeUIKillURL) ||
92 url == GURL(kChromeUIHangURL) ||
93 url == GURL(kChromeUIShorthangURL);
94}
95
[email protected]8bf1048012012-02-08 01:22:1896} // namespace content