Chromium Code Reviews| Index: third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp |
| diff --git a/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp b/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp |
| index 6a74bb269815f6ceac22616c1e5cb4f7404f6e8a..2a5851563d6cf57e863337a49bc8238f8671aa72 100644 |
| --- a/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp |
| +++ b/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp |
| @@ -49,6 +49,7 @@ |
| #include "core/loader/FrameLoadRequest.h" |
| #include "core/loader/FrameLoader.h" |
| #include "core/loader/HistoryItem.h" |
| +#include "core/loader/LinkLoaderClient.h" |
| #include "core/page/Page.h" |
| #include "core/page/WindowFeatures.h" |
| #include "modules/audio_output_devices/HTMLMediaElementAudioOutputDevice.h" |
| @@ -61,6 +62,7 @@ |
| #include "modules/mediasession/HTMLMediaElementMediaSession.h" |
| #include "modules/mediasession/MediaSession.h" |
| #include "modules/serviceworkers/NavigatorServiceWorker.h" |
| +#include "modules/serviceworkers/ServiceWorkerContainer.h" |
| #include "modules/storage/DOMWindowStorageController.h" |
| #include "modules/vr/NavigatorVRDevice.h" |
| #include "platform/Histogram.h" |
| @@ -77,6 +79,7 @@ |
| #include "public/platform/WebMediaPlayer.h" |
| #include "public/platform/WebMimeRegistry.h" |
| #include "public/platform/WebRTCPeerConnectionHandler.h" |
| +#include "public/platform/WebScheduler.h" |
| #include "public/platform/WebSecurityOrigin.h" |
| #include "public/platform/WebURL.h" |
| #include "public/platform/WebURLError.h" |
| @@ -1037,4 +1040,46 @@ void FrameLoaderClientImpl::suddenTerminationDisablerChanged(bool present, Sudde |
| } |
| } |
| +namespace { |
| + |
| +class RegistrationCallback : public WebServiceWorkerProvider::WebServiceWorkerRegistrationCallbacks { |
| +public: |
| + explicit RegistrationCallback(LinkLoaderClient* client) : m_client(client) {} |
| + ~RegistrationCallback() override {} |
| + |
| + void onSuccess(WebPassOwnPtr<WebServiceWorkerRegistration::Handle> handle) override |
| + { |
| + Platform::current()->currentThread()->scheduler()->timerTaskRunner()->postTask(BLINK_FROM_HERE, bind(&LinkLoaderClient::linkLoaded, m_client)); |
| + } |
| + |
| + void onError(const WebServiceWorkerError& error) override |
| + { |
| + Platform::current()->currentThread()->scheduler()->timerTaskRunner()->postTask(BLINK_FROM_HERE, bind(&LinkLoaderClient::linkLoadingErrored, m_client)); |
| + } |
| + |
| +private: |
| + WTF_MAKE_NONCOPYABLE(RegistrationCallback); |
| + |
| + RawPtrWillBePersistent<LinkLoaderClient> m_client; |
| +}; |
| + |
| +} |
| + |
| +void FrameLoaderClientImpl::registerServiceWorker(const KURL& scriptURL, const String& scope, LinkLoaderClient* client) |
| +{ |
| + if (!client->shouldLoadLink()) |
| + return; |
| + |
| + Document* document = m_webFrame->frame()->document(); |
| + KURL scopeURL; |
| + if (scope.isNull()) |
| + scopeURL = KURL(scriptURL, "./"); |
| + else |
| + scopeURL = document->completeURL(scope); |
| + scopeURL.removeFragmentIdentifier(); |
|
Nate Chapin
2016/03/17 22:49:03
Can we do this and the things about it in LinkServ
Marijn Kruisselbrink
2016/03/17 23:20:39
Done
|
| + |
| + TrackExceptionState exceptionState; |
| + NavigatorServiceWorker::serviceWorker(document, *m_webFrame->frame()->domWindow()->navigator(), exceptionState)->registerServiceWorkerImpl(document, scriptURL, scopeURL, adoptPtr(new RegistrationCallback(client))); |
| +} |
| + |
| } // namespace blink |