Chromium Code Reviews| Index: content/public/common/origin_util.cc |
| diff --git a/content/public/common/origin_util.cc b/content/public/common/origin_util.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0aef8ff30ea49d3c17e88b887b2db2e1d1f169f9 |
| --- /dev/null |
| +++ b/content/public/common/origin_util.cc |
| @@ -0,0 +1,34 @@ |
| +// Copyright (c) 2015 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 "content/public/common/origin_util.h" |
| + |
| +#include <string.h> |
| + |
| +#include "content/public/common/url_constants.h" |
| +#include "net/base/net_util.h" |
| +#include "url/gurl.h" |
| + |
| +namespace content { |
| + |
| +bool IsOriginSecure(const GURL& url) { |
| + if (url.SchemeUsesTLS() || url.SchemeIsFile()) |
| + return true; |
| + if (url.SchemeIsFileSystem() && url.inner_url() && |
| + url.inner_url()->SchemeIsSecure()) { |
|
davidben
2015/04/08 20:31:00
This should be IsOriginSecure(url.inner_url()), ri
|
| + return true; |
| + } |
| + |
| + std::string hostname = url.HostNoBrackets(); |
| + if (net::IsLocalhost(hostname) || net::IsLocalhostTLD(hostname)) |
| + return true; |
| + |
| + std::string scheme = url.scheme(); |
| + if (scheme == content::kChromeUIScheme) |
| + return true; |
| + |
| + return false; |
| +} |
| + |
| +} // namespace content |