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

Side by Side Diff: net/url_request/url_request_context.h

Issue 19613: Merge 8764 - Add support for UA spoofing, and spoof Safari's UA string when l... (Closed) Base URL: svn://chrome-svn/chrome/branches/release_154.next/src/
Patch Set: Created 11 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // This class represents contextual information (cookies, cache, etc.) 5 // This class represents contextual information (cookies, cache, etc.)
6 // that's useful when processing resource requests. 6 // that's useful when processing resource requests.
7 // The class is reference-counted so that it can be cleaned up after any 7 // The class is reference-counted so that it can be cleaned up after any
8 // requests that are using it have been completed. 8 // requests that are using it have been completed.
9 9
10 #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ 10 #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_
11 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ 11 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_
12 12
13 #include <string>
14
15 #include "base/basictypes.h"
16 #include "base/ref_counted.h" 13 #include "base/ref_counted.h"
17 #include "base/scoped_ptr.h" 14 #include "base/scoped_ptr.h"
15 #include "base/string_util.h"
18 #include "net/base/auth_cache.h" 16 #include "net/base/auth_cache.h"
19 #include "net/base/cookie_policy.h" 17 #include "net/base/cookie_policy.h"
20 #include "net/http/http_transaction_factory.h" 18 #include "net/http/http_transaction_factory.h"
21 19
22 namespace net { 20 namespace net {
23 class CookieMonster; 21 class CookieMonster;
24 } 22 }
25 23
26 // Subclass to provide application-specific context for URLRequest instances. 24 // Subclass to provide application-specific context for URLRequest instances.
27 class URLRequestContext : 25 class URLRequestContext :
(...skipping 12 matching lines...) Expand all
40 38
41 // Gets the cookie store for this context. 39 // Gets the cookie store for this context.
42 net::CookieMonster* cookie_store() { return cookie_store_; } 40 net::CookieMonster* cookie_store() { return cookie_store_; }
43 41
44 // Gets the cookie policy for this context. 42 // Gets the cookie policy for this context.
45 net::CookiePolicy* cookie_policy() { return &cookie_policy_; } 43 net::CookiePolicy* cookie_policy() { return &cookie_policy_; }
46 44
47 // Gets the FTP realm authentication cache for this context. 45 // Gets the FTP realm authentication cache for this context.
48 net::AuthCache* ftp_auth_cache() { return &ftp_auth_cache_; } 46 net::AuthCache* ftp_auth_cache() { return &ftp_auth_cache_; }
49 47
50 // Gets the UA string to use for this context.
51 const std::string& user_agent() const { return user_agent_; }
52
53 // Gets the value of 'Accept-Charset' header field. 48 // Gets the value of 'Accept-Charset' header field.
54 const std::string& accept_charset() const { return accept_charset_; } 49 const std::string& accept_charset() const { return accept_charset_; }
55 50
56 // Gets the value of 'Accept-Language' header field. 51 // Gets the value of 'Accept-Language' header field.
57 const std::string& accept_language() const { return accept_language_; } 52 const std::string& accept_language() const { return accept_language_; }
58 53
54 // Gets the UA string to use for the given URL. Pass an invalid URL (such as
55 // GURL()) to get the default UA string. Subclasses should override this
56 // method to provide a UA string.
57 virtual const std::string& GetUserAgent(const GURL& url) const {
58 return EmptyString();
59 }
60
59 // Returns true if this context is off the record. 61 // Returns true if this context is off the record.
60 bool is_off_the_record() { return is_off_the_record_; } 62 bool is_off_the_record() { return is_off_the_record_; }
61 63
62 // Do not call this directly. TODO(darin): extending from RefCounted* should 64
63 // not require a public destructor! 65 protected:
66 friend class base::RefCountedThreadSafe<URLRequestContext>;
67
64 virtual ~URLRequestContext() {} 68 virtual ~URLRequestContext() {}
65 69
66 protected:
67 // The following members are expected to be initialized and owned by 70 // The following members are expected to be initialized and owned by
68 // subclasses. 71 // subclasses.
69 net::HttpTransactionFactory* http_transaction_factory_; 72 net::HttpTransactionFactory* http_transaction_factory_;
70 net::CookieMonster* cookie_store_; 73 net::CookieMonster* cookie_store_;
71 net::CookiePolicy cookie_policy_; 74 net::CookiePolicy cookie_policy_;
72 net::AuthCache ftp_auth_cache_; 75 net::AuthCache ftp_auth_cache_;
73 std::string user_agent_;
74 bool is_off_the_record_; 76 bool is_off_the_record_;
75 std::string accept_language_; 77 std::string accept_language_;
76 std::string accept_charset_; 78 std::string accept_charset_;
77 79
78 private: 80 private:
79 DISALLOW_EVIL_CONSTRUCTORS(URLRequestContext); 81 DISALLOW_COPY_AND_ASSIGN(URLRequestContext);
80 }; 82 };
81 83
82 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ 84 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_
83
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698