| OLD | NEW |
| 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 // TODO(ukai): code is similar with http_network_transaction.cc. We should | 5 // TODO(ukai): code is similar with http_network_transaction.cc. We should |
| 6 // think about ways to share code, if possible. | 6 // think about ways to share code, if possible. |
| 7 | 7 |
| 8 #include "net/socket_stream/socket_stream.h" | 8 #include "net/socket_stream/socket_stream.h" |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 } | 125 } |
| 126 | 126 |
| 127 void SocketStream::SetUserData(const void* key, UserData* data) { | 127 void SocketStream::SetUserData(const void* key, UserData* data) { |
| 128 user_data_[key] = linked_ptr<UserData>(data); | 128 user_data_[key] = linked_ptr<UserData>(data); |
| 129 } | 129 } |
| 130 | 130 |
| 131 bool SocketStream::is_secure() const { | 131 bool SocketStream::is_secure() const { |
| 132 return url_.SchemeIs("wss"); | 132 return url_.SchemeIs("wss"); |
| 133 } | 133 } |
| 134 | 134 |
| 135 GURL SocketStream::GetURLForCookies(const GURL& url) { | |
| 136 std::string scheme = url.SchemeIs("wss") ? "https" : "http"; | |
| 137 url_canon::Replacements<char> replacements; | |
| 138 replacements.SetScheme(scheme.c_str(), | |
| 139 url_parse::Component(0, scheme.length())); | |
| 140 return url.ReplaceComponents(replacements); | |
| 141 } | |
| 142 | |
| 143 void SocketStream::set_context(URLRequestContext* context) { | 135 void SocketStream::set_context(URLRequestContext* context) { |
| 144 const URLRequestContext* prev_context = context_; | 136 const URLRequestContext* prev_context = context_; |
| 145 | 137 |
| 146 context_ = context; | 138 context_ = context; |
| 147 | 139 |
| 148 if (prev_context != context) { | 140 if (prev_context != context) { |
| 149 if (prev_context && pac_request_) { | 141 if (prev_context && pac_request_) { |
| 150 prev_context->proxy_service()->CancelPacRequest(pac_request_); | 142 prev_context->proxy_service()->CancelPacRequest(pac_request_); |
| 151 pac_request_ = NULL; | 143 pac_request_ = NULL; |
| 152 } | 144 } |
| (...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 return OK; | 1320 return OK; |
| 1329 } | 1321 } |
| 1330 | 1322 |
| 1331 if (!delegate_) | 1323 if (!delegate_) |
| 1332 return result; | 1324 return result; |
| 1333 | 1325 |
| 1334 SSLInfo ssl_info; | 1326 SSLInfo ssl_info; |
| 1335 ssl_socket->GetSSLInfo(&ssl_info); | 1327 ssl_socket->GetSSLInfo(&ssl_info); |
| 1336 | 1328 |
| 1337 TransportSecurityState::DomainState domain_state; | 1329 TransportSecurityState::DomainState domain_state; |
| 1338 const bool fatal = | 1330 const bool fatal = context_->transport_security_state() && |
| 1339 context_->transport_security_state() && | 1331 context_->transport_security_state()->GetDomainState(url_.host(), |
| 1340 context_->transport_security_state()->GetDomainState( | |
| 1341 url_.host(), | |
| 1342 SSLConfigService::IsSNIAvailable(context_->ssl_config_service()), | 1332 SSLConfigService::IsSNIAvailable(context_->ssl_config_service()), |
| 1343 delegate_->CanGetCookies(this, url_for_cookies()), | |
| 1344 &domain_state) && | 1333 &domain_state) && |
| 1345 domain_state.ShouldSSLErrorsBeFatal(); | 1334 domain_state.ShouldSSLErrorsBeFatal(); |
| 1346 | 1335 |
| 1347 delegate_->OnSSLCertificateError(this, ssl_info, fatal); | 1336 delegate_->OnSSLCertificateError(this, ssl_info, fatal); |
| 1348 return ERR_IO_PENDING; | 1337 return ERR_IO_PENDING; |
| 1349 } | 1338 } |
| 1350 | 1339 |
| 1351 } // namespace net | 1340 } // namespace net |
| OLD | NEW |