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

Unified Diff: third_party/WebKit/Source/core/html/LinkServiceWorker.cpp

Issue 1781783002: Implement support for link type serviceworker in link elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move scope parsing to LinkServiceWorker Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/LinkServiceWorker.cpp
diff --git a/third_party/WebKit/Source/core/html/LinkServiceWorker.cpp b/third_party/WebKit/Source/core/html/LinkServiceWorker.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..14168b5c6182b30f882455256d6d354797ebb385
--- /dev/null
+++ b/third_party/WebKit/Source/core/html/LinkServiceWorker.cpp
@@ -0,0 +1,56 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/html/LinkServiceWorker.h"
+
+#include "core/dom/Document.h"
+#include "core/frame/LocalFrame.h"
+#include "core/html/HTMLLinkElement.h"
+#include "core/loader/FrameLoaderClient.h"
+
+namespace blink {
+
+PassOwnPtrWillBeRawPtr<LinkServiceWorker> LinkServiceWorker::create(HTMLLinkElement* owner)
+{
+ return adoptPtrWillBeNoop(new LinkServiceWorker(owner));
+}
+
+LinkServiceWorker::~LinkServiceWorker()
+{
+}
+
+void LinkServiceWorker::process()
+{
+ if (!m_owner || !m_owner->document().frame())
+ return;
+
+ KURL scriptURL = m_owner->href();
+
+ String scope = m_owner->scope();
+ KURL scopeURL;
+ if (scope.isNull())
+ scopeURL = KURL(scriptURL, "./");
+ else
+ scopeURL = m_owner->document().completeURL(scope);
+ scopeURL.removeFragmentIdentifier();
+
+ m_owner->document().frame()->loader().client()->registerServiceWorker(scriptURL, scopeURL, m_owner);
+}
+
+bool LinkServiceWorker::hasLoaded() const
+{
+ return false;
+}
+
+void LinkServiceWorker::ownerRemoved()
+{
+ process();
+}
+
+LinkServiceWorker::LinkServiceWorker(HTMLLinkElement* owner)
+ : LinkResource(owner)
+{
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698