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_impl.h" | 5 #include "net/url_request/url_request_job_factory_impl.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "net/base/load_flags.h" | 8 #include "net/base/load_flags.h" |
9 #include "net/url_request/url_request_interceptor.h" | 9 #include "net/url_request/url_request_interceptor.h" |
10 #include "net/url_request/url_request_job_manager.h" | 10 #include "net/url_request/url_request_job_manager.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 return nullptr; | 73 return nullptr; |
74 } | 74 } |
75 | 75 |
76 bool URLRequestJobFactoryImpl::IsHandledProtocol( | 76 bool URLRequestJobFactoryImpl::IsHandledProtocol( |
77 const std::string& scheme) const { | 77 const std::string& scheme) const { |
78 DCHECK(CalledOnValidThread()); | 78 DCHECK(CalledOnValidThread()); |
79 return base::ContainsKey(protocol_handler_map_, scheme) || | 79 return base::ContainsKey(protocol_handler_map_, scheme) || |
80 URLRequestJobManager::GetInstance()->SupportsScheme(scheme); | 80 URLRequestJobManager::GetInstance()->SupportsScheme(scheme); |
81 } | 81 } |
82 | 82 |
83 bool URLRequestJobFactoryImpl::IsHandledURL(const GURL& url) const { | |
84 if (!url.is_valid()) { | |
85 // We handle error cases. | |
86 return true; | |
87 } | |
88 return IsHandledProtocol(url.scheme()); | |
89 } | |
90 | |
91 bool URLRequestJobFactoryImpl::IsSafeRedirectTarget( | 83 bool URLRequestJobFactoryImpl::IsSafeRedirectTarget( |
92 const GURL& location) const { | 84 const GURL& location) const { |
93 DCHECK(CalledOnValidThread()); | 85 DCHECK(CalledOnValidThread()); |
94 if (!location.is_valid()) { | 86 if (!location.is_valid()) { |
95 // Error cases are safely handled. | 87 // Error cases are safely handled. |
96 return true; | 88 return true; |
97 } | 89 } |
98 ProtocolHandlerMap::const_iterator it = protocol_handler_map_.find( | 90 ProtocolHandlerMap::const_iterator it = protocol_handler_map_.find( |
99 location.scheme()); | 91 location.scheme()); |
100 if (it == protocol_handler_map_.end()) { | 92 if (it == protocol_handler_map_.end()) { |
101 // Unhandled cases are safely handled. | 93 // Unhandled cases are safely handled. |
102 return true; | 94 return true; |
103 } | 95 } |
104 return it->second->IsSafeRedirectTarget(location); | 96 return it->second->IsSafeRedirectTarget(location); |
105 } | 97 } |
106 | 98 |
107 // static | 99 // static |
108 void URLRequestJobFactoryImpl::SetInterceptorForTesting( | 100 void URLRequestJobFactoryImpl::SetInterceptorForTesting( |
109 URLRequestInterceptor* interceptor) { | 101 URLRequestInterceptor* interceptor) { |
110 DCHECK(!interceptor || !g_interceptor_for_testing); | 102 DCHECK(!interceptor || !g_interceptor_for_testing); |
111 | 103 |
112 g_interceptor_for_testing = interceptor; | 104 g_interceptor_for_testing = interceptor; |
113 } | 105 } |
114 | 106 |
115 } // namespace net | 107 } // namespace net |
OLD | NEW |