OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.h" | 5 #include "chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 &NetInternalsTest::MessageHandler::GetNetLogFileContents, | 182 &NetInternalsTest::MessageHandler::GetNetLogFileContents, |
183 base::Unretained(this))); | 183 base::Unretained(this))); |
184 web_ui()->RegisterMessageCallback("enableDataReductionProxy", | 184 web_ui()->RegisterMessageCallback("enableDataReductionProxy", |
185 base::Bind( | 185 base::Bind( |
186 &NetInternalsTest::MessageHandler::EnableDataReductionProxy, | 186 &NetInternalsTest::MessageHandler::EnableDataReductionProxy, |
187 base::Unretained(this))); | 187 base::Unretained(this))); |
188 } | 188 } |
189 | 189 |
190 void NetInternalsTest::MessageHandler::RunJavascriptCallback( | 190 void NetInternalsTest::MessageHandler::RunJavascriptCallback( |
191 base::Value* value) { | 191 base::Value* value) { |
192 web_ui()->CallJavascriptFunction("NetInternalsTest.callback", *value); | 192 web_ui()->CallJavascriptFunctionUnsafe("NetInternalsTest.callback", *value); |
193 } | 193 } |
194 | 194 |
195 void NetInternalsTest::MessageHandler::GetTestServerURL( | 195 void NetInternalsTest::MessageHandler::GetTestServerURL( |
196 const base::ListValue* list_value) { | 196 const base::ListValue* list_value) { |
197 ASSERT_TRUE(net_internals_test_->StartTestServer()); | 197 ASSERT_TRUE(net_internals_test_->StartTestServer()); |
198 std::string path; | 198 std::string path; |
199 ASSERT_TRUE(list_value->GetString(0, &path)); | 199 ASSERT_TRUE(list_value->GetString(0, &path)); |
200 GURL url = net_internals_test_->embedded_test_server()->GetURL(path); | 200 GURL url = net_internals_test_->embedded_test_server()->GetURL(path); |
201 std::unique_ptr<base::Value> url_value(new base::StringValue(url.spec())); | 201 std::unique_ptr<base::Value> url_value(new base::StringValue(url.spec())); |
202 RunJavascriptCallback(url_value.get()); | 202 RunJavascriptCallback(url_value.get()); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 base::ASCIIToUTF16(base::StringPrintf("Click('%s')", url.c_str()))); | 257 base::ASCIIToUTF16(base::StringPrintf("Click('%s')", url.c_str()))); |
258 } | 258 } |
259 | 259 |
260 void NetInternalsTest::MessageHandler::CreateIncognitoBrowser( | 260 void NetInternalsTest::MessageHandler::CreateIncognitoBrowser( |
261 const base::ListValue* list_value) { | 261 const base::ListValue* list_value) { |
262 ASSERT_FALSE(incognito_browser_); | 262 ASSERT_FALSE(incognito_browser_); |
263 incognito_browser_ = net_internals_test_->CreateIncognitoBrowser(); | 263 incognito_browser_ = net_internals_test_->CreateIncognitoBrowser(); |
264 | 264 |
265 // Tell the test harness that creation is complete. | 265 // Tell the test harness that creation is complete. |
266 base::StringValue command_value("onIncognitoBrowserCreatedForTest"); | 266 base::StringValue command_value("onIncognitoBrowserCreatedForTest"); |
267 web_ui()->CallJavascriptFunction("g_browser.receive", command_value); | 267 web_ui()->CallJavascriptFunctionUnsafe("g_browser.receive", command_value); |
268 } | 268 } |
269 | 269 |
270 void NetInternalsTest::MessageHandler::CloseIncognitoBrowser( | 270 void NetInternalsTest::MessageHandler::CloseIncognitoBrowser( |
271 const base::ListValue* list_value) { | 271 const base::ListValue* list_value) { |
272 ASSERT_TRUE(incognito_browser_); | 272 ASSERT_TRUE(incognito_browser_); |
273 incognito_browser_->tab_strip_model()->CloseAllTabs(); | 273 incognito_browser_->tab_strip_model()->CloseAllTabs(); |
274 // Closing all a Browser's tabs will ultimately result in its destruction, | 274 // Closing all a Browser's tabs will ultimately result in its destruction, |
275 // thought it may not have been destroyed yet. | 275 // thought it may not have been destroyed yet. |
276 incognito_browser_ = NULL; | 276 incognito_browser_ = NULL; |
277 } | 277 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 if (test_server_started_) | 370 if (test_server_started_) |
371 return true; | 371 return true; |
372 test_server_started_ = embedded_test_server()->Start(); | 372 test_server_started_ = embedded_test_server()->Start(); |
373 | 373 |
374 // Sample domain for SDCH-view test. Dictionaries for localhost/127.0.0.1 | 374 // Sample domain for SDCH-view test. Dictionaries for localhost/127.0.0.1 |
375 // are forbidden. | 375 // are forbidden. |
376 host_resolver()->AddRule("testdomain.com", "127.0.0.1"); | 376 host_resolver()->AddRule("testdomain.com", "127.0.0.1"); |
377 host_resolver()->AddRule("sub.testdomain.com", "127.0.0.1"); | 377 host_resolver()->AddRule("sub.testdomain.com", "127.0.0.1"); |
378 return test_server_started_; | 378 return test_server_started_; |
379 } | 379 } |
OLD | NEW |