| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/InstallEvent.h" | 5 #include "modules/serviceworkers/InstallEvent.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
| 8 #include "core/dom/ExceptionCode.h" | 8 #include "core/dom/ExceptionCode.h" |
| 9 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" | 9 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" |
| 10 #include "public/platform/WebSecurityOrigin.h" | 10 #include "public/platform/WebSecurityOrigin.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 ServiceWorkerGlobalScopeClient::From(execution_context); | 61 ServiceWorkerGlobalScopeClient::From(execution_context); |
| 62 | 62 |
| 63 String scope_path = static_cast<KURL>(client->Scope()).GetPath(); | 63 String scope_path = static_cast<KURL>(client->Scope()).GetPath(); |
| 64 RefPtr<SecurityOrigin> origin = execution_context->GetSecurityOrigin(); | 64 RefPtr<SecurityOrigin> origin = execution_context->GetSecurityOrigin(); |
| 65 | 65 |
| 66 if (!options.hasScopes() || options.scopes().IsEmpty()) { | 66 if (!options.hasScopes() || options.scopes().IsEmpty()) { |
| 67 exception_state.ThrowTypeError("At least one scope is required"); | 67 exception_state.ThrowTypeError("At least one scope is required"); |
| 68 return; | 68 return; |
| 69 } | 69 } |
| 70 const Vector<String>& sub_scopes = options.scopes(); | 70 const Vector<String>& sub_scopes = options.scopes(); |
| 71 Vector<KURL> sub_scope_ur_ls(sub_scopes.size()); | 71 Vector<KURL> sub_scope_urls(sub_scopes.size()); |
| 72 for (size_t i = 0; i < sub_scopes.size(); ++i) { | 72 for (size_t i = 0; i < sub_scopes.size(); ++i) { |
| 73 sub_scope_ur_ls[i] = execution_context->CompleteURL(sub_scopes[i]); | 73 sub_scope_urls[i] = execution_context->CompleteURL(sub_scopes[i]); |
| 74 if (!sub_scope_ur_ls[i].IsValid()) { | 74 if (!sub_scope_urls[i].IsValid()) { |
| 75 exception_state.ThrowTypeError("Invalid subscope URL: " + sub_scopes[i]); | 75 exception_state.ThrowTypeError("Invalid subscope URL: " + sub_scopes[i]); |
| 76 return; | 76 return; |
| 77 } | 77 } |
| 78 sub_scope_ur_ls[i].RemoveFragmentIdentifier(); | 78 sub_scope_urls[i].RemoveFragmentIdentifier(); |
| 79 if (!origin->CanRequest(sub_scope_ur_ls[i])) { | 79 if (!origin->CanRequest(sub_scope_urls[i])) { |
| 80 exception_state.ThrowTypeError("Subscope URL is not within scope: " + | 80 exception_state.ThrowTypeError("Subscope URL is not within scope: " + |
| 81 sub_scopes[i]); | 81 sub_scopes[i]); |
| 82 return; | 82 return; |
| 83 } | 83 } |
| 84 String sub_scope_path = sub_scope_ur_ls[i].GetPath(); | 84 String sub_scope_path = sub_scope_urls[i].GetPath(); |
| 85 if (!sub_scope_path.StartsWith(scope_path)) { | 85 if (!sub_scope_path.StartsWith(scope_path)) { |
| 86 exception_state.ThrowTypeError("Subscope URL is not within scope: " + | 86 exception_state.ThrowTypeError("Subscope URL is not within scope: " + |
| 87 sub_scopes[i]); | 87 sub_scopes[i]); |
| 88 return; | 88 return; |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 client->RegisterForeignFetchScopes(sub_scope_ur_ls, parsed_origins); | 91 client->RegisterForeignFetchScopes(sub_scope_urls, parsed_origins); |
| 92 } | 92 } |
| 93 | 93 |
| 94 const AtomicString& InstallEvent::InterfaceName() const { | 94 const AtomicString& InstallEvent::InterfaceName() const { |
| 95 return EventNames::InstallEvent; | 95 return EventNames::InstallEvent; |
| 96 } | 96 } |
| 97 | 97 |
| 98 InstallEvent::InstallEvent(const AtomicString& type, | 98 InstallEvent::InstallEvent(const AtomicString& type, |
| 99 const ExtendableEventInit& initializer) | 99 const ExtendableEventInit& initializer) |
| 100 : ExtendableEvent(type, initializer) {} | 100 : ExtendableEvent(type, initializer) {} |
| 101 | 101 |
| 102 InstallEvent::InstallEvent(const AtomicString& type, | 102 InstallEvent::InstallEvent(const AtomicString& type, |
| 103 const ExtendableEventInit& initializer, | 103 const ExtendableEventInit& initializer, |
| 104 WaitUntilObserver* observer) | 104 WaitUntilObserver* observer) |
| 105 : ExtendableEvent(type, initializer, observer) {} | 105 : ExtendableEvent(type, initializer, observer) {} |
| 106 | 106 |
| 107 } // namespace blink | 107 } // namespace blink |
| OLD | NEW |