diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-30 18:45:47 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-30 18:45:47 +0000 |
commit | c7cfaa98f8f558ccb94ce8a0dbd7057d99be17d5 (patch) | |
tree | 63dec16696d767a035c80f55e053eb54785b82ac /webkit | |
parent | 20b204aefb86cd866e76fbcec0c9fa473be9d09c (diff) | |
download | chromium_src-c7cfaa98f8f558ccb94ce8a0dbd7057d99be17d5.zip chromium_src-c7cfaa98f8f558ccb94ce8a0dbd7057d99be17d5.tar.gz chromium_src-c7cfaa98f8f558ccb94ce8a0dbd7057d99be17d5.tar.bz2 |
Flesh out more of ChromiumBridge.cpp eliminating all but two methods on
TemporaryGlue.
Adds WebKitClient::userAgent() function to avoid a webkit_glue dependency.
R=dglazkov
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/350003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30609 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/api/public/WebKitClient.h | 7 | ||||
-rw-r--r-- | webkit/api/src/ChromeClientImpl.h | 2 | ||||
-rw-r--r-- | webkit/api/src/ChromiumBridge.cpp | 104 | ||||
-rw-r--r-- | webkit/api/src/FrameLoaderClientImpl.cpp | 9 | ||||
-rw-r--r-- | webkit/api/src/TemporaryGlue.h | 23 | ||||
-rw-r--r-- | webkit/api/src/WebMediaPlayerClientImpl.cpp | 20 | ||||
-rw-r--r-- | webkit/api/src/WebPluginContainerImpl.cpp | 9 | ||||
-rw-r--r-- | webkit/api/src/WebViewImpl.cpp | 2 | ||||
-rw-r--r-- | webkit/glue/webkitclient_impl.cc | 190 | ||||
-rw-r--r-- | webkit/glue/webkitclient_impl.h | 83 |
10 files changed, 183 insertions, 266 deletions
diff --git a/webkit/api/public/WebKitClient.h b/webkit/api/public/WebKitClient.h index 83ac70c..7c2634b 100644 --- a/webkit/api/public/WebKitClient.h +++ b/webkit/api/public/WebKitClient.h @@ -128,7 +128,7 @@ namespace WebKit { virtual bool isLinkVisited(unsigned long long linkHash) = 0; - // HTML5 DB ------------------------------------------------------------ + // Database ------------------------------------------------------------ #ifdef WIN32 typedef HANDLE FileHandle; @@ -150,6 +150,7 @@ namespace WebKit { // Returns the size of the given database file virtual long long databaseGetFileSize(const WebString& fileName) = 0; + // Keygen -------------------------------------------------------------- // Handle the <keygen> tag for generating client certificates @@ -160,6 +161,7 @@ namespace WebKit { const WebKit::WebString& challenge, const WebKit::WebURL& url) = 0; + // Message Ports ------------------------------------------------------- // Creates a Message Port Channel. This can be called on any thread. @@ -184,6 +186,9 @@ namespace WebKit { // Returns a new WebSocketStreamHandle instance. virtual WebSocketStreamHandle* createSocketStreamHandle() = 0; + // Returns the User-Agent string that should be used for the given URL. + virtual WebString userAgent(const WebURL&) = 0; + // Plugins ------------------------------------------------------------- diff --git a/webkit/api/src/ChromeClientImpl.h b/webkit/api/src/ChromeClientImpl.h index 9a1e443..f6407be 100644 --- a/webkit/api/src/ChromeClientImpl.h +++ b/webkit/api/src/ChromeClientImpl.h @@ -51,7 +51,7 @@ public: explicit ChromeClientImpl(WebViewImpl* webView); virtual ~ChromeClientImpl(); - WebViewImpl* webview() const { return m_webView; } + WebViewImpl* webView() const { return m_webView; } // ChromeClient methods: virtual void chromeDestroyed(); diff --git a/webkit/api/src/ChromiumBridge.cpp b/webkit/api/src/ChromiumBridge.cpp index 946e252..b0d5b0b 100644 --- a/webkit/api/src/ChromiumBridge.cpp +++ b/webkit/api/src/ChromiumBridge.cpp @@ -33,20 +33,26 @@ #include <googleurl/src/url_util.h> +#include "ChromeClientImpl.h" #include "WebClipboard.h" #include "WebCookie.h" +#include "WebCursorInfo.h" #include "WebData.h" +#include "WebFrameClient.h" +#include "WebFrameImpl.h" #include "WebImage.h" #include "WebKit.h" #include "WebKitClient.h" #include "WebMimeRegistry.h" #include "WebPluginContainerImpl.h" #include "WebPluginListBuilderImpl.h" +#include "WebScreenInfo.h" #include "WebString.h" #include "WebVector.h" #include "WebURL.h" -#include "Worker.h" -#include "WorkerContextProxy.h" +#include "WebViewClient.h" +#include "WebViewImpl.h" +#include "WebWorkerClientImpl.h" #if PLATFORM(WIN_OS) #include "WebRect.h" @@ -67,9 +73,12 @@ #include "Cookie.h" #include "GraphicsContext.h" #include "KURL.h" +#include "FrameView.h" #include "NotImplemented.h" #include "PlatformContextSkia.h" #include "PluginData.h" +#include "Worker.h" +#include "WorkerContextProxy.h" #include <wtf/Assertions.h> // We are part of the WebKit implementation. @@ -77,6 +86,31 @@ using namespace WebKit; namespace WebCore { +static ChromeClientImpl* toChromeClientImpl(Widget* widget) +{ + FrameView* view; + if (widget->isFrameView()) + view = static_cast<FrameView*>(widget); + else if (widget->parent() && widget->parent()->isFrameView()) + view = static_cast<FrameView*>(widget->parent()); + else + return 0; + + Page* page = view->frame() ? view->frame()->page() : 0; + if (!page) + return 0; + + return static_cast<ChromeClientImpl*>(page->chrome()->client()); +} + +static WebWidgetClient* toWebWidgetClient(Widget* widget) +{ + ChromeClientImpl* chromeClientImpl = toChromeClientImpl(widget); + if (!chromeClientImpl || !chromeClientImpl->webView()) + return 0; + return chromeClientImpl->webView()->client(); +} + // Clipboard ------------------------------------------------------------------ bool ChromiumBridge::clipboardIsFormatAvailable( @@ -365,7 +399,7 @@ bool ChromiumBridge::plugins(bool refresh, Vector<PluginInfo*>* results) NPObject* ChromiumBridge::pluginScriptableObject(Widget* widget) { if (!widget) - return NULL; + return 0; ASSERT(!widget->isFrameView()); @@ -520,18 +554,17 @@ void ChromiumBridge::traceEventEnd(const char* name, void* id, const char* extra // Visited Links -------------------------------------------------------------- -WebCore::LinkHash ChromiumBridge::visitedLinkHash(const UChar* url, - unsigned length) +LinkHash ChromiumBridge::visitedLinkHash(const UChar* url, unsigned length) { url_canon::RawCanonOutput<2048> buffer; url_parse::Parsed parsed; - if (!url_util::Canonicalize(url, length, NULL, &buffer, &parsed)) + if (!url_util::Canonicalize(url, length, 0, &buffer, &parsed)) return 0; // Invalid URLs are unvisited. return webKitClient()->visitedLinkHash(buffer.data(), buffer.length()); } -WebCore::LinkHash ChromiumBridge::visitedLinkHash(const WebCore::KURL& base, - const WebCore::AtomicString& attributeURL) +LinkHash ChromiumBridge::visitedLinkHash(const KURL& base, + const AtomicString& attributeURL) { // Resolve the relative URL using googleurl and pass the absolute URL up to // the embedder. We could create a GURL object from the base and resolve @@ -541,7 +574,7 @@ WebCore::LinkHash ChromiumBridge::visitedLinkHash(const WebCore::KURL& base, url_parse::Parsed parsed; #if USE(GOOGLEURL) - const WebCore::CString& cstr = base.utf8String(); + const CString& cstr = base.utf8String(); const char* data = cstr.data(); int length = cstr.length(); const url_parse::Parsed& srcParsed = base.parsed(); @@ -550,21 +583,21 @@ WebCore::LinkHash ChromiumBridge::visitedLinkHash(const WebCore::KURL& base, // below. url_canon::RawCanonOutput<2048> srcCanon; url_parse::Parsed srcParsed; - WebCore::String str = base.string(); - if (!url_util::Canonicalize(str.characters(), str.length(), NULL, &srcCanon, &srcParsed)) + String str = base.string(); + if (!url_util::Canonicalize(str.characters(), str.length(), 0, &srcCanon, &srcParsed)) return 0; const char* data = srcCanon.data(); int length = srcCanon.length(); #endif if (!url_util::ResolveRelative(data, length, srcParsed, attributeURL.characters(), - attributeURL.length(), NULL, &buffer, &parsed)) + attributeURL.length(), 0, &buffer, &parsed)) return 0; // Invalid resolved URL. return webKitClient()->visitedLinkHash(buffer.data(), buffer.length()); } -bool ChromiumBridge::isLinkVisited(WebCore::LinkHash visitedLinkHash) +bool ChromiumBridge::isLinkVisited(LinkHash visitedLinkHash) { return webKitClient()->isLinkVisited(visitedLinkHash); } @@ -578,34 +611,55 @@ String ChromiumBridge::uiResourceProtocol() return webKitClient()->uiResourceProtocol(); } -void ChromiumBridge::notifyJSOutOfMemory(WebCore::Frame* frame) +void ChromiumBridge::notifyJSOutOfMemory(Frame* frame) { - return webKitClient()->notifyJSOutOfMemory(frame); + if (!frame) + return; + + WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame); + if (!webFrame->client()) + return; + webFrame->client()->didExhaustMemoryAvailableForScript(webFrame); } int ChromiumBridge::screenDepth(Widget* widget) { - return webKitClient()->screenDepth(widget); + WebWidgetClient* client = toWebWidgetClient(widget); + if (!client) + return 0; + return client->screenInfo().depth; } int ChromiumBridge::screenDepthPerComponent(Widget* widget) { - return webKitClient()->screenDepthPerComponent(widget); + WebWidgetClient* client = toWebWidgetClient(widget); + if (!client) + return 0; + return client->screenInfo().depthPerComponent; } bool ChromiumBridge::screenIsMonochrome(Widget* widget) { - return webKitClient()->screenIsMonochrome(widget); + WebWidgetClient* client = toWebWidgetClient(widget); + if (!client) + return 0; + return client->screenInfo().isMonochrome; } IntRect ChromiumBridge::screenRect(Widget* widget) { - return webKitClient()->screenRect(widget); + WebWidgetClient* client = toWebWidgetClient(widget); + if (!client) + return IntRect(); + return client->screenInfo().rect; } IntRect ChromiumBridge::screenAvailableRect(Widget* widget) { - return webKitClient()->screenAvailableRect(widget); + WebWidgetClient* client = toWebWidgetClient(widget); + if (!client) + return IntRect(); + return client->screenInfo().availableRect; } bool ChromiumBridge::popupsAllowed(NPP npp) @@ -615,17 +669,21 @@ bool ChromiumBridge::popupsAllowed(NPP npp) void ChromiumBridge::widgetSetCursor(Widget* widget, const Cursor& cursor) { - return webKitClient()->widgetSetCursor(widget, cursor); + ChromeClientImpl* client = toChromeClientImpl(widget); + if (client) + client->setCursor(WebCursorInfo(cursor)); } void ChromiumBridge::widgetSetFocus(Widget* widget) { - return webKitClient()->widgetSetFocus(widget); + ChromeClientImpl* client = toChromeClientImpl(widget); + if (client) + client->focus(); } WorkerContextProxy* WorkerContextProxy::create(Worker* worker) { - return webKitClient()->createWorkerContextProxy(worker); + return WebWorkerClientImpl::createWorkerContextProxy(worker); } } // namespace WebCore diff --git a/webkit/api/src/FrameLoaderClientImpl.cpp b/webkit/api/src/FrameLoaderClientImpl.cpp index 3b7a906..b7b310e 100644 --- a/webkit/api/src/FrameLoaderClientImpl.cpp +++ b/webkit/api/src/FrameLoaderClientImpl.cpp @@ -51,6 +51,8 @@ #include "WebForm.h" #include "WebFrameClient.h" #include "WebFrameImpl.h" +#include "WebKit.h" +#include "WebKitClient.h" #include "WebNode.h" #include "WebPlugin.h" #include "WebPluginParams.h" @@ -68,11 +70,8 @@ #include "WrappedResourceResponse.h" // FIXME: remove these -#include "googleurl/src/gurl.h" #include "net/base/mime_util.h" -#include "webkit/glue/glue_util.h" #include "webkit/glue/webdevtoolsagent_impl.h" -#include "webkit/glue/webkit_glue.h" using namespace WebCore; @@ -1207,9 +1206,7 @@ void FrameLoaderClientImpl::setTitle(const String& title, const KURL& url) String FrameLoaderClientImpl::userAgent(const KURL& url) { - // FIXME: Convert this to a WebKitClient callback. - return webkit_glue::StdStringToString( - webkit_glue::GetUserAgent(webkit_glue::KURLToGURL(url))); + return webKitClient()->userAgent(url); } void FrameLoaderClientImpl::savePlatformDataToCachedFrame(CachedFrame*) diff --git a/webkit/api/src/TemporaryGlue.h b/webkit/api/src/TemporaryGlue.h index b52f384..6352943 100644 --- a/webkit/api/src/TemporaryGlue.h +++ b/webkit/api/src/TemporaryGlue.h @@ -40,35 +40,14 @@ typedef struct _NPP NPP_t; typedef NPP_t* NPP; namespace WebCore { - class Cursor; - class Frame; - class IntRect; class String; - class Widget; - class Worker; - class WorkerContextProxy; -} // namespace WebCore +} namespace WebKit { - class WebMediaPlayer; - class WebMediaPlayerClient; - struct WebCursorInfo; - class TemporaryGlue { public: - virtual WebMediaPlayer* createWebMediaPlayer(WebMediaPlayerClient*, WebCore::Frame*) = 0; - virtual void setCursorForPlugin(const WebCursorInfo&, WebCore::Frame*) = 0; virtual WebCore::String uiResourceProtocol() = 0; - virtual void notifyJSOutOfMemory(WebCore::Frame*) = 0; - virtual int screenDepth(WebCore::Widget*) = 0; - virtual int screenDepthPerComponent(WebCore::Widget*) = 0; - virtual bool screenIsMonochrome(WebCore::Widget*) = 0; - virtual WebCore::IntRect screenRect(WebCore::Widget*) = 0; - virtual WebCore::IntRect screenAvailableRect(WebCore::Widget*) = 0; virtual bool popupsAllowed(NPP) = 0; - virtual void widgetSetCursor(WebCore::Widget*, const WebCore::Cursor&) = 0; - virtual void widgetSetFocus(WebCore::Widget*) = 0; - virtual WebCore::WorkerContextProxy* createWorkerContextProxy(WebCore::Worker* worker) = 0; }; } // namespace WebKit diff --git a/webkit/api/src/WebMediaPlayerClientImpl.cpp b/webkit/api/src/WebMediaPlayerClientImpl.cpp index f0076e8..27de367 100644 --- a/webkit/api/src/WebMediaPlayerClientImpl.cpp +++ b/webkit/api/src/WebMediaPlayerClientImpl.cpp @@ -7,9 +7,10 @@ #if ENABLE(VIDEO) -#include "TimeRanges.h" #include "WebCanvas.h" #include "WebCString.h" +#include "WebFrameClient.h" +#include "WebFrameImpl.h" #include "WebKit.h" #include "WebKitClient.h" #include "WebMediaPlayer.h" @@ -27,6 +28,7 @@ #include "KURL.h" #include "MediaPlayer.h" #include "NotImplemented.h" +#include "TimeRanges.h" #include <wtf/Assertions.h> #if WEBKIT_USING_SKIA @@ -37,6 +39,15 @@ using namespace WebCore; namespace WebKit { +static WebMediaPlayer* createWebMediaPlayer( + WebMediaPlayerClient* client, Frame* frame) +{ + WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame); + if (!webFrame->client()) + return 0; + return webFrame->client()->createMediaPlayer(webFrame, client); +} + bool WebMediaPlayerClientImpl::m_isEnabled = false; bool WebMediaPlayerClientImpl::isEnabled() @@ -58,7 +69,6 @@ void WebMediaPlayerClientImpl::registerSelf(MediaEngineRegistrar registrar) } } - // WebMediaPlayerClient -------------------------------------------------------- void WebMediaPlayerClientImpl::networkStateChanged() @@ -121,7 +131,7 @@ void WebMediaPlayerClientImpl::load(const String& url) { Frame* frame = static_cast<HTMLMediaElement*>( m_mediaPlayer->mediaPlayerClient())->document()->frame(); - m_webMediaPlayer.set(webKitClient()->createWebMediaPlayer(this, frame)); + m_webMediaPlayer.set(createWebMediaPlayer(this, frame)); if (m_webMediaPlayer.get()) m_webMediaPlayer->load(KURL(ParsedURLString, url)); } @@ -258,13 +268,13 @@ float WebMediaPlayerClientImpl::maxTimeSeekable() const return 0.0f; } -WTF::PassRefPtr<WebCore::TimeRanges> WebMediaPlayerClientImpl::buffered() const +PassRefPtr<TimeRanges> WebMediaPlayerClientImpl::buffered() const { if (m_webMediaPlayer.get()) { const WebTimeRanges& webRanges = m_webMediaPlayer->buffered(); // FIXME: Save the time ranges in a member variable and update it when needed. - WTF::RefPtr<TimeRanges> ranges = TimeRanges::create(); + RefPtr<TimeRanges> ranges = TimeRanges::create(); for (size_t i = 0; i < webRanges.size(); ++i) ranges->add(webRanges[i].start, webRanges[i].end); return ranges.release(); diff --git a/webkit/api/src/WebPluginContainerImpl.cpp b/webkit/api/src/WebPluginContainerImpl.cpp index 5918529..7e37ef0 100644 --- a/webkit/api/src/WebPluginContainerImpl.cpp +++ b/webkit/api/src/WebPluginContainerImpl.cpp @@ -31,12 +31,12 @@ #include "config.h" #include "WebPluginContainerImpl.h" +#include "ChromeClientImpl.h" #include "WebCursorInfo.h" #include "WebDataSourceImpl.h" #include "WebInputEvent.h" #include "WebInputEventConversion.h" #include "WebKit.h" -#include "WebKitClient.h" #include "WebPlugin.h" #include "WebRect.h" #include "WebURLError.h" @@ -373,7 +373,12 @@ void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) // A windowless plugin can change the cursor in response to a mouse move // event. We need to reflect the changed cursor in the frame view as the // mouse is moved in the boundaries of the windowless plugin. - webKitClient()->setCursorForPlugin(cursorInfo, parentView->frame()); + Page* page = parentView->frame()->page(); + if (!page) + return; + ChromeClientImpl* chromeClient = + static_cast<ChromeClientImpl*>(page->chrome()->client()); + chromeClient->setCursorForPlugin(cursorInfo); } void WebPluginContainerImpl::handleKeyboardEvent(KeyboardEvent* event) diff --git a/webkit/api/src/WebViewImpl.cpp b/webkit/api/src/WebViewImpl.cpp index 3aa2279..4b2eb62 100644 --- a/webkit/api/src/WebViewImpl.cpp +++ b/webkit/api/src/WebViewImpl.cpp @@ -758,7 +758,7 @@ WebViewImpl* WebViewImpl::fromPage(Page* page) if (!page) return 0; - return static_cast<ChromeClientImpl*>(page->chrome()->client())->webview(); + return static_cast<ChromeClientImpl*>(page->chrome()->client())->webView(); } // WebWidget ------------------------------------------------------------------ diff --git a/webkit/glue/webkitclient_impl.cc b/webkit/glue/webkitclient_impl.cc index d29f73d..07cacbc 100644 --- a/webkit/glue/webkitclient_impl.cc +++ b/webkit/glue/webkitclient_impl.cc @@ -23,7 +23,6 @@ #include "grit/webkit_strings.h" #include "net/base/net_util.h" #include "webkit/api/public/WebCookie.h" -#include "webkit/api/public/WebCursorInfo.h" #include "webkit/api/public/WebData.h" #include "webkit/api/public/WebFrameClient.h" #include "webkit/api/public/WebPluginListBuilder.h" @@ -31,11 +30,6 @@ #include "webkit/api/public/WebString.h" #include "webkit/api/public/WebVector.h" #include "webkit/api/public/WebURL.h" -#include "webkit/api/public/WebViewClient.h" -#include "webkit/api/src/ChromeClientImpl.h" -#include "webkit/api/src/WebFrameImpl.h" -#include "webkit/api/src/WebViewImpl.h" -#include "webkit/api/src/WebWorkerClientImpl.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/plugins/plugin_instance.h" #include "webkit/glue/webkit_glue.h" @@ -43,13 +37,10 @@ #include "webkit/glue/websocketstreamhandle_impl.h" #include "webkit/glue/weburlloader_impl.h" -using WebKit::ChromeClientImpl; using WebKit::WebApplicationCacheHost; using WebKit::WebApplicationCacheHostClient; using WebKit::WebCookie; -using WebKit::WebCursorInfo; using WebKit::WebData; -using WebKit::WebFrameImpl; using WebKit::WebLocalizedString; using WebKit::WebPluginListBuilder; using WebKit::WebStorageNamespace; @@ -59,37 +50,6 @@ using WebKit::WebThemeEngine; using WebKit::WebURL; using WebKit::WebURLLoader; using WebKit::WebVector; -using WebKit::WebViewImpl; -using WebKit::WebWidgetClient; -using WebKit::WebWorkerClientImpl; - -namespace { - -ChromeClientImpl* ToChromeClient(WebCore::Widget* widget) { - WebCore::FrameView* view; - if (widget->isFrameView()) { - view = static_cast<WebCore::FrameView*>(widget); - } else if (widget->parent() && widget->parent()->isFrameView()) { - view = static_cast<WebCore::FrameView*>(widget->parent()); - } else { - return NULL; - } - - WebCore::Page* page = view->frame() ? view->frame()->page() : NULL; - if (!page) - return NULL; - - return static_cast<ChromeClientImpl*>(page->chrome()->client()); -} - -WebWidgetClient* ToWebWidgetClient(WebCore::Widget* widget) { - ChromeClientImpl* chrome_client = ToChromeClient(widget); - if (!chrome_client || !chrome_client->webview()) - return NULL; - return chrome_client->webview()->client(); -} - -} namespace webkit_glue { @@ -183,6 +143,10 @@ WebSocketStreamHandle* WebKitClientImpl::createSocketStreamHandle() { return new WebSocketStreamHandleImpl(); } +WebString WebKitClientImpl::userAgent(const WebURL& url) { + return WebString::fromUTF8(webkit_glue::GetUserAgent(url)); +} + void WebKitClientImpl::getPluginList(bool refresh, WebPluginListBuilder* builder) { std::vector<WebPluginInfo> plugins; @@ -326,6 +290,17 @@ void WebKitClientImpl::callOnMainThread(void (*func)()) { main_loop_->PostTask(FROM_HERE, NewRunnableFunction(func)); } +WebStorageNamespace* WebKitClientImpl::createLocalStorageNamespace( + const WebString& path, unsigned quota) { + NOTREACHED(); + return 0; +} + +WebStorageNamespace* WebKitClientImpl::createSessionStorageNamespace() { + NOTREACHED(); + return 0; +} + void WebKitClientImpl::dispatchStorageEvent(const WebString& key, const WebString& oldValue, const WebString& newValue, const WebString& origin, bool isLocalStorage) { @@ -412,45 +387,30 @@ bool WebKitClientImpl::makeAllDirectories( return file_util::CreateDirectory(FilePath(file_path)); } -//-------------------------------------------------------------------------- - -// These are temporary methods that the WebKit layer can use to call to the -// Glue layer. Once the Glue layer moves entirely into the WebKit layer, these -// methods will be deleted. - -WebKit::WebMediaPlayer* WebKitClientImpl::createWebMediaPlayer( - WebKit::WebMediaPlayerClient* client, WebCore::Frame* frame) { - WebFrameImpl* webframe = WebFrameImpl::fromFrame(frame); - if (!webframe->client()) - return NULL; - - return webframe->client()->createMediaPlayer(webframe, client); +WebKit::WebString WebKitClientImpl::getAbsolutePath( + const WebKit::WebString& path) { + FilePath file_path(webkit_glue::WebStringToFilePathString(path)); + file_util::AbsolutePath(&file_path); + return webkit_glue::FilePathStringToWebString(file_path.value()); } -void WebKitClientImpl::setCursorForPlugin( - const WebKit::WebCursorInfo& cursor_info, WebCore::Frame* frame) { - WebCore::Page* page = frame->page(); - if (!page) - return; - - ChromeClientImpl* chrome_client = - static_cast<ChromeClientImpl*>(page->chrome()->client()); +bool WebKitClientImpl::isDirectory(const WebKit::WebString& path) { + FilePath file_path(webkit_glue::WebStringToFilePathString(path)); + return file_util::DirectoryExists(file_path); +} - // A windowless plugin can change the cursor in response to the WM_MOUSEMOVE - // event. We need to reflect the changed cursor in the frame view as the - // mouse is moved in the boundaries of the windowless plugin. - chrome_client->setCursorForPlugin(cursor_info); +WebKit::WebURL WebKitClientImpl::filePathToURL(const WebKit::WebString& path) { + FilePath file_path(webkit_glue::WebStringToFilePathString(path)); + GURL file_url = net::FilePathToFileURL(file_path); + return webkit_glue::KURLToWebURL(webkit_glue::GURLToKURL(file_url)); } -void WebKitClientImpl::notifyJSOutOfMemory(WebCore::Frame* frame) { - if (!frame) - return; +//-------------------------------------------------------------------------- +// BEGIN(TemporaryGlue) - WebFrameImpl* webframe = WebFrameImpl::fromFrame(frame); - if (!webframe->client()) - return; - webframe->client()->didExhaustMemoryAvailableForScript(webframe); -} +// These are temporary methods that the WebKit layer can use to call to the +// Glue layer. Once the Glue layer moves entirely into the WebKit layer, these +// methods will be deleted. bool WebKitClientImpl::popupsAllowed(NPP npp) { bool popups_allowed = false; @@ -467,87 +427,7 @@ WebCore::String WebKitClientImpl::uiResourceProtocol() { return StdStringToString(webkit_glue::GetUIResourceProtocol()); } -int WebKitClientImpl::screenDepth(WebCore::Widget* widget) { - WebKit::WebWidgetClient* client = ToWebWidgetClient(widget); - if (!client) - return 0; - return client->screenInfo().depth; -} - -int WebKitClientImpl::screenDepthPerComponent(WebCore::Widget* widget) { - WebKit::WebWidgetClient* client = ToWebWidgetClient(widget); - if (!client) - return 0; - return client->screenInfo().depthPerComponent; -} - -bool WebKitClientImpl::screenIsMonochrome(WebCore::Widget* widget) { - WebKit::WebWidgetClient* client = ToWebWidgetClient(widget); - if (!client) - return false; - return client->screenInfo().isMonochrome; -} - -WebCore::IntRect WebKitClientImpl::screenRect(WebCore::Widget* widget) { - WebKit::WebWidgetClient* client = ToWebWidgetClient(widget); - if (!client) - return WebCore::IntRect(); - return ToIntRect(client->screenInfo().rect); -} - -WebCore::IntRect WebKitClientImpl::screenAvailableRect( - WebCore::Widget* widget) { - WebKit::WebWidgetClient* client = ToWebWidgetClient(widget); - if (!client) - return WebCore::IntRect(); - return ToIntRect(client->screenInfo().availableRect); -} - -void WebKitClientImpl::widgetSetCursor(WebCore::Widget* widget, - const WebCore::Cursor& cursor) { - ChromeClientImpl* chrome_client = ToChromeClient(widget); - if (chrome_client) - chrome_client->setCursor(CursorToWebCursorInfo(cursor)); -} - -void WebKitClientImpl::widgetSetFocus(WebCore::Widget* widget) { - ChromeClientImpl* chrome_client = ToChromeClient(widget); - if (chrome_client) - chrome_client->focus(); -} - -WebCore::WorkerContextProxy* WebKitClientImpl::createWorkerContextProxy( - WebCore::Worker* worker) { - return WebWorkerClientImpl::createWorkerContextProxy(worker); -} - -WebStorageNamespace* WebKitClientImpl::createLocalStorageNamespace( - const WebString& path, unsigned quota) { - NOTREACHED(); - return 0; -} - -WebStorageNamespace* WebKitClientImpl::createSessionStorageNamespace() { - NOTREACHED(); - return 0; -} - -WebKit::WebString WebKitClientImpl::getAbsolutePath( - const WebKit::WebString& path) { - FilePath file_path(webkit_glue::WebStringToFilePathString(path)); - file_util::AbsolutePath(&file_path); - return webkit_glue::FilePathStringToWebString(file_path.value()); -} - -bool WebKitClientImpl::isDirectory(const WebKit::WebString& path) { - FilePath file_path(webkit_glue::WebStringToFilePathString(path)); - return file_util::DirectoryExists(file_path); -} - -WebKit::WebURL WebKitClientImpl::filePathToURL(const WebKit::WebString& path) { - FilePath file_path(webkit_glue::WebStringToFilePathString(path)); - GURL file_url = net::FilePathToFileURL(file_path); - return webkit_glue::KURLToWebURL(webkit_glue::GURLToKURL(file_url)); -} +// END(TemporaryGlue) +//-------------------------------------------------------------------------- } // namespace webkit_glue diff --git a/webkit/glue/webkitclient_impl.h b/webkit/glue/webkitclient_impl.h index 284d6d3..f37e7ca 100644 --- a/webkit/glue/webkitclient_impl.h +++ b/webkit/glue/webkitclient_impl.h @@ -22,6 +22,37 @@ class WebKitClientImpl : public WebKit::WebKitClient { // WebKitClient methods (partial implementation): virtual WebKit::WebThemeEngine* themeEngine(); + virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost( + WebKit::WebApplicationCacheHostClient*); + virtual WebKit::WebStorageNamespace* createLocalStorageNamespace( + const WebKit::WebString& path, unsigned quota); + virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(); + virtual void dispatchStorageEvent(const WebKit::WebString& key, + const WebKit::WebString& oldValue, const WebKit::WebString& newValue, + const WebKit::WebString& origin, bool isLocalStorage); + virtual bool fileExists(const WebKit::WebString& path); + virtual bool deleteFile(const WebKit::WebString& path); + virtual bool deleteEmptyDirectory(const WebKit::WebString& path); + virtual bool getFileSize(const WebKit::WebString& path, long long& result); + virtual bool getFileModificationTime( + const WebKit::WebString& path, time_t& result); + virtual WebKit::WebString directoryName(const WebKit::WebString& path); + virtual WebKit::WebString pathByAppendingComponent( + const WebKit::WebString& path, const WebKit::WebString& component); + virtual bool makeAllDirectories(const WebKit::WebString& path); + virtual WebKit::WebString getAbsolutePath(const WebKit::WebString& path); + virtual bool isDirectory(const WebKit::WebString& path); + virtual WebKit::WebURL filePathToURL(const WebKit::WebString& path); + virtual base::PlatformFile databaseOpenFile( + const WebKit::WebString& file_name, int desired_flags, + base::PlatformFile* dir_handle); + virtual int databaseDeleteFile(const WebKit::WebString& file_name, + bool sync_dir); + virtual long databaseGetFileAttributes(const WebKit::WebString& file_name); + virtual long long databaseGetFileSize(const WebKit::WebString& file_name); + virtual WebKit::WebString signedPublicKeyAndChallengeString( + unsigned key_size_index, const WebKit::WebString& challenge, + const WebKit::WebURL& url); virtual bool rawCookies(const WebKit::WebURL& url, const WebKit::WebURL& policy_url, WebKit::WebVector<WebKit::WebCookie>*); @@ -29,6 +60,7 @@ class WebKitClientImpl : public WebKit::WebKitClient { const WebKit::WebString& cookie_name); virtual WebKit::WebURLLoader* createURLLoader(); virtual WebKit::WebSocketStreamHandle* createSocketStreamHandle(); + virtual WebKit::WebString userAgent(const WebKit::WebURL& url); virtual void getPluginList(bool refresh, WebKit::WebPluginListBuilder*); virtual void decrementStatsCounter(const char* name); virtual void incrementStatsCounter(const char* name); @@ -39,67 +71,18 @@ class WebKitClientImpl : public WebKit::WebKitClient { WebKit::WebLocalizedString::Name name); virtual WebKit::WebString queryLocalizedString( WebKit::WebLocalizedString::Name name, int numeric_value); + virtual void suddenTerminationChanged(bool enabled) { } virtual double currentTime(); virtual void setSharedTimerFiredFunction(void (*func)()); virtual void setSharedTimerFireTime(double fireTime); virtual void stopSharedTimer(); virtual void callOnMainThread(void (*func)()); - virtual void suddenTerminationChanged(bool enabled) { } - virtual void dispatchStorageEvent(const WebKit::WebString& key, - const WebKit::WebString& oldValue, const WebKit::WebString& newValue, - const WebKit::WebString& origin, bool isLocalStorage); - - virtual base::PlatformFile databaseOpenFile( - const WebKit::WebString& file_name, int desired_flags, - base::PlatformFile* dir_handle); - virtual int databaseDeleteFile(const WebKit::WebString& file_name, - bool sync_dir); - virtual long databaseGetFileAttributes(const WebKit::WebString& file_name); - virtual long long databaseGetFileSize(const WebKit::WebString& file_name); - - virtual WebKit::WebString signedPublicKeyAndChallengeString( - unsigned key_size_index, const WebKit::WebString& challenge, - const WebKit::WebURL& url); - - virtual bool fileExists(const WebKit::WebString& path); - virtual bool deleteFile(const WebKit::WebString& path); - virtual bool deleteEmptyDirectory(const WebKit::WebString& path); - virtual bool getFileSize(const WebKit::WebString& path, long long& result); - virtual bool getFileModificationTime(const WebKit::WebString& path, - time_t& result); - virtual WebKit::WebString directoryName(const WebKit::WebString& path); - virtual WebKit::WebString pathByAppendingComponent( - const WebKit::WebString& path, const WebKit::WebString& component); - virtual bool makeAllDirectories(const WebKit::WebString& path); - virtual WebKit::WebString getAbsolutePath(const WebKit::WebString& path); - virtual bool isDirectory(const WebKit::WebString& path); - virtual WebKit::WebURL filePathToURL(const WebKit::WebString& path); - - virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost( - WebKit::WebApplicationCacheHostClient*); // These are temporary methods that the WebKit layer can use to call to the // Glue layer. Once the Glue layer moves entirely into the WebKit layer, // these methods will be deleted. - virtual WebKit::WebMediaPlayer* createWebMediaPlayer( - WebKit::WebMediaPlayerClient*, WebCore::Frame*); - virtual void setCursorForPlugin( - const WebKit::WebCursorInfo&, WebCore::Frame*); virtual WebCore::String uiResourceProtocol(); - virtual void notifyJSOutOfMemory(WebCore::Frame*); - virtual int screenDepth(WebCore::Widget*); - virtual int screenDepthPerComponent(WebCore::Widget*); - virtual bool screenIsMonochrome(WebCore::Widget*); - virtual WebCore::IntRect screenRect(WebCore::Widget*); - virtual WebCore::IntRect screenAvailableRect(WebCore::Widget*); virtual bool popupsAllowed(NPP); - virtual void widgetSetCursor(WebCore::Widget*, const WebCore::Cursor&); - virtual void widgetSetFocus(WebCore::Widget*); - virtual WebCore::WorkerContextProxy* createWorkerContextProxy( - WebCore::Worker* worker); - virtual WebKit::WebStorageNamespace* createLocalStorageNamespace( - const WebKit::WebString& path, unsigned quota); - virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(); private: void DoTimeout() { |