1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/frame_host/debug_urls.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/gpu/gpu_process_host_ui_shim.h"
11 #include "content/browser/ppapi_plugin_process_host.h"
12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/common/content_constants.h"
14 #include "content/public/common/url_constants.h"
15 #include "ppapi/proxy/ppapi_messages.h"
22 void HandlePpapiFlashDebugURL(const GURL& url) {
23 #if defined(ENABLE_PLUGINS)
24 bool crash = url == GURL(kChromeUIPpapiFlashCrashURL);
26 std::vector<PpapiPluginProcessHost*> hosts;
27 PpapiPluginProcessHost::FindByName(UTF8ToUTF16(kFlashPluginName), &hosts);
28 for (std::vector<PpapiPluginProcessHost*>::iterator iter = hosts.begin();
29 iter != hosts.end(); ++iter) {
31 (*iter)->Send(new PpapiMsg_Crash());
33 (*iter)->Send(new PpapiMsg_Hang());
40 bool HandleDebugURL(const GURL& url, PageTransition transition) {
41 // Ensure that the user explicitly navigated to this URL.
42 if (!(transition & PAGE_TRANSITION_FROM_ADDRESS_BAR))
45 if (url.host() == kChromeUIBrowserCrashHost) {
46 // Induce an intentional crash in the browser process.
51 if (url == GURL(kChromeUIGpuCleanURL)) {
52 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance();
54 shim->SimulateRemoveAllContext();
58 if (url == GURL(kChromeUIGpuCrashURL)) {
59 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance();
61 shim->SimulateCrash();
65 if (url == GURL(kChromeUIGpuHangURL)) {
66 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance();
72 if (url == GURL(kChromeUIPpapiFlashCrashURL) ||
73 url == GURL(kChromeUIPpapiFlashHangURL)) {
74 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
75 base::Bind(&HandlePpapiFlashDebugURL, url));
82 } // namespace content