OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/password_manager/core/browser/hsts_query.h" |
| 6 #include "base/bind.h" |
| 7 #include "base/location.h" |
| 8 #include "base/task_runner_util.h" |
| 9 #include "net/url_request/url_request_context.h" |
| 10 #include "url/gurl.h" |
| 11 |
| 12 namespace password_manager { |
| 13 |
| 14 namespace { |
| 15 |
| 16 bool IsHSTSActiveForHostAndRequestContext( |
| 17 const GURL& origin, |
| 18 const scoped_refptr<net::URLRequestContextGetter>& request_context) { |
| 19 if (!origin.is_valid()) |
| 20 return false; |
| 21 |
| 22 net::TransportSecurityState* security_state = |
| 23 request_context->GetURLRequestContext()->transport_security_state(); |
| 24 |
| 25 if (!security_state) |
| 26 return false; |
| 27 |
| 28 return security_state->ShouldUpgradeToSSL(origin.host()); |
| 29 } |
| 30 |
| 31 } // namespace |
| 32 |
| 33 void PostHSTSQueryForHostAndRequestContext( |
| 34 const GURL& origin, |
| 35 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
| 36 const HSTSCallback& callback) { |
| 37 base::PostTaskAndReplyWithResult( |
| 38 request_context->GetNetworkTaskRunner().get(), FROM_HERE, |
| 39 base::Bind(&IsHSTSActiveForHostAndRequestContext, origin, |
| 40 request_context), |
| 41 callback); |
| 42 } |
| 43 |
| 44 } // namespace password_manager |
OLD | NEW |