2009-07-24 21:11:01 +02:00
|
|
|
// Copyright (c) 2009 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2009 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef _BROWSER_WEBKIT_INIT_H
|
|
|
|
#define _BROWSER_WEBKIT_INIT_H
|
|
|
|
|
|
|
|
#include "base/file_util.h"
|
|
|
|
#include "base/path_service.h"
|
2009-09-17 18:56:32 +02:00
|
|
|
#include "base/scoped_temp_dir.h"
|
2009-07-24 21:11:01 +02:00
|
|
|
#include "base/stats_counters.h"
|
2010-03-29 19:53:26 +02:00
|
|
|
#include "base/utf_string_conversions.h"
|
2009-07-24 21:11:01 +02:00
|
|
|
#include "media/base/media.h"
|
2009-08-25 18:35:18 +02:00
|
|
|
#include "webkit/appcache/web_application_cache_host_impl.h"
|
2009-10-03 03:36:52 +02:00
|
|
|
#include "webkit/database/vfs_backend.h"
|
|
|
|
#include "webkit/extensions/v8/gears_extension.h"
|
2010-01-12 02:37:00 +01:00
|
|
|
#include "third_party/WebKit/WebKit/chromium/public/WebData.h"
|
|
|
|
#include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h"
|
|
|
|
#include "third_party/WebKit/WebKit/chromium/public/WebKit.h"
|
|
|
|
#include "third_party/WebKit/WebKit/chromium/public/WebRuntimeFeatures.h"
|
|
|
|
#include "third_party/WebKit/WebKit/chromium/public/WebScriptController.h"
|
|
|
|
#include "third_party/WebKit/WebKit/chromium/public/WebSecurityPolicy.h"
|
|
|
|
#include "third_party/WebKit/WebKit/chromium/public/WebStorageArea.h"
|
|
|
|
#include "third_party/WebKit/WebKit/chromium/public/WebStorageEventDispatcher.h"
|
2010-08-09 21:13:43 +02:00
|
|
|
#include "third_party/WebKit/WebKit/chromium/public/WebIDBFactory.h"
|
2010-09-13 03:59:43 +02:00
|
|
|
#include "third_party/WebKit/WebKit/chromium/public/WebIDBKey.h"
|
|
|
|
#include "third_party/WebKit/WebKit/chromium/public/WebIDBKeyPath.h"
|
|
|
|
#include "third_party/WebKit/WebKit/chromium/public/WebSerializedScriptValue.h"
|
2010-01-12 02:37:00 +01:00
|
|
|
#include "third_party/WebKit/WebKit/chromium/public/WebStorageNamespace.h"
|
|
|
|
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
|
2009-07-24 21:11:01 +02:00
|
|
|
#include "webkit/glue/simple_webmimeregistry_impl.h"
|
|
|
|
#include "webkit/glue/webclipboard_impl.h"
|
2010-09-13 03:59:43 +02:00
|
|
|
#include "webkit/glue/webfileutilities_impl.h"
|
2009-07-24 21:11:01 +02:00
|
|
|
#include "webkit/glue/webkit_glue.h"
|
|
|
|
#include "webkit/glue/webkitclient_impl.h"
|
2009-08-25 18:35:18 +02:00
|
|
|
#include "browser_appcache_system.h"
|
2009-10-03 03:36:52 +02:00
|
|
|
#include "browser_database_system.h"
|
2010-10-03 22:35:06 +02:00
|
|
|
#include "browser_file_system.h"
|
2009-07-24 21:11:01 +02:00
|
|
|
#include "browser_resource_loader_bridge.h"
|
2010-09-13 03:59:43 +02:00
|
|
|
#include "browser_webblobregistry_impl.h"
|
2010-03-29 19:53:26 +02:00
|
|
|
#include "browser_webcookiejar_impl.h"
|
2009-07-24 21:11:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
class BrowserWebKitInit : public webkit_glue::WebKitClientImpl {
|
|
|
|
public:
|
2009-09-17 18:56:32 +02:00
|
|
|
explicit BrowserWebKitInit() {
|
2009-07-24 21:11:01 +02:00
|
|
|
v8::V8::SetCounterFunction(StatsTable::FindLocation);
|
|
|
|
|
|
|
|
WebKit::initialize(this);
|
|
|
|
WebKit::setLayoutTestMode(false);
|
2009-10-25 20:29:12 +01:00
|
|
|
WebKit::WebScriptController::registerExtension(
|
|
|
|
extensions_v8::GearsExtension::Get());
|
2009-11-03 02:39:16 +01:00
|
|
|
WebKit::WebRuntimeFeatures::enableSockets(true);
|
2010-01-12 02:37:00 +01:00
|
|
|
WebKit::WebRuntimeFeatures::enableApplicationCache(true);
|
|
|
|
WebKit::WebRuntimeFeatures::enableDatabase(true);
|
2010-03-29 19:53:26 +02:00
|
|
|
WebKit::WebRuntimeFeatures::enableWebGL(true);
|
2010-06-21 20:02:39 +02:00
|
|
|
WebKit::WebRuntimeFeatures::enablePushState(true);
|
|
|
|
WebKit::WebRuntimeFeatures::enableNotifications(true);
|
|
|
|
WebKit::WebRuntimeFeatures::enableTouch(true);
|
|
|
|
WebKit::WebRuntimeFeatures::enableIndexedDatabase(true);
|
2010-04-08 17:26:54 +02:00
|
|
|
WebKit::WebRuntimeFeatures::enableGeolocation(false);
|
2010-08-09 21:13:43 +02:00
|
|
|
WebKit::WebRuntimeFeatures::enableSpeechInput(true);
|
2010-09-13 03:59:43 +02:00
|
|
|
WebKit::WebRuntimeFeatures::enableFileSystem(true);
|
2010-08-09 21:13:43 +02:00
|
|
|
|
|
|
|
// TODO(hwennborg): Enable this once the implementation supports it.
|
|
|
|
WebKit::WebRuntimeFeatures::enableDeviceMotion(false);
|
|
|
|
WebKit::WebRuntimeFeatures::enableDeviceOrientation(false);
|
2009-07-24 21:11:01 +02:00
|
|
|
|
|
|
|
// Load libraries for media and enable the media player.
|
|
|
|
FilePath module_path;
|
2009-11-03 02:39:16 +01:00
|
|
|
WebKit::WebRuntimeFeatures::enableMediaPlayer(
|
|
|
|
PathService::Get(base::DIR_MODULE, &module_path) &&
|
|
|
|
media::InitializeMediaLibrary(module_path));
|
2009-09-17 18:56:32 +02:00
|
|
|
|
|
|
|
// Construct and initialize an appcache system for this scope.
|
|
|
|
// A new empty temp directory is created to house any cached
|
|
|
|
// content during the run. Upon exit that directory is deleted.
|
2010-02-11 19:33:33 +01:00
|
|
|
// If we can't create a tempdir, we'll use in-memory storage.
|
|
|
|
if (!appcache_dir_.CreateUniqueTempDir()) {
|
|
|
|
LOG(WARNING) << "Failed to create a temp dir for the appcache, "
|
|
|
|
"using in-memory storage.";
|
|
|
|
DCHECK(appcache_dir_.path().empty());
|
|
|
|
}
|
|
|
|
BrowserAppCacheSystem::InitializeOnUIThread(appcache_dir_.path());
|
2010-01-12 02:37:00 +01:00
|
|
|
|
|
|
|
WebKit::WebDatabase::setObserver(&database_system_);
|
2010-06-21 20:02:39 +02:00
|
|
|
|
2010-09-13 03:59:43 +02:00
|
|
|
blob_registry_ = new BrowserWebBlobRegistryImpl();
|
|
|
|
|
|
|
|
file_utilities_.set_sandbox_enabled(false);
|
2009-07-24 21:11:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
~BrowserWebKitInit() {
|
|
|
|
WebKit::shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual WebKit::WebMimeRegistry* mimeRegistry() {
|
|
|
|
return &mime_registry_;
|
|
|
|
}
|
|
|
|
|
|
|
|
WebKit::WebClipboard* clipboard() {
|
2009-08-13 19:23:08 +02:00
|
|
|
return &clipboard_;
|
2009-07-24 21:11:01 +02:00
|
|
|
}
|
|
|
|
|
2010-09-13 03:59:43 +02:00
|
|
|
virtual WebKit::WebFileUtilities* fileUtilities() {
|
|
|
|
return &file_utilities_;
|
2010-06-21 20:02:39 +02:00
|
|
|
}
|
|
|
|
|
2009-07-24 21:11:01 +02:00
|
|
|
virtual WebKit::WebSandboxSupport* sandboxSupport() {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-09-13 03:59:43 +02:00
|
|
|
virtual WebKit::WebBlobRegistry* blobRegistry() {
|
|
|
|
return blob_registry_.get();
|
|
|
|
}
|
|
|
|
|
2010-03-29 19:53:26 +02:00
|
|
|
virtual WebKit::WebCookieJar* cookieJar() {
|
|
|
|
return &cookie_jar_;
|
|
|
|
}
|
2010-10-03 22:35:06 +02:00
|
|
|
|
|
|
|
virtual WebKit::WebFileSystem* fileSystem() {
|
|
|
|
return &file_system_;
|
|
|
|
}
|
2010-03-29 19:53:26 +02:00
|
|
|
|
2009-08-13 19:23:08 +02:00
|
|
|
virtual bool sandboxEnabled() {
|
2009-10-03 03:36:52 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual WebKit::WebKitClient::FileHandle databaseOpenFile(
|
2010-06-21 20:02:39 +02:00
|
|
|
const WebKit::WebString& vfs_file_name, int desired_flags) {
|
2009-10-03 03:36:52 +02:00
|
|
|
return BrowserDatabaseSystem::GetInstance()->OpenFile(
|
2010-06-21 20:02:39 +02:00
|
|
|
vfs_file_name, desired_flags);
|
2009-10-03 03:36:52 +02:00
|
|
|
}
|
|
|
|
|
2010-01-12 02:37:00 +01:00
|
|
|
virtual int databaseDeleteFile(const WebKit::WebString& vfs_file_name,
|
2009-10-03 03:36:52 +02:00
|
|
|
bool sync_dir) {
|
|
|
|
return BrowserDatabaseSystem::GetInstance()->DeleteFile(
|
2010-01-12 02:37:00 +01:00
|
|
|
vfs_file_name, sync_dir);
|
2009-10-03 03:36:52 +02:00
|
|
|
}
|
|
|
|
|
2010-01-12 02:37:00 +01:00
|
|
|
virtual long databaseGetFileAttributes(
|
|
|
|
const WebKit::WebString& vfs_file_name) {
|
2009-10-03 03:36:52 +02:00
|
|
|
return BrowserDatabaseSystem::GetInstance()->GetFileAttributes(
|
2010-01-12 02:37:00 +01:00
|
|
|
vfs_file_name);
|
2009-10-03 03:36:52 +02:00
|
|
|
}
|
|
|
|
|
2010-01-12 02:37:00 +01:00
|
|
|
virtual long long databaseGetFileSize(
|
|
|
|
const WebKit::WebString& vfs_file_name) {
|
|
|
|
return BrowserDatabaseSystem::GetInstance()->GetFileSize(vfs_file_name);
|
2009-08-13 19:23:08 +02:00
|
|
|
}
|
|
|
|
|
2009-09-17 18:56:32 +02:00
|
|
|
virtual unsigned long long visitedLinkHash(const char* canonicalURL,
|
|
|
|
size_t length) {
|
2009-07-24 21:11:01 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool isLinkVisited(unsigned long long linkHash) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-08-13 19:23:08 +02:00
|
|
|
virtual WebKit::WebMessagePortChannel* createMessagePortChannel() {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-07-24 21:11:01 +02:00
|
|
|
virtual void prefetchHostName(const WebKit::WebString&) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual WebKit::WebData loadResource(const char* name) {
|
|
|
|
if (!strcmp(name, "deleteButton")) {
|
|
|
|
// Create a red 30x30 square.
|
|
|
|
const char red_square[] =
|
|
|
|
"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52"
|
|
|
|
"\x00\x00\x00\x1e\x00\x00\x00\x1e\x04\x03\x00\x00\x00\xc9\x1e\xb3"
|
|
|
|
"\x91\x00\x00\x00\x30\x50\x4c\x54\x45\x00\x00\x00\x80\x00\x00\x00"
|
|
|
|
"\x80\x00\x80\x80\x00\x00\x00\x80\x80\x00\x80\x00\x80\x80\x80\x80"
|
|
|
|
"\x80\xc0\xc0\xc0\xff\x00\x00\x00\xff\x00\xff\xff\x00\x00\x00\xff"
|
|
|
|
"\xff\x00\xff\x00\xff\xff\xff\xff\xff\x7b\x1f\xb1\xc4\x00\x00\x00"
|
|
|
|
"\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a"
|
|
|
|
"\x9c\x18\x00\x00\x00\x17\x49\x44\x41\x54\x78\x01\x63\x98\x89\x0a"
|
|
|
|
"\x18\x50\xb9\x33\x47\xf9\xa8\x01\x32\xd4\xc2\x03\x00\x33\x84\x0d"
|
|
|
|
"\x02\x3a\x91\xeb\xa5\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60"
|
|
|
|
"\x82";
|
|
|
|
return WebKit::WebData(red_square, arraysize(red_square));
|
|
|
|
}
|
|
|
|
return webkit_glue::WebKitClientImpl::loadResource(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual WebKit::WebString defaultLocale() {
|
|
|
|
return ASCIIToUTF16("en-US");
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual WebKit::WebStorageNamespace* createLocalStorageNamespace(
|
2009-10-13 03:39:30 +02:00
|
|
|
const WebKit::WebString& path, unsigned quota) {
|
|
|
|
return WebKit::WebStorageNamespace::createLocalStorageNamespace(path,
|
2010-06-21 20:02:39 +02:00
|
|
|
WebKit::WebStorageNamespace::m_localStorageQuota);
|
2009-08-25 18:35:18 +02:00
|
|
|
}
|
2009-07-24 21:11:01 +02:00
|
|
|
|
2010-08-09 21:13:43 +02:00
|
|
|
virtual WebKit::WebIDBFactory* idbFactory() {
|
|
|
|
return WebKit::WebIDBFactory::create();
|
2009-11-03 02:39:16 +01:00
|
|
|
}
|
|
|
|
|
2010-09-13 03:59:43 +02:00
|
|
|
virtual void createIDBKeysFromSerializedValuesAndKeyPath(
|
|
|
|
const WebKit::WebVector<WebKit::WebSerializedScriptValue>& values,
|
|
|
|
const WebKit::WebString& keyPath,
|
|
|
|
WebKit::WebVector<WebKit::WebIDBKey>& keys_out) {
|
|
|
|
WebKit::WebVector<WebKit::WebIDBKey> keys(values.size());
|
|
|
|
for (size_t i = 0; i < values.size(); ++i) {
|
|
|
|
keys[i] = WebKit::WebIDBKey::createFromValueAndKeyPath(
|
|
|
|
values[i], WebKit::WebIDBKeyPath::create(keyPath));
|
|
|
|
}
|
|
|
|
keys_out.swap(keys);
|
|
|
|
}
|
|
|
|
|
2010-01-12 02:37:00 +01:00
|
|
|
private:
|
2009-07-24 21:11:01 +02:00
|
|
|
webkit_glue::SimpleWebMimeRegistryImpl mime_registry_;
|
2009-08-13 19:23:08 +02:00
|
|
|
webkit_glue::WebClipboardImpl clipboard_;
|
2010-09-13 03:59:43 +02:00
|
|
|
webkit_glue::WebFileUtilitiesImpl file_utilities_;
|
2009-09-17 18:56:32 +02:00
|
|
|
ScopedTempDir appcache_dir_;
|
2009-08-25 18:35:18 +02:00
|
|
|
BrowserAppCacheSystem appcache_system_;
|
2009-10-03 03:36:52 +02:00
|
|
|
BrowserDatabaseSystem database_system_;
|
2010-03-29 19:53:26 +02:00
|
|
|
BrowserWebCookieJarImpl cookie_jar_;
|
2010-09-13 03:59:43 +02:00
|
|
|
scoped_refptr<BrowserWebBlobRegistryImpl> blob_registry_;
|
2010-10-03 22:35:06 +02:00
|
|
|
BrowserFileSystem file_system_;
|
2009-07-24 21:11:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _BROWSER_WEBKIT_INIT_H
|