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

Side by Side Diff: content/shell/renderer/test_runner/test_interfaces.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: review comments addressed 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
« no previous file with comments | « content/shell/browser/shell_devtools_frontend.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/test_runner/test_interfaces.h" 5 #include "content/shell/renderer/test_runner/test_interfaces.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_writer.h"
11 #include "base/json/string_escape.h"
10 #include "base/logging.h" 12 #include "base/logging.h"
11 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
12 #include "content/shell/common/shell_switches.h" 14 #include "content/shell/common/shell_switches.h"
13 #include "content/shell/renderer/test_runner/accessibility_controller.h" 15 #include "content/shell/renderer/test_runner/accessibility_controller.h"
14 #include "content/shell/renderer/test_runner/event_sender.h" 16 #include "content/shell/renderer/test_runner/event_sender.h"
15 #include "content/shell/renderer/test_runner/gamepad_controller.h" 17 #include "content/shell/renderer/test_runner/gamepad_controller.h"
16 #include "content/shell/renderer/test_runner/test_runner.h" 18 #include "content/shell/renderer/test_runner/test_runner.h"
17 #include "content/shell/renderer/test_runner/text_input_controller.h" 19 #include "content/shell/renderer/test_runner/text_input_controller.h"
18 #include "content/shell/renderer/test_runner/web_test_proxy.h" 20 #include "content/shell/renderer/test_runner/web_test_proxy.h"
19 #include "third_party/WebKit/public/platform/WebURL.h" 21 #include "third_party/WebKit/public/platform/WebURL.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 test_runner_->setShouldDumpFrameLoadCallbacks(true); 113 test_runner_->setShouldDumpFrameLoadCallbacks(true);
112 if (spec.find("/dumpAsText/") != std::string::npos) { 114 if (spec.find("/dumpAsText/") != std::string::npos) {
113 test_runner_->setShouldDumpAsText(true); 115 test_runner_->setShouldDumpAsText(true);
114 test_runner_->setShouldGeneratePixelResults(false); 116 test_runner_->setShouldGeneratePixelResults(false);
115 } 117 }
116 if (spec.find("/inspector/") != std::string::npos || 118 if (spec.find("/inspector/") != std::string::npos ||
117 spec.find("/inspector-enabled/") != std::string::npos) 119 spec.find("/inspector-enabled/") != std::string::npos)
118 test_runner_->ClearDevToolsLocalStorage(); 120 test_runner_->ClearDevToolsLocalStorage();
119 if (spec.find("/inspector/") != std::string::npos) { 121 if (spec.find("/inspector/") != std::string::npos) {
120 // Subfolder name determines default panel to open. 122 // Subfolder name determines default panel to open.
121 std::string settings = "";
122 std::string test_path = spec.substr(spec.find("/inspector/") + 11); 123 std::string test_path = spec.substr(spec.find("/inspector/") + 11);
123 size_t slash_index = test_path.find("/"); 124 base::DictionaryValue settings;
124 std::string test_path_setting = base::StringPrintf( 125 settings.SetString("testPath", base::GetQuotedJSONString(spec));
125 "\"testPath\":\"\\\"%s\\\"\"", spec.c_str()); 126 std::string settings_string;
126 127 base::JSONWriter::Write(&settings, &settings_string);
127 // TODO(pfeldman): remove once migrated to testPath. 128 test_runner_->ShowDevTools(settings_string, std::string());
128 std::string last_active_panel;
129 if (slash_index != std::string::npos) {
130 last_active_panel = base::StringPrintf(
131 ",\"lastActivePanel\":\"\\\"%s\\\"\"",
132 test_path.substr(0, slash_index).c_str());
133 }
134
135 test_runner_->ShowDevTools(base::StringPrintf("{%s%s}",
136 test_path_setting.c_str(), last_active_panel.c_str()), std::string());
137 } 129 }
138 if (spec.find("/viewsource/") != std::string::npos) { 130 if (spec.find("/viewsource/") != std::string::npos) {
139 test_runner_->setShouldEnableViewSource(true); 131 test_runner_->setShouldEnableViewSource(true);
140 test_runner_->setShouldGeneratePixelResults(false); 132 test_runner_->setShouldGeneratePixelResults(false);
141 test_runner_->setShouldDumpAsMarkup(true); 133 test_runner_->setShouldDumpAsMarkup(true);
142 } 134 }
143 } 135 }
144 136
145 void TestInterfaces::WindowOpened(WebTestProxyBase* proxy) { 137 void TestInterfaces::WindowOpened(WebTestProxyBase* proxy) {
146 window_list_.push_back(proxy); 138 window_list_.push_back(proxy);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 174
183 blink::WebThemeEngine* TestInterfaces::GetThemeEngine() { 175 blink::WebThemeEngine* TestInterfaces::GetThemeEngine() {
184 if (!test_runner_->UseMockTheme()) 176 if (!test_runner_->UseMockTheme())
185 return 0; 177 return 0;
186 if (!theme_engine_.get()) 178 if (!theme_engine_.get())
187 theme_engine_.reset(new MockWebThemeEngine()); 179 theme_engine_.reset(new MockWebThemeEngine());
188 return theme_engine_.get(); 180 return theme_engine_.get();
189 } 181 }
190 182
191 } // namespace content 183 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/shell_devtools_frontend.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698