Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: content/shell/browser/layout_test/layout_test_devtools_frontend.cc

Issue 644723002: Content Shell: Introduce LayoutTestDevToolsFrontend. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/shell/browser/layout_test/layout_test_devtools_frontend.h"
6
7 #include "base/command_line.h"
8 #include "base/path_service.h"
9 #include "base/strings/stringprintf.h"
10 #include "content/public/browser/web_contents.h"
11 #include "content/shell/browser/shell.h"
12 #include "content/shell/browser/webkit_test_controller.h"
13 #include "net/base/filename_util.h"
14
15 namespace content {
16
17 // static
18 LayoutTestDevToolsFrontend* LayoutTestDevToolsFrontend::Show(
19 WebContents* inspected_contents,
20 const std::string& settings,
21 const std::string& frontend_url) {
22 scoped_refptr<DevToolsAgentHost> agent(
23 DevToolsAgentHost::GetOrCreateFor(inspected_contents));
24 Shell* shell = Shell::CreateNewWindow(inspected_contents->GetBrowserContext(),
25 GURL(),
26 NULL,
27 MSG_ROUTING_NONE,
28 gfx::Size());
29 LayoutTestDevToolsFrontend* devtools_frontend =
30 new LayoutTestDevToolsFrontend(shell, agent.get());
31
32 shell->LoadURL(GetDevToolsPathAsURL(settings, frontend_url));
33
34 return devtools_frontend;
35 }
36
37 LayoutTestDevToolsFrontend::LayoutTestDevToolsFrontend(
38 Shell* frontend_shell,
39 DevToolsAgentHost* agent_host)
40 : ShellDevToolsFrontend(frontend_shell, agent_host) {
41 }
42
43 LayoutTestDevToolsFrontend::~LayoutTestDevToolsFrontend() {
44 }
45
46 // static.
47 GURL LayoutTestDevToolsFrontend::GetDevToolsPathAsURL(
48 const std::string& settings,
49 const std::string& frontend_url) {
50 if (!frontend_url.empty())
51 return GURL(frontend_url);
52 base::FilePath dir_exe;
53 if (!PathService::Get(base::DIR_EXE, &dir_exe)) {
54 NOTREACHED();
55 return GURL();
56 }
57 #if defined(OS_MACOSX)
58 // On Mac, the executable is in
59 // out/Release/Content Shell.app/Contents/MacOS/Content Shell.
60 // We need to go up 3 directories to get to out/Release.
61 dir_exe = dir_exe.AppendASCII("../../..");
62 #endif
63 base::FilePath dev_tools_path =
64 dir_exe.AppendASCII("resources/inspector/devtools.html");
65
66 GURL result = net::FilePathToFileURL(dev_tools_path);
67 if (!settings.empty())
68 result = GURL(base::StringPrintf("%s?settings=%s&experiments=true",
69 result.spec().c_str(),
70 settings.c_str()));
71 return result;
72 }
73
74 void LayoutTestDevToolsFrontend::RenderProcessGone(
75 base::TerminationStatus status) {
76 WebKitTestController::Get()->DevToolsProcessCrashed();
77 }
78
79 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/layout_test/layout_test_devtools_frontend.h ('k') | content/shell/browser/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698