Changeset 66570 in webkit


Ignore:
Timestamp:
Aug 31, 2010 8:27:01 PM (14 years ago)
Author:
kinuko@chromium.org
Message:

2010-08-31 Kinuko Yasuda <kinuko@chromium.org>

Reviewed by Jian Li.

Add LocalFileSystem.requestFileSystem interface to DOMWindow
https://bugs.webkit.org/show_bug.cgi?id=44734

  • public/WebRuntimeFeatures.h:
  • src/WebRuntimeFeatures.cpp: (WebKit::WebRuntimeFeatures::enableFileSystem): (WebKit::WebRuntimeFeatures::isFileSystemEnabled):

2010-08-31 Kinuko Yasuda <kinuko@chromium.org>

Reviewed by Jian Li.

Add LocalFileSystem.requestFileSystem interface to DOMWindow
https://bugs.webkit.org/show_bug.cgi?id=44734

No new tests; tests will be added later.

  • bindings/generic/RuntimeEnabledFeatures.cpp:
  • bindings/generic/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::fileSystemEnabled): (WebCore::RuntimeEnabledFeatures::setFileSystemEnabled): (WebCore::RuntimeEnabledFeatures::requestFileSystemEnabled):
  • page/DOMWindow.cpp: (WebCore::DOMWindow::requestFileSystem):
  • page/DOMWindow.h: (WebCore::DOMWindow::):
  • page/DOMWindow.idl:
  • page/Settings.cpp: (WebCore::Settings::setFileSystemRootPath):
  • page/Settings.h: (WebCore::Settings::fileSystemRootPath):
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r66569 r66570  
     12010-08-31  Kinuko Yasuda  <kinuko@chromium.org>
     2
     3        Reviewed by Jian Li.
     4
     5        Add LocalFileSystem.requestFileSystem interface to DOMWindow
     6        https://bugs.webkit.org/show_bug.cgi?id=44734
     7
     8        No new tests; tests will be added later.
     9
     10        * bindings/generic/RuntimeEnabledFeatures.cpp:
     11        * bindings/generic/RuntimeEnabledFeatures.h:
     12        (WebCore::RuntimeEnabledFeatures::fileSystemEnabled):
     13        (WebCore::RuntimeEnabledFeatures::setFileSystemEnabled):
     14        (WebCore::RuntimeEnabledFeatures::requestFileSystemEnabled):
     15        * page/DOMWindow.cpp:
     16        (WebCore::DOMWindow::requestFileSystem):
     17        * page/DOMWindow.h:
     18        (WebCore::DOMWindow::):
     19        * page/DOMWindow.idl:
     20        * page/Settings.cpp:
     21        (WebCore::Settings::setFileSystemRootPath):
     22        * page/Settings.h:
     23        (WebCore::Settings::fileSystemRootPath):
     24
    1252010-08-31  Kwang Yul Seo  <skyul@company100.net>
    226
  • trunk/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp

    r66243 r66570  
    5454#if ENABLE(XHR_RESPONSE_BLOB)
    5555bool RuntimeEnabledFeatures::isXHRResponseBlobEnabled = false;
     56#endif
     57
     58#if ENABLE(FILE_SYSTEM)
     59bool RuntimeEnabledFeatures::isFileSystemEnabled = false;
    5660#endif
    5761
  • trunk/WebCore/bindings/generic/RuntimeEnabledFeatures.h

    r66243 r66570  
    136136#endif
    137137
     138#if ENABLE(FILE_SYSTEM)
     139    static bool fileSystemEnabled() { return isFileSystemEnabled; }
     140    static void setFileSystemEnabled(bool isEnabled) { isFileSystemEnabled = isEnabled; }
     141    static bool requestFileSystemEnabled() { return isFileSystemEnabled; }
     142#endif
     143
    138144private:
    139145    // Never instantiate.
     
    155161    static bool isXHRResponseBlobEnabled;
    156162#endif
     163
     164#if ENABLE(FILE_SYSTEM)
     165    static bool isFileSystemEnabled;
     166#endif
    157167};
    158168
  • trunk/WebCore/page/DOMWindow.cpp

    r66462 r66570  
    8989#include <wtf/text/CString.h>
    9090
     91#if ENABLE(FILE_SYSTEM)
     92#include "AsyncFileSystem.h"
     93#include "DOMFileSystem.h"
     94#include "ErrorCallback.h"
     95#include "FileError.h"
     96#include "FileSystemCallback.h"
     97#include "LocalFileSystem.h"
     98#endif
     99
    91100using std::min;
    92101using std::max;
     
    722731#endif
    723732
     733#if ENABLE(FILE_SYSTEM)
     734void DOMWindow::requestFileSystem(int type, long long size, PassRefPtr<FileSystemCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     735{
     736    Document* document = this->document();
     737    if (!document)
     738        return;
     739
     740    if (!m_localFileSystem) {
     741        // FIXME: See if access is allowed.
     742
     743        Page* page = document->page();
     744        if (!page) {
     745            DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(INVALID_STATE_ERR));
     746            return;
     747        }
     748
     749        // FIXME: Get the quota settings as well.
     750        String path = page->settings()->fileSystemRootPath();
     751        m_localFileSystem = LocalFileSystem::create(path);
     752    }
     753
     754    m_localFileSystem->requestFileSystem(document, static_cast<AsyncFileSystem::Type>(type), size, successCallback, errorCallback);
     755}
     756
     757COMPILE_ASSERT(int(DOMWindow::TEMPORARY) == int(AsyncFileSystem::Temporary), enum_mismatch);
     758COMPILE_ASSERT(int(DOMWindow::PERSISTENT) == int(AsyncFileSystem::Persistent), enum_mismatch);
     759
     760#endif
     761
    724762void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, MessagePort* port, const String& targetOrigin, DOMWindow* source, ExceptionCode& ec)
    725763{
  • trunk/WebCore/page/DOMWindow.h

    r66464 r66570  
    5050    class Document;
    5151    class Element;
     52    class ErrorCallback;
    5253    class Event;
    5354    class EventListener;
     55    class FileSystemCallback;
    5456    class FloatRect;
    5557    class Frame;
     
    5860    class IDBKeyRange;
    5961    class InspectorTimelineAgent;
     62    class LocalFileSystem;
    6063    class Location;
    6164    class StyleMedia;
     
    237240        IDBFactory* indexedDB() const;
    238241        IDBKeyRange* iDBKeyRange() const;
     242#endif
     243
     244#if ENABLE(FILE_SYSTEM)
     245        // They are placed here and in all capital letters to enforce compile-time enum checking.
     246        enum FileSystemType {
     247            TEMPORARY,
     248            PERSISTENT,
     249        };
     250        void requestFileSystem(int type, long long size, PassRefPtr<FileSystemCallback>, PassRefPtr<ErrorCallback>);
    239251#endif
    240252
     
    436448        mutable RefPtr<IDBKeyRange> m_idbKeyRange;
    437449#endif
     450#if ENABLE(FILE_SYSTEM)
     451        RefPtr<LocalFileSystem> m_localFileSystem;
     452#endif
    438453
    439454        EventTargetData m_eventTargetData;
  • trunk/WebCore/page/DOMWindow.idl

    r66467 r66570  
    176176        readonly attribute [EnabledAtRuntime] IDBFactory indexedDB;
    177177        readonly attribute [EnabledAtRuntime] IDBKeyRange IDBKeyRange;
     178#endif
     179#if defined(ENABLE_FILE_SYSTEM) && ENABLE_FILE_SYSTEM
     180        const unsigned short TEMPORARY = 0;
     181        const unsigned short PERSISTENT = 1;
     182        [EnabledAtRuntime] void requestFileSystem(in unsigned short type, in long long size, in [Callback, Optional] FileSystemCallback successCallback, in [Callback, Optional] ErrorCallback errorCallback);
    178183#endif
    179184
  • trunk/WebCore/page/Settings.cpp

    r66251 r66570  
    484484}
    485485
     486void Settings::setFileSystemRootPath(const String& path)
     487{
     488    m_fileSystemRootPath = path;
     489}
     490
    486491void Settings::setApplicationChromeMode(bool mode)
    487492{
  • trunk/WebCore/page/Settings.h

    r66251 r66570  
    240240        void setLocalStorageDatabasePath(const String&);
    241241        const String& localStorageDatabasePath() const { return m_localStorageDatabasePath; }
    242        
     242
     243        void setFileSystemRootPath(const String&);
     244        const String& fileSystemRootPath() const { return m_fileSystemRootPath; }
     245
    243246        void setApplicationChromeMode(bool);
    244247        bool inApplicationChromeMode() const { return m_inApplicationChromeMode; }
     
    329332    private:
    330333        Page* m_page;
    331        
     334
    332335        String m_defaultTextEncodingName;
    333336        String m_ftpDirectoryTemplatePath;
    334337        String m_localStorageDatabasePath;
     338        String m_fileSystemRootPath;
    335339        KURL m_userStyleSheetLocation;
    336340        AtomicString m_standardFontFamily;
     
    413417        bool m_memoryInfoEnabled: 1;
    414418        bool m_interactiveFormValidation: 1;
    415    
     419
    416420#if USE(SAFARI_THEME)
    417421        static bool gShouldPaintNativeControls;
  • trunk/WebCore/storage/FileSystemCallbacks.cpp

    r66255 r66570  
    3535
    3636#include "AsyncFileSystem.h"
     37#include "DOMFilePath.h"
    3738#include "DOMFileSystem.h"
    3839#include "DirectoryEntry.h"
     
    133134void EntriesCallbacks::didReadDirectoryEntry(const String& name, bool isDirectory)
    134135{
     136    if (!m_entries)
     137        m_entries = EntryArray::create();
    135138    if (isDirectory)
    136         m_entries->append(DirectoryEntry::create(m_fileSystem, m_basePath + "/" + name));
     139        m_entries->append(DirectoryEntry::create(m_fileSystem, DOMFilePath::append(m_basePath, name)));
    137140    else
    138         m_entries->append(FileEntry::create(m_fileSystem, m_basePath + "/" + name));
     141        m_entries->append(FileEntry::create(m_fileSystem, DOMFilePath::append(m_basePath, name)));
    139142}
    140143
    141144void EntriesCallbacks::didReadDirectoryEntries(bool hasMore)
    142145{
     146    ASSERT(m_entries);
    143147    if (m_successCallback) {
    144148        m_successCallback->handleEvent(m_entries.get());
  • trunk/WebKit/chromium/ChangeLog

    r66473 r66570  
     12010-08-31  Kinuko Yasuda  <kinuko@chromium.org>
     2
     3        Reviewed by Jian Li.
     4
     5        Add LocalFileSystem.requestFileSystem interface to DOMWindow
     6        https://bugs.webkit.org/show_bug.cgi?id=44734
     7
     8        * public/WebRuntimeFeatures.h:
     9        * src/WebRuntimeFeatures.cpp:
     10        (WebKit::WebRuntimeFeatures::enableFileSystem):
     11        (WebKit::WebRuntimeFeatures::isFileSystemEnabled):
     12
    1132010-08-24  Jeremy Orlow  <jorlow@chromium.org>
    214
  • trunk/WebKit/chromium/public/WebRuntimeFeatures.h

    r66243 r66570  
    9090    WEBKIT_API static bool isXHRResponseBlobEnabled();
    9191
     92    WEBKIT_API static void enableFileSystem(bool);
     93    WEBKIT_API static bool isFileSystemEnabled();
     94
    9295private:
    9396    WebRuntimeFeatures();
  • trunk/WebKit/chromium/src/WebRuntimeFeatures.cpp

    r66243 r66570  
    273273}
    274274
     275void WebRuntimeFeatures::enableFileSystem(bool enable)
     276{
     277#if ENABLE(FILE_SYSTEM)
     278    RuntimeEnabledFeatures::setFileSystemEnabled(enable);
     279#endif
     280}
     281
     282bool WebRuntimeFeatures::isFileSystemEnabled()
     283{
     284#if ENABLE(FILE_SYSTEM)
     285    return RuntimeEnabledFeatures::fileSystemEnabled();
     286#else
     287    return false;
     288#endif
     289}
     290
    275291} // namespace WebKit
Note: See TracChangeset for help on using the changeset viewer.