| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef IOS_WEB_PUBLIC_TEST_RESPONSE_PROVIDERS_HTML_RESPONSE_PROVIDER_H_ | |
| 6 #define IOS_WEB_PUBLIC_TEST_RESPONSE_PROVIDERS_HTML_RESPONSE_PROVIDER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #import "ios/web/public/test/response_providers/data_response_provider.h" | |
| 13 #import "ios/web/public/test/response_providers/html_response_provider_impl.h" | |
| 14 #import "ios/web/public/test/response_providers/response_provider.h" | |
| 15 #include "url/gurl.h" | |
| 16 | |
| 17 namespace net { | |
| 18 class HttpResponseHeaders; | |
| 19 } | |
| 20 | |
| 21 // A web::DataResponseProvider that maps URLs to requests. | |
| 22 class HtmlResponseProvider : public web::DataResponseProvider { | |
| 23 public: | |
| 24 // Constructs an HtmlResponseProvider that does not respond to any request. | |
| 25 HtmlResponseProvider(); | |
| 26 // Constructs an HtmlResponseProvider that generates a simple string response | |
| 27 // to a URL based on the mapping present in |responses|. | |
| 28 explicit HtmlResponseProvider(const std::map<GURL, std::string>& responses); | |
| 29 // Constructs an HtmlResponseProvider that generates a simple string response | |
| 30 // to a URL with a Set-Cookie entry in the headers based on the mapping | |
| 31 // present in |responses|. | |
| 32 explicit HtmlResponseProvider( | |
| 33 const std::map<GURL, std::pair<std::string, std::string>>& responses); | |
| 34 // Constructs an HtmlResponseProvider that generates a response to a URL based | |
| 35 // on the mapping present in |responses|. | |
| 36 explicit HtmlResponseProvider( | |
| 37 const std::map<GURL, HtmlResponseProviderImpl::Response>& responses); | |
| 38 | |
| 39 ~HtmlResponseProvider() override; | |
| 40 | |
| 41 // web::ResponseProvider implementation. | |
| 42 bool CanHandleRequest(const Request& request) override; | |
| 43 // web::DataResponseProvider implementation. | |
| 44 void GetResponseHeadersAndBody( | |
| 45 const Request& request, | |
| 46 scoped_refptr<net::HttpResponseHeaders>* headers, | |
| 47 std::string* response_body) override; | |
| 48 | |
| 49 private: | |
| 50 std::unique_ptr<HtmlResponseProviderImpl> response_provider_impl_; | |
| 51 }; | |
| 52 | |
| 53 #endif // IOS_WEB_PUBLIC_TEST_RESPONSE_PROVIDERS_HTML_RESPONSE_PROVIDER_H_ | |
| OLD | NEW |