diff options
Diffstat (limited to 'Source/WebCore/page/DOMWindow.cpp')
| -rw-r--r-- | Source/WebCore/page/DOMWindow.cpp | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/Source/WebCore/page/DOMWindow.cpp b/Source/WebCore/page/DOMWindow.cpp index c732a10..269c109 100644 --- a/Source/WebCore/page/DOMWindow.cpp +++ b/Source/WebCore/page/DOMWindow.cpp @@ -99,6 +99,8 @@ #if ENABLE(FILE_SYSTEM) #include "AsyncFileSystem.h" #include "DOMFileSystem.h" +#include "DOMFileSystemBase.h" +#include "EntryCallback.h" #include "ErrorCallback.h" #include "FileError.h" #include "FileSystemCallback.h" @@ -753,6 +755,29 @@ void DOMWindow::requestFileSystem(int type, long long size, PassRefPtr<FileSyste LocalFileSystem::localFileSystem().requestFileSystem(document, fileSystemType, size, FileSystemCallbacks::create(successCallback, errorCallback, document), false); } +void DOMWindow::resolveLocalFileSystemURI(const String& uri, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) +{ + Document* document = this->document(); + if (!document) + return; + + SecurityOrigin* securityOrigin = document->securityOrigin(); + KURL completedURL = document->completeURL(uri); + if (!AsyncFileSystem::isAvailable() || !securityOrigin->canAccessFileSystem() || !securityOrigin->canRequest(completedURL)) { + DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::SECURITY_ERR)); + return; + } + + AsyncFileSystem::Type type; + String filePath; + if (!completedURL.isValid() || !DOMFileSystemBase::crackFileSystemURL(completedURL, type, filePath)) { + DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::SYNTAX_ERR)); + return; + } + + LocalFileSystem::localFileSystem().readFileSystem(document, type, ResolveURICallbacks::create(successCallback, errorCallback, document, filePath)); +} + COMPILE_ASSERT(static_cast<int>(DOMWindow::TEMPORARY) == static_cast<int>(AsyncFileSystem::Temporary), enum_mismatch); COMPILE_ASSERT(static_cast<int>(DOMWindow::PERSISTENT) == static_cast<int>(AsyncFileSystem::Persistent), enum_mismatch); @@ -1533,9 +1558,10 @@ bool DOMWindow::removeEventListener(const AtomicString& eventType, EventListener void DOMWindow::dispatchLoadEvent() { RefPtr<Event> loadEvent(Event::create(eventNames().loadEvent, false, false)); - // The DocumentLoader (and thus its DocumentLoadTiming) might get destroyed while dispatching - // the event, so protect it to prevent writing the end time into freed memory. - if (RefPtr<DocumentLoader> documentLoader = m_frame ? m_frame->loader()->documentLoader() : 0) { + if (m_frame && m_frame->loader()->documentLoader() && !m_frame->loader()->documentLoader()->timing()->loadEventStart) { + // The DocumentLoader (and thus its DocumentLoadTiming) might get destroyed while dispatching + // the event, so protect it to prevent writing the end time into freed memory. + RefPtr<DocumentLoader> documentLoader = m_frame->loader()->documentLoader(); DocumentLoadTiming* timing = documentLoader->timing(); dispatchTimedEvent(loadEvent, document(), &timing->loadEventStart, &timing->loadEventEnd); } else @@ -1544,7 +1570,7 @@ void DOMWindow::dispatchLoadEvent() // For load events, send a separate load event to the enclosing frame only. // This is a DOM extension and is independent of bubbling/capturing rules of // the DOM. - Element* ownerElement = document()->ownerElement(); + Element* ownerElement = m_frame ? m_frame->ownerElement() : 0; if (ownerElement) { RefPtr<Event> ownerEvent = Event::create(eventNames().loadEvent, false, false); ownerEvent->setTarget(ownerElement); |
