diff options
author | Ben Murdoch <benm@google.com> | 2011-05-24 11:24:40 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-02 09:53:15 +0100 |
commit | 81bc750723a18f21cd17d1b173cd2a4dda9cea6e (patch) | |
tree | 7a9e5ed86ff429fd347a25153107221543909b19 /Source/WebCore/page/DOMWindow.cpp | |
parent | 94088a6d336c1dd80a1e734af51e96abcbb689a7 (diff) | |
download | external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.zip external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.gz external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.bz2 |
Merge WebKit at r80534: Intial merge by Git
Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61
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); |