This source file includes following definitions.
- setInput
- createObjectURL
- createPublicURL
- revokeObjectURL
- revokeObjectUUID
#include "config.h"
#include "core/dom/DOMURL.h"
#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContext.h"
#include "core/fetch/MemoryCache.h"
#include "core/fileapi/Blob.h"
#include "core/html/PublicURLManager.h"
#include "platform/blob/BlobURL.h"
#include "platform/weborigin/SecurityOrigin.h"
#include "wtf/MainThread.h"
namespace WebCore {
DOMURL::DOMURL(const String& url, const KURL& base, ExceptionState& exceptionState)
{
ScriptWrappable::init(this);
if (!base.isValid())
exceptionState.throwDOMException(SyntaxError, "Invalid base URL");
m_url = KURL(base, url);
if (!m_url.isValid())
exceptionState.throwDOMException(SyntaxError, "Invalid URL");
}
void DOMURL::setInput(const String& value)
{
KURL url(blankURL(), value);
if (url.isValid()) {
m_url = url;
m_input = String();
} else {
m_url = KURL();
m_input = value;
}
}
String DOMURL::createObjectURL(ExecutionContext* executionContext, Blob* blob, ExceptionState& exceptionState)
{
if (!executionContext || !blob)
return String();
if (blob->hasBeenClosed()) {
exceptionState.throwDOMException(InvalidStateError, String(blob->isFile() ? "File" : "Blob") + " has been closed.");
return String();
}
return createPublicURL(executionContext, blob, blob->uuid());
}
String DOMURL::createPublicURL(ExecutionContext* executionContext, URLRegistrable* registrable, const String& uuid)
{
KURL publicURL = BlobURL::createPublicURL(executionContext->securityOrigin());
if (publicURL.isEmpty())
return String();
executionContext->publicURLManager().registerURL(executionContext->securityOrigin(), publicURL, registrable, uuid);
return publicURL.string();
}
void DOMURL::revokeObjectURL(ExecutionContext* executionContext, const String& urlString)
{
if (!executionContext)
return;
KURL url(KURL(), urlString);
MemoryCache::removeURLFromCache(executionContext, url);
executionContext->publicURLManager().revoke(url);
}
void DOMURL::revokeObjectUUID(ExecutionContext* executionContext, const String& uuid)
{
if (!executionContext)
return;
executionContext->publicURLManager().revoke(uuid);
}
}