diff options
author | dumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-27 23:06:34 +0000 |
---|---|---|
committer | dumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-27 23:06:34 +0000 |
commit | 017022b726b9e1b7ceb022c3b046b0cadb0302f9 (patch) | |
tree | 7fb115ea6421413029ae4f35ca7b6d09fc66fc95 /webkit | |
parent | 0f9813550e8055faab81e77a9e134b3cff3aa3b3 (diff) | |
download | chromium_src-017022b726b9e1b7ceb022c3b046b0cadb0302f9.zip chromium_src-017022b726b9e1b7ceb022c3b046b0cadb0302f9.tar.gz chromium_src-017022b726b9e1b7ceb022c3b046b0cadb0302f9.tar.bz2 |
Adding HTML5 DB support to Chromium: Chromium changes
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/74001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21736 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/api/public/WebKit.h | 4 | ||||
-rw-r--r-- | webkit/api/public/WebKitClient.h | 24 | ||||
-rw-r--r-- | webkit/api/src/ChromiumBridge.cpp | 16 | ||||
-rw-r--r-- | webkit/api/src/WebKit.cpp | 14 | ||||
-rw-r--r-- | webkit/glue/chrome_client_impl.cc | 6 | ||||
-rw-r--r-- | webkit/glue/webkitclient_impl.cc | 21 | ||||
-rw-r--r-- | webkit/glue/webkitclient_impl.h | 7 | ||||
-rw-r--r-- | webkit/glue/webview_impl.cc | 5 |
8 files changed, 84 insertions, 13 deletions
diff --git a/webkit/api/public/WebKit.h b/webkit/api/public/WebKit.h index f824808..94bb8b0 100644 --- a/webkit/api/public/WebKit.h +++ b/webkit/api/public/WebKit.h @@ -86,6 +86,10 @@ namespace WebKit { // Purge the plugin list cache. WEBKIT_API void resetPluginCache(); + // Enables HTML5 database support. + WEBKIT_API void enableDatabases(); + WEBKIT_API bool databasesEnabled(); + } // namespace WebKit #endif diff --git a/webkit/api/public/WebKitClient.h b/webkit/api/public/WebKitClient.h index 6e84c8d..a63ae3d 100644 --- a/webkit/api/public/WebKitClient.h +++ b/webkit/api/public/WebKitClient.h @@ -34,6 +34,10 @@ #include "WebCommon.h" #include "WebLocalizedString.h" +#if defined(OS_WIN) +#include <windows.h> +#endif + namespace WebKit { class WebClipboard; class WebData; @@ -154,6 +158,26 @@ namespace WebKit { // Callable from a background WebKit thread. virtual void callOnMainThread(void (*func)()) = 0; + + // HTML5 DB ------------------------------------------------------------ + +#if defined(OS_WIN) +typedef HANDLE FileType; +#else +typedef int FileType; +#endif + + // Opens a database file + virtual FileType databaseOpenFile(const WebString& fileName, int desiredFlags) = 0; + + // Deletes a database file and returns the error code + virtual bool databaseDeleteFile(const WebString& fileName) = 0; + + // Returns the attributes of the given database file + virtual long databaseGetFileAttributes(const WebString& fileName) = 0; + + // Returns the size of the given database file + virtual long long databaseGetFileSize(const WebString& fileName) = 0; }; } // namespace WebKit diff --git a/webkit/api/src/ChromiumBridge.cpp b/webkit/api/src/ChromiumBridge.cpp index 93ac857..5f0461f 100644 --- a/webkit/api/src/ChromiumBridge.cpp +++ b/webkit/api/src/ChromiumBridge.cpp @@ -429,30 +429,22 @@ bool ChromiumBridge::isLinkVisited(WebCore::LinkHash visitedLinkHash) PlatformFileHandle ChromiumBridge::databaseOpenFile(const String& fileName, int desiredFlags) { - // FIXME: un-stub when the code on the browser process side is submitted - //return webKitClient()->databaseOpenFile(WebString(fileName), desiredFlags); - return invalidPlatformFileHandle; + return webKitClient()->databaseOpenFile(WebString(fileName), desiredFlags); } bool ChromiumBridge::databaseDeleteFile(const String& fileName) { - // FIXME: un-stub when the code on the browser process side is submitted - //return webKitClient()->databaseDeleteFile(WebString(fileName)); - return false; + return webKitClient()->databaseDeleteFile(WebString(fileName)); } long ChromiumBridge::databaseGetFileAttributes(const String& fileName) { - // FIXME: un-stub when the code on the browser process side is submitted - //return webKitClient()->databaseGetFileAttributes(WebString(fileName)); - return 0L; + return webKitClient()->databaseGetFileAttributes(WebString(fileName)); } long long ChromiumBridge::databaseGetFileSize(const String& fileName) { - // FIXME: un-stub when the code on the browser process side is submitted - //return webKitClient()->databaseGetFileSize(WebString(fileName)); - return 0LL; + return webKitClient()->databaseGetFileSize(WebString(fileName)); } #endif diff --git a/webkit/api/src/WebKit.cpp b/webkit/api/src/WebKit.cpp index 0bdbf42..e88a7a8 100644 --- a/webkit/api/src/WebKit.cpp +++ b/webkit/api/src/WebKit.cpp @@ -47,6 +47,7 @@ namespace WebKit { static WebKitClient* s_webKitClient = 0; static bool s_layoutTestMode = false; +static bool s_databasesEnabled = false; void initialize(WebKitClient* webKitClient) { @@ -123,4 +124,17 @@ void resetPluginCache() WebCore::Page::refreshPlugins(false); } +void enableDatabases() +{ +#if ENABLE(DATABASE) + s_databasesEnabled = true; +#endif +} + +bool databasesEnabled() +{ + return s_databasesEnabled; +} + + } // namespace WebKit diff --git a/webkit/glue/chrome_client_impl.cc b/webkit/glue/chrome_client_impl.cc index fa965ef..1390dfa 100644 --- a/webkit/glue/chrome_client_impl.cc +++ b/webkit/glue/chrome_client_impl.cc @@ -14,6 +14,7 @@ MSVC_PUSH_WARNING_LEVEL(0); #include "Cursor.h" #include "Document.h" #include "DocumentLoader.h" +#include "DatabaseTracker.h" #include "FloatRect.h" #include "FileChooser.h" #include "FrameLoadRequest.h" @@ -541,7 +542,10 @@ void ChromeClientImpl::print(WebCore::Frame* frame) { void ChromeClientImpl::exceededDatabaseQuota(WebCore::Frame* frame, const WebCore::String& databaseName) { - // TODO(tc): If we enable the storage API, we need to implement this function. + // set a reasonable quota for now -- 5Mb should be enough for anybody + // TODO(dglazkov): this should be configurable + WebCore::SecurityOrigin* origin = frame->document()->securityOrigin(); + WebCore::DatabaseTracker::tracker().setQuota(origin, 1024 * 1024 * 5); } void ChromeClientImpl::runOpenPanel(WebCore::Frame* frame, diff --git a/webkit/glue/webkitclient_impl.cc b/webkit/glue/webkitclient_impl.cc index c6bd4c8..78c52be 100644 --- a/webkit/glue/webkitclient_impl.cc +++ b/webkit/glue/webkitclient_impl.cc @@ -5,6 +5,7 @@ #include "webkit/glue/webkitclient_impl.h" #include "base/message_loop.h" +#include "base/platform_file.h" #include "base/stats_counters.h" #include "base/string_util.h" #include "base/trace_event.h" @@ -224,4 +225,24 @@ void WebKitClientImpl::callOnMainThread(void (*func)()) { main_loop_->PostTask(FROM_HERE, NewRunnableFunction(func)); } +base::PlatformFile WebKitClientImpl::databaseOpenFile( + const WebKit::WebString& file_name, int desired_flags) { + return base::kInvalidPlatformFileValue; +} + +bool WebKitClientImpl::databaseDeleteFile( + const WebKit::WebString& file_name) { + return false; +} + +long WebKitClientImpl::databaseGetFileAttributes( + const WebKit::WebString& file_name) { + return 0; +} + +long long WebKitClientImpl::databaseGetFileSize( + const WebKit::WebString& file_name) { + return 0; +} + } // namespace webkit_glue diff --git a/webkit/glue/webkitclient_impl.h b/webkit/glue/webkitclient_impl.h index b97d63a..e3035ae 100644 --- a/webkit/glue/webkitclient_impl.h +++ b/webkit/glue/webkitclient_impl.h @@ -5,6 +5,7 @@ #ifndef WEBKIT_CLIENT_IMPL_H_ #define WEBKIT_CLIENT_IMPL_H_ +#include "base/platform_file.h" #include "base/timer.h" #include "webkit/api/public/WebKitClient.h" #if defined(OS_WIN) @@ -39,6 +40,12 @@ class WebKitClientImpl : public WebKit::WebKitClient { virtual void callOnMainThread(void (*func)()); virtual void suddenTerminationChanged(bool enabled) { } + virtual base::PlatformFile databaseOpenFile( + const WebKit::WebString& file_name, int desired_flags); + virtual bool databaseDeleteFile(const WebKit::WebString& file_name); + virtual long databaseGetFileAttributes(const WebKit::WebString& file_name); + virtual long long databaseGetFileSize(const WebKit::WebString& file_name); + private: void DoTimeout() { if (shared_timer_func_) diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index 78d4610..b40f60c 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -90,6 +90,7 @@ MSVC_POP_WARNING(); #include "base/string_util.h" #include "webkit/api/public/WebDragData.h" #include "webkit/api/public/WebInputEvent.h" +#include "webkit/api/public/WebKit.h" #include "webkit/api/public/WebPoint.h" #include "webkit/api/public/WebRect.h" #include "webkit/api/public/WebString.h" @@ -1447,6 +1448,10 @@ void WebViewImpl::SetPreferences(const WebPreferences& preferences) { // Turn this on to cause WebCore to paint the resize corner for us. settings->setShouldPaintCustomScrollbars(true); +#if ENABLE(DATABASE) + settings->setDatabasesEnabled(WebKit::databasesEnabled()); +#endif + // Mitigate attacks from local HTML files by not granting file:// URLs // universal access. settings->setAllowUniversalAccessFromFileURLs(false); |