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 #include "ios/web/public/test/response_providers/data_response_provider.h" | |
13 #include "ios/web/public/test/response_providers/html_response_provider_impl.h" | |
14 #include "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 // Note: This works with the web::test::HttpServer and hence works on UIWebView | |
Eugene But (OOO till 7-30)
2016/04/21 17:07:51
Please drop this comment. We don't support UIWebVi
baxley
2016/04/21 21:52:50
Done.
| |
23 // and WKWebView. | |
24 class HtmlResponseProvider : public web::DataResponseProvider { | |
25 public: | |
26 // Constructs an HtmlResponseProvider that does not respond to any request. | |
27 HtmlResponseProvider(); | |
28 // Constructs an HtmlResponseProvider that generates a simple string response | |
29 // to a URL based on the mapping present in |responses|. | |
30 explicit HtmlResponseProvider(const std::map<GURL, std::string>& responses); | |
31 // Constructs an HtmlResponseProvider that generates a response to a URL based | |
32 // on the mapping present in |responses|. | |
33 explicit HtmlResponseProvider( | |
34 const std::map<GURL, HtmlResponseProviderImpl::Response>& responses); | |
35 | |
36 ~HtmlResponseProvider() override; | |
37 | |
38 // web::ResponseProvider implementation. | |
39 bool CanHandleRequest(const Request& request) override; | |
40 // web::DataResponseProvider implementation. | |
41 void GetResponseHeadersAndBody( | |
42 const Request& request, | |
43 scoped_refptr<net::HttpResponseHeaders>* headers, | |
44 std::string* response_body) override; | |
45 | |
46 private: | |
47 std::unique_ptr<HtmlResponseProviderImpl> response_provider_impl_; | |
48 }; | |
49 | |
50 #endif // IOS_WEB_PUBLIC_TEST_RESPONSE_PROVIDERS_HTML_RESPONSE_PROVIDER_H_ | |
OLD | NEW |