| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/message_loop.h" |
| 8 #include "base/message_loop_proxy.h" |
| 7 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/io_thread.h" | |
| 9 #include "chrome/browser/net/chrome_net_log.h" | 10 #include "chrome/browser/net/chrome_net_log.h" |
| 11 #include "chrome/browser/policy/device_management_backend.h" |
| 10 #include "chrome/browser/policy/device_management_backend_impl.h" | 12 #include "chrome/browser/policy/device_management_backend_impl.h" |
| 11 #include "content/browser/browser_thread.h" | 13 #include "content/browser/browser_thread.h" |
| 12 #include "net/base/cookie_monster.h" | 14 #include "net/base/cookie_monster.h" |
| 13 #include "net/base/host_resolver.h" | 15 #include "net/base/host_resolver.h" |
| 14 #include "net/base/load_flags.h" | 16 #include "net/base/load_flags.h" |
| 15 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 16 #include "net/base/ssl_config_service_defaults.h" | 18 #include "net/base/ssl_config_service_defaults.h" |
| 17 #include "net/http/http_auth_handler_factory.h" | |
| 18 #include "net/http/http_network_layer.h" | 19 #include "net/http/http_network_layer.h" |
| 19 #include "net/proxy/proxy_service.h" | 20 #include "net/proxy/proxy_service.h" |
| 20 #include "net/url_request/url_request_context.h" | 21 #include "net/url_request/url_request_context.h" |
| 21 #include "net/url_request/url_request_context_getter.h" | 22 #include "net/url_request/url_request_context_getter.h" |
| 22 #include "net/url_request/url_request_status.h" | 23 #include "net/url_request/url_request_status.h" |
| 23 #include "webkit/glue/webkit_glue.h" | 24 #include "webkit/glue/webkit_glue.h" |
| 24 | 25 |
| 25 namespace policy { | 26 namespace policy { |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 // Custom request context implementation that allows to override the user agent, | 30 // Custom request context implementation that allows to override the user agent, |
| 30 // amongst others. Wraps a baseline request context from which we reuse the | 31 // amongst others. Wraps a baseline request context from which we reuse the |
| 31 // networking components. | 32 // networking components. |
| 32 class DeviceManagementRequestContext : public net::URLRequestContext { | 33 class DeviceManagementRequestContext : public net::URLRequestContext { |
| 33 public: | 34 public: |
| 34 explicit DeviceManagementRequestContext(net::URLRequestContext* base_context); | 35 explicit DeviceManagementRequestContext(net::URLRequestContext* base_context); |
| 35 virtual ~DeviceManagementRequestContext(); | 36 virtual ~DeviceManagementRequestContext(); |
| 36 | 37 |
| 37 private: | 38 private: |
| 38 // Overridden from net::URLRequestContext: | 39 // Overridden from net::URLRequestContext: |
| 39 virtual const std::string& GetUserAgent(const GURL& url) const; | 40 virtual const std::string& GetUserAgent(const GURL& url) const OVERRIDE; |
| 40 }; | 41 }; |
| 41 | 42 |
| 42 DeviceManagementRequestContext::DeviceManagementRequestContext( | 43 DeviceManagementRequestContext::DeviceManagementRequestContext( |
| 43 net::URLRequestContext* base_context) { | 44 net::URLRequestContext* base_context) { |
| 44 // Share resolver, proxy service and ssl bits with the baseline context. This | 45 // Share resolver, proxy service and ssl bits with the baseline context. This |
| 45 // is important so we don't make redundant requests (e.g. when resolving proxy | 46 // is important so we don't make redundant requests (e.g. when resolving proxy |
| 46 // auto configuration). | 47 // auto configuration). |
| 47 set_net_log(base_context->net_log()); | 48 set_net_log(base_context->net_log()); |
| 48 set_host_resolver(base_context->host_resolver()); | 49 set_host_resolver(base_context->host_resolver()); |
| 49 set_proxy_service(base_context->proxy_service()); | 50 set_proxy_service(base_context->proxy_service()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 68 | 69 |
| 69 const std::string& DeviceManagementRequestContext::GetUserAgent( | 70 const std::string& DeviceManagementRequestContext::GetUserAgent( |
| 70 const GURL& url) const { | 71 const GURL& url) const { |
| 71 return webkit_glue::GetUserAgent(url); | 72 return webkit_glue::GetUserAgent(url); |
| 72 } | 73 } |
| 73 | 74 |
| 74 // Request context holder. | 75 // Request context holder. |
| 75 class DeviceManagementRequestContextGetter | 76 class DeviceManagementRequestContextGetter |
| 76 : public net::URLRequestContextGetter { | 77 : public net::URLRequestContextGetter { |
| 77 public: | 78 public: |
| 78 DeviceManagementRequestContextGetter( | 79 explicit DeviceManagementRequestContextGetter( |
| 79 net::URLRequestContextGetter* base_context_getter) | 80 net::URLRequestContextGetter* base_context_getter) |
| 80 : base_context_getter_(base_context_getter) {} | 81 : base_context_getter_(base_context_getter) {} |
| 81 | 82 |
| 82 // Overridden from net::URLRequestContextGetter: | 83 // Overridden from net::URLRequestContextGetter: |
| 83 virtual net::URLRequestContext* GetURLRequestContext(); | 84 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; |
| 84 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const; | 85 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() |
| 86 const OVERRIDE; |
| 85 | 87 |
| 86 private: | 88 private: |
| 87 scoped_refptr<net::URLRequestContext> context_; | 89 scoped_refptr<net::URLRequestContext> context_; |
| 88 scoped_refptr<net::URLRequestContextGetter> base_context_getter_; | 90 scoped_refptr<net::URLRequestContextGetter> base_context_getter_; |
| 89 }; | 91 }; |
| 90 | 92 |
| 91 | 93 |
| 92 net::URLRequestContext* | 94 net::URLRequestContext* |
| 93 DeviceManagementRequestContextGetter::GetURLRequestContext() { | 95 DeviceManagementRequestContextGetter::GetURLRequestContext() { |
| 94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } else { | 231 } else { |
| 230 job->HandleResponse(status, response_code, cookies, data); | 232 job->HandleResponse(status, response_code, cookies, data); |
| 231 } | 233 } |
| 232 } else { | 234 } else { |
| 233 NOTREACHED() << "Callback from foreign URL fetcher"; | 235 NOTREACHED() << "Callback from foreign URL fetcher"; |
| 234 } | 236 } |
| 235 delete source; | 237 delete source; |
| 236 } | 238 } |
| 237 | 239 |
| 238 } // namespace policy | 240 } // namespace policy |
| OLD | NEW |