| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/shell/browser/layout_test/layout_test_devtools_frontend.h" | 5 #include "content/shell/browser/layout_test/layout_test_devtools_frontend.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 NULL, | 26 NULL, |
| 27 gfx::Size()); | 27 gfx::Size()); |
| 28 LayoutTestDevToolsFrontend* devtools_frontend = | 28 LayoutTestDevToolsFrontend* devtools_frontend = |
| 29 new LayoutTestDevToolsFrontend(shell, agent.get()); | 29 new LayoutTestDevToolsFrontend(shell, agent.get()); |
| 30 | 30 |
| 31 shell->LoadURL(GetDevToolsPathAsURL(settings, frontend_url)); | 31 shell->LoadURL(GetDevToolsPathAsURL(settings, frontend_url)); |
| 32 | 32 |
| 33 return devtools_frontend; | 33 return devtools_frontend; |
| 34 } | 34 } |
| 35 | 35 |
| 36 LayoutTestDevToolsFrontend::LayoutTestDevToolsFrontend( | |
| 37 Shell* frontend_shell, | |
| 38 DevToolsAgentHost* agent_host) | |
| 39 : ShellDevToolsFrontend(frontend_shell, agent_host) { | |
| 40 } | |
| 41 | |
| 42 LayoutTestDevToolsFrontend::~LayoutTestDevToolsFrontend() { | |
| 43 } | |
| 44 | |
| 45 // static. | 36 // static. |
| 46 GURL LayoutTestDevToolsFrontend::GetDevToolsPathAsURL( | 37 GURL LayoutTestDevToolsFrontend::GetDevToolsPathAsURL( |
| 47 const std::string& settings, | 38 const std::string& settings, |
| 48 const std::string& frontend_url) { | 39 const std::string& frontend_url) { |
| 49 if (!frontend_url.empty()) | 40 if (!frontend_url.empty()) |
| 50 return GURL(frontend_url); | 41 return GURL(frontend_url); |
| 51 base::FilePath dir_exe; | 42 base::FilePath dir_exe; |
| 52 if (!PathService::Get(base::DIR_EXE, &dir_exe)) { | 43 if (!PathService::Get(base::DIR_EXE, &dir_exe)) { |
| 53 NOTREACHED(); | 44 NOTREACHED(); |
| 54 return GURL(); | 45 return GURL(); |
| 55 } | 46 } |
| 56 #if defined(OS_MACOSX) | 47 #if defined(OS_MACOSX) |
| 57 // On Mac, the executable is in | 48 // On Mac, the executable is in |
| 58 // out/Release/Content Shell.app/Contents/MacOS/Content Shell. | 49 // out/Release/Content Shell.app/Contents/MacOS/Content Shell. |
| 59 // We need to go up 3 directories to get to out/Release. | 50 // We need to go up 3 directories to get to out/Release. |
| 60 dir_exe = dir_exe.AppendASCII("../../.."); | 51 dir_exe = dir_exe.AppendASCII("../../.."); |
| 61 #endif | 52 #endif |
| 62 base::FilePath dev_tools_path = | 53 base::FilePath dev_tools_path = |
| 63 dir_exe.AppendASCII("resources/inspector/devtools.html"); | 54 dir_exe.AppendASCII("resources/inspector/devtools.html"); |
| 64 | 55 |
| 65 GURL result = net::FilePathToFileURL(dev_tools_path); | 56 GURL result = net::FilePathToFileURL(dev_tools_path); |
| 66 if (!settings.empty()) | 57 if (!settings.empty()) |
| 67 result = GURL(base::StringPrintf("%s?settings=%s&experiments=true", | 58 result = GURL(base::StringPrintf("%s?settings=%s&experiments=true", |
| 68 result.spec().c_str(), | 59 result.spec().c_str(), |
| 69 settings.c_str())); | 60 settings.c_str())); |
| 70 return result; | 61 return result; |
| 71 } | 62 } |
| 72 | 63 |
| 64 LayoutTestDevToolsFrontend::LayoutTestDevToolsFrontend( |
| 65 Shell* frontend_shell, |
| 66 DevToolsAgentHost* agent_host) |
| 67 : ShellDevToolsFrontend(frontend_shell, agent_host) { |
| 68 } |
| 69 |
| 70 LayoutTestDevToolsFrontend::~LayoutTestDevToolsFrontend() { |
| 71 } |
| 72 |
| 73 void LayoutTestDevToolsFrontend::AgentHostClosed( |
| 74 DevToolsAgentHost* agent_host, bool replaced) { |
| 75 // Do not close the front-end shell. |
| 76 } |
| 77 |
| 73 void LayoutTestDevToolsFrontend::RenderProcessGone( | 78 void LayoutTestDevToolsFrontend::RenderProcessGone( |
| 74 base::TerminationStatus status) { | 79 base::TerminationStatus status) { |
| 75 WebKitTestController::Get()->DevToolsProcessCrashed(); | 80 WebKitTestController::Get()->DevToolsProcessCrashed(); |
| 76 } | 81 } |
| 77 | 82 |
| 78 } // namespace content | 83 } // namespace content |
| OLD | NEW |