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

Unified Diff: content/child/service_worker/service_worker_network_provider.cc

Issue 2082493002: Remove WebFrame::canHaveSecureChild (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: patch for landing Created 4 years, 6 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 | « no previous file | third_party/WebKit/Source/core/dom/Document.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/service_worker/service_worker_network_provider.cc
diff --git a/content/child/service_worker/service_worker_network_provider.cc b/content/child/service_worker/service_worker_network_provider.cc
index ab7597cda148c2f0b60b8336ffcbd97e86981cb3..5c883a0154ddb182d6ad680b5a4c77660f2b373f 100644
--- a/content/child/service_worker/service_worker_network_provider.cc
+++ b/content/child/service_worker/service_worker_network_provider.cc
@@ -11,6 +11,7 @@
#include "content/common/service_worker/service_worker_messages.h"
#include "content/common/service_worker/service_worker_utils.h"
#include "content/public/common/browser_side_navigation_policy.h"
+#include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebSandboxFlags.h"
@@ -26,6 +27,19 @@ int GetNextProviderId() {
return sequence.GetNext(); // We start at zero.
}
+// Returns whether it's possible for a document whose frame is a descendant of
+// |frame| to be a secure context, not considering scheme exceptions (since any
+// document can be a secure context if it has a scheme exception). See
+// Document::isSecureContextImpl for more details.
+bool IsFrameSecure(blink::WebFrame* frame) {
+ while (frame) {
+ if (!frame->getSecurityOrigin().isPotentiallyTrustworthy())
+ return false;
+ frame = frame->parent();
+ }
+ return true;
+}
+
} // namespace
void ServiceWorkerNetworkProvider::AttachToDocumentState(
@@ -78,8 +92,7 @@ ServiceWorkerNetworkProvider::CreateForNavigation(
// is_parent_frame_secure to the browser process, so it can determine the
// context security when deciding whether to allow a service worker to
// control the document.
- bool is_parent_frame_secure =
- !frame->parent() || frame->parent()->canHaveSecureChild();
+ const bool is_parent_frame_secure = IsFrameSecure(frame->parent());
if (service_worker_provider_id == kInvalidServiceWorkerProviderId) {
network_provider = std::unique_ptr<ServiceWorkerNetworkProvider>(
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698