Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" | 5 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
| 11 #include "core/dom/ExceptionCode.h" | 11 #include "core/dom/ExceptionCode.h" |
| 12 #include "core/dom/ExecutionContext.h" | 12 #include "core/dom/ExecutionContext.h" |
| 13 #include "core/loader/MixedContentChecker.h" | |
| 13 #include "core/page/PageVisibilityState.h" | 14 #include "core/page/PageVisibilityState.h" |
| 14 #include "core/workers/WorkerGlobalScope.h" | 15 #include "core/workers/WorkerGlobalScope.h" |
| 15 #include "core/workers/WorkerLocation.h" | 16 #include "core/workers/WorkerLocation.h" |
| 16 #include "modules/serviceworkers/ServiceWorkerError.h" | 17 #include "modules/serviceworkers/ServiceWorkerError.h" |
| 17 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" | 18 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" |
| 18 #include "modules/serviceworkers/ServiceWorkerWindowClientCallback.h" | 19 #include "modules/serviceworkers/ServiceWorkerWindowClientCallback.h" |
| 19 #include "platform/wtf/RefPtr.h" | 20 #include "platform/wtf/RefPtr.h" |
| 20 #include "public/platform/WebString.h" | 21 #include "public/platform/WebString.h" |
| 21 | 22 |
| 22 namespace blink { | 23 namespace blink { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); | 70 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); |
| 70 ScriptPromise promise = resolver->Promise(); | 71 ScriptPromise promise = resolver->Promise(); |
| 71 ExecutionContext* context = ExecutionContext::From(script_state); | 72 ExecutionContext* context = ExecutionContext::From(script_state); |
| 72 | 73 |
| 73 KURL parsed_url = KURL(ToWorkerGlobalScope(context)->location()->Url(), url); | 74 KURL parsed_url = KURL(ToWorkerGlobalScope(context)->location()->Url(), url); |
| 74 if (!parsed_url.IsValid() || parsed_url.ProtocolIsAbout()) { | 75 if (!parsed_url.IsValid() || parsed_url.ProtocolIsAbout()) { |
| 75 resolver->Reject(V8ThrowException::CreateTypeError( | 76 resolver->Reject(V8ThrowException::CreateTypeError( |
| 76 script_state->GetIsolate(), "'" + url + "' is not a valid URL.")); | 77 script_state->GetIsolate(), "'" + url + "' is not a valid URL.")); |
| 77 return promise; | 78 return promise; |
| 78 } | 79 } |
| 80 if (MixedContentChecker::IsMixedContent(context->GetSecurityOrigin(), | |
| 81 parsed_url)) { | |
|
falken
2017/05/29 01:07:04
Can you point me to the test that this fixes? I as
Mike West
2017/05/29 08:02:44
I don't have a strong opinion about what the test
leonhsl(Using Gerrit)
2017/05/29 13:09:54
Sorry now I realized that I've done a hurry&incorr
falken
2017/05/29 14:29:35
Thanks for the investigation and links. Yes it see
leonhsl(Using Gerrit)
2017/06/10 02:57:44
Done.
| |
| 82 resolver->Reject(V8ThrowException::CreateTypeError( | |
| 83 script_state->GetIsolate(), | |
| 84 "'" + url + "' navigation would create a mixed-content violation.")); | |
| 85 return promise; | |
| 86 } | |
| 79 if (!context->GetSecurityOrigin()->CanDisplay(parsed_url)) { | 87 if (!context->GetSecurityOrigin()->CanDisplay(parsed_url)) { |
| 80 resolver->Reject(V8ThrowException::CreateTypeError( | 88 resolver->Reject(V8ThrowException::CreateTypeError( |
| 81 script_state->GetIsolate(), | 89 script_state->GetIsolate(), |
| 82 "'" + parsed_url.ElidedString() + "' cannot navigate.")); | 90 "'" + parsed_url.ElidedString() + "' cannot navigate.")); |
| 83 return promise; | 91 return promise; |
| 84 } | 92 } |
| 85 | 93 |
| 86 ServiceWorkerGlobalScopeClient::From(context)->Navigate( | 94 ServiceWorkerGlobalScopeClient::From(context)->Navigate( |
| 87 Uuid(), parsed_url, WTF::MakeUnique<NavigateClientCallback>(resolver)); | 95 Uuid(), parsed_url, WTF::MakeUnique<NavigateClientCallback>(resolver)); |
| 88 return promise; | 96 return promise; |
| 89 } | 97 } |
| 90 | 98 |
| 91 DEFINE_TRACE(ServiceWorkerWindowClient) { | 99 DEFINE_TRACE(ServiceWorkerWindowClient) { |
| 92 ServiceWorkerClient::Trace(visitor); | 100 ServiceWorkerClient::Trace(visitor); |
| 93 } | 101 } |
| 94 | 102 |
| 95 } // namespace blink | 103 } // namespace blink |
| OLD | NEW |