diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-28 01:13:47 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-28 01:13:47 +0000 |
commit | 90a3fbb1723ba60bcf557121b7bbe80817a7533f (patch) | |
tree | 28d845ed0f1d64cdfa418f4561af4536de6f3c40 /webkit | |
parent | 41fb1d7d262e44d8561a5c4d6d7e353f638b56e8 (diff) | |
download | chromium_src-90a3fbb1723ba60bcf557121b7bbe80817a7533f.zip chromium_src-90a3fbb1723ba60bcf557121b7bbe80817a7533f.tar.gz chromium_src-90a3fbb1723ba60bcf557121b7bbe80817a7533f.tar.bz2 |
Chrome side to pick up new WebKit API changes.
WebKit API now provides:
- layoutTestMode
- support for registering extra local URL schemes
- access to the current WebKitClient
WebKitClient was extended to include:
- access to the default locale
- access to the current time
- methods to start/stop the shared timer
- method to get work scheduled on the main thread
- methods to access cookies
- method to prefetch hostnames
R=dglazkov
Review URL: http://codereview.chromium.org/27276
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10665 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
23 files changed, 205 insertions, 248 deletions
diff --git a/webkit/build/JavaScriptCore/WTF.vcproj b/webkit/build/JavaScriptCore/WTF.vcproj index be75e21..502ca67 100644 --- a/webkit/build/JavaScriptCore/WTF.vcproj +++ b/webkit/build/JavaScriptCore/WTF.vcproj @@ -158,15 +158,15 @@ > </File> <File - RelativePath="..\..\..\third_party\WebKit\JavaScriptCore\wtf\unicode\Collator.h" + RelativePath="..\..\..\third_party\WebKit\JavaScriptCore\wtf\chromium\ChromiumThreading.h" > </File> <File - RelativePath="..\..\..\third_party\WebKit\JavaScriptCore\wtf\unicode\icu\CollatorICU.cpp" + RelativePath="..\..\..\third_party\WebKit\JavaScriptCore\wtf\unicode\Collator.h" > </File> <File - RelativePath="..\..\..\third_party\WebKit\JavaScriptCore\wtf\CurrentTime.cpp" + RelativePath="..\..\..\third_party\WebKit\JavaScriptCore\wtf\unicode\icu\CollatorICU.cpp" > </File> <File @@ -242,6 +242,10 @@ > </File> <File + RelativePath="..\..\..\third_party\WebKit\JavaScriptCore\wtf\chromium\MainThreadChromium.cpp" + > + </File> + <File RelativePath="..\..\pending\wtf\MathExtras.h" > </File> @@ -266,10 +270,6 @@ > </File> <File - RelativePath="..\..\..\third_party\WebKit\JavaScriptCore\wtf\PtrAndFlags.h" - > - </File> - <File RelativePath="..\precompiled_webkit.cc" > <FileConfiguration @@ -294,6 +294,10 @@ > </File> <File + RelativePath="..\..\..\third_party\WebKit\JavaScriptCore\wtf\PtrAndFlags.h" + > + </File> + <File RelativePath="..\..\..\third_party\WebKit\JavaScriptCore\wtf\RandomNumber.cpp" > </File> @@ -362,15 +366,15 @@ > </File> <File - RelativePath="..\..\..\third_party\WebKit\JavaScriptCore\wtf\TypeTraits.cpp" + RelativePath="..\..\..\third_party\WebKit\JavaScriptCore\wtf\ThreadSpecificWin.cpp" > </File> <File - RelativePath="..\..\..\third_party\WebKit\JavaScriptCore\wtf\TypeTraits.h" + RelativePath="..\..\..\third_party\WebKit\JavaScriptCore\wtf\TypeTraits.cpp" > </File> <File - RelativePath="..\..\..\third_party\WebKit\JavaScriptCore\wtf\ThreadSpecificWin.cpp" + RelativePath="..\..\..\third_party\WebKit\JavaScriptCore\wtf\TypeTraits.h" > </File> <File @@ -401,14 +405,6 @@ RelativePath="..\..\..\third_party\WebKit\JavaScriptCore\wtf\VectorTraits.h" > </File> - <File - RelativePath="..\..\..\third_party\WebKit\JavaScriptCore\wtf\chromium\ChromiumThreading.h" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\JavaScriptCore\wtf\chromium\MainThreadChromium.cpp" - > - </File> </Files> <Globals> </Globals> diff --git a/webkit/build/WebKit/SConscript b/webkit/build/WebKit/SConscript index fa87fe0..8686346 100644 --- a/webkit/build/WebKit/SConscript +++ b/webkit/build/WebKit/SConscript @@ -19,6 +19,8 @@ env.Append( input_files = [ '$THIRD_PARTY_WEBKIT_DIR/WebKit/chromium/src/ChromiumBridge.cpp', + '$THIRD_PARTY_WEBKIT_DIR/WebKit/chromium/src/ChromiumCurrentTime.cpp', + '$THIRD_PARTY_WEBKIT_DIR/WebKit/chromium/src/ChromiumThreading.cpp', '$THIRD_PARTY_WEBKIT_DIR/WebKit/chromium/src/WebCString.cpp', '$THIRD_PARTY_WEBKIT_DIR/WebKit/chromium/src/WebImageSkia.cpp', '$THIRD_PARTY_WEBKIT_DIR/WebKit/chromium/src/WebKit.cpp', diff --git a/webkit/build/WebKit/WebKit.vcproj b/webkit/build/WebKit/WebKit.vcproj index 2aa6c6c..6b798b7 100644 --- a/webkit/build/WebKit/WebKit.vcproj +++ b/webkit/build/WebKit/WebKit.vcproj @@ -180,6 +180,14 @@ > </File> <File + RelativePath="..\..\..\third_party\WebKit\WebKit\chromium\src\ChromiumCurrentTime.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebKit\chromium\src\ChromiumThreading.cpp" + > + </File> + <File RelativePath="..\..\..\third_party\WebKit\WebKit\chromium\src\WebCString.cpp" > </File> diff --git a/webkit/build/WebKit/using_webkit.scons b/webkit/build/WebKit/using_webkit.scons new file mode 100644 index 0000000..6584790 --- /dev/null +++ b/webkit/build/WebKit/using_webkit.scons @@ -0,0 +1,21 @@ +# 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. + +__doc__ = """ +Settings for other components using the WebKit library. +""" + +Import("env") + +env.Append( + CPPDEFINES = [ + 'WEBKIT_USING_SKIA' + ], + CPPPATH = [ + '$THIRD_PARTY_WEBKIT_DIR/WebKit/chromium/public' + ], + LIBS = [ + 'WebKit', + ], +) diff --git a/webkit/glue/SConscript b/webkit/glue/SConscript index 555f657..8e2bdf3 100644 --- a/webkit/glue/SConscript +++ b/webkit/glue/SConscript @@ -42,7 +42,6 @@ input_files = [ 'cache_manager.cc', 'chrome_client_impl.cc', 'chromium_bridge_impl.cc', - 'chromium_threading.cc', 'clipboard_conversion.cc', 'context_menu_client_impl.cc', 'cpp_binding_example.cc', diff --git a/webkit/glue/chrome_client_impl.cc b/webkit/glue/chrome_client_impl.cc index 8d3f161..c9965dd 100644 --- a/webkit/glue/chrome_client_impl.cc +++ b/webkit/glue/chrome_client_impl.cc @@ -21,6 +21,9 @@ MSVC_PUSH_WARNING_LEVEL(0); #include "v8_proxy.h" #endif MSVC_POP_WARNING(); + +#include "WebKit.h" + #undef LOG #include "webkit/glue/chrome_client_impl.h" @@ -149,7 +152,7 @@ void ChromeClientImpl::unfocus() { bool ChromeClientImpl::canTakeFocus(WebCore::FocusDirection) { // For now the browser can always take focus if we're not running layout // tests. - return !webkit_glue::IsLayoutTestMode(); + return !WebKit::layoutTestMode(); } void ChromeClientImpl::takeFocus(WebCore::FocusDirection direction) { @@ -376,7 +379,7 @@ bool ChromeClientImpl::tabsToLinks() const { // a preference system in place. // For now Chrome will allow link to take focus if we're not running layout // tests. - return !webkit_glue::IsLayoutTestMode(); + return !WebKit::layoutTestMode(); } WebCore::IntRect ChromeClientImpl::windowResizerRect() const { diff --git a/webkit/glue/chromium_bridge_impl.cc b/webkit/glue/chromium_bridge_impl.cc index 8c701a4..3af3a53 100644 --- a/webkit/glue/chromium_bridge_impl.cc +++ b/webkit/glue/chromium_bridge_impl.cc @@ -25,6 +25,8 @@ #include "Widget.h" #include <wtf/CurrentTime.h> +#include "WebKit.h" + #undef LOG #include "base/file_util.h" #include "base/message_loop.h" @@ -93,28 +95,6 @@ ChromeClientImpl* ToChromeClient(WebCore::Widget* widget) { namespace WebCore { -// Cookies -------------------------------------------------------------------- - -void ChromiumBridge::setCookies( - const KURL& url, const KURL& policy_url, const String& cookie) { - webkit_glue::SetCookie( - webkit_glue::KURLToGURL(url), - webkit_glue::KURLToGURL(policy_url), - webkit_glue::StringToStdString(cookie)); -} - -String ChromiumBridge::cookies(const KURL& url, const KURL& policy_url) { - return webkit_glue::StdStringToString(webkit_glue::GetCookies( - webkit_glue::KURLToGURL(url), - webkit_glue::KURLToGURL(policy_url))); -} - -// DNS ------------------------------------------------------------------------ - -void ChromiumBridge::prefetchDNS(const String& hostname) { - webkit_glue::PrefetchDns(webkit_glue::StringToStdString(hostname)); -} - // Font ----------------------------------------------------------------------- #if defined(OS_WIN) @@ -129,18 +109,6 @@ void ChromiumBridge::notifyJSOutOfMemory(Frame* frame) { webkit_glue::NotifyJSOutOfMemory(frame); } -// Language ------------------------------------------------------------------- - -String ChromiumBridge::computedDefaultLanguage() { - return webkit_glue::StdWStringToString(webkit_glue::GetWebKitLocale()); -} - -// LayoutTestMode ------------------------------------------------------------- - -bool ChromiumBridge::layoutTestMode() { - return webkit_glue::IsLayoutTestMode(); -} - // Plugin --------------------------------------------------------------------- bool ChromiumBridge::plugins(bool refresh, Vector<PluginInfo*>* results) { @@ -231,7 +199,7 @@ PassRefPtr<Image> ChromiumBridge::loadPlatformImageResource(const char* name) { } else if (!strcmp(name, "linuxRadioOn")) { resource_id = IDR_LINUX_RADIO_ON; } else if (!strcmp(name, "deleteButton")) { - if (webkit_glue::IsLayoutTestMode()) { + if (WebKit::layoutTestMode()) { RefPtr<Image> image = BitmapImage::create(); // Create a red 30x30 square used only in layout tests. const char red_square[] = @@ -289,65 +257,6 @@ IntRect ChromiumBridge::screenAvailableRect(Widget* widget) { webkit_glue::GetScreenInfo(ToNativeId(widget)).available_rect); } -// SharedTimers ---------------------------------------------------------------- -// Called by SharedTimerChromium.cpp - -class SharedTimerTask; - -// We maintain a single active timer and a single active task for -// setting timers directly on the platform. -static SharedTimerTask* shared_timer_task; -static void (*shared_timer_function)(); - -// Timer task to run in the chrome message loop. -class SharedTimerTask : public Task { - public: - SharedTimerTask(void (*callback)()) : callback_(callback) {} - - virtual void Run() { - if (!callback_) - return; - // Since we only have one task running at a time, verify 'this' is it - DCHECK(shared_timer_task == this); - shared_timer_task = NULL; - callback_(); - } - - void Cancel() { - callback_ = NULL; - } - - private: - void (*callback_)(); - DISALLOW_COPY_AND_ASSIGN(SharedTimerTask); -}; - -void ChromiumBridge::setSharedTimerFiredFunction(void (*func)()) { - shared_timer_function = func; -} - -void ChromiumBridge::setSharedTimerFireTime(double fire_time) { - DCHECK(shared_timer_function); - int interval = static_cast<int>((fire_time - WTF::currentTime()) * 1000); - if (interval < 0) - interval = 0; - - stopSharedTimer(); - - // Verify that we didn't leak the task or timer objects. - DCHECK(shared_timer_task == NULL); - shared_timer_task = new SharedTimerTask(shared_timer_function); - MessageLoop::current()->PostDelayedTask(FROM_HERE, shared_timer_task, - interval); -} - -void ChromiumBridge::stopSharedTimer() { - if (!shared_timer_task) - return; - shared_timer_task->Cancel(); - shared_timer_task = NULL; -} - // StatsCounters -------------------------------------------------------------- void ChromiumBridge::decrementStatsCounter(const char* name) { @@ -366,15 +275,6 @@ void ChromiumBridge::initV8CounterFunction() { } #endif -// SystemTime ----------------------------------------------------------------- -// Called by SystemTimeChromium.cpp - -double ChromiumBridge::currentTime() { - // TODO(mbelshe): This can be deleted; SystemTimeChromium does not need this - // anymore. - return base::Time::Now().ToDoubleT(); -} - // Theming -------------------------------------------------------------------- #if PLATFORM(WIN_OS) diff --git a/webkit/glue/chromium_threading.cc b/webkit/glue/chromium_threading.cc deleted file mode 100644 index 7484e5e9..0000000 --- a/webkit/glue/chromium_threading.cc +++ /dev/null @@ -1,27 +0,0 @@ -// 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. - -#include "config.h" -#include <wtf/Assertions.h> -#include <wtf/MainThread.h> -#include <wtf/chromium/ChromiumThreading.h> - -#undef LOG -#include "base/message_loop.h" - -namespace WTF { - -static MessageLoop* main_thread = NULL; - -void ChromiumThreading::initializeMainThread() { - main_thread = MessageLoop::current(); -} - -void ChromiumThreading::scheduleDispatchFunctionsOnMainThread() { - ASSERT(main_thread); - main_thread->PostTask(FROM_HERE, - NewRunnableFunction(&WTF::dispatchFunctionsFromMainThread)); -} - -} // namespace WTF diff --git a/webkit/glue/editor_client_impl.cc b/webkit/glue/editor_client_impl.cc index f7fc4e4..7e60c4e 100644 --- a/webkit/glue/editor_client_impl.cc +++ b/webkit/glue/editor_client_impl.cc @@ -25,6 +25,8 @@ MSVC_PUSH_WARNING_LEVEL(0); #include "PlatformString.h" MSVC_POP_WARNING(); +#include "WebKit.h" + #undef LOG #include "base/message_loop.h" #include "base/string_util.h" @@ -92,7 +94,7 @@ bool EditorClientImpl::shouldShowDeleteInterface(WebCore::HTMLElement* elem) { // Normally, we don't care to show WebCore's deletion UI, so we only enable // it if in testing mode and the test specifically requests it by using this // magic class name. - return webkit_glue::IsLayoutTestMode() && + return WebKit::layoutTestMode() && elem->className() == "needsDeletionUI"; } @@ -493,9 +495,9 @@ static const KeyDownEntry keyDownEntries[] = { { WebCore::VKEY_RETURN, AltKey, "InsertNewline" }, { WebCore::VKEY_RETURN, AltKey | ShiftKey, "InsertNewline" }, { WebCore::VKEY_RETURN, ShiftKey, "InsertLineBreak" }, - { WebCore::VKEY_INSERT, CtrlKey, "Copy" }, - { WebCore::VKEY_INSERT, ShiftKey, "Paste" }, - { WebCore::VKEY_DELETE, ShiftKey, "Cut" }, + { WebCore::VKEY_INSERT, CtrlKey, "Copy" }, + { WebCore::VKEY_INSERT, ShiftKey, "Paste" }, + { WebCore::VKEY_DELETE, ShiftKey, "Cut" }, #if defined(OS_MACOSX) { 'C', CommandKey, "Copy" }, { 'V', CommandKey, "Paste" }, diff --git a/webkit/glue/event_conversion.cc b/webkit/glue/event_conversion.cc index ea89652..0902778 100644 --- a/webkit/glue/event_conversion.cc +++ b/webkit/glue/event_conversion.cc @@ -16,6 +16,8 @@ MSVC_PUSH_WARNING_LEVEL(0); #include "Widget.h" MSVC_POP_WARNING(); +#include "WebKit.h" + #undef LOG #include "base/gfx/point.h" #include "base/logging.h" @@ -109,7 +111,7 @@ MakePlatformMouseEvent::MakePlatformMouseEvent(Widget* widget, NOTREACHED() << "unexpected mouse event type"; } - if (webkit_glue::IsLayoutTestMode()) { + if (WebKit::layoutTestMode()) { m_clickCount = e.layout_test_click_count; } } diff --git a/webkit/glue/glue.vcproj b/webkit/glue/glue.vcproj index 661cffb..304c24b 100644 --- a/webkit/glue/glue.vcproj +++ b/webkit/glue/glue.vcproj @@ -309,10 +309,6 @@ >
</File>
<File
- RelativePath=".\chromium_threading.cc"
- >
- </File>
- <File
RelativePath=".\clipboard_conversion.cc"
>
</File>
diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc index cd099b3..70f17fd 100644 --- a/webkit/glue/webkit_glue.cc +++ b/webkit/glue/webkit_glue.cc @@ -73,21 +73,6 @@ void SetShouldExposeGCController(bool enable) { #endif } -static bool layout_test_mode_ = false; - -void SetLayoutTestMode(bool enable) { - layout_test_mode_ = enable; -} - -bool IsLayoutTestMode() { - return layout_test_mode_; -} - -void InitializeForTesting() { - WTF::initializeThreading(); - WebCore::AtomicString::init(); -} - void EnableWebCoreNotImplementedLogging() { WebCore::LogNotYetImplemented.state = WTFLogChannelOn; } diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h index 579ca5d..efe0576 100644 --- a/webkit/glue/webkit_glue.h +++ b/webkit/glue/webkit_glue.h @@ -76,13 +76,6 @@ void SetShouldExposeGCController(bool enable); //----------------------------------------------------------------------------- // Functions implemented by WebKit, called by the embedder: -// Turns on "layout test" mode, which tries to mimic the font and widget sizing -// of the Mac DumpRenderTree. -void SetLayoutTestMode(bool enable); -bool IsLayoutTestMode(); - -void InitializeForTesting(); - // Turn on the logging for notImplemented() calls from WebCore. void EnableWebCoreNotImplementedLogging(); @@ -150,10 +143,6 @@ void SetMediaPlayerAvailable(bool value); // Returns true if media player is available and can be created. bool IsMediaPlayerAvailable(); -// This function is called to request a prefetch of the DNS resolution for the -// provided hostname. -void PrefetchDns(const std::string& hostname); - // This function is called to request a prefetch of the entire URL, loading it // into our cache for (expected) future needs. The given URL may NOT be in // canonical form and it will NOT be null-terminated; use the length instead. @@ -162,18 +151,6 @@ void PrecacheUrl(const char16* url, int url_length); // This function is called to add a line to the application's log file. void AppendToLog(const char* filename, int line, const char* message); -// Sets a cookie string for the given URL. The policy_url argument indicates -// the URL of the topmost frame, which may be useful for determining whether or -// not to allow this cookie setting. NOTE: the cookie string is a standard -// cookie string of the form "name=value; option1=x; option2=y" -void SetCookie(const GURL& url, const GURL& policy_url, - const std::string& cookie); - -// Returns all cookies in the form "a=1; b=2; c=3" for the given URL. NOTE: -// this string should not include any options that may have been specified when -// the cookie was set. Semicolons delimit individual cookies in this context. -std::string GetCookies(const GURL& url, const GURL& policy_url); - // Gather usage statistics from the in-memory cache and inform our host, if // applicable. void NotifyCacheStats(); diff --git a/webkit/glue/webkitclient_impl.cc b/webkit/glue/webkitclient_impl.cc index 901ebee..e726a6c 100644 --- a/webkit/glue/webkitclient_impl.cc +++ b/webkit/glue/webkitclient_impl.cc @@ -4,10 +4,43 @@ #include "webkit/glue/webkitclient_impl.h" +#include "base/message_loop.h" + namespace webkit_glue { +WebKitClientImpl::WebKitClientImpl() + : main_loop_(MessageLoop::current()), + shared_timer_func_(NULL) { +} + WebKit::WebClipboard* WebKitClientImpl::clipboard() { return &clipboard_; } +double WebKitClientImpl::currentTime() { + return base::Time::Now().ToDoubleT(); +} + +void WebKitClientImpl::setSharedTimerFiredFunction(void (*func)()) { + shared_timer_func_ = func; +} + +void WebKitClientImpl::setSharedTimerFireTime(double fire_time) { + int interval = static_cast<int>((fire_time - currentTime()) * 1000); + if (interval < 0) + interval = 0; + + shared_timer_.Stop(); + shared_timer_.Start(base::TimeDelta::FromMilliseconds(interval), this, + &WebKitClientImpl::DoTimeout); +} + +void WebKitClientImpl::stopSharedTimer() { + shared_timer_.Stop(); +} + +void WebKitClientImpl::callOnMainThread(void (*func)()) { + main_loop_->PostTask(FROM_HERE, NewRunnableFunction(func)); +} + } // namespace webkit_glue diff --git a/webkit/glue/webkitclient_impl.h b/webkit/glue/webkitclient_impl.h index 481a5fe..4980685 100644 --- a/webkit/glue/webkitclient_impl.h +++ b/webkit/glue/webkitclient_impl.h @@ -8,18 +8,43 @@ #include "WebKitClient.h" #include "base/scoped_ptr.h" +#include "base/timer.h" #include "webkit/glue/webclipboard_impl.h" +class MessageLoop; + namespace webkit_glue { class WebKitClientImpl : public WebKit::WebKitClient { public: + WebKitClientImpl(); + // WebKitClient methods: virtual WebKit::WebClipboard* clipboard(); virtual WebKit::WebMimeRegistry* mimeRegistry() = 0; + virtual void setCookies( + const WebKit::WebURL& url, const WebKit::WebURL& policy_url, + const WebKit::WebString&) = 0; + virtual WebKit::WebString cookies( + const WebKit::WebURL& url, const WebKit::WebURL& policy_url) = 0; + virtual void prefetchHostName(const WebKit::WebString&) = 0; + virtual WebKit::WebString defaultLocale() = 0; + virtual double currentTime(); + virtual void setSharedTimerFiredFunction(void (*func)()); + virtual void setSharedTimerFireTime(double fireTime); + virtual void stopSharedTimer(); + virtual void callOnMainThread(void (*func)()); private: + void DoTimeout() { + if (shared_timer_func_) + shared_timer_func_(); + } + WebClipboardImpl clipboard_; + MessageLoop* main_loop_; + base::OneShotTimer<WebKitClientImpl> shared_timer_; + void (*shared_timer_func_)(); }; } // namespace webkit_glue diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc index e128227..8449b89 100644 --- a/webkit/glue/webplugin_impl.cc +++ b/webkit/glue/webplugin_impl.cc @@ -41,6 +41,12 @@ MSVC_PUSH_WARNING_LEVEL(0); #include "ScrollView.h" #include "Widget.h" MSVC_POP_WARNING(); + +#include "WebKit.h" +#include "WebKitClient.h" +#include "WebString.h" +#include "WebURL.h" + #undef LOG #include "base/gfx/rect.h" @@ -541,11 +547,11 @@ NPObject* WebPluginImpl::GetPluginElement() { void WebPluginImpl::SetCookie(const GURL& url, const GURL& policy_url, const std::string& cookie) { - webkit_glue::SetCookie(url, policy_url, cookie); + WebKit::webKitClient()->setCookies(url, policy_url, UTF8ToUTF16(cookie)); } std::string WebPluginImpl::GetCookies(const GURL& url, const GURL& policy_url) { - return webkit_glue::GetCookies(url, policy_url); + return UTF16ToUTF8(WebKit::webKitClient()->cookies(url, policy_url)); } void WebPluginImpl::ShowModalHTMLDialog(const GURL& url, int width, int height, diff --git a/webkit/tools/test_shell/simple_resource_loader_bridge.cc b/webkit/tools/test_shell/simple_resource_loader_bridge.cc index 08bb34d..478313e 100644 --- a/webkit/tools/test_shell/simple_resource_loader_bridge.cc +++ b/webkit/tools/test_shell/simple_resource_loader_bridge.cc @@ -498,36 +498,6 @@ ResourceLoaderBridge* ResourceLoaderBridge::Create( headers, load_flags); } -void SetCookie(const GURL& url, const GURL& policy_url, - const std::string& cookie) { - // Proxy to IO thread to synchronize w/ network loading. - - if (!EnsureIOThread()) { - NOTREACHED(); - return; - } - - scoped_refptr<CookieSetter> cookie_setter = new CookieSetter(); - io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( - cookie_setter.get(), &CookieSetter::Set, url, cookie)); -} - -std::string GetCookies(const GURL& url, const GURL& policy_url) { - // Proxy to IO thread to synchronize w/ network loading - - if (!EnsureIOThread()) { - NOTREACHED(); - return std::string(); - } - - scoped_refptr<CookieGetter> getter = new CookieGetter(); - - io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( - getter.get(), &CookieGetter::Get, url)); - - return getter->GetResult(); -} - // Issue the proxy resolve request on the io thread, and wait // for the result. bool FindProxyForUrl(const GURL& url, std::string* proxy_list) { @@ -574,3 +544,33 @@ void SimpleResourceLoaderBridge::Shutdown() { } } +void SimpleResourceLoaderBridge::SetCookie( + const GURL& url, const GURL& policy_url, const std::string& cookie) { + // Proxy to IO thread to synchronize w/ network loading. + + if (!EnsureIOThread()) { + NOTREACHED(); + return; + } + + scoped_refptr<CookieSetter> cookie_setter = new CookieSetter(); + io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( + cookie_setter.get(), &CookieSetter::Set, url, cookie)); +} + +std::string SimpleResourceLoaderBridge::GetCookies( + const GURL& url, const GURL& policy_url) { + // Proxy to IO thread to synchronize w/ network loading + + if (!EnsureIOThread()) { + NOTREACHED(); + return std::string(); + } + + scoped_refptr<CookieGetter> getter = new CookieGetter(); + + io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( + getter.get(), &CookieGetter::Get, url)); + + return getter->GetResult(); +} diff --git a/webkit/tools/test_shell/simple_resource_loader_bridge.h b/webkit/tools/test_shell/simple_resource_loader_bridge.h index 89935b5..c14bfd4 100644 --- a/webkit/tools/test_shell/simple_resource_loader_bridge.h +++ b/webkit/tools/test_shell/simple_resource_loader_bridge.h @@ -5,8 +5,9 @@ #ifndef WEBKIT_TOOLS_TEST_SHELL_SIMPLE_RESOURCE_LOADER_BRIDGE_H__ #define WEBKIT_TOOLS_TEST_SHELL_SIMPLE_RESOURCE_LOADER_BRIDGE_H__ -#include "base/ref_counted.h" +#include <string> +class GURL; class URLRequestContext; class SimpleResourceLoaderBridge { @@ -25,6 +26,12 @@ class SimpleResourceLoaderBridge { // Call this function to shutdown the simple resource loader bridge. static void Shutdown(); + + // May only be called after Init. + static void SetCookie( + const GURL& url, const GURL& policy_url, const std::string& cookie); + static std::string GetCookies( + const GURL& url, const GURL& policy_url); }; #endif // WEBKIT_TOOLS_TEST_SHELL_SIMPLE_RESOURCE_LOADER_BRIDGE_H__ diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index 7cba160..c0cbd4d 100755 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -557,8 +557,6 @@ bool IsMediaPlayerAvailable() { return g_media_player_available; } -void PrefetchDns(const std::string& hostname) {} - void PrecacheUrl(const char16* url, int url_length) {} void AppendToLog(const char* file, int line, const char* msg) { diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h index 05003a0..75f7c4c 100644 --- a/webkit/tools/test_shell/test_shell_webkit_init.h +++ b/webkit/tools/test_shell/test_shell_webkit_init.h @@ -5,21 +5,23 @@ #ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_ #define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_ +#include "base/string_util.h" #include "webkit/glue/simple_webmimeregistry_impl.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webkitclient_impl.h" +#include "webkit/tools/test_shell/simple_resource_loader_bridge.h" #include "WebKit.h" +#include "WebString.h" +#include "WebURL.h" class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { public: TestShellWebKitInit(bool layout_test_mode) { WebKit::initialize(this); - - webkit_glue::InitializeForTesting(); - - // TODO(darin): This should eventually be a property of WebKitClientImpl. - webkit_glue::SetLayoutTestMode(layout_test_mode); + WebKit::setLayoutTestMode(layout_test_mode); + WebKit::registerURLSchemeAsLocal( + ASCIIToUTF16(webkit_glue::GetUIResourceProtocol())); } ~TestShellWebKitInit() { @@ -30,6 +32,24 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { return &mime_registry_; } + virtual void setCookies( + const WebKit::WebURL& url, const WebKit::WebURL& policy_url, + const WebKit::WebString& value) { + SimpleResourceLoaderBridge::SetCookie(url, policy_url, UTF16ToUTF8(value)); + } + + virtual WebKit::WebString cookies( + const WebKit::WebURL& url, const WebKit::WebURL& policy_url) { + return UTF8ToUTF16(SimpleResourceLoaderBridge::GetCookies(url, policy_url)); + } + + virtual void prefetchHostName(const WebKit::WebString&) { + } + + virtual WebKit::WebString defaultLocale() { + return ASCIIToUTF16("en-US"); + } + private: webkit_glue::SimpleWebMimeRegistryImpl mime_registry_; }; diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index 77dad42..9097dbd 100755 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -8,6 +8,8 @@ #include "webkit/tools/test_shell/test_webview_delegate.h" +#include "WebKit.h" + #include "base/file_util.h" #include "base/gfx/point.h" #include "base/gfx/native_widget_types.h" @@ -444,7 +446,7 @@ bool TestWebViewDelegate::RunJavaScriptPrompt(WebView* webview, void TestWebViewDelegate::SetStatusbarText(WebView* webview, const std::wstring& message) { - if (webkit_glue::IsLayoutTestMode() && + if (WebKit::layoutTestMode() && shell_->layout_test_controller()->ShouldDumpStatusCallbacks()) { // When running tests, write to stdout. printf("UI DELEGATE STATUS CALLBACK: setStatusText:%S\n", message.c_str()); @@ -453,7 +455,7 @@ void TestWebViewDelegate::SetStatusbarText(WebView* webview, void TestWebViewDelegate::StartDragging(WebView* webview, const WebDropData& drop_data) { - if (webkit_glue::IsLayoutTestMode()) { + if (WebKit::layoutTestMode()) { WebDropData mutable_drop_data = drop_data; if (shell_->layout_test_controller()->ShouldAddFileToPasteboard()) { // Add a file called DRTFakeFile to the drag&drop clipboard. diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index dc3915c..876ae94 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -4070,10 +4070,11 @@ '../third_party/WebKit/WebKit/chromium/public/WebString.h', '../third_party/WebKit/WebKit/chromium/public/WebURL.h', '../third_party/WebKit/WebKit/chromium/src/ChromiumBridge.cpp', + '../third_party/WebKit/WebKit/chromium/src/ChromiumCurrentTime.cpp', + '../third_party/WebKit/WebKit/chromium/src/ChromiumThreading.cpp', '../third_party/WebKit/WebKit/chromium/src/WebCString.cpp', '../third_party/WebKit/WebKit/chromium/src/WebImageSkia.cpp', '../third_party/WebKit/WebKit/chromium/src/WebKit.cpp', - '../third_party/WebKit/WebKit/chromium/src/WebKitPrivate.h', '../third_party/WebKit/WebKit/chromium/src/WebString.cpp', '../third_party/WebKit/WebKit/chromium/src/WebURL.cpp', ], @@ -4192,7 +4193,6 @@ 'glue/chrome_client_impl.cc', 'glue/chrome_client_impl.h', 'glue/chromium_bridge_impl.cc', - 'glue/chromium_threading.cc', 'glue/clipboard_conversion.cc', 'glue/clipboard_conversion.h', 'glue/console_message_level.h', diff --git a/webkit/webkit.xcodeproj/project.pbxproj b/webkit/webkit.xcodeproj/project.pbxproj index 3784613..9ba1d13 100644 --- a/webkit/webkit.xcodeproj/project.pbxproj +++ b/webkit/webkit.xcodeproj/project.pbxproj @@ -46,7 +46,6 @@ 41807C570F268375007BB4CC /* ByteArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41807C550F268375007BB4CC /* ByteArray.cpp */; }; 41D0113F0F438DA3004A662F /* V8HTMLPlugInElementCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41D0113E0F438DA3004A662F /* V8HTMLPlugInElementCustom.cpp */; }; 41DE6EBC0F3A328C0049BC24 /* MainThreadChromium.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41DE6EBB0F3A328C0049BC24 /* MainThreadChromium.cpp */; }; - 41DE6EBF0F3A32EE0049BC24 /* chromium_threading.cc in Sources */ = {isa = PBXBuildFile; fileRef = 41DE6EBE0F3A32EE0049BC24 /* chromium_threading.cc */; }; 41DE748C0F3CDBCB0049BC24 /* V8SVGElementInstanceCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41DE74890F3CDBCB0049BC24 /* V8SVGElementInstanceCustom.cpp */; }; 41DE748D0F3CDBCB0049BC24 /* V8SVGLengthCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41DE748A0F3CDBCB0049BC24 /* V8SVGLengthCustom.cpp */; }; 41DE748E0F3CDBCB0049BC24 /* V8SVGMatrixCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41DE748B0F3CDBCB0049BC24 /* V8SVGMatrixCustom.cpp */; }; @@ -1005,6 +1004,8 @@ 82F14D610ED230E700B36428 /* webcursor_mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 82F14D600ED230E700B36428 /* webcursor_mac.mm */; }; 89F4A0D50F200D5B000A326A /* V8CanvasPixelArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 89F4A0D30F200D59000A326A /* V8CanvasPixelArray.cpp */; }; 89F4A2090F2106EF000A326A /* V8CanvasPixelArrayCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 89F4A1FC0F2101F8000A326A /* V8CanvasPixelArrayCustom.cpp */; }; + 9310E2290F58C54B007D8D07 /* ChromiumCurrentTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9310E2270F58C54B007D8D07 /* ChromiumCurrentTime.cpp */; }; + 9310E22A0F58C54B007D8D07 /* ChromiumThreading.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9310E2280F58C54B007D8D07 /* ChromiumThreading.cpp */; }; 934CC0040EBFE0E000A658F2 /* chromium_bridge_impl.cc in Sources */ = {isa = PBXBuildFile; fileRef = 934CC0030EBFE0E000A658F2 /* chromium_bridge_impl.cc */; }; 937A16090F5332AB003E8D2D /* WebString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 937A15B50F53325D003E8D2D /* WebString.cpp */; }; 938180500EF3394A00993F02 /* back_forward_list_client_impl.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9381804E0EF3394A00993F02 /* back_forward_list_client_impl.cc */; }; @@ -1608,7 +1609,6 @@ 41D0113E0F438DA3004A662F /* V8HTMLPlugInElementCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = V8HTMLPlugInElementCustom.cpp; sourceTree = "<group>"; }; 41DE6EBB0F3A328C0049BC24 /* MainThreadChromium.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MainThreadChromium.cpp; sourceTree = "<group>"; }; 41DE6EBD0F3A329F0049BC24 /* ChromiumThreading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChromiumThreading.h; sourceTree = "<group>"; }; - 41DE6EBE0F3A32EE0049BC24 /* chromium_threading.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chromium_threading.cc; sourceTree = "<group>"; }; 41DE74870F3CDBCB0049BC24 /* V8CustomBinding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = V8CustomBinding.h; sourceTree = "<group>"; }; 41DE74880F3CDBCB0049BC24 /* V8CustomEventListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = V8CustomEventListener.h; sourceTree = "<group>"; }; 41DE74890F3CDBCB0049BC24 /* V8SVGElementInstanceCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = V8SVGElementInstanceCustom.cpp; sourceTree = "<group>"; }; @@ -4107,6 +4107,8 @@ 89F4A0D30F200D59000A326A /* V8CanvasPixelArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = V8CanvasPixelArray.cpp; sourceTree = "<group>"; }; 89F4A0D40F200D59000A326A /* V8CanvasPixelArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = V8CanvasPixelArray.h; sourceTree = "<group>"; }; 89F4A1FC0F2101F8000A326A /* V8CanvasPixelArrayCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = V8CanvasPixelArrayCustom.cpp; sourceTree = "<group>"; }; + 9310E2270F58C54B007D8D07 /* ChromiumCurrentTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ChromiumCurrentTime.cpp; path = ../third_party/WebKit/WebKit/chromium/src/ChromiumCurrentTime.cpp; sourceTree = SOURCE_ROOT; }; + 9310E2280F58C54B007D8D07 /* ChromiumThreading.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ChromiumThreading.cpp; path = ../third_party/WebKit/WebKit/chromium/src/ChromiumThreading.cpp; sourceTree = SOURCE_ROOT; }; 8CF41B1A2D4E8F64A2C5C3F6 /* Gears.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Gears.h; path = port/bindings/v8/extensions/Gears.h; sourceTree = SOURCE_ROOT; }; 934CC0030EBFE0E000A658F2 /* chromium_bridge_impl.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chromium_bridge_impl.cc; sourceTree = "<group>"; }; 934CC2270EDCC37600A658F2 /* RGBColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RGBColor.cpp; sourceTree = "<group>"; }; @@ -4140,7 +4142,6 @@ 9389E82A0F55C4550035E7D0 /* ChromiumBridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ChromiumBridge.cpp; path = ../third_party/WebKit/WebKit/chromium/src/ChromiumBridge.cpp; sourceTree = SOURCE_ROOT; }; 9389E82B0F55C4550035E7D0 /* WebCString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebCString.cpp; path = ../third_party/WebKit/WebKit/chromium/src/WebCString.cpp; sourceTree = SOURCE_ROOT; }; 9389E82C0F55C4550035E7D0 /* WebKit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebKit.cpp; path = ../third_party/WebKit/WebKit/chromium/src/WebKit.cpp; sourceTree = SOURCE_ROOT; }; - 9389E82D0F55C4550035E7D0 /* WebKitPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebKitPrivate.h; path = ../third_party/WebKit/WebKit/chromium/src/WebKitPrivate.h; sourceTree = SOURCE_ROOT; }; 9389E82E0F55C4550035E7D0 /* WebURL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebURL.cpp; path = ../third_party/WebKit/WebKit/chromium/src/WebURL.cpp; sourceTree = SOURCE_ROOT; }; 9389E8330F55C4810035E7D0 /* webclipboard_impl.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = webclipboard_impl.cc; sourceTree = "<group>"; }; 9389E8340F55C4810035E7D0 /* webclipboard_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = webclipboard_impl.h; sourceTree = "<group>"; }; @@ -7700,7 +7701,6 @@ 825404F10D92E3DA0006B936 /* chrome_client_impl.cc */, 825404F20D92E3DA0006B936 /* chrome_client_impl.h */, 934CC0030EBFE0E000A658F2 /* chromium_bridge_impl.cc */, - 41DE6EBE0F3A32EE0049BC24 /* chromium_threading.cc */, 535EE0BE0EC4D10E00939D54 /* clipboard_conversion.cc */, 535EE0BF0EC4D10E00939D54 /* clipboard_conversion.h */, 825404F30D92E3DA0006B936 /* context_menu_client_impl.cc */, @@ -7898,10 +7898,11 @@ 937A15B20F5331FB003E8D2D /* src */ = { isa = PBXGroup; children = ( + 9310E2270F58C54B007D8D07 /* ChromiumCurrentTime.cpp */, + 9310E2280F58C54B007D8D07 /* ChromiumThreading.cpp */, 9389E82A0F55C4550035E7D0 /* ChromiumBridge.cpp */, 9389E82B0F55C4550035E7D0 /* WebCString.cpp */, 9389E82C0F55C4550035E7D0 /* WebKit.cpp */, - 9389E82D0F55C4550035E7D0 /* WebKitPrivate.h */, 937A15B50F53325D003E8D2D /* WebString.cpp */, 9389E82E0F55C4550035E7D0 /* WebURL.cpp */, ); @@ -8816,6 +8817,8 @@ 9389E8300F55C4550035E7D0 /* WebCString.cpp in Sources */, 9389E8310F55C4550035E7D0 /* WebKit.cpp in Sources */, 9389E8320F55C4550035E7D0 /* WebURL.cpp in Sources */, + 9310E2290F58C54B007D8D07 /* ChromiumCurrentTime.cpp in Sources */, + 9310E22A0F58C54B007D8D07 /* ChromiumThreading.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -9749,7 +9752,6 @@ 938180500EF3394A00993F02 /* back_forward_list_client_impl.cc in Sources */, E456270D0E268F03005E4685 /* chrome_client_impl.cc in Sources */, 934CC0040EBFE0E000A658F2 /* chromium_bridge_impl.cc in Sources */, - 41DE6EBF0F3A32EE0049BC24 /* chromium_threading.cc in Sources */, 535EE0C00EC4D10E00939D54 /* clipboard_conversion.cc in Sources */, E45626FD0E268F03005E4685 /* context_menu_client_impl.cc in Sources */, E4506C170EF03AB5003BE099 /* cpp_binding_example.cc in Sources */, |