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

Side by Side Diff: ios/web/public/test/response_providers/html_response_provider.h

Issue 2291393003: Add capability to simple http server to bound Set-Cookie to URLs. (Closed)
Patch Set: Addressed comments from Peter Created 4 years, 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 #ifndef IOS_WEB_PUBLIC_TEST_RESPONSE_PROVIDERS_HTML_RESPONSE_PROVIDER_H_ 5 #ifndef IOS_WEB_PUBLIC_TEST_RESPONSE_PROVIDERS_HTML_RESPONSE_PROVIDER_H_
6 #define IOS_WEB_PUBLIC_TEST_RESPONSE_PROVIDERS_HTML_RESPONSE_PROVIDER_H_ 6 #define IOS_WEB_PUBLIC_TEST_RESPONSE_PROVIDERS_HTML_RESPONSE_PROVIDER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "ios/web/public/test/response_providers/data_response_provider.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" 13 #include "ios/web/public/test/response_providers/html_response_provider_impl.h"
14 #include "ios/web/public/test/response_providers/response_provider.h" 14 #include "ios/web/public/test/response_providers/response_provider.h"
15 #include "url/gurl.h" 15 #include "url/gurl.h"
16 16
17 namespace net { 17 namespace net {
18 class HttpResponseHeaders; 18 class HttpResponseHeaders;
19 } 19 }
20 20
21 // A web::DataResponseProvider that maps URLs to requests. 21 // A web::DataResponseProvider that maps URLs to requests.
22 class HtmlResponseProvider : public web::DataResponseProvider { 22 class HtmlResponseProvider : public web::DataResponseProvider {
23 public: 23 public:
24 // Constructs an HtmlResponseProvider that does not respond to any request. 24 // Constructs an HtmlResponseProvider that does not respond to any request.
25 HtmlResponseProvider(); 25 HtmlResponseProvider();
26 // Constructs an HtmlResponseProvider that generates a simple string response 26 // Constructs an HtmlResponseProvider that generates a simple string response
27 // to a URL based on the mapping present in |responses|. 27 // to a URL based on the mapping present in |responses|.
28 explicit HtmlResponseProvider(const std::map<GURL, std::string>& responses); 28 explicit HtmlResponseProvider(const std::map<GURL, std::string>& responses);
29 // Constructs an HtmlResponseProvider that generates a simple string response 29 // Constructs an HtmlResponseProvider that generates a simple string response
30 // to a URL based on the mapping present in |responses| and |cookie|. 30 // to a URL with a Set-Cookie entry in the headers based on the mapping
31 explicit HtmlResponseProvider(const std::map<GURL, std::string>& responses, 31 // present in |responses|.
32 const std::string& cookie); 32 explicit HtmlResponseProvider(
33 const std::map<GURL, std::pair<std::string, std::string>>& responses);
33 // Constructs an HtmlResponseProvider that generates a response to a URL based 34 // Constructs an HtmlResponseProvider that generates a response to a URL based
34 // on the mapping present in |responses|. 35 // on the mapping present in |responses|.
35 explicit HtmlResponseProvider( 36 explicit HtmlResponseProvider(
36 const std::map<GURL, HtmlResponseProviderImpl::Response>& responses); 37 const std::map<GURL, HtmlResponseProviderImpl::Response>& responses);
37 38
38 ~HtmlResponseProvider() override; 39 ~HtmlResponseProvider() override;
39 40
40 // web::ResponseProvider implementation. 41 // web::ResponseProvider implementation.
41 bool CanHandleRequest(const Request& request) override; 42 bool CanHandleRequest(const Request& request) override;
42 // web::DataResponseProvider implementation. 43 // web::DataResponseProvider implementation.
43 void GetResponseHeadersAndBody( 44 void GetResponseHeadersAndBody(
44 const Request& request, 45 const Request& request,
45 scoped_refptr<net::HttpResponseHeaders>* headers, 46 scoped_refptr<net::HttpResponseHeaders>* headers,
46 std::string* response_body) override; 47 std::string* response_body) override;
47 48
48 private: 49 private:
49 std::unique_ptr<HtmlResponseProviderImpl> response_provider_impl_; 50 std::unique_ptr<HtmlResponseProviderImpl> response_provider_impl_;
50 }; 51 };
51 52
52 #endif // IOS_WEB_PUBLIC_TEST_RESPONSE_PROVIDERS_HTML_RESPONSE_PROVIDER_H_ 53 #endif // IOS_WEB_PUBLIC_TEST_RESPONSE_PROVIDERS_HTML_RESPONSE_PROVIDER_H_
OLDNEW
« no previous file with comments | « ios/web/public/test/http_server_util.mm ('k') | ios/web/public/test/response_providers/html_response_provider.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698