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

Unified Diff: content/common/origin_util.cc

Issue 1905033002: PlzNavigate: Move navigation-level mixed content checks to the browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@console-security-message
Patch Set: Minor changes from nasko@'s comments Created 3 years, 10 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/common/frame_messages.h ('k') | content/public/browser/web_contents_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/origin_util.cc
diff --git a/content/common/origin_util.cc b/content/common/origin_util.cc
index d6e806a3c85073b7e287415ebc2c1a93f9533d1f..2fdc553b5c55aeca570ec772f5ee53573222fe64 100644
--- a/content/common/origin_util.cc
+++ b/content/common/origin_util.cc
@@ -12,6 +12,19 @@
#include "url/gurl.h"
#include "url/url_util.h"
+namespace {
+
+// This function partially reflects the result from SecurityOrigin::isUnique,
+// not its actual implementation. It takes into account how
+// SecurityOrigin::create might return unique origins for URLs whose schemes are
+// included in SchemeRegistry::shouldTreatURLSchemeAsNoAccess.
+bool IsOriginUnique(const url::Origin& origin) {
+ return origin.unique() ||
+ base::ContainsValue(url::GetNoAccessSchemes(), origin.scheme());
+}
+
+} // namespace
+
namespace content {
bool IsOriginSecure(const GURL& url) {
@@ -30,9 +43,8 @@ bool IsOriginSecure(const GURL& url) {
if (base::ContainsValue(url::GetSecureSchemes(), url.scheme()))
return true;
- if (base::ContainsValue(GetSecureOrigins(), url.GetOrigin())) {
+ if (base::ContainsValue(GetSecureOrigins(), url.GetOrigin()))
return true;
- }
return false;
}
@@ -48,4 +60,33 @@ bool OriginCanAccessServiceWorkers(const GURL& url) {
return false;
}
+bool IsOriginWhiteListedTrustworthy(const url::Origin& origin) {
+ if (IsOriginUnique(origin))
+ return false;
+
+ return base::ContainsValue(GetSecureOrigins(),
+ origin.GetURL().HostNoBrackets());
+}
+
+bool IsPotentiallyTrustworthyOrigin(const url::Origin& origin) {
+ // Note: Considering this mirrors SecurityOrigin::isPotentiallyTrustworthy, it
+ // assumes m_isUniqueOriginPotentiallyTrustworthy is set to false. This
+ // implementation follows Blink's default behavior but in the renderer it can
+ // be changed per instance by calls to
+ // SecurityOrigin::setUniqueOriginIsPotentiallyTrustworthy.
+ if (IsOriginUnique(origin))
+ return false;
+
+ if (base::ContainsValue(url::GetSecureSchemes(), origin.scheme()) ||
+ base::ContainsValue(url::GetLocalSchemes(), origin.scheme()) ||
+ net::IsLocalhost(origin.GetURL().HostNoBrackets())) {
+ return true;
+ }
+
+ if (IsOriginWhiteListedTrustworthy(origin))
+ return true;
+
+ return false;
+}
+
} // namespace content
« no previous file with comments | « content/common/frame_messages.h ('k') | content/public/browser/web_contents_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698