Index: components/password_manager/core/browser/hsts_query.cc |
diff --git a/components/password_manager/core/browser/hsts_query.cc b/components/password_manager/core/browser/hsts_query.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..24810d3220cc79b34404b741c48be0c7b07d9993 |
--- /dev/null |
+++ b/components/password_manager/core/browser/hsts_query.cc |
@@ -0,0 +1,44 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "components/password_manager/core/browser/hsts_query.h" |
+#include "base/bind.h" |
+#include "base/location.h" |
+#include "base/task_runner_util.h" |
+#include "net/url_request/url_request_context.h" |
+#include "url/gurl.h" |
+ |
+namespace password_manager { |
+ |
+namespace { |
+ |
+bool IsHSTSActiveForHostAndRequestContext( |
+ const GURL& origin, |
+ const scoped_refptr<net::URLRequestContextGetter>& request_context) { |
+ if (!origin.is_valid()) |
+ return false; |
+ |
+ net::TransportSecurityState* security_state = |
+ request_context->GetURLRequestContext()->transport_security_state(); |
+ |
+ if (!security_state) |
+ return false; |
+ |
+ return security_state->ShouldUpgradeToSSL(origin.host()); |
+} |
+ |
+} // namespace |
+ |
+void PostHSTSQueryForHostAndRequestContext( |
+ const GURL& origin, |
+ const scoped_refptr<net::URLRequestContextGetter>& request_context, |
+ const HSTSCallback& callback) { |
+ base::PostTaskAndReplyWithResult( |
+ request_context->GetNetworkTaskRunner().get(), FROM_HERE, |
+ base::Bind(&IsHSTSActiveForHostAndRequestContext, origin, |
+ request_context), |
+ callback); |
+} |
+ |
+} // namespace password_manager |