| 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/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "content/public/browser/render_frame_host.h" | 14 #include "content/public/browser/render_frame_host.h" |
| 15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 16 #include "content/shell/browser/layout_test/blink_test_controller.h" | 16 #include "content/shell/browser/layout_test/blink_test_controller.h" |
| 17 #include "content/shell/browser/shell.h" | 17 #include "content/shell/browser/shell.h" |
| 18 #include "content/shell/common/layout_test/layout_test_switches.h" | 18 #include "content/shell/common/layout_test/layout_test_switches.h" |
| 19 #include "net/base/filename_util.h" | 19 #include "net/base/filename_util.h" |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 | 22 |
| 23 // static | 23 // static |
| 24 LayoutTestDevToolsFrontend* |
| 25 LayoutTestDevToolsFrontend::CreateDevToolsMainWindow( |
| 26 const Shell& inspected_window) { |
| 27 Shell* devtools_shell = Shell::CreateNewWindow( |
| 28 inspected_window.web_contents()->GetBrowserContext(), GURL(), NULL, |
| 29 gfx::Size()); |
| 30 LayoutTestDevToolsFrontend* devtools_frontend = |
| 31 new LayoutTestDevToolsFrontend(devtools_shell, |
| 32 inspected_window.web_contents()); |
| 33 devtools_frontend->Activate(); |
| 34 devtools_frontend->Focus(); |
| 35 return devtools_frontend; |
| 36 } |
| 37 |
| 38 // static |
| 24 LayoutTestDevToolsFrontend* LayoutTestDevToolsFrontend::Show( | 39 LayoutTestDevToolsFrontend* LayoutTestDevToolsFrontend::Show( |
| 25 WebContents* inspected_contents, | 40 WebContents* inspected_contents, |
| 26 const std::string& settings, | 41 const std::string& settings, |
| 27 const std::string& frontend_url) { | 42 const std::string& frontend_url) { |
| 28 Shell* shell = Shell::CreateNewWindow(inspected_contents->GetBrowserContext(), | 43 Shell* shell = Shell::CreateNewWindow(inspected_contents->GetBrowserContext(), |
| 29 GURL(), | 44 GURL(), |
| 30 NULL, | 45 NULL, |
| 31 gfx::Size()); | 46 gfx::Size()); |
| 32 LayoutTestDevToolsFrontend* devtools_frontend = | 47 LayoutTestDevToolsFrontend* devtools_frontend = |
| 33 new LayoutTestDevToolsFrontend(shell, inspected_contents); | 48 new LayoutTestDevToolsFrontend(shell, inspected_contents); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 GURL result = | 82 GURL result = |
| 68 net::FilePathToFileURL(dev_tools_path.AppendASCII("inspector.html")); | 83 net::FilePathToFileURL(dev_tools_path.AppendASCII("inspector.html")); |
| 69 std::string url_string = | 84 std::string url_string = |
| 70 base::StringPrintf("%s?experiments=true", result.spec().c_str()); | 85 base::StringPrintf("%s?experiments=true", result.spec().c_str()); |
| 71 if (is_debug_dev_tools) | 86 if (is_debug_dev_tools) |
| 72 url_string += "&debugFrontend=true"; | 87 url_string += "&debugFrontend=true"; |
| 73 return GURL(url_string); | 88 return GURL(url_string); |
| 74 } | 89 } |
| 75 | 90 |
| 76 // static. | 91 // static. |
| 77 GURL LayoutTestDevToolsFrontend::MapJSTestURL(const GURL& test_url) { | 92 GURL LayoutTestDevToolsFrontend::MapIntegrationTestURL(const GURL& test_url) { |
| 78 std::string url_string = GetDevToolsPathAsURL(std::string()).spec(); | 93 std::string url_string = GetDevToolsPathAsURL(std::string()).spec(); |
| 79 std::string inspector_file_name = "inspector.html"; | 94 std::string inspector_file_name = "inspector.html"; |
| 80 size_t start_position = url_string.find(inspector_file_name); | 95 size_t start_position = url_string.find(inspector_file_name); |
| 96 url_string.replace(start_position, inspector_file_name.length(), |
| 97 "integration_test_runner.html"); |
| 98 url_string += "&test=" + test_url.spec(); |
| 99 return GURL(url_string); |
| 100 } |
| 101 |
| 102 // static. |
| 103 GURL LayoutTestDevToolsFrontend::MapUnitTestURL(const GURL& test_url) { |
| 104 std::string url_string = GetDevToolsPathAsURL(std::string()).spec(); |
| 105 std::string inspector_file_name = "inspector.html"; |
| 106 size_t start_position = url_string.find(inspector_file_name); |
| 81 url_string.replace(start_position, inspector_file_name.length(), | 107 url_string.replace(start_position, inspector_file_name.length(), |
| 82 "unit_test_runner.html"); | 108 "unit_test_runner.html"); |
| 83 url_string += "&test=" + test_url.spec(); | 109 url_string += "&test=" + test_url.spec(); |
| 84 return GURL(url_string); | 110 return GURL(url_string); |
| 85 } | 111 } |
| 86 | 112 |
| 87 void LayoutTestDevToolsFrontend::ReuseFrontend(const std::string& settings, | 113 void LayoutTestDevToolsFrontend::ReuseFrontend(const std::string& settings, |
| 88 const std::string frontend_url) { | 114 const std::string frontend_url) { |
| 89 DisconnectFromTarget(); | 115 DisconnectFromTarget(); |
| 90 SetPreferences(settings); | 116 SetPreferences(settings); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 base::TerminationStatus status) { | 175 base::TerminationStatus status) { |
| 150 BlinkTestController::Get()->DevToolsProcessCrashed(); | 176 BlinkTestController::Get()->DevToolsProcessCrashed(); |
| 151 } | 177 } |
| 152 | 178 |
| 153 void LayoutTestDevToolsFrontend::RenderFrameCreated( | 179 void LayoutTestDevToolsFrontend::RenderFrameCreated( |
| 154 RenderFrameHost* render_frame_host) { | 180 RenderFrameHost* render_frame_host) { |
| 155 BlinkTestController::Get()->HandleNewRenderFrameHost(render_frame_host); | 181 BlinkTestController::Get()->HandleNewRenderFrameHost(render_frame_host); |
| 156 } | 182 } |
| 157 | 183 |
| 158 } // namespace content | 184 } // namespace content |
| OLD | NEW |