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

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/InstallEvent.cpp

Issue 1406823002: Start of foreign fetch implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove blank line Created 5 years, 2 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "InstallEvent.h"
7
8 #include "core/dom/ExceptionCode.h"
9 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
10
11 namespace blink {
12
13 PassRefPtrWillBeRawPtr<InstallEvent> InstallEvent::create()
14 {
15 return adoptRefWillBeNoop(new InstallEvent());
16 }
17
18 PassRefPtrWillBeRawPtr<InstallEvent> InstallEvent::create(const AtomicString& ty pe, const ExtendableEventInit& eventInit)
19 {
20 return adoptRefWillBeNoop(new InstallEvent(type, eventInit));
21 }
22
23 PassRefPtrWillBeRawPtr<InstallEvent> InstallEvent::create(const AtomicString& ty pe, const ExtendableEventInit& eventInit, WaitUntilObserver* observer)
24 {
25 return adoptRefWillBeNoop(new InstallEvent(type, eventInit, observer));
26 }
27
28 InstallEvent::~InstallEvent()
29 {
30 }
31
32 void InstallEvent::registerForeignFetchScopes(ExecutionContext* executionContext , const Vector<String>& subScopes, ExceptionState& exceptionState)
33 {
34 if (!isBeingDispatched()) {
35 exceptionState.throwDOMException(InvalidStateError, "The event handler i s already finished.");
36 return;
37 }
38
39 ServiceWorkerGlobalScopeClient* client = ServiceWorkerGlobalScopeClient::fro m(executionContext);
40
41 String scopePath = static_cast<KURL>(client->scope()).path();
42 RefPtr<SecurityOrigin> origin = executionContext->securityOrigin();
43
44 Vector<KURL> subScopeURLs(subScopes.size());
45 for (size_t i = 0; i < subScopes.size(); ++i) {
46 subScopeURLs[i] = executionContext->completeURL(subScopes[i]);
47 if (!subScopeURLs[i].isValid()) {
48 exceptionState.throwTypeError("Invalid URL: " + subScopes[i]);
49 return;
50 }
51 subScopeURLs[i].removeFragmentIdentifier();
52 if (!origin->canRequest(subScopeURLs[i])) {
53 exceptionState.throwTypeError("URL is not within scope: " + subScope s[i]);
54 return;
55 }
56 String subScopePath = subScopeURLs[i].path();
57 if (!subScopePath.startsWith(scopePath)) {
58 exceptionState.throwTypeError("URL is not within scope: " + subScope s[i]);
59 return;
60 }
61 }
62 client->registerForeignFetchScopes(subScopeURLs);
63 }
64
65 const AtomicString& InstallEvent::interfaceName() const
66 {
67 return EventNames::InstallEvent;
68 }
69
70 InstallEvent::InstallEvent()
71 {
72 }
73
74 InstallEvent::InstallEvent(const AtomicString& type, const ExtendableEventInit& initializer)
75 : ExtendableEvent(type, initializer)
76 {
77 }
78
79 InstallEvent::InstallEvent(const AtomicString& type, const ExtendableEventInit& initializer, WaitUntilObserver* observer)
80 : ExtendableEvent(type, initializer, observer)
81 {
82 }
83
84 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698