| OLD | NEW |
| 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 #ifdef CHROME_PERSONALIZATION | 5 #ifdef CHROME_PERSONALIZATION |
| 6 | 6 |
| 7 #ifndef CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_ | 7 #ifndef CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_ |
| 8 #define CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_ | 8 #define CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_ |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 bool is_user_agent_set() const { return !user_agent_.empty(); } | 56 bool is_user_agent_set() const { return !user_agent_.empty(); } |
| 57 | 57 |
| 58 virtual const std::string& GetUserAgent(const GURL& url) const { | 58 virtual const std::string& GetUserAgent(const GURL& url) const { |
| 59 // If the user agent is set explicitly return that, otherwise call the | 59 // If the user agent is set explicitly return that, otherwise call the |
| 60 // base class method to return default value. | 60 // base class method to return default value. |
| 61 return user_agent_.empty() ? | 61 return user_agent_.empty() ? |
| 62 URLRequestContext::GetUserAgent(url) : user_agent_; | 62 URLRequestContext::GetUserAgent(url) : user_agent_; |
| 63 } | 63 } |
| 64 | 64 |
| 65 virtual bool AllowSendingCookies(const URLRequest* request) const { | 65 virtual bool AllowSendingCookies(const URLRequest* request) const { |
| 66 return false; // Never send cookies. | 66 // TODO(chron): http://crbug.com/20182. Change this to return false once |
| 67 // all clients use Authenticate: header auth mode. |
| 68 return true; |
| 67 } | 69 } |
| 68 | 70 |
| 69 private: | 71 private: |
| 70 std::string user_agent_; | 72 std::string user_agent_; |
| 71 | 73 |
| 72 DISALLOW_COPY_AND_ASSIGN(RequestContext); | 74 DISALLOW_COPY_AND_ASSIGN(RequestContext); |
| 73 }; | 75 }; |
| 74 | 76 |
| 75 HttpBridge(RequestContext* context, MessageLoop* io_loop); | 77 HttpBridge(RequestContext* context, MessageLoop* io_loop); |
| 76 virtual ~HttpBridge(); | 78 virtual ~HttpBridge(); |
| 77 | 79 |
| 78 // sync_api::HttpPostProvider implementation. | 80 // sync_api::HttpPostProvider implementation. |
| 79 virtual void SetUserAgent(const char* user_agent); | 81 virtual void SetUserAgent(const char* user_agent); |
| 80 virtual void SetExtraRequestHeaders(const char* headers); | 82 virtual void SetExtraRequestHeaders(const char* headers); |
| 81 virtual void SetURL(const char* url, int port); | 83 virtual void SetURL(const char* url, int port); |
| 82 virtual void SetPostPayload(const char* content_type, int content_length, | 84 virtual void SetPostPayload(const char* content_type, int content_length, |
| 83 const char* content); | 85 const char* content); |
| 84 virtual void AddCookieForRequest(const char* cookie); | 86 virtual void AddCookieForRequest(const char* cookie); |
| 85 virtual bool MakeSynchronousPost(int* os_error_code, int* response_code); | 87 virtual bool MakeSynchronousPost(int* os_error_code, int* response_code); |
| 88 |
| 89 // WARNING: these response content methods are used to extract plain old data |
| 90 // and not null terminated strings, so you should make sure you have read |
| 91 // GetResponseContentLength() characters when using GetResponseContent. e.g |
| 92 // string r(b->GetResponseContent(), b->GetResponseContentLength()). |
| 86 virtual int GetResponseContentLength() const; | 93 virtual int GetResponseContentLength() const; |
| 87 virtual const char* GetResponseContent() const; | 94 virtual const char* GetResponseContent() const; |
| 88 virtual int GetResponseCookieCount() const; | 95 virtual int GetResponseCookieCount() const; |
| 89 virtual const char* GetResponseCookieAt(int cookie_number) const; | 96 virtual const char* GetResponseCookieAt(int cookie_number) const; |
| 90 | 97 |
| 91 // URLFetcher::Delegate implementation. | 98 // URLFetcher::Delegate implementation. |
| 92 virtual void OnURLFetchComplete(const URLFetcher* source, const GURL& url, | 99 virtual void OnURLFetchComplete(const URLFetcher* source, const GURL& url, |
| 93 const URLRequestStatus& status, | 100 const URLRequestStatus& status, |
| 94 int response_code, | 101 int response_code, |
| 95 const ResponseCookies& cookies, | 102 const ResponseCookies& cookies, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 // We must Release() this from the IO thread. | 177 // We must Release() this from the IO thread. |
| 171 HttpBridge::RequestContext* request_context_; | 178 HttpBridge::RequestContext* request_context_; |
| 172 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory); | 179 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory); |
| 173 }; | 180 }; |
| 174 | 181 |
| 175 } // namespace browser_sync | 182 } // namespace browser_sync |
| 176 | 183 |
| 177 #endif // CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_ | 184 #endif // CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_ |
| 178 | 185 |
| 179 #endif // CHROME_PERSONALIZATION | 186 #endif // CHROME_PERSONALIZATION |
| OLD | NEW |