2009-03-05 18:14:16 +01: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
|
|
|
|
|
2009-04-28 02:29:14 +02:00
|
|
|
#include "base/stats_counters.h"
|
2009-03-05 18:14:16 +01:00
|
|
|
#include "base/string_util.h"
|
2009-05-15 17:09:51 +02:00
|
|
|
#include "webkit/api/public/WebCString.h"
|
|
|
|
#include "webkit/api/public/WebData.h"
|
|
|
|
#include "webkit/api/public/WebKit.h"
|
|
|
|
#include "webkit/api/public/WebString.h"
|
|
|
|
#include "webkit/api/public/WebURL.h"
|
2009-03-05 18:14:16 +01:00
|
|
|
#include "webkit/glue/simple_webmimeregistry_impl.h"
|
2009-04-28 02:29:14 +02:00
|
|
|
#include "webkit/glue/webclipboard_impl.h"
|
2009-03-05 18:14:16 +01:00
|
|
|
#include "webkit/glue/webkit_glue.h"
|
|
|
|
#include "webkit/glue/webkitclient_impl.h"
|
2009-03-09 20:38:59 +01:00
|
|
|
#include "webkit/extensions/v8/gears_extension.h"
|
|
|
|
#include "webkit/extensions/v8/interval_extension.h"
|
2009-03-05 18:14:16 +01:00
|
|
|
#include "browser_resource_loader_bridge.h"
|
|
|
|
|
|
|
|
|
|
|
|
class BrowserWebKitInit : public webkit_glue::WebKitClientImpl {
|
|
|
|
public:
|
|
|
|
BrowserWebKitInit() {
|
2009-03-24 16:06:38 +01:00
|
|
|
v8::V8::SetCounterFunction(StatsTable::FindLocation);
|
|
|
|
|
2009-03-05 18:14:16 +01:00
|
|
|
WebKit::initialize(this);
|
|
|
|
WebKit::setLayoutTestMode(false);
|
|
|
|
WebKit::registerURLSchemeAsLocal(
|
|
|
|
ASCIIToUTF16(webkit_glue::GetUIResourceProtocol()));
|
2009-03-24 16:06:38 +01:00
|
|
|
WebKit::registerURLSchemeAsNoAccess(
|
|
|
|
ASCIIToUTF16(webkit_glue::GetUIResourceProtocol()));
|
2009-03-09 20:38:59 +01:00
|
|
|
WebKit::registerExtension(extensions_v8::GearsExtension::Get());
|
|
|
|
WebKit::registerExtension(extensions_v8::IntervalExtension::Get());
|
2009-03-05 18:14:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
~BrowserWebKitInit() {
|
|
|
|
WebKit::shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual WebKit::WebMimeRegistry* mimeRegistry() {
|
|
|
|
return &mime_registry_;
|
|
|
|
}
|
|
|
|
|
2009-04-28 02:29:14 +02:00
|
|
|
WebKit::WebClipboard* clipboard() {
|
|
|
|
if (!clipboard_.get()) {
|
|
|
|
clipboard_.reset(new webkit_glue::WebClipboardImpl());
|
|
|
|
}
|
|
|
|
return clipboard_.get();
|
|
|
|
}
|
|
|
|
|
2009-03-24 16:06:38 +01:00
|
|
|
virtual WebKit::WebSandboxSupport* sandboxSupport() {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-04-28 02:29:14 +02:00
|
|
|
virtual unsigned long long visitedLinkHash(const char* canonicalURL, size_t length) {
|
2009-03-09 20:38:59 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-04-28 02:29:14 +02:00
|
|
|
virtual bool isLinkVisited(unsigned long long linkHash) {
|
2009-03-09 20:38:59 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-06-03 01:27:47 +02:00
|
|
|
virtual void setCookies(const WebKit::WebURL& url,
|
|
|
|
const WebKit::WebURL& first_party_for_cookies,
|
|
|
|
const WebKit::WebString& value) {
|
|
|
|
BrowserResourceLoaderBridge::SetCookie(
|
|
|
|
url, first_party_for_cookies, UTF16ToUTF8(value));
|
2009-03-05 18:14:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual WebKit::WebString cookies(
|
2009-06-03 01:27:47 +02:00
|
|
|
const WebKit::WebURL& url,
|
|
|
|
const WebKit::WebURL& first_party_for_cookies) {
|
|
|
|
return UTF8ToUTF16(BrowserResourceLoaderBridge::GetCookies(
|
|
|
|
url, first_party_for_cookies));
|
2009-03-05 18:14:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void prefetchHostName(const WebKit::WebString&) {
|
|
|
|
}
|
|
|
|
|
2009-04-28 02:29:14 +02:00
|
|
|
virtual WebKit::WebData loadResource(const char* name) {
|
2009-03-09 20:38:59 +01:00
|
|
|
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";
|
2009-04-28 02:29:14 +02:00
|
|
|
return WebKit::WebData(red_square, arraysize(red_square));
|
2009-03-09 20:38:59 +01:00
|
|
|
}
|
|
|
|
return webkit_glue::WebKitClientImpl::loadResource(name);
|
|
|
|
}
|
|
|
|
|
2009-03-05 18:14:16 +01:00
|
|
|
virtual WebKit::WebString defaultLocale() {
|
|
|
|
return ASCIIToUTF16("en-US");
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
webkit_glue::SimpleWebMimeRegistryImpl mime_registry_;
|
2009-04-28 02:29:14 +02:00
|
|
|
scoped_ptr<WebKit::WebClipboard> clipboard_;
|
2009-03-05 18:14:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _BROWSER_WEBKIT_INIT_H
|