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>( |