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

Side by Side Diff: chrome/browser/policy/device_management_service.cc

Issue 10918279: Provide mutable members of UrlRequestContext via pure-virtual interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address erikwright's second round of comments. Created 8 years, 2 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/policy/device_management_service.h" 5 #include "chrome/browser/policy/device_management_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
13 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/sys_info.h" 14 #include "base/sys_info.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/net/basic_http_user_agent_settings.h"
16 #include "chrome/browser/net/chrome_net_log.h" 17 #include "chrome/browser/net/chrome_net_log.h"
17 #include "chrome/common/chrome_version_info.h" 18 #include "chrome/common/chrome_version_info.h"
18 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
19 #include "content/public/common/content_client.h" 20 #include "content/public/common/content_client.h"
20 #include "googleurl/src/gurl.h" 21 #include "googleurl/src/gurl.h"
21 #include "net/base/escape.h" 22 #include "net/base/escape.h"
22 #include "net/base/host_resolver.h" 23 #include "net/base/host_resolver.h"
23 #include "net/base/load_flags.h" 24 #include "net/base/load_flags.h"
24 #include "net/base/net_errors.h" 25 #include "net/base/net_errors.h"
25 #include "net/base/ssl_config_service_defaults.h" 26 #include "net/base/ssl_config_service_defaults.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 return platform; 177 return platform;
177 } 178 }
178 179
179 // Custom request context implementation that allows to override the user agent, 180 // Custom request context implementation that allows to override the user agent,
180 // amongst others. Wraps a baseline request context from which we reuse the 181 // amongst others. Wraps a baseline request context from which we reuse the
181 // networking components. 182 // networking components.
182 class DeviceManagementRequestContext : public net::URLRequestContext { 183 class DeviceManagementRequestContext : public net::URLRequestContext {
183 public: 184 public:
184 explicit DeviceManagementRequestContext(net::URLRequestContext* base_context); 185 explicit DeviceManagementRequestContext(net::URLRequestContext* base_context);
185 virtual ~DeviceManagementRequestContext(); 186 virtual ~DeviceManagementRequestContext();
186
187 private: 187 private:
188 // Overridden from net::URLRequestContext: 188 scoped_ptr<BasicHttpUserAgentSettings> basic_http_user_agent_settings_;
189 virtual const std::string& GetUserAgent(const GURL& url) const OVERRIDE;
190 }; 189 };
191 190
192 DeviceManagementRequestContext::DeviceManagementRequestContext( 191 DeviceManagementRequestContext::DeviceManagementRequestContext(
193 net::URLRequestContext* base_context) { 192 net::URLRequestContext* base_context) {
194 // Share resolver, proxy service and ssl bits with the baseline context. This 193 // Share resolver, proxy service and ssl bits with the baseline context. This
195 // is important so we don't make redundant requests (e.g. when resolving proxy 194 // is important so we don't make redundant requests (e.g. when resolving proxy
196 // auto configuration). 195 // auto configuration).
197 set_net_log(base_context->net_log()); 196 set_net_log(base_context->net_log());
198 set_host_resolver(base_context->host_resolver()); 197 set_host_resolver(base_context->host_resolver());
199 set_proxy_service(base_context->proxy_service()); 198 set_proxy_service(base_context->proxy_service());
200 set_ssl_config_service(base_context->ssl_config_service()); 199 set_ssl_config_service(base_context->ssl_config_service());
201 200
202 // Share the http session. 201 // Share the http session.
203 set_http_transaction_factory( 202 set_http_transaction_factory(
204 new net::HttpNetworkLayer( 203 new net::HttpNetworkLayer(
205 base_context->http_transaction_factory()->GetSession())); 204 base_context->http_transaction_factory()->GetSession()));
206 205
207 // No cookies, please. 206 // No cookies, please.
208 set_cookie_store(new net::CookieMonster(NULL, NULL)); 207 set_cookie_store(new net::CookieMonster(NULL, NULL));
209 208
210 // Initialize these to sane values for our purposes. 209 // Initialize Accept-Language and Accept-Charset to sane values for our
211 set_accept_language("*"); 210 // purposes.
212 set_accept_charset("*"); 211 basic_http_user_agent_settings_.reset(
212 new BasicHttpUserAgentSettings("*", "*"));
213 set_http_user_agent_settings(basic_http_user_agent_settings_.get());
213 } 214 }
214 215
215 DeviceManagementRequestContext::~DeviceManagementRequestContext() { 216 DeviceManagementRequestContext::~DeviceManagementRequestContext() {
216 delete http_transaction_factory(); 217 delete http_transaction_factory();
217 } 218 }
218 219
219 const std::string& DeviceManagementRequestContext::GetUserAgent(
220 const GURL& url) const {
221 return content::GetUserAgent(url);
222 }
223
224 // Request context holder. 220 // Request context holder.
225 class DeviceManagementRequestContextGetter 221 class DeviceManagementRequestContextGetter
226 : public net::URLRequestContextGetter { 222 : public net::URLRequestContextGetter {
227 public: 223 public:
228 explicit DeviceManagementRequestContextGetter( 224 explicit DeviceManagementRequestContextGetter(
229 net::URLRequestContextGetter* base_context_getter) 225 net::URLRequestContextGetter* base_context_getter)
230 : base_context_getter_(base_context_getter) {} 226 : base_context_getter_(base_context_getter) {}
231 227
232 // Overridden from net::URLRequestContextGetter: 228 // Overridden from net::URLRequestContextGetter:
233 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; 229 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE;
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 } 581 }
586 } 582 }
587 583
588 const JobQueue::iterator elem = 584 const JobQueue::iterator elem =
589 std::find(queued_jobs_.begin(), queued_jobs_.end(), job); 585 std::find(queued_jobs_.begin(), queued_jobs_.end(), job);
590 if (elem != queued_jobs_.end()) 586 if (elem != queued_jobs_.end())
591 queued_jobs_.erase(elem); 587 queued_jobs_.erase(elem);
592 } 588 }
593 589
594 } // namespace policy 590 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698