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

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

Issue 1079843002: DevTools: allow storing devtools preferences on the browser side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
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"
11 #include "content/shell/browser/shell.h" 11 #include "content/shell/browser/shell.h"
12 #include "content/shell/browser/webkit_test_controller.h" 12 #include "content/shell/browser/webkit_test_controller.h"
13 #include "net/base/filename_util.h" 13 #include "net/base/filename_util.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 // static 17 // static
18 LayoutTestDevToolsFrontend* LayoutTestDevToolsFrontend::Show( 18 LayoutTestDevToolsFrontend* LayoutTestDevToolsFrontend::Show(
19 WebContents* inspected_contents, 19 WebContents* inspected_contents,
20 const std::string& settings, 20 const std::string& test_path,
21 const std::string& frontend_url) { 21 const std::string& frontend_url) {
22 Shell* shell = Shell::CreateNewWindow(inspected_contents->GetBrowserContext(), 22 Shell* shell = Shell::CreateNewWindow(inspected_contents->GetBrowserContext(),
23 GURL(), 23 GURL(),
24 NULL, 24 NULL,
25 gfx::Size()); 25 gfx::Size());
26 LayoutTestDevToolsFrontend* devtools_frontend = 26 LayoutTestDevToolsFrontend* devtools_frontend =
27 new LayoutTestDevToolsFrontend(shell, inspected_contents); 27 new LayoutTestDevToolsFrontend(shell, inspected_contents);
28 28 devtools_frontend->preferences()->
29 shell->LoadURL(GetDevToolsPathAsURL(settings, frontend_url)); 29 SetStringWithoutPathExpansion("testPath", "\"" + test_path + "\"");
30 shell->LoadURL(GetDevToolsPathAsURL(frontend_url));
30 31
31 return devtools_frontend; 32 return devtools_frontend;
32 } 33 }
33 34
34 // static. 35 // static.
35 GURL LayoutTestDevToolsFrontend::GetDevToolsPathAsURL( 36 GURL LayoutTestDevToolsFrontend::GetDevToolsPathAsURL(
36 const std::string& settings,
37 const std::string& frontend_url) { 37 const std::string& frontend_url) {
38 if (!frontend_url.empty()) 38 if (!frontend_url.empty())
39 return GURL(frontend_url); 39 return GURL(frontend_url);
40 base::FilePath dir_exe; 40 base::FilePath dir_exe;
41 if (!PathService::Get(base::DIR_EXE, &dir_exe)) { 41 if (!PathService::Get(base::DIR_EXE, &dir_exe)) {
42 NOTREACHED(); 42 NOTREACHED();
43 return GURL(); 43 return GURL();
44 } 44 }
45 #if defined(OS_MACOSX) 45 #if defined(OS_MACOSX)
46 // On Mac, the executable is in 46 // On Mac, the executable is in
47 // out/Release/Content Shell.app/Contents/MacOS/Content Shell. 47 // out/Release/Content Shell.app/Contents/MacOS/Content Shell.
48 // We need to go up 3 directories to get to out/Release. 48 // We need to go up 3 directories to get to out/Release.
49 dir_exe = dir_exe.AppendASCII("../../.."); 49 dir_exe = dir_exe.AppendASCII("../../..");
50 #endif 50 #endif
51 base::FilePath dev_tools_path = 51 base::FilePath dev_tools_path =
52 dir_exe.AppendASCII("resources/inspector/devtools.html"); 52 dir_exe.AppendASCII("resources/inspector/devtools.html");
53 53
54 GURL result = net::FilePathToFileURL(dev_tools_path); 54 return net::FilePathToFileURL(dev_tools_path);
55 if (!settings.empty())
56 result = GURL(base::StringPrintf("%s?settings=%s&experiments=true",
57 result.spec().c_str(),
58 settings.c_str()));
59 return result;
60 } 55 }
61 56
62 void LayoutTestDevToolsFrontend::ReuseFrontend(const std::string& settings, 57 void LayoutTestDevToolsFrontend::ReuseFrontend(const std::string& test_path,
63 const std::string frontend_url) { 58 const std::string frontend_url) {
64 DisconnectFromTarget(); 59 DisconnectFromTarget();
65 frontend_shell()->LoadURL(GetDevToolsPathAsURL(settings, frontend_url)); 60 preferences()->Clear();
61 preferences()->SetStringWithoutPathExpansion("testPath",
62 "\"" + test_path + "\"");
63 frontend_shell()->LoadURL(GetDevToolsPathAsURL(frontend_url));
66 } 64 }
67 65
68 LayoutTestDevToolsFrontend::LayoutTestDevToolsFrontend( 66 LayoutTestDevToolsFrontend::LayoutTestDevToolsFrontend(
69 Shell* frontend_shell, 67 Shell* frontend_shell,
70 WebContents* inspected_contents) 68 WebContents* inspected_contents)
71 : ShellDevToolsFrontend(frontend_shell, inspected_contents) { 69 : ShellDevToolsFrontend(frontend_shell, inspected_contents) {
72 } 70 }
73 71
74 LayoutTestDevToolsFrontend::~LayoutTestDevToolsFrontend() { 72 LayoutTestDevToolsFrontend::~LayoutTestDevToolsFrontend() {
75 } 73 }
76 74
77 void LayoutTestDevToolsFrontend::AgentHostClosed( 75 void LayoutTestDevToolsFrontend::AgentHostClosed(
78 DevToolsAgentHost* agent_host, bool replaced) { 76 DevToolsAgentHost* agent_host, bool replaced) {
79 // Do not close the front-end shell. 77 // Do not close the front-end shell.
80 } 78 }
81 79
82 void LayoutTestDevToolsFrontend::RenderProcessGone( 80 void LayoutTestDevToolsFrontend::RenderProcessGone(
83 base::TerminationStatus status) { 81 base::TerminationStatus status) {
84 WebKitTestController::Get()->DevToolsProcessCrashed(); 82 WebKitTestController::Get()->DevToolsProcessCrashed();
85 } 83 }
86 84
87 } // namespace content 85 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698