Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Unified Diff: content/public/common/origin_util.cc

Issue 1049533002: Add IsOriginSecure and GURL::SchemeUsesTLS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: One does not simply check schemes and hosts for membership in tiny sets... Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/common/origin_util.h ('k') | url/gurl.h » ('j') | url/gurl.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()) {
+ 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
« no previous file with comments | « content/public/common/origin_util.h ('k') | url/gurl.h » ('j') | url/gurl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698