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

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

Issue 5293005: Make the device management service send a proper user agent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/policy/device_management_service.h" 5 #include "chrome/browser/policy/device_management_service.h"
6 6
7 #include "chrome/browser/browser_thread.h" 7 #include "chrome/browser/browser_thread.h"
8 #include "net/base/cookie_monster.h" 8 #include "net/base/cookie_monster.h"
9 #include "net/base/host_resolver.h" 9 #include "net/base/host_resolver.h"
10 #include "net/base/load_flags.h" 10 #include "net/base/load_flags.h"
11 #include "net/base/ssl_config_service_defaults.h" 11 #include "net/base/ssl_config_service_defaults.h"
12 #include "net/http/http_auth_handler_factory.h" 12 #include "net/http/http_auth_handler_factory.h"
13 #include "net/http/http_network_layer.h" 13 #include "net/http/http_network_layer.h"
14 #include "net/proxy/proxy_service.h" 14 #include "net/proxy/proxy_service.h"
15 #include "net/url_request/url_request_context.h" 15 #include "net/url_request/url_request_context.h"
16 #include "net/url_request/url_request_status.h" 16 #include "net/url_request/url_request_status.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/io_thread.h" 18 #include "chrome/browser/io_thread.h"
19 #include "chrome/browser/net/chrome_net_log.h" 19 #include "chrome/browser/net/chrome_net_log.h"
20 #include "chrome/browser/policy/device_management_backend_impl.h" 20 #include "chrome/browser/policy/device_management_backend_impl.h"
21 #include "chrome/common/net/url_request_context_getter.h" 21 #include "chrome/common/net/url_request_context_getter.h"
22 #include "webkit/glue/webkit_glue.h"
22 23
23 namespace policy { 24 namespace policy {
24 25
25 namespace { 26 namespace {
26 27
27 // Custom request context implementation that allows to override the user agent, 28 // Custom request context implementation that allows to override the user agent,
28 // amongst others. Wraps a baseline request context from which we reuse the 29 // amongst others. Wraps a baseline request context from which we reuse the
29 // networking components. 30 // networking components.
30 class DeviceManagementRequestContext : public URLRequestContext { 31 class DeviceManagementRequestContext : public URLRequestContext {
31 public: 32 public:
32 explicit DeviceManagementRequestContext(URLRequestContext* base_context); 33 explicit DeviceManagementRequestContext(URLRequestContext* base_context);
33 virtual ~DeviceManagementRequestContext(); 34 virtual ~DeviceManagementRequestContext();
35
36 private:
37 // Overriden from URLRequestContext.
38 virtual const std::string& GetUserAgent(const GURL& url) const;
34 }; 39 };
35 40
36 DeviceManagementRequestContext::DeviceManagementRequestContext( 41 DeviceManagementRequestContext::DeviceManagementRequestContext(
37 URLRequestContext* base_context) { 42 URLRequestContext* base_context) {
38 // Share resolver, proxy service and ssl bits with the baseline context. This 43 // Share resolver, proxy service and ssl bits with the baseline context. This
39 // is important so we don't make redundant requests (e.g. when resolving proxy 44 // is important so we don't make redundant requests (e.g. when resolving proxy
40 // auto configuration). 45 // auto configuration).
41 net_log_ = base_context->net_log(); 46 net_log_ = base_context->net_log();
42 host_resolver_ = base_context->host_resolver(); 47 host_resolver_ = base_context->host_resolver();
43 proxy_service_ = base_context->proxy_service(); 48 proxy_service_ = base_context->proxy_service();
44 ssl_config_service_ = base_context->ssl_config_service(); 49 ssl_config_service_ = base_context->ssl_config_service();
45 50
46 // Share the http session. 51 // Share the http session.
47 http_transaction_factory_ = net::HttpNetworkLayer::CreateFactory( 52 http_transaction_factory_ = net::HttpNetworkLayer::CreateFactory(
48 base_context->http_transaction_factory()->GetSession()); 53 base_context->http_transaction_factory()->GetSession());
49 54
50 // No cookies, please. 55 // No cookies, please.
51 cookie_store_ = new net::CookieMonster(NULL, NULL); 56 cookie_store_ = new net::CookieMonster(NULL, NULL);
52 57
53 // Initialize these to sane values for our purposes. 58 // Initialize these to sane values for our purposes.
54 accept_language_ = "*"; 59 accept_language_ = "*";
55 accept_charset_ = "*"; 60 accept_charset_ = "*";
56 } 61 }
57 62
58 DeviceManagementRequestContext::~DeviceManagementRequestContext() { 63 DeviceManagementRequestContext::~DeviceManagementRequestContext() {
59 delete http_transaction_factory_; 64 delete http_transaction_factory_;
60 delete http_auth_handler_factory_; 65 delete http_auth_handler_factory_;
61 } 66 }
62 67
68 const std::string& DeviceManagementRequestContext::GetUserAgent(
69 const GURL& url) const {
70 return webkit_glue::GetUserAgent(url);
71 }
72
63 // Request context holder. 73 // Request context holder.
64 class DeviceManagementRequestContextGetter : public URLRequestContextGetter { 74 class DeviceManagementRequestContextGetter : public URLRequestContextGetter {
65 public: 75 public:
66 DeviceManagementRequestContextGetter( 76 DeviceManagementRequestContextGetter(
67 URLRequestContextGetter* base_context_getter) 77 URLRequestContextGetter* base_context_getter)
68 : base_context_getter_(base_context_getter) {} 78 : base_context_getter_(base_context_getter) {}
69 79
70 // URLRequestContextGetter overrides. 80 // URLRequestContextGetter overrides.
71 virtual URLRequestContext* GetURLRequestContext(); 81 virtual URLRequestContext* GetURLRequestContext();
72 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const; 82 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 DeviceManagementJob* job = entry->second; 184 DeviceManagementJob* job = entry->second;
175 job->HandleResponse(status, response_code, cookies, data); 185 job->HandleResponse(status, response_code, cookies, data);
176 pending_jobs_.erase(entry); 186 pending_jobs_.erase(entry);
177 } else { 187 } else {
178 NOTREACHED() << "Callback from foreign URL fetcher"; 188 NOTREACHED() << "Callback from foreign URL fetcher";
179 } 189 }
180 delete source; 190 delete source;
181 } 191 }
182 192
183 } // namespace policy 193 } // namespace policy
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698