OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_ | 5 #ifndef CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_ |
6 #define CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_ | 6 #define CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 // the profile is not available. | 30 // the profile is not available. |
31 // | 31 // |
32 class ServiceURLRequestContext : public URLRequestContext { | 32 class ServiceURLRequestContext : public URLRequestContext { |
33 public: | 33 public: |
34 explicit ServiceURLRequestContext(const std::string& user_agent); | 34 explicit ServiceURLRequestContext(const std::string& user_agent); |
35 void set_cookie_policy(net::CookiePolicy* policy) { | 35 void set_cookie_policy(net::CookiePolicy* policy) { |
36 cookie_policy_ = policy; | 36 cookie_policy_ = policy; |
37 } | 37 } |
38 | 38 |
39 // URLRequestContext overrides | 39 // URLRequestContext overrides |
40 virtual const std::string& GetUserAgent(const GURL& url) const { | 40 virtual const std::string& GetUserAgent(const GURL& url) const; |
41 // If the user agent is set explicitly return that, otherwise call the | |
42 // base class method to return default value. | |
43 return user_agent_.empty() ? | |
44 URLRequestContext::GetUserAgent(url) : user_agent_; | |
45 } | |
46 | 41 |
47 protected: | 42 protected: |
48 virtual ~ServiceURLRequestContext(); | 43 virtual ~ServiceURLRequestContext(); |
49 | 44 |
50 private: | 45 private: |
51 std::string user_agent_; | 46 std::string user_agent_; |
52 }; | 47 }; |
53 | 48 |
54 class ServiceURLRequestContextGetter : public URLRequestContextGetter { | 49 class ServiceURLRequestContextGetter : public URLRequestContextGetter { |
55 public: | 50 public: |
(...skipping 11 matching lines...) Expand all Loading... |
67 private: | 62 private: |
68 virtual ~ServiceURLRequestContextGetter(); | 63 virtual ~ServiceURLRequestContextGetter(); |
69 | 64 |
70 std::string user_agent_; | 65 std::string user_agent_; |
71 scoped_refptr<URLRequestContext> url_request_context_; | 66 scoped_refptr<URLRequestContext> url_request_context_; |
72 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; | 67 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; |
73 }; | 68 }; |
74 | 69 |
75 #endif // CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_ | 70 #endif // CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_ |
76 | 71 |
OLD | NEW |