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 "net/url_request/url_request_job_factory.h" | 5 #include "net/url_request/url_request_job_factory.h" |
6 | 6 |
7 #include "base/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" |
8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
9 #include "net/base/load_flags.h" | 9 #include "net/base/load_flags.h" |
10 #include "net/url_request/url_request_job_manager.h" | 10 #include "net/url_request/url_request_job_manager.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 URLRequestJob* URLRequestJobFactory::MaybeCreateJobWithProtocolHandler( | 69 URLRequestJob* URLRequestJobFactory::MaybeCreateJobWithProtocolHandler( |
70 const std::string& scheme, | 70 const std::string& scheme, |
71 URLRequest* request) const { | 71 URLRequest* request) const { |
72 DCHECK(CalledOnValidThread()); | 72 DCHECK(CalledOnValidThread()); |
73 ProtocolHandlerMap::const_iterator it = protocol_handler_map_.find(scheme); | 73 ProtocolHandlerMap::const_iterator it = protocol_handler_map_.find(scheme); |
74 if (it == protocol_handler_map_.end()) | 74 if (it == protocol_handler_map_.end()) |
75 return NULL; | 75 return NULL; |
76 return it->second->MaybeCreateJob(request); | 76 return it->second->MaybeCreateJob(request); |
77 } | 77 } |
78 | 78 |
| 79 URLRequestJob* URLRequestJobFactory::MaybeInterceptRedirect( |
| 80 const GURL& location, |
| 81 URLRequest* request) const { |
| 82 DCHECK(CalledOnValidThread()); |
| 83 URLRequestJob* job = NULL; |
| 84 |
| 85 if (!(request->load_flags() & LOAD_DISABLE_INTERCEPT)) { |
| 86 InterceptorList::const_iterator i; |
| 87 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { |
| 88 job = (*i)->MaybeInterceptRedirect(location, request); |
| 89 if (job) |
| 90 return job; |
| 91 } |
| 92 } |
| 93 return NULL; |
| 94 } |
| 95 |
| 96 URLRequestJob* URLRequestJobFactory::MaybeInterceptResponse( |
| 97 URLRequest* request) const { |
| 98 DCHECK(CalledOnValidThread()); |
| 99 URLRequestJob* job = NULL; |
| 100 |
| 101 if (!(request->load_flags() & LOAD_DISABLE_INTERCEPT)) { |
| 102 InterceptorList::const_iterator i; |
| 103 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { |
| 104 job = (*i)->MaybeInterceptResponse(request); |
| 105 if (job) |
| 106 return job; |
| 107 } |
| 108 } |
| 109 return NULL; |
| 110 } |
| 111 |
79 bool URLRequestJobFactory::IsHandledProtocol(const std::string& scheme) const { | 112 bool URLRequestJobFactory::IsHandledProtocol(const std::string& scheme) const { |
80 DCHECK(CalledOnValidThread()); | 113 DCHECK(CalledOnValidThread()); |
81 InterceptorList::const_iterator i; | 114 InterceptorList::const_iterator i; |
82 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { | 115 for (i = interceptors_.begin(); i != interceptors_.end(); ++i) { |
83 if ((*i)->WillHandleProtocol(scheme)) | 116 if ((*i)->WillHandleProtocol(scheme)) |
84 return true; | 117 return true; |
85 } | 118 } |
86 return ContainsKey(protocol_handler_map_, scheme) || | 119 return ContainsKey(protocol_handler_map_, scheme) || |
87 URLRequestJobManager::GetInstance()->SupportsScheme(scheme); | 120 URLRequestJobManager::GetInstance()->SupportsScheme(scheme); |
88 } | 121 } |
89 | 122 |
90 bool URLRequestJobFactory::IsHandledURL(const GURL& url) const { | 123 bool URLRequestJobFactory::IsHandledURL(const GURL& url) const { |
91 if (!url.is_valid()) { | 124 if (!url.is_valid()) { |
92 // We handle error cases. | 125 // We handle error cases. |
93 return true; | 126 return true; |
94 } | 127 } |
95 return IsHandledProtocol(url.scheme()); | 128 return IsHandledProtocol(url.scheme()); |
96 } | 129 } |
97 | 130 |
98 } // namespace net | 131 } // namespace net |
OLD | NEW |