| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <queue> | 5 #include <queue> |
| 6 #include <utility> |
| 6 | 7 |
| 7 #include "base/location.h" | 8 #include "base/location.h" |
| 8 #include "base/macros.h" | 9 #include "base/macros.h" |
| 9 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 10 #include "base/process/process.h" | 11 #include "base/process/process.h" |
| 11 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
| 15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 auto it = request.headers.find("User-Agent"); | 419 auto it = request.headers.find("User-Agent"); |
| 419 EXPECT_TRUE(it != request.headers.end()); | 420 EXPECT_TRUE(it != request.headers.end()); |
| 420 if (!base::StartsWith("foobar", it->second, | 421 if (!base::StartsWith("foobar", it->second, |
| 421 base::CompareCase::SENSITIVE)) | 422 base::CompareCase::SENSITIVE)) |
| 422 return scoped_ptr<net::test_server::HttpResponse>(); | 423 return scoped_ptr<net::test_server::HttpResponse>(); |
| 423 | 424 |
| 424 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 425 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
| 425 new net::test_server::BasicHttpResponse); | 426 new net::test_server::BasicHttpResponse); |
| 426 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); | 427 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); |
| 427 http_response->AddCustomHeader("Location", redirect_target.spec()); | 428 http_response->AddCustomHeader("Location", redirect_target.spec()); |
| 428 return http_response.Pass(); | 429 return std::move(http_response); |
| 429 } | 430 } |
| 430 | 431 |
| 431 // Handles |request| by serving a redirect response. | 432 // Handles |request| by serving a redirect response. |
| 432 static scoped_ptr<net::test_server::HttpResponse> RedirectResponseHandler( | 433 static scoped_ptr<net::test_server::HttpResponse> RedirectResponseHandler( |
| 433 const std::string& path, | 434 const std::string& path, |
| 434 const GURL& redirect_target, | 435 const GURL& redirect_target, |
| 435 const net::test_server::HttpRequest& request) { | 436 const net::test_server::HttpRequest& request) { |
| 436 if (!base::StartsWith(path, request.relative_url, | 437 if (!base::StartsWith(path, request.relative_url, |
| 437 base::CompareCase::SENSITIVE)) | 438 base::CompareCase::SENSITIVE)) |
| 438 return scoped_ptr<net::test_server::HttpResponse>(); | 439 return scoped_ptr<net::test_server::HttpResponse>(); |
| 439 | 440 |
| 440 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 441 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
| 441 new net::test_server::BasicHttpResponse); | 442 new net::test_server::BasicHttpResponse); |
| 442 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); | 443 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); |
| 443 http_response->AddCustomHeader("Location", redirect_target.spec()); | 444 http_response->AddCustomHeader("Location", redirect_target.spec()); |
| 444 return http_response.Pass(); | 445 return std::move(http_response); |
| 445 } | 446 } |
| 446 | 447 |
| 447 // Handles |request| by serving an empty response. | 448 // Handles |request| by serving an empty response. |
| 448 static scoped_ptr<net::test_server::HttpResponse> EmptyResponseHandler( | 449 static scoped_ptr<net::test_server::HttpResponse> EmptyResponseHandler( |
| 449 const std::string& path, | 450 const std::string& path, |
| 450 const net::test_server::HttpRequest& request) { | 451 const net::test_server::HttpRequest& request) { |
| 451 if (base::StartsWith(path, request.relative_url, | 452 if (base::StartsWith(path, request.relative_url, |
| 452 base::CompareCase::SENSITIVE)) | 453 base::CompareCase::SENSITIVE)) |
| 453 return scoped_ptr<net::test_server::HttpResponse>( | 454 return scoped_ptr<net::test_server::HttpResponse>( |
| 454 new net::test_server::RawHttpResponse("", "")); | 455 new net::test_server::RawHttpResponse("", "")); |
| 455 | 456 |
| 456 return scoped_ptr<net::test_server::HttpResponse>(); | 457 return scoped_ptr<net::test_server::HttpResponse>(); |
| 457 } | 458 } |
| 458 | 459 |
| 459 // Handles |request| by serving cache-able response. | 460 // Handles |request| by serving cache-able response. |
| 460 static scoped_ptr<net::test_server::HttpResponse> CacheControlResponseHandler( | 461 static scoped_ptr<net::test_server::HttpResponse> CacheControlResponseHandler( |
| 461 const std::string& path, | 462 const std::string& path, |
| 462 const net::test_server::HttpRequest& request) { | 463 const net::test_server::HttpRequest& request) { |
| 463 if (!base::StartsWith(path, request.relative_url, | 464 if (!base::StartsWith(path, request.relative_url, |
| 464 base::CompareCase::SENSITIVE)) | 465 base::CompareCase::SENSITIVE)) |
| 465 return scoped_ptr<net::test_server::HttpResponse>(); | 466 return scoped_ptr<net::test_server::HttpResponse>(); |
| 466 | 467 |
| 467 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 468 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
| 468 new net::test_server::BasicHttpResponse); | 469 new net::test_server::BasicHttpResponse); |
| 469 http_response->AddCustomHeader("Cache-control", "max-age=3600"); | 470 http_response->AddCustomHeader("Cache-control", "max-age=3600"); |
| 470 http_response->set_content_type("text/plain"); | 471 http_response->set_content_type("text/plain"); |
| 471 http_response->set_content("dummy text"); | 472 http_response->set_content("dummy text"); |
| 472 return http_response.Pass(); | 473 return std::move(http_response); |
| 473 } | 474 } |
| 474 | 475 |
| 475 // Shortcut to return the current MenuManager. | 476 // Shortcut to return the current MenuManager. |
| 476 extensions::MenuManager* menu_manager() { | 477 extensions::MenuManager* menu_manager() { |
| 477 return extensions::MenuManager::Get(browser()->profile()); | 478 return extensions::MenuManager::Get(browser()->profile()); |
| 478 } | 479 } |
| 479 | 480 |
| 480 // This gets all the items that any extension has registered for possible | 481 // This gets all the items that any extension has registered for possible |
| 481 // inclusion in context menus. | 482 // inclusion in context menus. |
| 482 MenuItem::List GetItems() { | 483 MenuItem::List GetItems() { |
| (...skipping 2471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2954 // 4 tasks expected. The order is arbitrary. | 2955 // 4 tasks expected. The order is arbitrary. |
| 2955 // Tab: about:blank, | 2956 // Tab: about:blank, |
| 2956 // Background Page: <webview> task manager test, | 2957 // Background Page: <webview> task manager test, |
| 2957 // App: <webview> task manager test, | 2958 // App: <webview> task manager test, |
| 2958 // Webview: WebViewed test content. | 2959 // Webview: WebViewed test content. |
| 2959 EXPECT_EQ(4U, task_manager.tasks().size()); | 2960 EXPECT_EQ(4U, task_manager.tasks().size()); |
| 2960 EXPECT_TRUE(HasExpectedGuestTask(task_manager, guest_contents)); | 2961 EXPECT_TRUE(HasExpectedGuestTask(task_manager, guest_contents)); |
| 2961 } | 2962 } |
| 2962 | 2963 |
| 2963 #endif // defined(ENABLE_TASK_MANAGER) | 2964 #endif // defined(ENABLE_TASK_MANAGER) |
| OLD | NEW |