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

Unified Diff: third_party/WebKit/Source/core/fileapi/URLFileAPI.cpp

Issue 1908263002: Don't expose URL.createObjectURL and revokeObjectURL to Service Workers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/fileapi/URLFileAPI.cpp
diff --git a/third_party/WebKit/Source/core/fileapi/URLFileAPI.cpp b/third_party/WebKit/Source/core/fileapi/URLFileAPI.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..93c0db4abc484c817bf214c46ed283c3da9d5243
--- /dev/null
+++ b/third_party/WebKit/Source/core/fileapi/URLFileAPI.cpp
@@ -0,0 +1,39 @@
+// 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/fileapi/URLFileAPI.h"
+
+#include "bindings/core/v8/ExceptionState.h"
+#include "core/dom/DOMURL.h"
+#include "core/dom/ExecutionContext.h"
+#include "core/fileapi/Blob.h"
+#include "core/html/PublicURLManager.h"
+
+namespace blink {
+
+// static
+String URLFileAPI::createObjectURL(ExecutionContext* executionContext, Blob* blob, ExceptionState& exceptionState)
+{
+ DCHECK(blob);
+ if (!executionContext)
sof 2016/04/22 06:19:29 assert instead? i.e., can the current execution co
jsbell 2016/04/22 18:14:34 That's how I found the code. :( I'll switch it to
+ return String();
+ if (blob->hasBeenClosed()) {
+ exceptionState.throwDOMException(InvalidStateError, String(blob->isFile() ? "File" : "Blob") + " has been closed.");
+ return String();
+ }
+ return DOMURL::createPublicURL(executionContext, blob, blob->uuid());
+}
+
+// static
+void URLFileAPI::revokeObjectURL(ExecutionContext* executionContext, const String& urlString)
+{
+ if (!executionContext)
+ return;
+
+ KURL url(KURL(), urlString);
+ executionContext->removeURLFromMemoryCache(url);
+ executionContext->publicURLManager().revoke(url);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698