diff options
| author | Ben Murdoch <benm@google.com> | 2011-05-13 16:23:25 +0100 |
|---|---|---|
| committer | Ben Murdoch <benm@google.com> | 2011-05-16 11:35:02 +0100 |
| commit | 65f03d4f644ce73618e5f4f50dd694b26f55ae12 (patch) | |
| tree | f478babb801e720de7bfaee23443ffe029f58731 /Source/WebKit2/WebProcess/WebCoreSupport | |
| parent | 47de4a2fb7262c7ebdb9cd133ad2c54c187454d0 (diff) | |
| download | external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.zip external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.gz external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.bz2 | |
Merge WebKit at r75993: Initial merge by git.
Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3
Diffstat (limited to 'Source/WebKit2/WebProcess/WebCoreSupport')
51 files changed, 7217 insertions, 0 deletions
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp new file mode 100644 index 0000000..ffca3fa --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp @@ -0,0 +1,686 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebChromeClient.h" + +#define DISABLE_NOT_IMPLEMENTED_WARNINGS 1 +#include "NotImplemented.h" + +#include "DrawingArea.h" +#include "InjectedBundleUserMessageCoders.h" +#include "WebContextMenu.h" +#include "WebCoreArgumentCoders.h" +#include "WebFrame.h" +#include "WebFrameLoaderClient.h" +#include "WebOpenPanelParameters.h" +#include "WebOpenPanelResultListener.h" +#include "WebPage.h" +#include "WebPageCreationParameters.h" +#include "WebPageProxyMessages.h" +#include "WebPopupMenu.h" +#include "WebPreferencesStore.h" +#include "WebProcess.h" +#include "WebProcessProxyMessageKinds.h" +#include "WebSearchPopupMenu.h" +#include <WebCore/DatabaseTracker.h> +#include <WebCore/FileChooser.h> +#include <WebCore/Frame.h> +#include <WebCore/FrameLoader.h> +#include <WebCore/HTMLNames.h> +#include <WebCore/HTMLPlugInImageElement.h> +#include <WebCore/Page.h> +#include <WebCore/SecurityOrigin.h> + +using namespace WebCore; +using namespace HTMLNames; + +namespace WebKit { + +static double area(WebFrame* frame) +{ + IntSize size = frame->size(); + return static_cast<double>(size.height()) * size.width(); +} + + +static WebFrame* findLargestFrameInFrameSet(WebPage* page) +{ + WebFrame* mainFrame = page->mainFrame(); + if (!mainFrame->isFrameSet()) + return 0; + + WebFrame* largestSoFar = 0; + + RefPtr<ImmutableArray> frameChildren = mainFrame->childFrames(); + size_t count = frameChildren->size(); + for (size_t i = 0; i < count; ++i) { + WebFrame* childFrame = frameChildren->at<WebFrame>(i); + if (!largestSoFar || area(childFrame) > area(largestSoFar)) + largestSoFar = childFrame; + } + + return largestSoFar; +} + +void WebChromeClient::chromeDestroyed() +{ + delete this; +} + +void WebChromeClient::setWindowRect(const FloatRect& windowFrame) +{ + m_page->send(Messages::WebPageProxy::SetWindowFrame(windowFrame)); +} + +FloatRect WebChromeClient::windowRect() +{ + FloatRect newWindowFrame; + + if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetWindowFrame(), Messages::WebPageProxy::GetWindowFrame::Reply(newWindowFrame), m_page->pageID())) + return FloatRect(); + + return newWindowFrame; +} + +FloatRect WebChromeClient::pageRect() +{ + return FloatRect(FloatPoint(), m_page->size()); +} + +float WebChromeClient::scaleFactor() +{ + notImplemented(); + return 1.0; +} + +void WebChromeClient::focus() +{ + notImplemented(); +} + +void WebChromeClient::unfocus() +{ + notImplemented(); +} + +bool WebChromeClient::canTakeFocus(FocusDirection) +{ + notImplemented(); + return true; +} + +void WebChromeClient::takeFocus(FocusDirection direction) +{ + m_page->send(Messages::WebPageProxy::TakeFocus(direction == FocusDirectionForward ? true : false)); +} + +void WebChromeClient::focusedNodeChanged(Node*) +{ + notImplemented(); +} + +void WebChromeClient::focusedFrameChanged(Frame* frame) +{ + WebFrame* webFrame = frame ? static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame() : 0; + + WebProcess::shared().connection()->send(Messages::WebPageProxy::FocusedFrameChanged(webFrame ? webFrame->frameID() : 0), m_page->pageID()); +} + +Page* WebChromeClient::createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures& windowFeatures, const NavigationAction& navigationAction) +{ + uint32_t modifiers = modifiersForNavigationAction(navigationAction); + int32_t mouseButton = mouseButtonForNavigationAction(navigationAction); + + uint64_t newPageID = 0; + WebPageCreationParameters parameters; + if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::CreateNewPage(windowFeatures, modifiers, mouseButton), Messages::WebPageProxy::CreateNewPage::Reply(newPageID, parameters), m_page->pageID())) + return 0; + + if (!newPageID) + return 0; + + WebProcess::shared().createWebPage(newPageID, parameters); + return WebProcess::shared().webPage(newPageID)->corePage(); +} + +void WebChromeClient::show() +{ + m_page->show(); +} + +bool WebChromeClient::canRunModal() +{ + notImplemented(); + return false; +} + +void WebChromeClient::runModal() +{ + notImplemented(); +} + +void WebChromeClient::setToolbarsVisible(bool toolbarsAreVisible) +{ + m_page->send(Messages::WebPageProxy::SetToolbarsAreVisible(toolbarsAreVisible)); +} + +bool WebChromeClient::toolbarsVisible() +{ + bool toolbarsAreVisible = true; + if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetToolbarsAreVisible(), Messages::WebPageProxy::GetToolbarsAreVisible::Reply(toolbarsAreVisible), m_page->pageID())) + return true; + + return toolbarsAreVisible; +} + +void WebChromeClient::setStatusbarVisible(bool statusBarIsVisible) +{ + m_page->send(Messages::WebPageProxy::SetStatusBarIsVisible(statusBarIsVisible)); +} + +bool WebChromeClient::statusbarVisible() +{ + bool statusBarIsVisible = true; + if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetStatusBarIsVisible(), Messages::WebPageProxy::GetStatusBarIsVisible::Reply(statusBarIsVisible), m_page->pageID())) + return true; + + return statusBarIsVisible; +} + +void WebChromeClient::setScrollbarsVisible(bool) +{ + notImplemented(); +} + +bool WebChromeClient::scrollbarsVisible() +{ + notImplemented(); + return true; +} + +void WebChromeClient::setMenubarVisible(bool menuBarVisible) +{ + m_page->send(Messages::WebPageProxy::SetMenuBarIsVisible(menuBarVisible)); +} + +bool WebChromeClient::menubarVisible() +{ + bool menuBarIsVisible = true; + if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetMenuBarIsVisible(), Messages::WebPageProxy::GetMenuBarIsVisible::Reply(menuBarIsVisible), m_page->pageID())) + return true; + + return menuBarIsVisible; +} + +void WebChromeClient::setResizable(bool resizable) +{ + m_page->send(Messages::WebPageProxy::SetIsResizable(resizable)); +} + +void WebChromeClient::addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID) +{ + // Notify the bundle client. + m_page->injectedBundleUIClient().willAddMessageToConsole(m_page, message, lineNumber); + + notImplemented(); +} + +bool WebChromeClient::canRunBeforeUnloadConfirmPanel() +{ + bool canRun = false; + if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::CanRunBeforeUnloadConfirmPanel(), Messages::WebPageProxy::CanRunBeforeUnloadConfirmPanel::Reply(canRun), m_page->pageID())) + return false; + + return canRun; +} + +bool WebChromeClient::runBeforeUnloadConfirmPanel(const String& message, Frame* frame) +{ + WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame(); + + bool shouldClose = false; + if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunBeforeUnloadConfirmPanel(message, webFrame->frameID()), Messages::WebPageProxy::RunBeforeUnloadConfirmPanel::Reply(shouldClose), m_page->pageID())) + return false; + + return shouldClose; +} + +void WebChromeClient::closeWindowSoon() +{ + // FIXME: This code assumes that the client will respond to a close page + // message by actually closing the page. Safari does this, but there is + // no guarantee that other applications will, which will leave this page + // half detached. This approach is an inherent limitation making parts of + // a close execute synchronously as part of window.close, but other parts + // later on. + + m_page->corePage()->setGroupName(String()); + + if (WebFrame* frame = m_page->mainFrame()) { + if (Frame* coreFrame = frame->coreFrame()) + coreFrame->loader()->stopForUserCancel(); + } + + m_page->sendClose(); +} + +void WebChromeClient::runJavaScriptAlert(Frame* frame, const String& alertText) +{ + WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame(); + + // Notify the bundle client. + m_page->injectedBundleUIClient().willRunJavaScriptAlert(m_page, alertText, webFrame); + + WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply(), m_page->pageID()); +} + +bool WebChromeClient::runJavaScriptConfirm(Frame* frame, const String& message) +{ + WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame(); + + // Notify the bundle client. + m_page->injectedBundleUIClient().willRunJavaScriptConfirm(m_page, message, webFrame); + + bool result = false; + if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result), m_page->pageID())) + return false; + + return result; +} + +bool WebChromeClient::runJavaScriptPrompt(Frame* frame, const String& message, const String& defaultValue, String& result) +{ + WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame(); + + // Notify the bundle client. + m_page->injectedBundleUIClient().willRunJavaScriptPrompt(m_page, message, defaultValue, webFrame); + + if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result), m_page->pageID())) + return false; + + return !result.isNull(); +} + +void WebChromeClient::setStatusbarText(const String& statusbarText) +{ + // Notify the bundle client. + m_page->injectedBundleUIClient().willSetStatusbarText(m_page, statusbarText); + + m_page->send(Messages::WebPageProxy::SetStatusText(statusbarText)); +} + +bool WebChromeClient::shouldInterruptJavaScript() +{ + notImplemented(); + return false; +} + +bool WebChromeClient::tabsToLinks() const +{ + return m_page->tabsToLinks(); +} + +IntRect WebChromeClient::windowResizerRect() const +{ + return m_page->windowResizerRect(); +} + +void WebChromeClient::invalidateWindow(const IntRect&, bool) +{ + // Do nothing here, there's no concept of invalidating the window in the web process. +} + +void WebChromeClient::invalidateContentsAndWindow(const IntRect& rect, bool) +{ + m_page->drawingArea()->setNeedsDisplay(rect); +} + +void WebChromeClient::invalidateContentsForSlowScroll(const IntRect& rect, bool) +{ + m_page->pageDidScroll(); + m_page->drawingArea()->setNeedsDisplay(rect); +} + +void WebChromeClient::scroll(const IntSize& scrollDelta, const IntRect& scrollRect, const IntRect&) +{ + m_page->pageDidScroll(); + m_page->drawingArea()->scroll(scrollRect, scrollDelta); +} + +#if ENABLE(TILED_BACKING_STORE) +void WebChromeClient::delegatedScrollRequested(const IntSize& scrollDelta) +{ + m_page->pageDidRequestScroll(scrollDelta); +} +#endif + +IntPoint WebChromeClient::screenToWindow(const IntPoint&) const +{ + notImplemented(); + return IntPoint(); +} + +IntRect WebChromeClient::windowToScreen(const IntRect&) const +{ + notImplemented(); + return IntRect(); +} + +PlatformPageClient WebChromeClient::platformPageClient() const +{ + notImplemented(); + return 0; +} + +void WebChromeClient::contentsSizeChanged(Frame* frame, const IntSize& size) const +{ +#if PLATFORM(QT) +#if ENABLE(TILED_BACKING_STORE) + if (frame->page()->mainFrame() == frame) + m_page->resizeToContentsIfNeeded(); +#endif + + WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame(); + + if (!m_page->mainFrame() || m_page->mainFrame() != webFrame) + return; + + m_page->send(Messages::WebPageProxy::DidChangeContentsSize(size)); +#endif + + WebFrame* largestFrame = findLargestFrameInFrameSet(m_page); + if (largestFrame != m_cachedFrameSetLargestFrame.get()) { + m_cachedFrameSetLargestFrame = largestFrame; + WebProcess::shared().connection()->send(Messages::WebPageProxy::FrameSetLargestFrameChanged(largestFrame ? largestFrame->frameID() : 0), m_page->pageID()); + } +} + +void WebChromeClient::scrollRectIntoView(const IntRect&, const ScrollView*) const +{ + notImplemented(); +} + +bool WebChromeClient::shouldMissingPluginMessageBeButton() const +{ + // FIXME: <rdar://problem/8794397> We should only return true when there is a + // missingPluginButtonClicked callback defined on the Page UI client. + return true; +} + +void WebChromeClient::missingPluginButtonClicked(Element* element) const +{ + ASSERT(element->hasTagName(objectTag) || element->hasTagName(embedTag)); + + HTMLPlugInImageElement* pluginElement = static_cast<HTMLPlugInImageElement*>(element); + + m_page->send(Messages::WebPageProxy::MissingPluginButtonClicked(pluginElement->serviceType(), pluginElement->url())); +} + +void WebChromeClient::scrollbarsModeDidChange() const +{ + notImplemented(); +} + +void WebChromeClient::mouseDidMoveOverElement(const HitTestResult& hitTestResult, unsigned modifierFlags) +{ + RefPtr<APIObject> userData; + + // Notify the bundle client. + m_page->injectedBundleUIClient().mouseDidMoveOverElement(m_page, hitTestResult, static_cast<WebEvent::Modifiers>(modifierFlags), userData); + + // Notify the UIProcess. + m_page->send(Messages::WebPageProxy::MouseDidMoveOverElement(modifierFlags, InjectedBundleUserMessageEncoder(userData.get()))); +} + +void WebChromeClient::setToolTip(const String& toolTip, TextDirection) +{ + // Only send a tool tip to the WebProcess if it has changed since the last time this function was called. + + if (toolTip == m_cachedToolTip) + return; + m_cachedToolTip = toolTip; + + m_page->send(Messages::WebPageProxy::SetToolTip(m_cachedToolTip)); +} + +void WebChromeClient::print(Frame*) +{ + notImplemented(); +} + +#if ENABLE(DATABASE) +void WebChromeClient::exceededDatabaseQuota(Frame* frame, const String& databaseName) +{ + WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame(); + SecurityOrigin* origin = frame->document()->securityOrigin(); + + DatabaseDetails details = DatabaseTracker::tracker().detailsForNameAndOrigin(databaseName, origin); + uint64_t currentQuota = DatabaseTracker::tracker().quotaForOrigin(origin); + uint64_t newQuota = 0; + WebProcess::shared().connection()->sendSync( + Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), databaseName, details.displayName(), currentQuota, details.currentUsage(), details.expectedUsage()), + Messages::WebPageProxy::ExceededDatabaseQuota::Reply(newQuota), m_page->pageID()); + + DatabaseTracker::tracker().setQuota(origin, newQuota); +} +#endif + + +#if ENABLE(OFFLINE_WEB_APPLICATIONS) +void WebChromeClient::reachedMaxAppCacheSize(int64_t) +{ + notImplemented(); +} + +void WebChromeClient::reachedApplicationCacheOriginQuota(SecurityOrigin*) +{ + notImplemented(); +} +#endif + +#if ENABLE(DASHBOARD_SUPPORT) +void WebChromeClient::dashboardRegionsChanged() +{ + notImplemented(); +} +#endif + +void WebChromeClient::populateVisitedLinks() +{ +} + +FloatRect WebChromeClient::customHighlightRect(Node*, const AtomicString& type, const FloatRect& lineRect) +{ + notImplemented(); + return FloatRect(); +} + +void WebChromeClient::paintCustomHighlight(Node*, const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect, + bool behindText, bool entireLine) +{ + notImplemented(); +} + +bool WebChromeClient::shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename) +{ + notImplemented(); + return false; +} + +String WebChromeClient::generateReplacementFile(const String& path) +{ + notImplemented(); + return String(); +} + +bool WebChromeClient::paintCustomScrollbar(GraphicsContext*, const FloatRect&, ScrollbarControlSize, + ScrollbarControlState, ScrollbarPart pressedPart, bool vertical, + float value, float proportion, ScrollbarControlPartMask) +{ + notImplemented(); + return false; +} + +bool WebChromeClient::paintCustomScrollCorner(GraphicsContext*, const FloatRect&) +{ + notImplemented(); + return false; +} + +void WebChromeClient::requestGeolocationPermissionForFrame(Frame*, Geolocation*) +{ + notImplemented(); +} + +void WebChromeClient::cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*) +{ + notImplemented(); +} + +void WebChromeClient::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> prpFileChooser) +{ + if (m_page->activeOpenPanelResultListener()) + return; + + RefPtr<FileChooser> fileChooser = prpFileChooser; + + m_page->setActiveOpenPanelResultListener(WebOpenPanelResultListener::create(m_page, fileChooser.get())); + + WebOpenPanelParameters::Data parameters; + parameters.allowMultipleFiles = fileChooser->allowsMultipleFiles(); +#if ENABLE(DIRECTORY_UPLOAD) + parameters.allowsDirectoryUpload = fileChooser->allowsDirectoryUpload(); +#else + parameters.allowsDirectoryUpload = false; +#endif + parameters.acceptTypes = fileChooser->acceptTypes(); + parameters.filenames = fileChooser->filenames(); + + m_page->send(Messages::WebPageProxy::RunOpenPanel(static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame()->frameID(), parameters)); +} + +void WebChromeClient::chooseIconForFiles(const Vector<String>&, FileChooser*) +{ + notImplemented(); +} + +void WebChromeClient::setCursor(const WebCore::Cursor& cursor) +{ +#if USE(LAZY_NATIVE_CURSOR) + m_page->send(Messages::WebPageProxy::SetCursor(cursor)); +#endif +} + +void WebChromeClient::formStateDidChange(const Node*) +{ + notImplemented(); +} + +void WebChromeClient::formDidFocus(const Node*) +{ + notImplemented(); +} + +void WebChromeClient::formDidBlur(const Node*) +{ + notImplemented(); +} + +bool WebChromeClient::selectItemWritingDirectionIsNatural() +{ + return true; +} + +PassRefPtr<WebCore::PopupMenu> WebChromeClient::createPopupMenu(WebCore::PopupMenuClient* client) const +{ + return WebPopupMenu::create(m_page, client); +} + +PassRefPtr<WebCore::SearchPopupMenu> WebChromeClient::createSearchPopupMenu(WebCore::PopupMenuClient* client) const +{ + return WebSearchPopupMenu::create(m_page, client); +} + +#if ENABLE(CONTEXT_MENUS) +void WebChromeClient::showContextMenu() +{ + m_page->contextMenu()->show(); +} +#endif + +PassOwnPtr<HTMLParserQuirks> WebChromeClient::createHTMLParserQuirks() +{ + notImplemented(); + return 0; +} + +#if USE(ACCELERATED_COMPOSITING) +void WebChromeClient::attachRootGraphicsLayer(Frame*, GraphicsLayer* layer) +{ + if (layer) + m_page->enterAcceleratedCompositingMode(layer); + else + m_page->exitAcceleratedCompositingMode(); +} + +void WebChromeClient::setNeedsOneShotDrawingSynchronization() +{ + notImplemented(); +} + +void WebChromeClient::scheduleCompositingLayerSync() +{ + if (m_page->drawingArea()) + m_page->drawingArea()->scheduleCompositingLayerSync(); +} + +#endif + +#if ENABLE(NOTIFICATIONS) +WebCore::NotificationPresenter* WebChromeClient::notificationPresenter() const +{ + return 0; +} +#endif + +#if ENABLE(TOUCH_EVENTS) +void WebChromeClient::needTouchEvents(bool) +{ +} +#endif + +#if PLATFORM(WIN) +void WebChromeClient::setLastSetCursorToCurrentCursor() +{ +} +#endif + +void WebChromeClient::dispatchViewportDataDidChange(const ViewportArguments& args) const +{ + m_page->send(Messages::WebPageProxy::DidChangeViewportData(args)); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h new file mode 100644 index 0000000..44c3658 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h @@ -0,0 +1,212 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebChromeClient_h +#define WebChromeClient_h + +#include <WebCore/ChromeClient.h> +#include <WebCore/ViewportArguments.h> +#include <wtf/text/WTFString.h> + +namespace WebKit { + +class WebFrame; +class WebPage; + +class WebChromeClient : public WebCore::ChromeClient { +public: + WebChromeClient(WebPage* page) + : m_page(page) + { + } + + WebPage* page() const { return m_page; } +private: + virtual void chromeDestroyed(); + + virtual void setWindowRect(const WebCore::FloatRect&); + virtual WebCore::FloatRect windowRect(); + + virtual WebCore::FloatRect pageRect(); + + virtual float scaleFactor(); + + virtual void focus(); + virtual void unfocus(); + + virtual bool canTakeFocus(WebCore::FocusDirection); + virtual void takeFocus(WebCore::FocusDirection); + + virtual void focusedNodeChanged(WebCore::Node*); + virtual void focusedFrameChanged(WebCore::Frame*); + + // The Frame pointer provides the ChromeClient with context about which + // Frame wants to create the new Page. Also, the newly created window + // should not be shown to the user until the ChromeClient of the newly + // created Page has its show method called. + virtual WebCore::Page* createWindow(WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&, const WebCore::NavigationAction&); + virtual void show(); + + virtual bool canRunModal(); + virtual void runModal(); + + virtual void setToolbarsVisible(bool); + virtual bool toolbarsVisible(); + + virtual void setStatusbarVisible(bool); + virtual bool statusbarVisible(); + + virtual void setScrollbarsVisible(bool); + virtual bool scrollbarsVisible(); + + virtual void setMenubarVisible(bool); + virtual bool menubarVisible(); + + virtual void setResizable(bool); + + virtual void addMessageToConsole(WebCore::MessageSource, WebCore::MessageType, WebCore::MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID); + + virtual bool canRunBeforeUnloadConfirmPanel(); + virtual bool runBeforeUnloadConfirmPanel(const String& message, WebCore::Frame* frame); + + virtual void closeWindowSoon(); + + virtual void runJavaScriptAlert(WebCore::Frame*, const String&); + virtual bool runJavaScriptConfirm(WebCore::Frame*, const String&); + virtual bool runJavaScriptPrompt(WebCore::Frame*, const String& message, const String& defaultValue, String& result); + virtual void setStatusbarText(const String&); + virtual bool shouldInterruptJavaScript(); + virtual bool tabsToLinks() const; + + virtual WebCore::IntRect windowResizerRect() const; + + // Methods used by HostWindow. + virtual void invalidateWindow(const WebCore::IntRect&, bool); + virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool); + virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool); + virtual void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect, const WebCore::IntRect& clipRect); +#if ENABLE(TILED_BACKING_STORE) + virtual void delegatedScrollRequested(const WebCore::IntSize& scrollDelta); +#endif + virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const; + virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const; + virtual PlatformPageClient platformPageClient() const; + virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const; + virtual void scrollRectIntoView(const WebCore::IntRect&, const WebCore::ScrollView*) const; // Currently only Mac has a non empty implementation. + // End methods used by HostWindow. + + virtual bool shouldMissingPluginMessageBeButton() const; + virtual void missingPluginButtonClicked(WebCore::Element*) const; + + virtual void scrollbarsModeDidChange() const; + virtual void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags); + + virtual void setToolTip(const String&, WebCore::TextDirection); + + virtual void print(WebCore::Frame*); + +#if ENABLE(DATABASE) + virtual void exceededDatabaseQuota(WebCore::Frame*, const String& databaseName); +#endif + +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + virtual void reachedMaxAppCacheSize(int64_t spaceNeeded); + virtual void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin*); +#endif + +#if ENABLE(DASHBOARD_SUPPORT) + virtual void dashboardRegionsChanged(); +#endif + + virtual void populateVisitedLinks(); + + virtual WebCore::FloatRect customHighlightRect(WebCore::Node*, const WTF::AtomicString& type, const WebCore::FloatRect& lineRect); + virtual void paintCustomHighlight(WebCore::Node*, const WTF::AtomicString& type, const WebCore::FloatRect& boxRect, const WebCore::FloatRect& lineRect, + bool behindText, bool entireLine); + + virtual bool shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename); + virtual String generateReplacementFile(const String& path); + + virtual bool paintCustomScrollbar(WebCore::GraphicsContext*, const WebCore::FloatRect&, WebCore::ScrollbarControlSize, + WebCore::ScrollbarControlState, WebCore::ScrollbarPart pressedPart, bool vertical, + float value, float proportion, WebCore::ScrollbarControlPartMask); + virtual bool paintCustomScrollCorner(WebCore::GraphicsContext*, const WebCore::FloatRect&); + + // This is an asynchronous call. The ChromeClient can display UI asking the user for permission + // to use Geolococation. The ChromeClient must call Geolocation::setShouldClearCache() appropriately. + virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*); + virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*); + + virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>); + virtual void chooseIconForFiles(const Vector<String>&, WebCore::FileChooser*); + + virtual void setCursor(const WebCore::Cursor&); + + // Notification that the given form element has changed. This function + // will be called frequently, so handling should be very fast. + virtual void formStateDidChange(const WebCore::Node*); + + virtual void formDidFocus(const WebCore::Node*); + virtual void formDidBlur(const WebCore::Node*); + + virtual PassOwnPtr<WebCore::HTMLParserQuirks> createHTMLParserQuirks(); + + virtual bool selectItemWritingDirectionIsNatural(); + virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const; + virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const; + +#if ENABLE(CONTEXT_MENUS) + virtual void showContextMenu(); +#endif + +#if USE(ACCELERATED_COMPOSITING) + virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*); + virtual void setNeedsOneShotDrawingSynchronization(); + virtual void scheduleCompositingLayerSync(); +#endif + +#if ENABLE(NOTIFICATIONS) + virtual WebCore::NotificationPresenter* notificationPresenter() const; +#endif + +#if ENABLE(TOUCH_EVENTS) + virtual void needTouchEvents(bool); +#endif + +#if PLATFORM(WIN) + virtual void setLastSetCursorToCurrentCursor(); +#endif + + virtual void dispatchViewportDataDidChange(const WebCore::ViewportArguments&) const; + + String m_cachedToolTip; + mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame; + WebPage* m_page; +}; + +} // namespace WebKit + +#endif // WebChromeClient_h diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.cpp new file mode 100644 index 0000000..42b60a5 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebContextMenuClient.h" + +#include "WebContextMenuItemData.h" +#include "WebPage.h" +#include <WebCore/ContextMenu.h> +#include <WebCore/Frame.h> +#include <WebCore/Page.h> +#include <WebCore/UserGestureIndicator.h> + +#define DISABLE_NOT_IMPLEMENTED_WARNINGS 1 +#include "NotImplemented.h" + +using namespace WebCore; + +namespace WebKit { + +void WebContextMenuClient::contextMenuDestroyed() +{ + delete this; +} + +#if USE(CROSS_PLATFORM_CONTEXT_MENUS) +PassOwnPtr<ContextMenu> WebContextMenuClient::customizeMenu(PassOwnPtr<ContextMenu> menu) +{ + // WebKit2 ignores this client callback and does context menu customization when it is told to show the menu. + return menu; +} +#else +PlatformMenuDescription WebContextMenuClient::getCustomMenuFromDefaultItems(ContextMenu* menu) +{ + // WebKit2 ignores this client callback and does context menu customization when it is told to show the menu. + return menu->platformDescription(); +} +#endif + +void WebContextMenuClient::contextMenuItemSelected(ContextMenuItem*, const ContextMenu*) +{ + notImplemented(); +} + +void WebContextMenuClient::downloadURL(const KURL& url) +{ + // This is handled in the UI process. + ASSERT_NOT_REACHED(); +} + +void WebContextMenuClient::searchWithGoogle(const Frame* frame) +{ + String searchString = frame->editor()->selectedText(); + searchString.stripWhiteSpace(); + String encoded = encodeWithURLEscapeSequences(searchString); + encoded.replace("%20", "+"); + + String url("http://www.google.com/search?q="); + url.append(encoded); + url.append("&ie=UTF-8&oe=UTF-8"); + + if (Page* page = frame->page()) { + UserGestureIndicator indicator(DefinitelyProcessingUserGesture); + page->mainFrame()->loader()->urlSelected(KURL(ParsedURLString, url), String(), 0, false, false, SendReferrer); + } +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.h new file mode 100644 index 0000000..0545a7d --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebContextMenuClient_h +#define WebContextMenuClient_h + +#include <WebCore/ContextMenuClient.h> + +namespace WebKit { + +class WebPage; + +class WebContextMenuClient : public WebCore::ContextMenuClient { +public: + WebContextMenuClient(WebPage* page) + : m_page(page) + { + } + +private: + virtual void contextMenuDestroyed(); + +#if USE(CROSS_PLATFORM_CONTEXT_MENUS) + virtual PassOwnPtr<WebCore::ContextMenu> customizeMenu(PassOwnPtr<WebCore::ContextMenu>); +#else + virtual WebCore::PlatformMenuDescription getCustomMenuFromDefaultItems(WebCore::ContextMenu*); +#endif + virtual void contextMenuItemSelected(WebCore::ContextMenuItem*, const WebCore::ContextMenu*); + + virtual void downloadURL(const WebCore::KURL& url); + virtual void searchWithGoogle(const WebCore::Frame*); + virtual void lookUpInDictionary(WebCore::Frame*); + virtual bool isSpeaking(); + virtual void speak(const String&); + virtual void stopSpeaking(); + +#if PLATFORM(MAC) + virtual void searchWithSpotlight(); +#endif + + WebPage* m_page; +}; + +} // namespace WebKit + +#endif // WebContextMenuClient_h diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp new file mode 100644 index 0000000..cc61b04 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebDatabaseManager.h" + +#include "Connection.h" +#include "MessageID.h" +#include "OriginAndDatabases.h" +#include "WebCoreArgumentCoders.h" +#include "WebDatabaseManagerProxyMessages.h" +#include "WebProcess.h" +#include <WebCore/DatabaseDetails.h> +#include <WebCore/DatabaseTracker.h> +#include <WebCore/SecurityOrigin.h> + +using namespace WebCore; + +namespace WebKit { + +WebDatabaseManager& WebDatabaseManager::shared() +{ + static WebDatabaseManager& shared = *new WebDatabaseManager; + return shared; +} + +WebDatabaseManager::WebDatabaseManager() +{ + DatabaseTracker::initializeTracker(databaseDirectory()); + DatabaseTracker::tracker().setClient(this); +} + +WebDatabaseManager::~WebDatabaseManager() +{ +} + +void WebDatabaseManager::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) +{ + didReceiveWebDatabaseManagerMessage(connection, messageID, arguments); +} + +void WebDatabaseManager::getDatabasesByOrigin(uint64_t callbackID) const +{ + // FIXME: This could be made more efficient by adding a function to DatabaseTracker + // to get both the origins and the Vector of DatabaseDetails for each origin in one + // shot. That would avoid taking the numerous locks this requires. + + Vector<RefPtr<SecurityOrigin> > origins; + DatabaseTracker::tracker().origins(origins); + + Vector<OriginAndDatabases> originAndDatabasesVector; + originAndDatabasesVector.reserveInitialCapacity(origins.size()); + + for (size_t i = 0; i < origins.size(); ++i) { + OriginAndDatabases originAndDatabases; + + Vector<String> nameVector; + if (!DatabaseTracker::tracker().databaseNamesForOrigin(origins[i].get(), nameVector)) + continue; + + Vector<DatabaseDetails> detailsVector; + detailsVector.reserveInitialCapacity(nameVector.size()); + for (size_t j = 0; j < nameVector.size(); j++) { + DatabaseDetails details = DatabaseTracker::tracker().detailsForNameAndOrigin(nameVector[j], origins[i].get()); + if (details.name().isNull()) + continue; + + detailsVector.append(details); + } + + if (detailsVector.isEmpty()) + continue; + + originAndDatabases.originIdentifier = origins[i]->databaseIdentifier(); + originAndDatabases.originQuota = DatabaseTracker::tracker().quotaForOrigin(origins[i].get()); + originAndDatabases.originUsage = DatabaseTracker::tracker().usageForOrigin(origins[i].get()); + originAndDatabases.databases.swap(detailsVector); + originAndDatabasesVector.append(originAndDatabases); + } + + WebProcess::shared().connection()->send(Messages::WebDatabaseManagerProxy::DidGetDatabasesByOrigin(originAndDatabasesVector, callbackID), 0); +} + +void WebDatabaseManager::getDatabaseOrigins(uint64_t callbackID) const +{ + Vector<RefPtr<SecurityOrigin> > origins; + DatabaseTracker::tracker().origins(origins); + + size_t numOrigins = origins.size(); + + Vector<String> identifiers(numOrigins); + for (size_t i = 0; i < numOrigins; ++i) + identifiers[i] = origins[i]->databaseIdentifier(); + WebProcess::shared().connection()->send(Messages::WebDatabaseManagerProxy::DidGetDatabaseOrigins(identifiers, callbackID), 0); +} + +void WebDatabaseManager::deleteDatabaseWithNameForOrigin(const String& databaseIdentifier, const String& originIdentifier) const +{ + RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromDatabaseIdentifier(originIdentifier); + if (!origin) + return; + + DatabaseTracker::tracker().deleteDatabase(origin.get(), databaseIdentifier); +} + +void WebDatabaseManager::deleteDatabasesForOrigin(const String& originIdentifier) const +{ + RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromDatabaseIdentifier(originIdentifier); + if (!origin) + return; + + DatabaseTracker::tracker().deleteOrigin(origin.get()); +} + +void WebDatabaseManager::deleteAllDatabases() const +{ + DatabaseTracker::tracker().deleteAllDatabases(); +} + +void WebDatabaseManager::setQuotaForOrigin(const String& originIdentifier, unsigned long long quota) const +{ + // If the quota is set to a value lower than the current usage, that quota will + // "stick" but no data will be purged to meet the new quota. This will simply + // prevent new data from being added to databases in that origin. + + RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromDatabaseIdentifier(originIdentifier); + if (!origin) + return; + + DatabaseTracker::tracker().setQuota(origin.get(), quota); +} + +void WebDatabaseManager::dispatchDidModifyOrigin(SecurityOrigin* origin) +{ + // NOTE: This may be called on a non-main thread. + WebProcess::shared().connection()->send(Messages::WebDatabaseManagerProxy::DidModifyOrigin(origin->databaseIdentifier()), 0); +} + +void WebDatabaseManager::dispatchDidModifyDatabase(WebCore::SecurityOrigin* origin, const String& databaseIdentifier) +{ + // NOTE: This may be called on a non-main thread. + WebProcess::shared().connection()->send(Messages::WebDatabaseManagerProxy::DidModifyDatabase(origin->databaseIdentifier(), databaseIdentifier), 0); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h new file mode 100644 index 0000000..4701645 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebDatabaseManager_h +#define WebDatabaseManager_h + +#include "Arguments.h" +#include <WebCore/DatabaseTrackerClient.h> +#include <wtf/Noncopyable.h> +#include <wtf/text/WTFString.h> + +namespace CoreIPC { +class ArgumentDecoder; +class Connection; +class MessageID; +} + +namespace WebKit { + +class WebDatabaseManager : public WebCore::DatabaseTrackerClient { + WTF_MAKE_NONCOPYABLE(WebDatabaseManager); +public: + static WebDatabaseManager& shared(); + + void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + +private: + WebDatabaseManager(); + virtual ~WebDatabaseManager(); + + // Implemented in generated WebDatabaseManagerMessageReceiver.cpp + void didReceiveWebDatabaseManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + + void getDatabasesByOrigin(uint64_t callbackID) const; + void getDatabaseOrigins(uint64_t callbackID) const; + void deleteDatabaseWithNameForOrigin(const String& databaseIdentifier, const String& originIdentifier) const; + void deleteDatabasesForOrigin(const String& originIdentifier) const; + void deleteAllDatabases() const; + void setQuotaForOrigin(const String& originIdentifier, unsigned long long quota) const; + + // WebCore::DatabaseTrackerClient + virtual void dispatchDidModifyOrigin(WebCore::SecurityOrigin*); + virtual void dispatchDidModifyDatabase(WebCore::SecurityOrigin*, const String& databaseIdentifier); + + String databaseDirectory() const; +}; + +} // namespace WebKit + +#endif // WebDatabaseManager_h diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.messages.in b/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.messages.in new file mode 100644 index 0000000..e928ef6 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.messages.in @@ -0,0 +1,30 @@ +# Copyright (C) 2010 Apple Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +messages -> WebDatabaseManager { + void GetDatabasesByOrigin(uint64_t callbackID) + void GetDatabaseOrigins(uint64_t callbackID) + void DeleteDatabaseWithNameForOrigin(WTF::String databaseIdentifier, WTF::String originIdentifier) + void DeleteDatabasesForOrigin(WTF::String originIdentifier) + void DeleteAllDatabases() + void SetQuotaForOrigin(WTF::String originIdentifier, uint64_t quota) +} diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp new file mode 100644 index 0000000..d11017f --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebDragClient.h" + +#define DISABLE_NOT_IMPLEMENTED_WARNINGS 1 +#include "NotImplemented.h" + +using namespace WebCore; + +namespace WebKit { + +void WebDragClient::willPerformDragDestinationAction(DragDestinationAction, DragData*) +{ +} + +void WebDragClient::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*) +{ +} + +DragDestinationAction WebDragClient::actionMaskForDrag(DragData*) +{ + return DragDestinationActionAny; +} + +DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntPoint& windowPoint) +{ + return DragSourceActionAny; +} + +void WebDragClient::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool) +{ +} + +DragImageRef WebDragClient::createDragImageForLink(KURL&, const String&, Frame*) +{ + notImplemented(); + return 0; +} + +void WebDragClient::dragControllerDestroyed() +{ + delete this; +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h new file mode 100644 index 0000000..ce123c8 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebDragClient_h +#define WebDragClient_h + +#include <WebCore/DragClient.h> + +namespace WebKit { + +class WebPage; + +class WebDragClient : public WebCore::DragClient { +public: + WebDragClient(WebPage* page) + : m_page(page) + { + } + +private: + virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData*); + virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard*); + virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData*); + virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint); + + virtual void startDrag(WebCore::DragImageRef dragImage, const WebCore::IntPoint& dragImageOrigin, const WebCore::IntPoint& eventPos, WebCore::Clipboard*, WebCore::Frame*, bool linkDrag = false); + virtual WebCore::DragImageRef createDragImageForLink(WebCore::KURL&, const String& label, WebCore::Frame*); + + virtual void dragControllerDestroyed(); + + WebPage* m_page; +}; + +} // namespace WebKit + +#endif // WebDragClient_h diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp new file mode 100644 index 0000000..e3db967 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp @@ -0,0 +1,438 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebEditorClient.h" + +#define DISABLE_NOT_IMPLEMENTED_WARNINGS 1 +#include "NotImplemented.h" + +#include "SelectionState.h" +#include "WebFrameLoaderClient.h" +#include "WebPage.h" +#include "WebPageProxyMessages.h" +#include "WebProcess.h" +#include <WebCore/ArchiveResource.h> +#include <WebCore/DocumentFragment.h> +#include <WebCore/EditCommand.h> +#include <WebCore/FocusController.h> +#include <WebCore/Frame.h> +#include <WebCore/HTMLInputElement.h> +#include <WebCore/HTMLNames.h> +#include <WebCore/HTMLTextAreaElement.h> +#include <WebCore/KeyboardEvent.h> +#include <WebCore/Page.h> +#include <WebCore/UserTypingGestureIndicator.h> + +using namespace WebCore; +using namespace HTMLNames; + +namespace WebKit { + +void WebEditorClient::pageDestroyed() +{ + delete this; +} + +bool WebEditorClient::shouldDeleteRange(Range* range) +{ + bool result = m_page->injectedBundleEditorClient().shouldDeleteRange(m_page, range); + notImplemented(); + return result; +} + +bool WebEditorClient::shouldShowDeleteInterface(HTMLElement*) +{ + notImplemented(); + return false; +} + +bool WebEditorClient::smartInsertDeleteEnabled() +{ + // FIXME: Why isn't this Mac specific like toggleSmartInsertDeleteEnabled? +#if PLATFORM(MAC) + return m_page->isSmartInsertDeleteEnabled(); +#else + return true; +#endif +} + +bool WebEditorClient::isSelectTrailingWhitespaceEnabled() +{ + notImplemented(); + return false; +} + +bool WebEditorClient::isContinuousSpellCheckingEnabled() +{ + return WebProcess::shared().textCheckerState().isContinuousSpellCheckingEnabled; +} + +void WebEditorClient::toggleContinuousSpellChecking() +{ + notImplemented(); +} + +bool WebEditorClient::isGrammarCheckingEnabled() +{ + return WebProcess::shared().textCheckerState().isGrammarCheckingEnabled; +} + +void WebEditorClient::toggleGrammarChecking() +{ + notImplemented(); +} + +int WebEditorClient::spellCheckerDocumentTag() +{ + notImplemented(); + return false; +} + + +bool WebEditorClient::isEditable() +{ + notImplemented(); + return false; +} + + +bool WebEditorClient::shouldBeginEditing(Range* range) +{ + bool result = m_page->injectedBundleEditorClient().shouldBeginEditing(m_page, range); + notImplemented(); + return result; +} + +bool WebEditorClient::shouldEndEditing(Range* range) +{ + bool result = m_page->injectedBundleEditorClient().shouldEndEditing(m_page, range); + notImplemented(); + return result; +} + +bool WebEditorClient::shouldInsertNode(Node* node, Range* rangeToReplace, EditorInsertAction action) +{ + bool result = m_page->injectedBundleEditorClient().shouldInsertNode(m_page, node, rangeToReplace, action); + notImplemented(); + return result; +} + +bool WebEditorClient::shouldInsertText(const String& text, Range* rangeToReplace, EditorInsertAction action) +{ + bool result = m_page->injectedBundleEditorClient().shouldInsertText(m_page, text.impl(), rangeToReplace, action); + notImplemented(); + return result; +} + +bool WebEditorClient::shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAffinity affinity, bool stillSelecting) +{ + bool result = m_page->injectedBundleEditorClient().shouldChangeSelectedRange(m_page, fromRange, toRange, affinity, stillSelecting); + notImplemented(); + return result; +} + +bool WebEditorClient::shouldApplyStyle(CSSStyleDeclaration* style, Range* range) +{ + bool result = m_page->injectedBundleEditorClient().shouldApplyStyle(m_page, style, range); + notImplemented(); + return result; +} + +bool WebEditorClient::shouldMoveRangeAfterDelete(Range*, Range*) +{ + notImplemented(); + return true; +} + +void WebEditorClient::didBeginEditing() +{ + // FIXME: What good is a notification name, if it's always the same? + static const String WebViewDidBeginEditingNotification = "WebViewDidBeginEditingNotification"; + m_page->injectedBundleEditorClient().didBeginEditing(m_page, WebViewDidBeginEditingNotification.impl()); + notImplemented(); +} + +void WebEditorClient::respondToChangedContents() +{ + static const String WebViewDidChangeNotification = "WebViewDidChangeNotification"; + m_page->injectedBundleEditorClient().didChange(m_page, WebViewDidChangeNotification.impl()); + notImplemented(); +} + +void WebEditorClient::respondToChangedSelection() +{ + static const String WebViewDidChangeSelectionNotification = "WebViewDidChangeSelectionNotification"; + m_page->injectedBundleEditorClient().didChangeSelection(m_page, WebViewDidChangeSelectionNotification.impl()); + Frame* frame = m_page->corePage()->focusController()->focusedFrame(); + if (!frame) + return; + + SelectionState selectionState; + selectionState.isNone = frame->selection()->isNone(); + selectionState.isContentEditable = frame->selection()->isContentEditable(); + selectionState.isInPasswordField = frame->selection()->isInPasswordField(); + selectionState.hasComposition = frame->editor()->hasComposition(); + + WebPage::getLocationAndLengthFromRange(frame->selection()->toNormalizedRange().get(), selectionState.selectedRangeStart, selectionState.selectedRangeLength); + + m_page->send(Messages::WebPageProxy::SelectionStateChanged(selectionState)); + +#if PLATFORM(WIN) + // FIXME: This should also go into the selection state. + if (!frame->editor()->hasComposition() || frame->editor()->ignoreCompositionSelectionChange()) + return; + + unsigned start; + unsigned end; + m_page->send(Messages::WebPageProxy::DidChangeCompositionSelection(frame->editor()->getCompositionSelection(start, end))); +#endif +} + +void WebEditorClient::didEndEditing() +{ + static const String WebViewDidEndEditingNotification = "WebViewDidEndEditingNotification"; + m_page->injectedBundleEditorClient().didEndEditing(m_page, WebViewDidEndEditingNotification.impl()); + notImplemented(); +} + +void WebEditorClient::didWriteSelectionToPasteboard() +{ + notImplemented(); +} + +void WebEditorClient::didSetSelectionTypesForPasteboard() +{ + notImplemented(); +} + +void WebEditorClient::registerCommandForUndo(PassRefPtr<EditCommand> command) +{ + // FIXME: Add assertion that the command being reapplied is the same command that is + // being passed to us. + if (m_page->isInRedo()) + return; + + RefPtr<WebEditCommand> webCommand = WebEditCommand::create(command); + m_page->addWebEditCommand(webCommand->commandID(), webCommand.get()); + uint32_t editAction = static_cast<uint32_t>(webCommand->command()->editingAction()); + + m_page->send(Messages::WebPageProxy::RegisterEditCommandForUndo(webCommand->commandID(), editAction)); +} + +void WebEditorClient::registerCommandForRedo(PassRefPtr<EditCommand>) +{ +} + +void WebEditorClient::clearUndoRedoOperations() +{ + m_page->send(Messages::WebPageProxy::ClearAllEditCommands()); +} + +bool WebEditorClient::canUndo() const +{ + notImplemented(); + return false; +} + +bool WebEditorClient::canRedo() const +{ + notImplemented(); + return false; +} + +void WebEditorClient::undo() +{ + notImplemented(); +} + +void WebEditorClient::redo() +{ + notImplemented(); +} + +#if !PLATFORM(MAC) +void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event) +{ + if (m_page->handleEditingKeyboardEvent(event)) + event->setDefaultHandled(); +} + +void WebEditorClient::handleInputMethodKeydown(KeyboardEvent*) +{ + notImplemented(); +} +#endif + +void WebEditorClient::textFieldDidBeginEditing(Element* element) +{ + if (!element->hasTagName(inputTag)) + return; + + WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(element->document()->frame()->loader()->client())->webFrame(); + m_page->injectedBundleFormClient().textFieldDidBeginEditing(m_page, static_cast<HTMLInputElement*>(element), webFrame); +} + +void WebEditorClient::textFieldDidEndEditing(Element* element) +{ + if (!element->hasTagName(inputTag)) + return; + + WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(element->document()->frame()->loader()->client())->webFrame(); + m_page->injectedBundleFormClient().textFieldDidEndEditing(m_page, static_cast<HTMLInputElement*>(element), webFrame); +} + +void WebEditorClient::textDidChangeInTextField(Element* element) +{ + if (!element->hasTagName(inputTag)) + return; + + if (!UserTypingGestureIndicator::processingUserTypingGesture() || UserTypingGestureIndicator::focusedElementAtGestureStart() != element) + return; + + WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(element->document()->frame()->loader()->client())->webFrame(); + m_page->injectedBundleFormClient().textDidChangeInTextField(m_page, static_cast<HTMLInputElement*>(element), webFrame); +} + +void WebEditorClient::textDidChangeInTextArea(Element* element) +{ + if (!element->hasTagName(textareaTag)) + return; + + WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(element->document()->frame()->loader()->client())->webFrame(); + m_page->injectedBundleFormClient().textDidChangeInTextArea(m_page, static_cast<HTMLTextAreaElement*>(element), webFrame); +} + +static bool getActionTypeForKeyEvent(KeyboardEvent* event, WKInputFieldActionType& type) +{ + String key = event->keyIdentifier(); + if (key == "Up") + type = WKInputFieldActionTypeMoveUp; + else if (key == "Down") + type = WKInputFieldActionTypeMoveDown; + else if (key == "U+001B") + type = WKInputFieldActionTypeCancel; + else if (key == "U+0009") { + if (event->shiftKey()) + type = WKInputFieldActionTypeInsertBacktab; + else + type = WKInputFieldActionTypeInsertTab; + } else if (key == "Enter") + type = WKInputFieldActionTypeInsertNewline; + else + return false; + + return true; +} + +bool WebEditorClient::doTextFieldCommandFromEvent(Element* element, KeyboardEvent* event) +{ + if (!element->hasTagName(inputTag)) + return false; + + WKInputFieldActionType actionType = static_cast<WKInputFieldActionType>(0); + if (!getActionTypeForKeyEvent(event, actionType)) + return false; + + WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(element->document()->frame()->loader()->client())->webFrame(); + return m_page->injectedBundleFormClient().shouldPerformActionInTextField(m_page, static_cast<HTMLInputElement*>(element), actionType, webFrame); +} + +void WebEditorClient::textWillBeDeletedInTextField(Element* element) +{ + if (!element->hasTagName(inputTag)) + return; + + WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(element->document()->frame()->loader()->client())->webFrame(); + m_page->injectedBundleFormClient().shouldPerformActionInTextField(m_page, static_cast<HTMLInputElement*>(element), WKInputFieldActionTypeInsertDelete, webFrame); +} + +void WebEditorClient::ignoreWordInSpellDocument(const String& word) +{ + m_page->send(Messages::WebPageProxy::IgnoreWord(word)); +} + +void WebEditorClient::learnWord(const String& word) +{ + m_page->send(Messages::WebPageProxy::LearnWord(word)); +} + +void WebEditorClient::checkSpellingOfString(const UChar*, int, int*, int*) +{ + notImplemented(); +} + +String WebEditorClient::getAutoCorrectSuggestionForMisspelledWord(const String&) +{ + notImplemented(); + return String(); +} + +void WebEditorClient::checkGrammarOfString(const UChar*, int, Vector<GrammarDetail>&, int*, int*) +{ + notImplemented(); +} + +void WebEditorClient::updateSpellingUIWithGrammarString(const String&, const GrammarDetail&) +{ + notImplemented(); +} + +void WebEditorClient::updateSpellingUIWithMisspelledWord(const String& misspelledWord) +{ + m_page->send(Messages::WebPageProxy::UpdateSpellingUIWithMisspelledWord(misspelledWord)); +} + +void WebEditorClient::showSpellingUI(bool) +{ + notImplemented(); +} + +bool WebEditorClient::spellingUIIsShowing() +{ + notImplemented(); + return false; +} + +void WebEditorClient::getGuessesForWord(const String& word, const String& context, Vector<String>& guesses) +{ + m_page->sendSync(Messages::WebPageProxy::GetGuessesForWord(word, context), Messages::WebPageProxy::GetGuessesForWord::Reply(guesses)); +} + +void WebEditorClient::willSetInputMethodState() +{ + notImplemented(); +} + +void WebEditorClient::setInputMethodState(bool) +{ + notImplemented(); +} + +void WebEditorClient::requestCheckingOfString(WebCore::SpellChecker*, int, const WTF::String&) +{ + notImplemented(); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h new file mode 100644 index 0000000..40bd8c6 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebEditorClient_h +#define WebEditorClient_h + +#include <WebCore/EditorClient.h> + +namespace WebKit { + +class WebPage; + +class WebEditorClient : public WebCore::EditorClient { +public: + WebEditorClient(WebPage* page) + : m_page(page) + { + } + +private: + virtual void pageDestroyed(); + + virtual bool shouldDeleteRange(WebCore::Range*); + virtual bool shouldShowDeleteInterface(WebCore::HTMLElement*); + virtual bool smartInsertDeleteEnabled(); + virtual bool isSelectTrailingWhitespaceEnabled(); + virtual bool isContinuousSpellCheckingEnabled(); + virtual void toggleContinuousSpellChecking(); + virtual bool isGrammarCheckingEnabled(); + virtual void toggleGrammarChecking(); + virtual int spellCheckerDocumentTag(); + + virtual bool isEditable(); + + virtual bool shouldBeginEditing(WebCore::Range*); + virtual bool shouldEndEditing(WebCore::Range*); + virtual bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction); + virtual bool shouldInsertText(const String&, WebCore::Range*, WebCore::EditorInsertAction); + virtual bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting); + + virtual bool shouldApplyStyle(WebCore::CSSStyleDeclaration*, WebCore::Range*); + virtual bool shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range*); + + virtual void didBeginEditing(); + virtual void respondToChangedContents(); + virtual void respondToChangedSelection(); + virtual void didEndEditing(); + virtual void didWriteSelectionToPasteboard(); + virtual void didSetSelectionTypesForPasteboard(); + + virtual void registerCommandForUndo(PassRefPtr<WebCore::EditCommand>); + virtual void registerCommandForRedo(PassRefPtr<WebCore::EditCommand>); + virtual void clearUndoRedoOperations(); + + virtual bool canUndo() const; + virtual bool canRedo() const; + + virtual void undo(); + virtual void redo(); + + virtual void handleKeyboardEvent(WebCore::KeyboardEvent*); + virtual void handleInputMethodKeydown(WebCore::KeyboardEvent*); + + virtual void textFieldDidBeginEditing(WebCore::Element*); + virtual void textFieldDidEndEditing(WebCore::Element*); + virtual void textDidChangeInTextField(WebCore::Element*); + virtual bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*); + virtual void textWillBeDeletedInTextField(WebCore::Element*); + virtual void textDidChangeInTextArea(WebCore::Element*); + +#if PLATFORM(MAC) + virtual NSString *userVisibleString(NSURL *); + virtual WebCore::DocumentFragment* documentFragmentFromAttributedString(NSAttributedString *, Vector< RefPtr<WebCore::ArchiveResource> >&); + virtual void setInsertionPasteboard(NSPasteboard *); + virtual NSURL* canonicalizeURL(NSURL*); + virtual NSURL* canonicalizeURLString(NSString*); +#ifdef BUILDING_ON_TIGER + virtual NSArray *pasteboardTypesForSelection(WebCore::Frame*); +#endif +#endif + +#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + virtual void uppercaseWord(); + virtual void lowercaseWord(); + virtual void capitalizeWord(); + virtual void showSubstitutionsPanel(bool show); + virtual bool substitutionsPanelIsShowing(); + virtual void toggleSmartInsertDelete(); + virtual bool isAutomaticQuoteSubstitutionEnabled(); + virtual void toggleAutomaticQuoteSubstitution(); + virtual bool isAutomaticLinkDetectionEnabled(); + virtual void toggleAutomaticLinkDetection(); + virtual bool isAutomaticDashSubstitutionEnabled(); + virtual void toggleAutomaticDashSubstitution(); + virtual bool isAutomaticTextReplacementEnabled(); + virtual void toggleAutomaticTextReplacement(); + virtual bool isAutomaticSpellingCorrectionEnabled(); + virtual void toggleAutomaticSpellingCorrection(); +#endif + + virtual void ignoreWordInSpellDocument(const String&); + virtual void learnWord(const String&); + virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength); + virtual String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord); + virtual void checkGrammarOfString(const UChar*, int length, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength); +#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + virtual void checkTextOfParagraph(const UChar* text, int length, uint64_t checkingTypes, Vector<WebCore::TextCheckingResult>& results); +#endif + virtual void updateSpellingUIWithGrammarString(const String&, const WebCore::GrammarDetail& detail); + virtual void updateSpellingUIWithMisspelledWord(const String&); + virtual void showSpellingUI(bool show); + virtual bool spellingUIIsShowing(); + virtual void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses); + virtual void willSetInputMethodState(); + virtual void setInputMethodState(bool enabled); + virtual void requestCheckingOfString(WebCore::SpellChecker*, int, const WTF::String&); +#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) + virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings, WebCore::Editor*); + virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel); + virtual bool isShowingCorrectionPanel(); +#endif + WebPage* m_page; +}; + +} // namespace WebKit + +#endif // WebEditorClient_h diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebErrors.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebErrors.h new file mode 100644 index 0000000..ed43c57 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebErrors.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebErrors_h +#define WebErrors_h + +#include <WebCore/ResourceError.h> +#include <WebCore/ResourceRequest.h> +#include <WebCore/ResourceResponse.h> + +namespace WebKit { + +WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&); +WebCore::ResourceError blockedError(const WebCore::ResourceRequest&); +WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&); +WebCore::ResourceError interruptForPolicyChangeError(const WebCore::ResourceRequest&); +WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&); +WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&); +WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&); + +} // namespace WebKit + +#endif // WebErrors_h diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp new file mode 100644 index 0000000..49ce240 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp @@ -0,0 +1,1300 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebFrameLoaderClient.h" + +#define DISABLE_NOT_IMPLEMENTED_WARNINGS 1 +#include "NotImplemented.h" + +#include "AuthenticationManager.h" +#include "DataReference.h" +#include "InjectedBundleUserMessageCoders.h" +#include "PlatformCertificateInfo.h" +#include "PluginView.h" +#include "StringPairVector.h" +#include "WebContextMessages.h" +#include "WebCoreArgumentCoders.h" +#include "WebErrors.h" +#include "WebEvent.h" +#include "WebFrame.h" +#include "WebFrameNetworkingContext.h" +#include "WebNavigationDataStore.h" +#include "WebPage.h" +#include "WebPageProxyMessages.h" +#include "WebProcess.h" +#include "WebProcessProxyMessageKinds.h" +#include "WebProcessProxyMessages.h" +#include <JavaScriptCore/APICast.h> +#include <JavaScriptCore/JSObject.h> +#include <WebCore/Chrome.h> +#include <WebCore/DOMWrapperWorld.h> +#include <WebCore/DocumentLoader.h> +#include <WebCore/FormState.h> +#include <WebCore/Frame.h> +#include <WebCore/FrameLoadRequest.h> +#include <WebCore/FrameView.h> +#include <WebCore/HTMLAppletElement.h> +#include <WebCore/HTMLFormElement.h> +#include <WebCore/MIMETypeRegistry.h> +#include <WebCore/MouseEvent.h> +#include <WebCore/Page.h> +#include <WebCore/PluginData.h> +#include <WebCore/ProgressTracker.h> +#include <WebCore/ResourceError.h> +#include <WebCore/UIEventWithKeyState.h> +#include <WebCore/Widget.h> +#include <WebCore/WindowFeatures.h> + +using namespace WebCore; + +namespace WebKit { + +WebFrameLoaderClient::WebFrameLoaderClient(WebFrame* frame) + : m_frame(frame) + , m_hasSentResponseToPluginView(false) + , m_frameHasCustomRepresentation(false) +{ +} + +WebFrameLoaderClient::~WebFrameLoaderClient() +{ +} + +void WebFrameLoaderClient::frameLoaderDestroyed() +{ + m_frame->invalidate(); + + // Balances explicit ref() in WebFrame::createMainFrame and WebFrame::createSubframe. + m_frame->deref(); +} + +bool WebFrameLoaderClient::hasHTMLView() const +{ + return !m_frameHasCustomRepresentation; +} + +bool WebFrameLoaderClient::hasWebView() const +{ + return m_frame->page(); +} + +void WebFrameLoaderClient::makeRepresentation(DocumentLoader*) +{ + notImplemented(); +} + +void WebFrameLoaderClient::forceLayout() +{ + notImplemented(); +} + +void WebFrameLoaderClient::forceLayoutForNonHTML() +{ + notImplemented(); +} + +void WebFrameLoaderClient::setCopiesOnScroll() +{ + notImplemented(); +} + +void WebFrameLoaderClient::detachedFromParent2() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + RefPtr<APIObject> userData; + + // Notify the bundle client. + webPage->injectedBundleLoaderClient().didRemoveFrameFromHierarchy(webPage, m_frame, userData); + + // Notify the UIProcess. + webPage->send(Messages::WebPageProxy::DidRemoveFrameFromHierarchy(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get()))); + +} + +void WebFrameLoaderClient::detachedFromParent3() +{ + notImplemented(); +} + +void WebFrameLoaderClient::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest& request) +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + webPage->send(Messages::WebPageProxy::DidInitiateLoadForResource(m_frame->frameID(), identifier, request)); +} + +void WebFrameLoaderClient::dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse) +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + if (!webPage->injectedBundleLoaderClient().shouldLoadResourceForFrame(webPage, m_frame, request.url().string())) { + request = ResourceRequest(); + // FIXME: We should probably send a message saying we cancelled the request for the resource. + return; + } + + webPage->send(Messages::WebPageProxy::DidSendRequestForResource(m_frame->frameID(), identifier, request, redirectResponse)); +} + +bool WebFrameLoaderClient::shouldUseCredentialStorage(DocumentLoader*, unsigned long identifier) +{ + return true; +} + +void WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge& challenge) +{ + // FIXME: Authentication is a per-resource concept, but we don't do per-resource handling in the UIProcess at the API level quite yet. + // Once we do, we might need to make sure authentication fits with our solution. + + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + AuthenticationManager::shared().didReceiveAuthenticationChallenge(m_frame, challenge); +} + +void WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) +{ + notImplemented(); +} + +#if USE(PROTECTION_SPACE_AUTH_CALLBACK) +bool WebFrameLoaderClient::canAuthenticateAgainstProtectionSpace(DocumentLoader*, unsigned long, const ProtectionSpace& protectionSpace) +{ + // FIXME: Authentication is a per-resource concept, but we don't do per-resource handling in the UIProcess at the API level quite yet. + // Once we do, we might need to make sure authentication fits with our solution. + + WebPage* webPage = m_frame->page(); + if (!webPage) + return false; + + bool canAuthenticate; + if (!webPage->sendSync(Messages::WebPageProxy::CanAuthenticateAgainstProtectionSpaceInFrame(m_frame->frameID(), protectionSpace), Messages::WebPageProxy::CanAuthenticateAgainstProtectionSpaceInFrame::Reply(canAuthenticate))) + return false; + + return canAuthenticate; +} +#endif + +void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse& response) +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + webPage->send(Messages::WebPageProxy::DidReceiveResponseForResource(m_frame->frameID(), identifier, response)); +} + +void WebFrameLoaderClient::dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int lengthReceived) +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + webPage->send(Messages::WebPageProxy::DidReceiveContentLengthForResource(m_frame->frameID(), identifier, lengthReceived)); +} + +void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier) +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + webPage->send(Messages::WebPageProxy::DidFinishLoadForResource(m_frame->frameID(), identifier)); +} + +void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError& error) +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + webPage->send(Messages::WebPageProxy::DidFailLoadForResource(m_frame->frameID(), identifier, error)); +} + +bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length) +{ + notImplemented(); + return false; +} + +void WebFrameLoaderClient::dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const String&) +{ + notImplemented(); +} + +void WebFrameLoaderClient::dispatchDidHandleOnloadEvents() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + // Notify the bundle client. + webPage->injectedBundleLoaderClient().didHandleOnloadEventsForFrame(webPage, m_frame); +} + +void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + DocumentLoader* provisionalLoader = m_frame->coreFrame()->loader()->provisionalDocumentLoader(); + const String& url = provisionalLoader->url().string(); + RefPtr<APIObject> userData; + + // Notify the bundle client. + webPage->injectedBundleLoaderClient().didReceiveServerRedirectForProvisionalLoadForFrame(webPage, m_frame, userData); + + // Notify the UIProcess. + webPage->send(Messages::WebPageProxy::DidReceiveServerRedirectForProvisionalLoadForFrame(m_frame->frameID(), url, InjectedBundleUserMessageEncoder(userData.get()))); +} + +void WebFrameLoaderClient::dispatchDidCancelClientRedirect() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + // Notify the bundle client. + webPage->injectedBundleLoaderClient().didCancelClientRedirectForFrame(webPage, m_frame); +} + +void WebFrameLoaderClient::dispatchWillPerformClientRedirect(const KURL& url, double interval, double fireDate) +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + // Notify the bundle client. + webPage->injectedBundleLoaderClient().willPerformClientRedirectForFrame(webPage, m_frame, url.string(), interval, fireDate); +} + +void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + RefPtr<APIObject> userData; + + // Notify the bundle client. + webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationAnchorNavigation, userData); + + // Notify the UIProcess. + webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationAnchorNavigation, m_frame->coreFrame()->loader()->url().string(), InjectedBundleUserMessageEncoder(userData.get()))); +} + +void WebFrameLoaderClient::dispatchDidPushStateWithinPage() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + RefPtr<APIObject> userData; + + // Notify the bundle client. + webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationSessionStatePush, userData); + + // Notify the UIProcess. + webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationSessionStatePush, m_frame->coreFrame()->loader()->url().string(), InjectedBundleUserMessageEncoder(userData.get()))); +} + +void WebFrameLoaderClient::dispatchDidReplaceStateWithinPage() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + RefPtr<APIObject> userData; + + // Notify the bundle client. + webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationSessionStateReplace, userData); + + // Notify the UIProcess. + webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationSessionStateReplace, m_frame->coreFrame()->loader()->url().string(), InjectedBundleUserMessageEncoder(userData.get()))); +} + +void WebFrameLoaderClient::dispatchDidPopStateWithinPage() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + RefPtr<APIObject> userData; + + // Notify the bundle client. + webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationSessionStatePop, userData); + + // Notify the UIProcess. + webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationSessionStatePop, m_frame->coreFrame()->loader()->url().string(), InjectedBundleUserMessageEncoder(userData.get()))); +} + +void WebFrameLoaderClient::dispatchWillClose() +{ + notImplemented(); +} + +void WebFrameLoaderClient::dispatchDidReceiveIcon() +{ + notImplemented(); +} + +void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + webPage->findController().hideFindUI(); + + DocumentLoader* provisionalLoader = m_frame->coreFrame()->loader()->provisionalDocumentLoader(); + const String& url = provisionalLoader->url().string(); + RefPtr<APIObject> userData; + + // Notify the bundle client. + webPage->injectedBundleLoaderClient().didStartProvisionalLoadForFrame(webPage, m_frame, userData); + + bool loadingSubstituteDataForUnreachableURL = !provisionalLoader->unreachableURL().isNull(); + + webPage->sandboxExtensionTracker().didStartProvisionalLoad(m_frame); + + // Notify the UIProcess. + webPage->send(Messages::WebPageProxy::DidStartProvisionalLoadForFrame(m_frame->frameID(), url, loadingSubstituteDataForUnreachableURL, InjectedBundleUserMessageEncoder(userData.get()))); +} + +void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title) +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + RefPtr<APIObject> userData; + + // Notify the bundle client. + webPage->injectedBundleLoaderClient().didReceiveTitleForFrame(webPage, title, m_frame, userData); + + // Notify the UIProcess. + webPage->send(Messages::WebPageProxy::DidReceiveTitleForFrame(m_frame->frameID(), title, InjectedBundleUserMessageEncoder(userData.get()))); +} + +void WebFrameLoaderClient::dispatchDidChangeIcons() +{ + notImplemented(); +} + +void WebFrameLoaderClient::dispatchDidCommitLoad() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + const ResourceResponse& response = m_frame->coreFrame()->loader()->documentLoader()->response(); + RefPtr<APIObject> userData; + + // Notify the bundle client. + webPage->injectedBundleLoaderClient().didCommitLoadForFrame(webPage, m_frame, userData); + + webPage->sandboxExtensionTracker().didCommitProvisionalLoad(m_frame); + + // Notify the UIProcess. + webPage->send(Messages::WebPageProxy::DidCommitLoadForFrame(m_frame->frameID(), response.mimeType(), m_frameHasCustomRepresentation, PlatformCertificateInfo(response), InjectedBundleUserMessageEncoder(userData.get()))); +} + +void WebFrameLoaderClient::dispatchDidFailProvisionalLoad(const ResourceError& error) +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + RefPtr<APIObject> userData; + + // Notify the bundle client. + webPage->injectedBundleLoaderClient().didFailProvisionalLoadWithErrorForFrame(webPage, m_frame, error, userData); + + webPage->sandboxExtensionTracker().didFailProvisionalLoad(m_frame); + + // Notify the UIProcess. + webPage->send(Messages::WebPageProxy::DidFailProvisionalLoadForFrame(m_frame->frameID(), error, InjectedBundleUserMessageEncoder(userData.get()))); + + // If we have a load listener, notify it. + if (WebFrame::LoadListener* loadListener = m_frame->loadListener()) + loadListener->didFailLoad(m_frame, error.isCancellation()); +} + +void WebFrameLoaderClient::dispatchDidFailLoad(const ResourceError& error) +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + RefPtr<APIObject> userData; + + // Notify the bundle client. + webPage->injectedBundleLoaderClient().didFailLoadWithErrorForFrame(webPage, m_frame, error, userData); + + // Notify the UIProcess. + webPage->send(Messages::WebPageProxy::DidFailLoadForFrame(m_frame->frameID(), error, InjectedBundleUserMessageEncoder(userData.get()))); + + // If we have a load listener, notify it. + if (WebFrame::LoadListener* loadListener = m_frame->loadListener()) + loadListener->didFailLoad(m_frame, error.isCancellation()); +} + +void WebFrameLoaderClient::dispatchDidFinishDocumentLoad() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + RefPtr<APIObject> userData; + + // Notify the bundle client. + webPage->injectedBundleLoaderClient().didFinishDocumentLoadForFrame(webPage, m_frame, userData); + + // Notify the UIProcess. + webPage->send(Messages::WebPageProxy::DidFinishDocumentLoadForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get()))); +} + +void WebFrameLoaderClient::dispatchDidFinishLoad() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + RefPtr<APIObject> userData; + + // Notify the bundle client. + webPage->injectedBundleLoaderClient().didFinishLoadForFrame(webPage, m_frame, userData); + + // Notify the UIProcess. + webPage->send(Messages::WebPageProxy::DidFinishLoadForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get()))); + + // If we have a load listener, notify it. + if (WebFrame::LoadListener* loadListener = m_frame->loadListener()) + loadListener->didFinishLoad(m_frame); +} + +void WebFrameLoaderClient::dispatchDidFirstLayout() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + RefPtr<APIObject> userData; + + // Notify the bundle client. + webPage->injectedBundleLoaderClient().didFirstLayoutForFrame(webPage, m_frame, userData); + + // Notify the UIProcess. + webPage->send(Messages::WebPageProxy::DidFirstLayoutForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get()))); +} + +void WebFrameLoaderClient::dispatchDidFirstVisuallyNonEmptyLayout() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + RefPtr<APIObject> userData; + + // Notify the bundle client. + webPage->injectedBundleLoaderClient().didFirstVisuallyNonEmptyLayoutForFrame(webPage, m_frame, userData); + + // Notify the UIProcess. + webPage->send(Messages::WebPageProxy::DidFirstVisuallyNonEmptyLayoutForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get()))); +} + +Frame* WebFrameLoaderClient::dispatchCreatePage(const NavigationAction& navigationAction) +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return 0; + + // Just call through to the chrome client. + Page* newPage = webPage->corePage()->chrome()->createWindow(m_frame->coreFrame(), FrameLoadRequest(m_frame->coreFrame()->document()->securityOrigin()), WindowFeatures(), navigationAction); + if (!newPage) + return 0; + + return newPage->mainFrame(); +} + +void WebFrameLoaderClient::dispatchShow() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + webPage->show(); +} + +uint32_t modifiersForNavigationAction(const NavigationAction& navigationAction) +{ + uint32_t modifiers = 0; + if (const UIEventWithKeyState* keyStateEvent = findEventWithKeyState(const_cast<Event*>(navigationAction.event()))) { + if (keyStateEvent->shiftKey()) + modifiers |= WebEvent::ShiftKey; + if (keyStateEvent->ctrlKey()) + modifiers |= WebEvent::ControlKey; + if (keyStateEvent->altKey()) + modifiers |= WebEvent::AltKey; + if (keyStateEvent->metaKey()) + modifiers |= WebEvent::MetaKey; + } + + return modifiers; +} + +static const MouseEvent* findMouseEvent(const Event* event) +{ + for (const Event* e = event; e; e = e->underlyingEvent()) { + if (e->isMouseEvent()) + return static_cast<const MouseEvent*>(e); + } + return 0; +} + +int32_t mouseButtonForNavigationAction(const NavigationAction& navigationAction) +{ + const MouseEvent* mouseEvent = findMouseEvent(navigationAction.event()); + if (!mouseEvent) + return -1; + + if (!mouseEvent->buttonDown()) + return -1; + + return mouseEvent->button(); +} + +void WebFrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const String& MIMEType, const ResourceRequest& request) +{ + if (m_frame->coreFrame()->loader()->documentLoader()->url().isEmpty() && request.url() == blankURL()) { + // WebKit2 loads initial about:blank documents synchronously, without consulting the policy delegate + ASSERT(m_frame->coreFrame()->loader()->stateMachine()->committingFirstRealLoad()); + (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse); + return; + } + + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + uint64_t listenerID = m_frame->setUpPolicyListener(function); + const String& url = request.url().string(); // FIXME: Pass entire request. + + bool receivedPolicyAction; + uint64_t policyAction; + uint64_t downloadID; + if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForMIMEType(m_frame->frameID(), MIMEType, url, listenerID), Messages::WebPageProxy::DecidePolicyForMIMEType::Reply(receivedPolicyAction, policyAction, downloadID))) + return; + + // We call this synchronously because CFNetwork can only convert a loading connection to a download from its didReceiveResponse callback. + if (receivedPolicyAction) + m_frame->didReceivePolicyDecision(listenerID, static_cast<PolicyAction>(policyAction), downloadID); +} + +void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState>, const String& frameName) +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + uint64_t listenerID = m_frame->setUpPolicyListener(function); + + // FIXME: Pass more than just the navigation action type. + // FIXME: Pass the frame name. + const String& url = request.url().string(); // FIXME: Pass entire request. + + uint32_t navigationType = static_cast<uint32_t>(navigationAction.type()); + uint32_t modifiers = modifiersForNavigationAction(navigationAction); + int32_t mouseButton = mouseButtonForNavigationAction(navigationAction); + + webPage->send(Messages::WebPageProxy::DecidePolicyForNewWindowAction(m_frame->frameID(), navigationType, modifiers, mouseButton, url, listenerID)); +} + +void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState>) +{ + if (m_frame->coreFrame()->loader()->documentLoader()->url().isEmpty() && request.url() == blankURL()) { + // WebKit2 loads initial about:blank documents synchronously, without consulting the policy delegate + ASSERT(m_frame->coreFrame()->loader()->stateMachine()->committingFirstRealLoad()); + (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse); + return; + } + + // Always ignore requests with empty URLs. + if (request.isEmpty()) { + (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyIgnore); + return; + } + + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + uint64_t listenerID = m_frame->setUpPolicyListener(function); + + // FIXME: Pass more than just the navigation action type. + const String& url = request.url().string(); // FIXME: Pass entire request. + + uint32_t navigationType = static_cast<uint32_t>(navigationAction.type()); + uint32_t modifiers = modifiersForNavigationAction(navigationAction); + int32_t mouseButton = mouseButtonForNavigationAction(navigationAction); + + webPage->send(Messages::WebPageProxy::DecidePolicyForNavigationAction(m_frame->frameID(), navigationType, modifiers, mouseButton, url, listenerID)); +} + +void WebFrameLoaderClient::cancelPolicyCheck() +{ + m_frame->invalidatePolicyListener(); +} + +void WebFrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError&) +{ + notImplemented(); +} + +void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function, PassRefPtr<FormState> prpFormState) +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + // FIXME: Pass more of the form state. + RefPtr<FormState> formState = prpFormState; + + HTMLFormElement* form = formState->form(); + WebFrame* sourceFrame = static_cast<WebFrameLoaderClient*>(formState->sourceFrame()->loader()->client())->webFrame(); + const Vector<std::pair<String, String> >& values = formState->textFieldValues(); + + RefPtr<APIObject> userData; + webPage->injectedBundleFormClient().willSubmitForm(webPage, form, m_frame, sourceFrame, values, userData); + + + uint64_t listenerID = m_frame->setUpPolicyListener(function); + StringPairVector valuesVector(values); + + webPage->send(Messages::WebPageProxy::WillSubmitForm(m_frame->frameID(), sourceFrame->frameID(), valuesVector, listenerID, InjectedBundleUserMessageEncoder(userData.get()))); +} + +void WebFrameLoaderClient::dispatchDidLoadMainResource(DocumentLoader*) +{ + notImplemented(); +} + +void WebFrameLoaderClient::revertToProvisionalState(DocumentLoader*) +{ + notImplemented(); +} + +void WebFrameLoaderClient::setMainDocumentError(DocumentLoader*, const ResourceError& error) +{ + if (!m_pluginView) + return; + + m_pluginView->manualLoadDidFail(error); + m_pluginView = 0; + m_hasSentResponseToPluginView = false; +} + +void WebFrameLoaderClient::willChangeEstimatedProgress() +{ + notImplemented(); +} + +void WebFrameLoaderClient::didChangeEstimatedProgress() +{ + notImplemented(); +} + +void WebFrameLoaderClient::postProgressStartedNotification() +{ + if (WebPage* webPage = m_frame->page()) + webPage->send(Messages::WebPageProxy::DidStartProgress()); +} + +void WebFrameLoaderClient::postProgressEstimateChangedNotification() +{ + if (WebPage* webPage = m_frame->page()) { + double progress = webPage->corePage()->progress()->estimatedProgress(); + webPage->send(Messages::WebPageProxy::DidChangeProgress(progress)); + + } +} + +void WebFrameLoaderClient::postProgressFinishedNotification() +{ + if (WebPage* webPage = m_frame->page()) + webPage->send(Messages::WebPageProxy::DidFinishProgress()); +} + +void WebFrameLoaderClient::setMainFrameDocumentReady(bool) +{ + notImplemented(); +} + +void WebFrameLoaderClient::startDownload(const ResourceRequest& request) +{ + m_frame->startDownload(request); +} + +void WebFrameLoaderClient::willChangeTitle(DocumentLoader*) +{ + notImplemented(); +} + +void WebFrameLoaderClient::didChangeTitle(DocumentLoader*) +{ + notImplemented(); +} + +void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, const char* data, int length) +{ + // If we're loading a custom representation, we don't want to hand off the data to WebCore. + if (m_frameHasCustomRepresentation) + return; + + if (!m_pluginView) + loader->commitData(data, length); + + // If the document is a stand-alone media document, now is the right time to cancel the WebKit load. + // FIXME: This code should be shared across all ports. <http://webkit.org/b/48762>. + if (m_frame->coreFrame()->document()->isMediaDocument()) + loader->cancelMainResourceLoad(pluginWillHandleLoadError(loader->response())); + + // Calling commitData did not create the plug-in view. + if (!m_pluginView) + return; + + if (!m_hasSentResponseToPluginView) { + m_pluginView->manualLoadDidReceiveResponse(loader->response()); + // manualLoadDidReceiveResponse sets up a new stream to the plug-in. on a full-page plug-in, a failure in + // setting up this stream can cause the main document load to be cancelled, setting m_pluginView + // to null + if (!m_pluginView) + return; + m_hasSentResponseToPluginView = true; + } + m_pluginView->manualLoadDidReceiveData(data, length); +} + +void WebFrameLoaderClient::finishedLoading(DocumentLoader* loader) +{ + if (!m_pluginView) { + committedLoad(loader, 0, 0); + + if (m_frameHasCustomRepresentation) { + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + RefPtr<SharedBuffer> mainResourceData = loader->mainResourceData(); + CoreIPC::DataReference dataReference(reinterpret_cast<const uint8_t*>(mainResourceData ? mainResourceData->data() : 0), mainResourceData ? mainResourceData->size() : 0); + + webPage->send(Messages::WebPageProxy::DidFinishLoadingDataForCustomRepresentation(dataReference)); + } + + return; + } + + m_pluginView->manualLoadDidFinishLoading(); + m_pluginView = 0; + m_hasSentResponseToPluginView = false; +} + +void WebFrameLoaderClient::updateGlobalHistory() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + DocumentLoader* loader = m_frame->coreFrame()->loader()->documentLoader(); + + WebNavigationDataStore data; + data.url = loader->urlForHistory().string(); + data.title = loader->title(); + + WebProcess::shared().connection()->send(Messages::WebContext::DidNavigateWithNavigationData(webPage->pageID(), data, m_frame->frameID()), 0); +} + +void WebFrameLoaderClient::updateGlobalHistoryRedirectLinks() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + DocumentLoader* loader = m_frame->coreFrame()->loader()->documentLoader(); + ASSERT(loader->unreachableURL().isEmpty()); + + // Client redirect + if (!loader->clientRedirectSourceForHistory().isNull()) { + WebProcess::shared().connection()->send(Messages::WebContext::DidPerformClientRedirect(webPage->pageID(), + loader->clientRedirectSourceForHistory(), loader->clientRedirectDestinationForHistory(), m_frame->frameID()), 0); + } + + // Server redirect + if (!loader->serverRedirectSourceForHistory().isNull()) { + WebProcess::shared().connection()->send(Messages::WebContext::DidPerformServerRedirect(webPage->pageID(), + loader->serverRedirectSourceForHistory(), loader->serverRedirectDestinationForHistory(), m_frame->frameID()), 0); + } +} + +bool WebFrameLoaderClient::shouldGoToHistoryItem(HistoryItem*) const +{ + notImplemented(); + return true; +} + +void WebFrameLoaderClient::dispatchDidAddBackForwardItem(HistoryItem*) const +{ + notImplemented(); +} + +void WebFrameLoaderClient::dispatchDidRemoveBackForwardItem(HistoryItem*) const +{ + notImplemented(); +} + +void WebFrameLoaderClient::dispatchDidChangeBackForwardIndex() const +{ + notImplemented(); +} + +void WebFrameLoaderClient::didDisplayInsecureContent() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + RefPtr<APIObject> userData; + + webPage->injectedBundleLoaderClient().didDisplayInsecureContentForFrame(webPage, m_frame, userData); + + webPage->send(Messages::WebPageProxy::DidDisplayInsecureContentForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get()))); +} + +void WebFrameLoaderClient::didRunInsecureContent(SecurityOrigin*) +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + RefPtr<APIObject> userData; + + webPage->injectedBundleLoaderClient().didRunInsecureContentForFrame(webPage, m_frame, userData); + + webPage->send(Messages::WebPageProxy::DidRunInsecureContentForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get()))); +} + +ResourceError WebFrameLoaderClient::cancelledError(const ResourceRequest& request) +{ + return WebKit::cancelledError(request); +} + +ResourceError WebFrameLoaderClient::blockedError(const ResourceRequest& request) +{ + return WebKit::blockedError(request); +} + +ResourceError WebFrameLoaderClient::cannotShowURLError(const ResourceRequest& request) +{ + return WebKit::cannotShowURLError(request); +} + +ResourceError WebFrameLoaderClient::interruptForPolicyChangeError(const ResourceRequest& request) +{ + return WebKit::interruptForPolicyChangeError(request); +} + +ResourceError WebFrameLoaderClient::cannotShowMIMETypeError(const ResourceResponse& response) +{ + return WebKit::cannotShowMIMETypeError(response); +} + +ResourceError WebFrameLoaderClient::fileDoesNotExistError(const ResourceResponse& response) +{ + return WebKit::fileDoesNotExistError(response); +} + +ResourceError WebFrameLoaderClient::pluginWillHandleLoadError(const ResourceResponse& response) +{ + return WebKit::pluginWillHandleLoadError(response); +} + +bool WebFrameLoaderClient::shouldFallBack(const ResourceError& error) +{ + DEFINE_STATIC_LOCAL(const ResourceError, cancelledError, (this->cancelledError(ResourceRequest()))); + DEFINE_STATIC_LOCAL(const ResourceError, pluginWillHandleLoadError, (this->pluginWillHandleLoadError(ResourceResponse()))); + + if (error.errorCode() == cancelledError.errorCode() && error.domain() == cancelledError.domain()) + return false; + + if (error.errorCode() == pluginWillHandleLoadError.errorCode() && error.domain() == pluginWillHandleLoadError.domain()) + return false; + + return true; +} + +bool WebFrameLoaderClient::canHandleRequest(const ResourceRequest&) const +{ + notImplemented(); + return true; +} + +bool WebFrameLoaderClient::canShowMIMEType(const String& MIMEType) const +{ + notImplemented(); + return true; +} + +bool WebFrameLoaderClient::canShowMIMETypeAsHTML(const String& MIMEType) const +{ + return true; +} + +bool WebFrameLoaderClient::representationExistsForURLScheme(const String& URLScheme) const +{ + notImplemented(); + return false; +} + +String WebFrameLoaderClient::generatedMIMETypeForURLScheme(const String& URLScheme) const +{ + notImplemented(); + return String(); +} + +void WebFrameLoaderClient::frameLoadCompleted() +{ + notImplemented(); +} + +void WebFrameLoaderClient::saveViewStateToItem(HistoryItem*) +{ + notImplemented(); +} + +void WebFrameLoaderClient::restoreViewState() +{ + notImplemented(); +} + +void WebFrameLoaderClient::provisionalLoadStarted() +{ + notImplemented(); +} + +void WebFrameLoaderClient::didFinishLoad() +{ + // If we have a load listener, notify it. + if (WebFrame::LoadListener* loadListener = m_frame->loadListener()) + loadListener->didFinishLoad(m_frame); +} + +void WebFrameLoaderClient::prepareForDataSourceReplacement() +{ + notImplemented(); +} + +PassRefPtr<DocumentLoader> WebFrameLoaderClient::createDocumentLoader(const ResourceRequest& request, const SubstituteData& data) +{ + return DocumentLoader::create(request, data); +} + +void WebFrameLoaderClient::setTitle(const String& title, const KURL& url) +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + WebProcess::shared().connection()->send(Messages::WebContext::DidUpdateHistoryTitle(webPage->pageID(), + title, url.string(), m_frame->frameID()), 0); +} + +String WebFrameLoaderClient::userAgent(const KURL&) +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return String(); + + return webPage->userAgent(); +} + +void WebFrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame*) +{ +} + +void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame*) +{ +} + +void WebFrameLoaderClient::transitionToCommittedForNewPage() +{ + WebPage* webPage = m_frame->page(); + Color backgroundColor = webPage->drawsTransparentBackground() ? Color::transparent : Color::white; + + bool isMainFrame = webPage->mainFrame() == m_frame; + +#if ENABLE(TILED_BACKING_STORE) + IntSize currentVisibleContentSize = m_frame->coreFrame()->view() ? m_frame->coreFrame()->view()->actualVisibleContentRect().size() : IntSize(); + m_frame->coreFrame()->createView(webPage->size(), backgroundColor, false, webPage->resizesToContentsLayoutSize(), isMainFrame && webPage->resizesToContentsEnabled()); + + if (isMainFrame && webPage->resizesToContentsEnabled()) { + m_frame->coreFrame()->view()->setDelegatesScrolling(true); + m_frame->coreFrame()->view()->setPaintsEntireContents(true); + } + + // The HistoryController will update the scroll position later if needed. + m_frame->coreFrame()->view()->setActualVisibleContentRect(IntRect(IntPoint::zero(), currentVisibleContentSize)); +#else + const String& mimeType = m_frame->coreFrame()->loader()->documentLoader()->response().mimeType(); + m_frameHasCustomRepresentation = isMainFrame && WebProcess::shared().shouldUseCustomRepresentationForMIMEType(mimeType); + + m_frame->coreFrame()->createView(webPage->size(), backgroundColor, false, IntSize(), false); +#endif + + m_frame->coreFrame()->view()->setTransparent(!webPage->drawsBackground()); +} + +void WebFrameLoaderClient::didSaveToPageCache() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + if (m_frame->isMainFrame()) + return; + + webPage->send(Messages::WebPageProxy::DidSaveFrameToPageCache(m_frame->frameID())); +} + +void WebFrameLoaderClient::didRestoreFromPageCache() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + if (m_frame->isMainFrame()) + return; + + WebFrame* parentFrame = static_cast<WebFrameLoaderClient*>(m_frame->coreFrame()->tree()->parent()->loader()->client())->webFrame(); + webPage->send(Messages::WebPageProxy::DidRestoreFrameFromPageCache(m_frame->frameID(), parentFrame->frameID())); +} + +void WebFrameLoaderClient::dispatchDidBecomeFrameset(bool value) +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + webPage->send(Messages::WebPageProxy::FrameDidBecomeFrameSet(m_frame->frameID(), value)); +} + +bool WebFrameLoaderClient::canCachePage() const +{ + // We cannot cache frames that have custom representations because they are + // rendered in the UIProcess. + return !m_frameHasCustomRepresentation; +} + +void WebFrameLoaderClient::download(ResourceHandle* handle, const ResourceRequest& request, const ResourceRequest& initialRequest, const ResourceResponse& response) +{ + m_frame->convertHandleToDownload(handle, request, initialRequest, response); +} + +PassRefPtr<Frame> WebFrameLoaderClient::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, + const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) +{ + WebPage* webPage = m_frame->page(); + + RefPtr<WebFrame> subframe = WebFrame::createSubframe(webPage, name, ownerElement); + + Frame* coreSubframe = subframe->coreFrame(); + + // The creation of the frame may have run arbitrary JavaScript that removed it from the page already. + m_frame->coreFrame()->loader()->loadURLIntoChildFrame(url, referrer, coreSubframe); + + // The frame's onload handler may have removed it from the document. + if (!coreSubframe->tree()->parent()) + return 0; + + return coreSubframe; +} + +void WebFrameLoaderClient::didTransferChildFrameToNewDocument(Page*) +{ + notImplemented(); +} + +void WebFrameLoaderClient::transferLoadingResourceFromPage(unsigned long, DocumentLoader*, const ResourceRequest&, Page*) +{ + notImplemented(); +} + +PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugInElement* pluginElement, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually) +{ + ASSERT(paramNames.size() == paramValues.size()); + + WebPage* webPage = m_frame->page(); + ASSERT(webPage); + + Plugin::Parameters parameters; + parameters.url = url; + parameters.names = paramNames; + parameters.values = paramValues; + parameters.mimeType = mimeType; + parameters.loadManually = loadManually; + + // <rdar://problem/8440903>: AppleConnect has a bug where it does not + // understand the parameter names specified in the <object> element that + // embeds its plug-in. This hack works around the issue by converting the + // parameter names to lowercase before passing them to the plug-in. + // FIXME: This workaround should be dependent on site-specific quirks being + // enabled. This requires adding this setting to WebKit2's WebPreferences + // implementation. See <https://bugs.webkit.org/show_bug.cgi?id=46076>. + if (equalIgnoringCase(mimeType, "application/x-snkp")) { + for (size_t i = 0; i < paramNames.size(); ++i) + parameters.names[i] = paramNames[i].lower(); + } + + RefPtr<Plugin> plugin = webPage->createPlugin(parameters); + if (!plugin) + return 0; + + return PluginView::create(pluginElement, plugin.release(), parameters); +} + +void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget) +{ + ASSERT(!m_pluginView); + ASSERT(pluginWidget); + + m_pluginView = static_cast<PluginView*>(pluginWidget); +} + +PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize& pluginSize, HTMLAppletElement* appletElement, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues) +{ + return createPlugin(pluginSize, appletElement, KURL(), paramNames, paramValues, "application/x-java-applet", false); +} + +ObjectContentType WebFrameLoaderClient::objectContentType(const KURL& url, const String& mimeTypeIn) +{ + // FIXME: This should be merged with WebCore::FrameLoader::defaultObjectContentType when the plugin code + // is consolidated. + + String mimeType = mimeTypeIn; + if (mimeType.isEmpty()) + mimeType = MIMETypeRegistry::getMIMETypeForExtension(url.path().substring(url.path().reverseFind('.') + 1)); + + if (mimeType.isEmpty()) + return ObjectContentFrame; + + if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType)) + return WebCore::ObjectContentImage; + + if (WebPage* webPage = m_frame->page()) { + if (PluginData* pluginData = webPage->corePage()->pluginData()) { + if (pluginData->supportsMimeType(mimeType)) + return ObjectContentNetscapePlugin; + } + } + + if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType)) + return ObjectContentFrame; + + return ObjectContentNone; +} + +String WebFrameLoaderClient::overrideMediaType() const +{ + notImplemented(); + return String(); +} + +void WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world) +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + webPage->injectedBundleLoaderClient().didClearWindowObjectForFrame(webPage, m_frame, world); +} + +void WebFrameLoaderClient::documentElementAvailable() +{ + notImplemented(); +} + +void WebFrameLoaderClient::didPerformFirstNavigation() const +{ + notImplemented(); +} + +void WebFrameLoaderClient::registerForIconNotification(bool listen) +{ + notImplemented(); +} + +#if PLATFORM(MAC) + +RemoteAXObjectRef WebFrameLoaderClient::accessibilityRemoteObject() +{ + return m_frame->page()->accessibilityRemoteObject(); +} + +#if ENABLE(MAC_JAVA_BRIDGE) +jobject WebFrameLoaderClient::javaApplet(NSView*) { return 0; } +#endif +NSCachedURLResponse* WebFrameLoaderClient::willCacheResponse(DocumentLoader*, unsigned long identifier, NSCachedURLResponse* response) const +{ + return response; +} + +#endif +#if USE(CFNETWORK) +bool WebFrameLoaderClient::shouldCacheResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&, const unsigned char* data, unsigned long long length) +{ + return true; +} + +#endif + +bool WebFrameLoaderClient::shouldUsePluginDocument(const String& /*mimeType*/) const +{ + notImplemented(); + return false; +} + +PassRefPtr<FrameNetworkingContext> WebFrameLoaderClient::createNetworkingContext() +{ + return WebFrameNetworkingContext::create(m_frame->coreFrame()); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h new file mode 100644 index 0000000..29c8bdd --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h @@ -0,0 +1,230 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebFrameLoaderClient_h +#define WebFrameLoaderClient_h + +#include <WebCore/FrameLoaderClient.h> + +namespace WebKit { + +class PluginView; +class WebFrame; + +class WebFrameLoaderClient : public WebCore::FrameLoaderClient { +public: + WebFrameLoaderClient(WebFrame*); + ~WebFrameLoaderClient(); + + WebFrame* webFrame() const { return m_frame; } + + bool frameHasCustomRepresentation() const { return m_frameHasCustomRepresentation; } + +private: + virtual void frameLoaderDestroyed(); + + virtual bool hasHTMLView() const; + virtual bool hasWebView() const; + + virtual void makeRepresentation(WebCore::DocumentLoader*); + virtual void forceLayout(); + virtual void forceLayoutForNonHTML(); + + virtual void setCopiesOnScroll(); + + virtual void detachedFromParent2(); + virtual void detachedFromParent3(); + + virtual void assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&); + + virtual void dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse); + virtual bool shouldUseCredentialStorage(WebCore::DocumentLoader*, unsigned long identifier); + virtual void dispatchDidReceiveAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&); + virtual void dispatchDidCancelAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&); +#if USE(PROTECTION_SPACE_AUTH_CALLBACK) + virtual bool canAuthenticateAgainstProtectionSpace(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ProtectionSpace&); +#endif + virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&); + virtual void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int lengthReceived); + virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier); + virtual void dispatchDidFailLoading(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceError&); + virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length); + virtual void dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const WTF::String&); + + virtual void dispatchDidHandleOnloadEvents(); + virtual void dispatchDidReceiveServerRedirectForProvisionalLoad(); + virtual void dispatchDidCancelClientRedirect(); + virtual void dispatchWillPerformClientRedirect(const WebCore::KURL&, double interval, double fireDate); + virtual void dispatchDidChangeLocationWithinPage(); + virtual void dispatchDidPushStateWithinPage(); + virtual void dispatchDidReplaceStateWithinPage(); + virtual void dispatchDidPopStateWithinPage(); + virtual void dispatchWillClose(); + virtual void dispatchDidReceiveIcon(); + virtual void dispatchDidStartProvisionalLoad(); + virtual void dispatchDidReceiveTitle(const String& title); + virtual void dispatchDidChangeIcons(); + virtual void dispatchDidCommitLoad(); + virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&); + virtual void dispatchDidFailLoad(const WebCore::ResourceError&); + virtual void dispatchDidFinishDocumentLoad(); + virtual void dispatchDidFinishLoad(); + virtual void dispatchDidFirstLayout(); + virtual void dispatchDidFirstVisuallyNonEmptyLayout(); + + virtual WebCore::Frame* dispatchCreatePage(const WebCore::NavigationAction&); + virtual void dispatchShow(); + + virtual void dispatchDecidePolicyForMIMEType(WebCore::FramePolicyFunction, const String& MIMEType, const WebCore::ResourceRequest&); + virtual void dispatchDecidePolicyForNewWindowAction(WebCore::FramePolicyFunction, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<WebCore::FormState>, const String& frameName); + virtual void dispatchDecidePolicyForNavigationAction(WebCore::FramePolicyFunction, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<WebCore::FormState>); + virtual void cancelPolicyCheck(); + + virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&); + + virtual void dispatchWillSendSubmitEvent(WebCore::HTMLFormElement*) { } + virtual void dispatchWillSubmitForm(WebCore::FramePolicyFunction, PassRefPtr<WebCore::FormState>); + + virtual void dispatchDidLoadMainResource(WebCore::DocumentLoader*); + virtual void revertToProvisionalState(WebCore::DocumentLoader*); + virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&); + + // Maybe these should go into a ProgressTrackerClient some day + virtual void willChangeEstimatedProgress(); + virtual void didChangeEstimatedProgress(); + virtual void postProgressStartedNotification(); + virtual void postProgressEstimateChangedNotification(); + virtual void postProgressFinishedNotification(); + + virtual void setMainFrameDocumentReady(bool); + + virtual void startDownload(const WebCore::ResourceRequest&); + + virtual void willChangeTitle(WebCore::DocumentLoader*); + virtual void didChangeTitle(WebCore::DocumentLoader*); + + virtual void committedLoad(WebCore::DocumentLoader*, const char*, int); + virtual void finishedLoading(WebCore::DocumentLoader*); + + virtual void updateGlobalHistory(); + virtual void updateGlobalHistoryRedirectLinks(); + + virtual bool shouldGoToHistoryItem(WebCore::HistoryItem*) const; + virtual void dispatchDidAddBackForwardItem(WebCore::HistoryItem*) const; + virtual void dispatchDidRemoveBackForwardItem(WebCore::HistoryItem*) const; + virtual void dispatchDidChangeBackForwardIndex() const; + + virtual void didDisplayInsecureContent(); + virtual void didRunInsecureContent(WebCore::SecurityOrigin*); + + virtual WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&); + virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&); + virtual WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&); + virtual WebCore::ResourceError interruptForPolicyChangeError(const WebCore::ResourceRequest&); + + virtual WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&); + virtual WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&); + virtual WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&); + + virtual bool shouldFallBack(const WebCore::ResourceError&); + + virtual bool canHandleRequest(const WebCore::ResourceRequest&) const; + virtual bool canShowMIMEType(const String& MIMEType) const; + virtual bool canShowMIMETypeAsHTML(const String& MIMEType) const; + virtual bool representationExistsForURLScheme(const String& URLScheme) const; + virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const; + + virtual void frameLoadCompleted(); + virtual void saveViewStateToItem(WebCore::HistoryItem*); + virtual void restoreViewState(); + virtual void provisionalLoadStarted(); + virtual void didFinishLoad(); + virtual void prepareForDataSourceReplacement(); + + virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&); + virtual void setTitle(const String& title, const WebCore::KURL&); + + virtual String userAgent(const WebCore::KURL&); + + virtual void savePlatformDataToCachedFrame(WebCore::CachedFrame*); + virtual void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*); + virtual void transitionToCommittedForNewPage(); + + virtual void didSaveToPageCache(); + virtual void didRestoreFromPageCache(); + + virtual void dispatchDidBecomeFrameset(bool); + + virtual bool canCachePage() const; + virtual void download(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&); + + virtual PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL& url, const String& name, WebCore::HTMLFrameOwnerElement* ownerElement, + const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight); + virtual void didTransferChildFrameToNewDocument(WebCore::Page*); + virtual void transferLoadingResourceFromPage(unsigned long, WebCore::DocumentLoader*, const WebCore::ResourceRequest&, WebCore::Page*); + + virtual PassRefPtr<WebCore::Widget> createPlugin(const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually); + virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget); + + virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement*, const WebCore::KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues); + + virtual WebCore::ObjectContentType objectContentType(const WebCore::KURL& url, const String& mimeType); + virtual String overrideMediaType() const; + + virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*); + + virtual void documentElementAvailable(); + virtual void didPerformFirstNavigation() const; // "Navigation" here means a transition from one page to another that ends up in the back/forward list. + + virtual void registerForIconNotification(bool listen = true); + +#if PLATFORM(MAC) + virtual RemoteAXObjectRef accessibilityRemoteObject(); + +#if ENABLE(MAC_JAVA_BRIDGE) + virtual jobject javaApplet(NSView*); +#endif + virtual NSCachedURLResponse* willCacheResponse(WebCore::DocumentLoader*, unsigned long identifier, NSCachedURLResponse*) const; +#endif +#if USE(CFNETWORK) + virtual bool shouldCacheResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&, const unsigned char* data, unsigned long long length); +#endif + + virtual bool shouldUsePluginDocument(const String& /*mimeType*/) const; + + virtual PassRefPtr<WebCore::FrameNetworkingContext> createNetworkingContext(); + + WebFrame* m_frame; + RefPtr<PluginView> m_pluginView; + bool m_hasSentResponseToPluginView; + bool m_frameHasCustomRepresentation; +}; + +uint32_t modifiersForNavigationAction(const WebCore::NavigationAction&); +int32_t mouseButtonForNavigationAction(const WebCore::NavigationAction&); + +} // namespace WebKit + +#endif // WebFrameLoaderClient_h diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebGeolocationClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebGeolocationClient.cpp new file mode 100644 index 0000000..8701022 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebGeolocationClient.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebGeolocationClient.h" + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +#include "WebGeolocationManager.h" +#include "WebPage.h" +#include "WebProcess.h" +#include <WebCore/Geolocation.h> +#include <WebCore/GeolocationPosition.h> + +using namespace WebCore; + +namespace WebKit { + +WebGeolocationClient::~WebGeolocationClient() +{ +} + +void WebGeolocationClient::geolocationDestroyed() +{ + WebProcess::shared().geolocationManager().unregisterWebPage(m_page); + delete this; +} + +void WebGeolocationClient::startUpdating() +{ + WebProcess::shared().geolocationManager().registerWebPage(m_page); +} + +void WebGeolocationClient::stopUpdating() +{ + WebProcess::shared().geolocationManager().unregisterWebPage(m_page); +} + +void WebGeolocationClient::setEnableHighAccuracy(bool) +{ +} + +GeolocationPosition* WebGeolocationClient::lastPosition() +{ + // FIXME: Implement this. + return 0; +} + +void WebGeolocationClient::requestPermission(Geolocation* geolocation) +{ + m_page->geolocationPermissionRequestManager().startRequestForGeolocation(geolocation); +} + +void WebGeolocationClient::cancelPermissionRequest(Geolocation* geolocation) +{ + m_page->geolocationPermissionRequestManager().cancelRequestForGeolocation(geolocation); +} + +} // namespace WebKit + +#endif // ENABLE(CLIENT_BASED_GEOLOCATION) diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebGeolocationClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebGeolocationClient.h new file mode 100644 index 0000000..e72124d --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebGeolocationClient.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebGeolocationClient_h +#define WebGeolocationClient_h + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +#include <WebCore/GeolocationClient.h> + +namespace WebKit { + +class WebPage; + +class WebGeolocationClient : public WebCore::GeolocationClient { +public: + WebGeolocationClient(WebPage* page) + : m_page(page) + { + } + + virtual ~WebGeolocationClient(); + +private: + virtual void geolocationDestroyed(); + + virtual void startUpdating(); + virtual void stopUpdating(); + virtual void setEnableHighAccuracy(bool); + + virtual WebCore::GeolocationPosition* lastPosition(); + + virtual void requestPermission(WebCore::Geolocation*); + virtual void cancelPermissionRequest(WebCore::Geolocation*); + + + WebPage* m_page; +}; + +} // namespace WebKit + +#endif // ENABLE(CLIENT_BASED_GEOLOCATION) + +#endif // WebGeolocationClient_h diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp new file mode 100644 index 0000000..ddd1fa8 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebInspectorClient.h" + +#if ENABLE(INSPECTOR) + +#include "WebInspectorFrontendClient.h" +#include "WebInspector.h" +#include "WebPage.h" +#include <WebCore/InspectorController.h> +#include <WebCore/Page.h> + +#define DISABLE_NOT_IMPLEMENTED_WARNINGS 1 +#include "NotImplemented.h" + +using namespace WebCore; + +namespace WebKit { + +void WebInspectorClient::inspectorDestroyed() +{ + delete this; +} + +void WebInspectorClient::openInspectorFrontend(InspectorController*) +{ + WebPage* inspectorPage = m_page->inspector()->createInspectorPage(); + ASSERT(inspectorPage); + if (!inspectorPage) + return; + + inspectorPage->corePage()->inspectorController()->setInspectorFrontendClient(adoptPtr(new WebInspectorFrontendClient(m_page, inspectorPage))); +} + +void WebInspectorClient::highlight(Node*) +{ + notImplemented(); +} + +void WebInspectorClient::hideHighlight() +{ + notImplemented(); +} + +void WebInspectorClient::populateSetting(const String& key, String*) +{ + notImplemented(); +} + +void WebInspectorClient::storeSetting(const String&, const String&) +{ + notImplemented(); +} + +bool WebInspectorClient::sendMessageToFrontend(const String& message) +{ + WebInspector* inspector = m_page->inspector(); + if (!inspector) + return false; + WebPage* inspectorPage = inspector->inspectorPage(); + if (!inspectorPage) + return false; + return doDispatchMessageOnFrontendPage(inspectorPage->corePage(), message); +} + +} // namespace WebKit + +#endif // ENABLE(INSPECTOR) diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h new file mode 100644 index 0000000..7a12206 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebInspectorClient_h +#define WebInspectorClient_h + +#if ENABLE(INSPECTOR) + +#include <WebCore/InspectorClient.h> + +namespace WebKit { + +class WebPage; + +class WebInspectorClient : public WebCore::InspectorClient { +public: + WebInspectorClient(WebPage* page) + : m_page(page) + { + } + +private: + virtual void inspectorDestroyed(); + + virtual void openInspectorFrontend(WebCore::InspectorController*); + + virtual void highlight(WebCore::Node*); + virtual void hideHighlight(); + + virtual void populateSetting(const String& key, String* value); + virtual void storeSetting(const String& key, const String& value); + + virtual bool sendMessageToFrontend(const String&); + + WebPage* m_page; +}; + +} // namespace WebKit + +#endif // ENABLE(INSPECTOR) + +#endif // WebInspectorClient_h diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp new file mode 100644 index 0000000..28d3b3d --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebInspectorFrontendClient.h" + +#if ENABLE(INSPECTOR) + +#include "WebInspector.h" +#include "WebPage.h" +#include <WebCore/Page.h> +#include <wtf/text/WTFString.h> + +#define DISABLE_NOT_IMPLEMENTED_WARNINGS 1 +#include "NotImplemented.h" + +using namespace WebCore; + +namespace WebKit { + +WebInspectorFrontendClient::WebInspectorFrontendClient(WebPage* page, WebPage* inspectorPage) + : InspectorFrontendClientLocal(page->corePage()->inspectorController(), inspectorPage->corePage()) + , m_page(page) +{ +} + +void WebInspectorFrontendClient::frontendLoaded() +{ + InspectorFrontendClientLocal::frontendLoaded(); + + m_page->inspector()->didLoadInspectorPage(); +} + +String WebInspectorFrontendClient::localizedStringsURL() +{ + return m_page->inspector()->localizedStringsURL(); +} + +String WebInspectorFrontendClient::hiddenPanels() +{ + notImplemented(); + return String(); +} + +void WebInspectorFrontendClient::bringToFront() +{ + notImplemented(); +} + +void WebInspectorFrontendClient::closeWindow() +{ + m_page->inspector()->didClose(); +} + +void WebInspectorFrontendClient::disconnectFromBackend() +{ + m_page->inspector()->didClose(); +} + +void WebInspectorFrontendClient::attachWindow() +{ + notImplemented(); +} + +void WebInspectorFrontendClient::detachWindow() +{ + notImplemented(); +} + +void WebInspectorFrontendClient::setAttachedWindowHeight(unsigned) +{ + notImplemented(); +} + +void WebInspectorFrontendClient::inspectedURLChanged(const String&) +{ + notImplemented(); +} + +} // namespace WebKit + +#endif // ENABLE(INSPECTOR) diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.h new file mode 100644 index 0000000..48b4de9 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebInspectorFrontendClient_h +#define WebInspectorFrontendClient_h + +#if ENABLE(INSPECTOR) + +#include <WebCore/InspectorFrontendClientLocal.h> + +namespace WebKit { + +class WebPage; + +class WebInspectorFrontendClient : public WebCore::InspectorFrontendClientLocal { +public: + WebInspectorFrontendClient(WebPage* page, WebPage* inspectorPage); + +private: + virtual void frontendLoaded(); + + virtual String localizedStringsURL(); + virtual String hiddenPanels(); + + virtual void bringToFront(); + virtual void closeWindow(); + virtual void disconnectFromBackend(); + + virtual void attachWindow(); + virtual void detachWindow(); + virtual void setAttachedWindowHeight(unsigned); + + virtual void inspectedURLChanged(const String&); + + WebPage* m_page; +}; + +} // namespace WebKit + +#endif // ENABLE(INSPECTOR) + +#endif // WebInspectorFrontendClient_h diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp new file mode 100644 index 0000000..4567f35 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp @@ -0,0 +1,908 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebPlatformStrategies.h" + +#if USE(PLATFORM_STRATEGIES) + +#include "NotImplemented.h" +#include "PluginInfoStore.h" +#include "WebContextMessages.h" +#include "WebCoreArgumentCoders.h" +#include "WebProcess.h" +#include <WebCore/Page.h> +#include <WebCore/PageGroup.h> +#include <wtf/MathExtras.h> +#include <wtf/text/CString.h> + +#if PLATFORM(CF) +#include <wtf/RetainPtr.h> +#endif + +// FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized +#define UI_STRING(string, description) String::fromUTF8(string, strlen(string)) +#define UI_STRING_KEY(string, key, description) String::fromUTF8(string, strlen(string)) + +using namespace WebCore; + +namespace WebKit { + +// We can't use String::format for two reasons: +// 1) It doesn't handle non-ASCII characters in the format string. +// 2) It doesn't handle the %2$d syntax. +// Note that because |format| is used as the second parameter to va_start, it cannot be a reference +// type according to section 18.7/3 of the C++ N1905 standard. +static String formatLocalizedString(String format, ...) +{ +#if PLATFORM(CF) + va_list arguments; + va_start(arguments, format); + RetainPtr<CFStringRef> formatCFString(AdoptCF, format.createCFString()); + RetainPtr<CFStringRef> result(AdoptCF, CFStringCreateWithFormatAndArguments(0, 0, formatCFString.get(), arguments)); + va_end(arguments); + return result.get(); +#else + notImplemented(); + return format; +#endif +} + +void WebPlatformStrategies::initialize() +{ + DEFINE_STATIC_LOCAL(WebPlatformStrategies, platformStrategies, ()); + setPlatformStrategies(&platformStrategies); +} + +WebPlatformStrategies::WebPlatformStrategies() + : m_pluginCacheIsPopulated(false) + , m_shouldRefreshPlugins(false) +{ +} + +// PluginStrategy + +PluginStrategy* WebPlatformStrategies::createPluginStrategy() +{ + return this; +} + +LocalizationStrategy* WebPlatformStrategies::createLocalizationStrategy() +{ + return this; +} + +VisitedLinkStrategy* WebPlatformStrategies::createVisitedLinkStrategy() +{ + return this; +} + +// PluginStrategy + +void WebPlatformStrategies::populatePluginCache() +{ + if (m_pluginCacheIsPopulated) + return; + + ASSERT(m_cachedPlugins.isEmpty()); + + Vector<PluginInfo> plugins; + + // FIXME: Should we do something in case of error here? + WebProcess::shared().connection()->sendSync(Messages::WebContext::GetPlugins(m_shouldRefreshPlugins), + Messages::WebContext::GetPlugins::Reply(plugins), 0); + + m_cachedPlugins.swap(plugins); + + m_shouldRefreshPlugins = false; + m_pluginCacheIsPopulated = true; +} + +void WebPlatformStrategies::refreshPlugins() +{ + m_cachedPlugins.clear(); + m_pluginCacheIsPopulated = false; + m_shouldRefreshPlugins = true; + + populatePluginCache(); +} + +void WebPlatformStrategies::getPluginInfo(const WebCore::Page*, Vector<WebCore::PluginInfo>& plugins) +{ + populatePluginCache(); + plugins = m_cachedPlugins; +} + +// LocalizationStrategy + +String WebPlatformStrategies::inputElementAltText() +{ + return UI_STRING_KEY("Submit", "Submit (input element)", "alt text for <input> elements with no alt, title, or value"); +} + +String WebPlatformStrategies::resetButtonDefaultLabel() +{ + return UI_STRING("Reset", "default label for Reset buttons in forms on web pages"); +} + +String WebPlatformStrategies::searchableIndexIntroduction() +{ + return UI_STRING("This is a searchable index. Enter search keywords: ", + "text that appears at the start of nearly-obsolete web pages in the form of a 'searchable index'"); +} + +String WebPlatformStrategies::submitButtonDefaultLabel() +{ + return UI_STRING("Submit", "default label for Submit buttons in forms on web pages"); +} + +String WebPlatformStrategies::fileButtonChooseFileLabel() +{ + return UI_STRING("Choose File", "title for file button used in HTML forms"); +} + +String WebPlatformStrategies::fileButtonNoFileSelectedLabel() +{ + return UI_STRING("no file selected", "text to display in file button used in HTML forms when no file is selected"); +} + +#if PLATFORM(MAC) +String WebPlatformStrategies::copyImageUnknownFileLabel() +{ + return UI_STRING("unknown", "Unknown filename"); +} +#endif + +#if ENABLE(CONTEXT_MENUS) + +String WebPlatformStrategies::contextMenuItemTagOpenLinkInNewWindow() +{ + return UI_STRING("Open Link in New Window", "Open in New Window context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagDownloadLinkToDisk() +{ + return UI_STRING("Download Linked File", "Download Linked File context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagCopyLinkToClipboard() +{ + return UI_STRING("Copy Link", "Copy Link context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagOpenImageInNewWindow() +{ + return UI_STRING("Open Image in New Window", "Open Image in New Window context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagDownloadImageToDisk() +{ + return UI_STRING("Download Image", "Download Image context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagCopyImageToClipboard() +{ + return UI_STRING("Copy Image", "Copy Image context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagOpenVideoInNewWindow() +{ + return UI_STRING("Open Video in New Window", "Open Video in New Window context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagOpenAudioInNewWindow() +{ + return UI_STRING("Open Audio in New Window", "Open Audio in New Window context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagCopyVideoLinkToClipboard() +{ + return UI_STRING("Copy Video Address", "Copy Video Address Location context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagCopyAudioLinkToClipboard() +{ + return UI_STRING("Copy Audio Address", "Copy Audio Address Location context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagToggleMediaControls() +{ + return UI_STRING("Controls", "Media Controls context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagToggleMediaLoop() +{ + return UI_STRING("Loop", "Media Loop context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagEnterVideoFullscreen() +{ + return UI_STRING("Enter Fullscreen", "Video Enter Fullscreen context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagMediaPlay() +{ + return UI_STRING("Play", "Media Play context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagMediaPause() +{ + return UI_STRING("Pause", "Media Pause context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagMediaMute() +{ + return UI_STRING("Mute", "Media Mute context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagOpenFrameInNewWindow() +{ + return UI_STRING("Open Frame in New Window", "Open Frame in New Window context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagCopy() +{ + return UI_STRING("Copy", "Copy context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagGoBack() +{ + return UI_STRING("Back", "Back context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagGoForward() +{ + return UI_STRING("Forward", "Forward context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagStop() +{ + return UI_STRING("Stop", "Stop context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagReload() +{ + return UI_STRING("Reload", "Reload context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagCut() +{ + return UI_STRING("Cut", "Cut context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagPaste() +{ + return UI_STRING("Paste", "Paste context menu item"); +} + +#if PLATFORM(GTK) + +String WebPlatformStrategies::contextMenuItemTagDelete() +{ + notImplemented(); + return "Delete"; +} + +String WebPlatformStrategies::contextMenuItemTagInputMethods() +{ + notImplemented(); + return "Input Methods"; +} + +String WebPlatformStrategies::contextMenuItemTagUnicode() +{ + notImplemented(); + return "Unicode"; +} + +#endif + +#if PLATFORM(GTK) || PLATFORM(QT) + +String WebPlatformStrategies::contextMenuItemTagSelectAll() +{ + notImplemented(); + return "Select All"; +} + +#endif + +String WebPlatformStrategies::contextMenuItemTagNoGuessesFound() +{ + return UI_STRING("No Guesses Found", "No Guesses Found context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagIgnoreSpelling() +{ + return UI_STRING("Ignore Spelling", "Ignore Spelling context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagLearnSpelling() +{ + return UI_STRING("Learn Spelling", "Learn Spelling context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagSearchWeb() +{ + return UI_STRING("Search in Google", "Search in Google context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagLookUpInDictionary() +{ + return UI_STRING("Look Up in Dictionary", "Look Up in Dictionary context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagOpenLink() +{ + return UI_STRING("Open Link", "Open Link context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagIgnoreGrammar() +{ + return UI_STRING("Ignore Grammar", "Ignore Grammar context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagSpellingMenu() +{ + return UI_STRING("Spelling and Grammar", "Spelling and Grammar context sub-menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagShowSpellingPanel(bool show) +{ + if (show) + return UI_STRING("Show Spelling and Grammar", "menu item title"); + return UI_STRING("Hide Spelling and Grammar", "menu item title"); +} + +String WebPlatformStrategies::contextMenuItemTagCheckSpelling() +{ + return UI_STRING("Check Document Now", "Check spelling context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagCheckSpellingWhileTyping() +{ + return UI_STRING("Check Spelling While Typing", "Check spelling while typing context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagCheckGrammarWithSpelling() +{ + return UI_STRING("Check Grammar With Spelling", "Check grammar with spelling context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagFontMenu() +{ + return UI_STRING("Font", "Font context sub-menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagBold() +{ + return UI_STRING("Bold", "Bold context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagItalic() +{ + return UI_STRING("Italic", "Italic context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagUnderline() +{ + return UI_STRING("Underline", "Underline context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagOutline() +{ + return UI_STRING("Outline", "Outline context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagWritingDirectionMenu() +{ + return UI_STRING("Paragraph Direction", "Paragraph direction context sub-menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagTextDirectionMenu() +{ + return UI_STRING("Selection Direction", "Selection direction context sub-menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagDefaultDirection() +{ + return UI_STRING("Default", "Default writing direction context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagLeftToRight() +{ + return UI_STRING("Left to Right", "Left to Right context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagRightToLeft() +{ + return UI_STRING("Right to Left", "Right to Left context menu item"); +} + +#if PLATFORM(MAC) + +String WebPlatformStrategies::contextMenuItemTagSearchInSpotlight() +{ + return UI_STRING("Search in Spotlight", "Search in Spotlight context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagShowFonts() +{ + return UI_STRING("Show Fonts", "Show fonts context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagStyles() +{ + return UI_STRING("Styles...", "Styles context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagShowColors() +{ + return UI_STRING("Show Colors", "Show colors context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagSpeechMenu() +{ + return UI_STRING("Speech", "Speech context sub-menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagStartSpeaking() +{ + return UI_STRING("Start Speaking", "Start speaking context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagStopSpeaking() +{ + return UI_STRING("Stop Speaking", "Stop speaking context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagCorrectSpellingAutomatically() +{ + return UI_STRING("Correct Spelling Automatically", "Correct Spelling Automatically context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagSubstitutionsMenu() +{ + return UI_STRING("Substitutions", "Substitutions context sub-menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagShowSubstitutions(bool show) +{ + if (show) + return UI_STRING("Show Substitutions", "menu item title"); + return UI_STRING("Hide Substitutions", "menu item title"); +} + +String WebPlatformStrategies::contextMenuItemTagSmartCopyPaste() +{ + return UI_STRING("Smart Copy/Paste", "Smart Copy/Paste context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagSmartQuotes() +{ + return UI_STRING("Smart Quotes", "Smart Quotes context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagSmartDashes() +{ + return UI_STRING("Smart Dashes", "Smart Dashes context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagSmartLinks() +{ + return UI_STRING("Smart Links", "Smart Links context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagTextReplacement() +{ + return UI_STRING("Text Replacement", "Text Replacement context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagTransformationsMenu() +{ + return UI_STRING("Transformations", "Transformations context sub-menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagMakeUpperCase() +{ + return UI_STRING("Make Upper Case", "Make Upper Case context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagMakeLowerCase() +{ + return UI_STRING("Make Lower Case", "Make Lower Case context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagCapitalize() +{ + return UI_STRING("Capitalize", "Capitalize context menu item"); +} + +String WebPlatformStrategies::contextMenuItemTagChangeBack(const String& replacedString) +{ + notImplemented(); + return replacedString; +} + +#endif + +String WebPlatformStrategies::contextMenuItemTagInspectElement() +{ + return UI_STRING("Inspect Element", "Inspect Element context menu item"); +} + +#endif // ENABLE(CONTEXT_MENUS) + +String WebPlatformStrategies::searchMenuNoRecentSearchesText() +{ + return UI_STRING("No recent searches", "Label for only item in menu that appears when clicking on the search field image, when no searches have been performed"); +} + +String WebPlatformStrategies::searchMenuRecentSearchesText() +{ + return UI_STRING("Recent Searches", "label for first item in the menu that appears when clicking on the search field image, used as embedded menu title"); +} + +String WebPlatformStrategies::searchMenuClearRecentSearchesText() +{ + return UI_STRING("Clear Recent Searches", "menu item in Recent Searches menu that empties menu's contents"); +} + +String WebPlatformStrategies::AXWebAreaText() +{ + return UI_STRING("HTML content", "accessibility role description for web area"); +} + +String WebPlatformStrategies::AXLinkText() +{ + return UI_STRING("link", "accessibility role description for link"); +} + +String WebPlatformStrategies::AXListMarkerText() +{ + return UI_STRING("list marker", "accessibility role description for list marker"); +} + +String WebPlatformStrategies::AXImageMapText() +{ + return UI_STRING("image map", "accessibility role description for image map"); +} + +String WebPlatformStrategies::AXHeadingText() +{ + return UI_STRING("heading", "accessibility role description for headings"); +} + +String WebPlatformStrategies::AXDefinitionListTermText() +{ + return UI_STRING("term", "term word of a definition"); +} + +String WebPlatformStrategies::AXDefinitionListDefinitionText() +{ + return UI_STRING("definition", "definition phrase"); +} + +#if PLATFORM(MAC) +String WebPlatformStrategies::AXARIAContentGroupText(const String& ariaType) +{ + if (ariaType == "ARIAApplicationAlert") + return UI_STRING("alert", "An ARIA accessibility group that acts as an alert."); + if (ariaType == "ARIAApplicationAlertDialog") + return UI_STRING("alert dialog", "An ARIA accessibility group that acts as an alert dialog."); + if (ariaType == "ARIAApplicationDialog") + return UI_STRING("dialog", "An ARIA accessibility group that acts as an dialog."); + if (ariaType == "ARIAApplicationLog") + return UI_STRING("log", "An ARIA accessibility group that acts as a console log."); + if (ariaType == "ARIAApplicationMarquee") + return UI_STRING("marquee", "An ARIA accessibility group that acts as a marquee."); + if (ariaType == "ARIAApplicationStatus") + return UI_STRING("application status", "An ARIA accessibility group that acts as a status update."); + if (ariaType == "ARIAApplicationTimer") + return UI_STRING("timer", "An ARIA accessibility group that acts as an updating timer."); + if (ariaType == "ARIADocument") + return UI_STRING("document", "An ARIA accessibility group that acts as a document."); + if (ariaType == "ARIADocumentArticle") + return UI_STRING("article", "An ARIA accessibility group that acts as an article."); + if (ariaType == "ARIADocumentNote") + return UI_STRING("note", "An ARIA accessibility group that acts as a note in a document."); + if (ariaType == "ARIADocumentRegion") + return UI_STRING("region", "An ARIA accessibility group that acts as a distinct region in a document."); + if (ariaType == "ARIALandmarkApplication") + return UI_STRING("application", "An ARIA accessibility group that acts as an application."); + if (ariaType == "ARIALandmarkBanner") + return UI_STRING("banner", "An ARIA accessibility group that acts as a banner."); + if (ariaType == "ARIALandmarkComplementary") + return UI_STRING("complementary", "An ARIA accessibility group that acts as a region of complementary information."); + if (ariaType == "ARIALandmarkContentInfo") + return UI_STRING("content", "An ARIA accessibility group that contains content."); + if (ariaType == "ARIALandmarkMain") + return UI_STRING("main", "An ARIA accessibility group that is the main portion of the website."); + if (ariaType == "ARIALandmarkNavigation") + return UI_STRING("navigation", "An ARIA accessibility group that contains the main navigation elements of a website."); + if (ariaType == "ARIALandmarkSearch") + return UI_STRING("search", "An ARIA accessibility group that contains a search feature of a website."); + if (ariaType == "ARIAUserInterfaceTooltip") + return UI_STRING("tooltip", "An ARIA accessibility group that acts as a tooltip."); + if (ariaType == "ARIATabPanel") + return UI_STRING("tab panel", "An ARIA accessibility group that contains the content of a tab."); + if (ariaType == "ARIADocumentMath") + return UI_STRING("math", "An ARIA accessibility group that contains mathematical symbols."); + return String(); +} +#endif + +String WebPlatformStrategies::AXButtonActionVerb() +{ + return UI_STRING("press", "Verb stating the action that will occur when a button is pressed, as used by accessibility"); +} + +String WebPlatformStrategies::AXRadioButtonActionVerb() +{ + return UI_STRING("select", "Verb stating the action that will occur when a radio button is clicked, as used by accessibility"); +} + +String WebPlatformStrategies::AXTextFieldActionVerb() +{ + return UI_STRING("activate", "Verb stating the action that will occur when a text field is selected, as used by accessibility"); +} + +String WebPlatformStrategies::AXCheckedCheckBoxActionVerb() +{ + return UI_STRING("uncheck", "Verb stating the action that will occur when a checked checkbox is clicked, as used by accessibility"); +} + +String WebPlatformStrategies::AXUncheckedCheckBoxActionVerb() +{ + return UI_STRING("check", "Verb stating the action that will occur when an unchecked checkbox is clicked, as used by accessibility"); +} + +String WebPlatformStrategies::AXMenuListActionVerb() +{ + notImplemented(); + return "select"; +} + +String WebPlatformStrategies::AXMenuListPopupActionVerb() +{ + notImplemented(); + return "select"; +} + +String WebPlatformStrategies::AXLinkActionVerb() +{ + return UI_STRING("jump", "Verb stating the action that will occur when a link is clicked, as used by accessibility"); +} + +String WebPlatformStrategies::missingPluginText() +{ + return UI_STRING("Missing Plug-in", "Label text to be used when a plugin is missing"); +} + +String WebPlatformStrategies::crashedPluginText() +{ + return UI_STRING("Plug-in Failure", "Label text to be used if plugin host process has crashed"); +} + +String WebPlatformStrategies::multipleFileUploadText(unsigned numberOfFiles) +{ + return formatLocalizedString(UI_STRING("%d files", "Label to describe the number of files selected in a file upload control that allows multiple files"), numberOfFiles); +} + +String WebPlatformStrategies::unknownFileSizeText() +{ + return UI_STRING("Unknown", "Unknown filesize FTP directory listing item"); +} + +#if PLATFORM(WIN) + +String WebPlatformStrategies::uploadFileText() +{ + notImplemented(); + return "upload"; +} + +String WebPlatformStrategies::allFilesText() +{ + notImplemented(); + return "all files"; +} + +#endif + +String WebPlatformStrategies::imageTitle(const String& filename, const IntSize& size) +{ + // FIXME: It would be nice to have the filename inside the format string, but it's not easy to do that in a way that works with non-ASCII characters in the filename. + return filename + formatLocalizedString(UI_STRING(" %d×%d pixels", "window title suffix for a standalone image (uses multiplication symbol, not x)"), size.width(), size.height()); +} + +String WebPlatformStrategies::mediaElementLoadingStateText() +{ + return UI_STRING("Loading...", "Media controller status message when the media is loading"); +} + +String WebPlatformStrategies::mediaElementLiveBroadcastStateText() +{ + return UI_STRING("Live Broadcast", "Media controller status message when watching a live broadcast"); +} + +String WebPlatformStrategies::localizedMediaControlElementString(const String& name) +{ + if (name == "AudioElement") + return UI_STRING("audio element controller", "accessibility role description for audio element controller"); + if (name == "VideoElement") + return UI_STRING("video element controller", "accessibility role description for video element controller"); + if (name == "MuteButton") + return UI_STRING("mute", "accessibility role description for mute button"); + if (name == "UnMuteButton") + return UI_STRING("unmute", "accessibility role description for turn mute off button"); + if (name == "PlayButton") + return UI_STRING("play", "accessibility role description for play button"); + if (name == "PauseButton") + return UI_STRING("pause", "accessibility role description for pause button"); + if (name == "Slider") + return UI_STRING("movie time", "accessibility role description for timeline slider"); + if (name == "SliderThumb") + return UI_STRING("timeline slider thumb", "accessibility role description for timeline thumb"); + if (name == "RewindButton") + return UI_STRING("back 30 seconds", "accessibility role description for seek back 30 seconds button"); + if (name == "ReturnToRealtimeButton") + return UI_STRING("return to realtime", "accessibility role description for return to real time button"); + if (name == "CurrentTimeDisplay") + return UI_STRING("elapsed time", "accessibility role description for elapsed time display"); + if (name == "TimeRemainingDisplay") + return UI_STRING("remaining time", "accessibility role description for time remaining display"); + if (name == "StatusDisplay") + return UI_STRING("status", "accessibility role description for movie status"); + if (name == "FullscreenButton") + return UI_STRING("fullscreen", "accessibility role description for enter fullscreen button"); + if (name == "SeekForwardButton") + return UI_STRING("fast forward", "accessibility role description for fast forward button"); + if (name == "SeekBackButton") + return UI_STRING("fast reverse", "accessibility role description for fast reverse button"); + if (name == "ShowClosedCaptionsButton") + return UI_STRING("show closed captions", "accessibility role description for show closed captions button"); + if (name == "HideClosedCaptionsButton") + return UI_STRING("hide closed captions", "accessibility role description for hide closed captions button"); + + // FIXME: the ControlsPanel container should never be visible in the accessibility hierarchy. + if (name == "ControlsPanel") + return String(); + + ASSERT_NOT_REACHED(); + return String(); +} + +String WebPlatformStrategies::localizedMediaControlElementHelpText(const String& name) +{ + if (name == "AudioElement") + return UI_STRING("audio element playback controls and status display", "accessibility role description for audio element controller"); + if (name == "VideoElement") + return UI_STRING("video element playback controls and status display", "accessibility role description for video element controller"); + if (name == "MuteButton") + return UI_STRING("mute audio tracks", "accessibility help text for mute button"); + if (name == "UnMuteButton") + return UI_STRING("unmute audio tracks", "accessibility help text for un mute button"); + if (name == "PlayButton") + return UI_STRING("begin playback", "accessibility help text for play button"); + if (name == "PauseButton") + return UI_STRING("pause playback", "accessibility help text for pause button"); + if (name == "Slider") + return UI_STRING("movie time scrubber", "accessibility help text for timeline slider"); + if (name == "SliderThumb") + return UI_STRING("movie time scrubber thumb", "accessibility help text for timeline slider thumb"); + if (name == "RewindButton") + return UI_STRING("seek movie back 30 seconds", "accessibility help text for jump back 30 seconds button"); + if (name == "ReturnToRealtimeButton") + return UI_STRING("return streaming movie to real time", "accessibility help text for return streaming movie to real time button"); + if (name == "CurrentTimeDisplay") + return UI_STRING("current movie time in seconds", "accessibility help text for elapsed time display"); + if (name == "TimeRemainingDisplay") + return UI_STRING("number of seconds of movie remaining", "accessibility help text for remaining time display"); + if (name == "StatusDisplay") + return UI_STRING("current movie status", "accessibility help text for movie status display"); + if (name == "SeekBackButton") + return UI_STRING("seek quickly back", "accessibility help text for fast rewind button"); + if (name == "SeekForwardButton") + return UI_STRING("seek quickly forward", "accessibility help text for fast forward button"); + if (name == "FullscreenButton") + return UI_STRING("Play movie in fullscreen mode", "accessibility help text for enter fullscreen button"); + if (name == "ShowClosedCaptionsButton") + return UI_STRING("start displaying closed captions", "accessibility help text for show closed captions button"); + if (name == "HideClosedCaptionsButton") + return UI_STRING("stop displaying closed captions", "accessibility help text for hide closed captions button"); + + ASSERT_NOT_REACHED(); + return String(); +} + +String WebPlatformStrategies::localizedMediaTimeDescription(float time) +{ + if (!isfinite(time)) + return UI_STRING("indefinite time", "accessibility help text for an indefinite media controller time value"); + + int seconds = static_cast<int>(fabsf(time)); + int days = seconds / (60 * 60 * 24); + int hours = seconds / (60 * 60); + int minutes = (seconds / 60) % 60; + seconds %= 60; + + if (days) + return formatLocalizedString(UI_STRING("%1$d days %2$d hours %3$d minutes %4$d seconds", "accessibility help text for media controller time value >= 1 day"), days, hours, minutes, seconds); + if (hours) + return formatLocalizedString(UI_STRING("%1$d hours %2$d minutes %3$d seconds", "accessibility help text for media controller time value >= 60 minutes"), hours, minutes, seconds); + if (minutes) + return formatLocalizedString(UI_STRING("%1$d minutes %2$d seconds", "accessibility help text for media controller time value >= 60 seconds"), minutes, seconds); + return formatLocalizedString(UI_STRING("%1$d seconds", "accessibility help text for media controller time value < 60 seconds"), seconds); +} + +String WebPlatformStrategies::validationMessageValueMissingText() +{ + return UI_STRING("value missing", "Validation message for required form control elements that have no value"); +} + +String WebPlatformStrategies::validationMessageTypeMismatchText() +{ + return UI_STRING("type mismatch", "Validation message for input form controls with a value not matching type"); +} + +String WebPlatformStrategies::validationMessagePatternMismatchText() +{ + return UI_STRING("pattern mismatch", "Validation message for input form controls requiring a constrained value according to pattern"); +} + +String WebPlatformStrategies::validationMessageTooLongText() +{ + return UI_STRING("too long", "Validation message for form control elements with a value longer than maximum allowed length"); +} + +String WebPlatformStrategies::validationMessageRangeUnderflowText() +{ + return UI_STRING("range underflow", "Validation message for input form controls with value lower than allowed minimum"); +} + +String WebPlatformStrategies::validationMessageRangeOverflowText() +{ + return UI_STRING("range overflow", "Validation message for input form controls with value higher than allowed maximum"); +} + +String WebPlatformStrategies::validationMessageStepMismatchText() +{ + return UI_STRING("step mismatch", "Validation message for input form controls with value not respecting the step attribute"); +} + +// VisitedLinkStrategy +bool WebPlatformStrategies::isLinkVisited(Page* page, LinkHash linkHash) +{ + return WebProcess::shared().isLinkVisited(linkHash); +} + +void WebPlatformStrategies::addVisitedLink(Page* page, LinkHash linkHash) +{ + WebProcess::shared().addVisitedLink(linkHash); +} + +} // namespace WebKit + +#endif // USE(PLATFORM_STRATEGIES) diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h new file mode 100644 index 0000000..b584f8d --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h @@ -0,0 +1,201 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebPlatformStrategies_h +#define WebPlatformStrategies_h + +#if USE(PLATFORM_STRATEGIES) + +#include <WebCore/PlatformStrategies.h> +#include <WebCore/PluginStrategy.h> +#include <WebCore/LocalizationStrategy.h> +#include <WebCore/VisitedLinkStrategy.h> + +namespace WebKit { + +class WebPlatformStrategies : public WebCore::PlatformStrategies, private WebCore::PluginStrategy, private WebCore::LocalizationStrategy, private WebCore::VisitedLinkStrategy { +public: + static void initialize(); + +private: + WebPlatformStrategies(); + + // WebCore::PlatformStrategies + virtual WebCore::PluginStrategy* createPluginStrategy(); + virtual WebCore::LocalizationStrategy* createLocalizationStrategy(); + virtual WebCore::VisitedLinkStrategy* createVisitedLinkStrategy(); + + // WebCore::PluginStrategy + virtual void refreshPlugins(); + virtual void getPluginInfo(const WebCore::Page*, Vector<WebCore::PluginInfo>&); + + // WebCore::LocalizationStrategy + virtual String inputElementAltText(); + virtual String resetButtonDefaultLabel(); + virtual String searchableIndexIntroduction(); + virtual String submitButtonDefaultLabel(); + virtual String fileButtonChooseFileLabel(); + virtual String fileButtonNoFileSelectedLabel(); +#if PLATFORM(MAC) + virtual String copyImageUnknownFileLabel(); +#endif +#if ENABLE(CONTEXT_MENUS) + virtual String contextMenuItemTagOpenLinkInNewWindow(); + virtual String contextMenuItemTagDownloadLinkToDisk(); + virtual String contextMenuItemTagCopyLinkToClipboard(); + virtual String contextMenuItemTagOpenImageInNewWindow(); + virtual String contextMenuItemTagDownloadImageToDisk(); + virtual String contextMenuItemTagCopyImageToClipboard(); + virtual String contextMenuItemTagOpenFrameInNewWindow(); + virtual String contextMenuItemTagCopy(); + virtual String contextMenuItemTagGoBack(); + virtual String contextMenuItemTagGoForward(); + virtual String contextMenuItemTagStop(); + virtual String contextMenuItemTagReload(); + virtual String contextMenuItemTagCut(); + virtual String contextMenuItemTagPaste(); +#if PLATFORM(GTK) + virtual String contextMenuItemTagDelete(); + virtual String contextMenuItemTagInputMethods(); + virtual String contextMenuItemTagUnicode(); +#endif +#if PLATFORM(GTK) || PLATFORM(QT) + virtual String contextMenuItemTagSelectAll(); +#endif + virtual String contextMenuItemTagNoGuessesFound(); + virtual String contextMenuItemTagIgnoreSpelling(); + virtual String contextMenuItemTagLearnSpelling(); + virtual String contextMenuItemTagSearchWeb(); + virtual String contextMenuItemTagLookUpInDictionary(); + virtual String contextMenuItemTagOpenLink(); + virtual String contextMenuItemTagIgnoreGrammar(); + virtual String contextMenuItemTagSpellingMenu(); + virtual String contextMenuItemTagShowSpellingPanel(bool show); + virtual String contextMenuItemTagCheckSpelling(); + virtual String contextMenuItemTagCheckSpellingWhileTyping(); + virtual String contextMenuItemTagCheckGrammarWithSpelling(); + virtual String contextMenuItemTagFontMenu(); + virtual String contextMenuItemTagBold(); + virtual String contextMenuItemTagItalic(); + virtual String contextMenuItemTagUnderline(); + virtual String contextMenuItemTagOutline(); + virtual String contextMenuItemTagWritingDirectionMenu(); + virtual String contextMenuItemTagTextDirectionMenu(); + virtual String contextMenuItemTagDefaultDirection(); + virtual String contextMenuItemTagLeftToRight(); + virtual String contextMenuItemTagRightToLeft(); +#if PLATFORM(MAC) + virtual String contextMenuItemTagSearchInSpotlight(); + virtual String contextMenuItemTagShowFonts(); + virtual String contextMenuItemTagStyles(); + virtual String contextMenuItemTagShowColors(); + virtual String contextMenuItemTagSpeechMenu(); + virtual String contextMenuItemTagStartSpeaking(); + virtual String contextMenuItemTagStopSpeaking(); + virtual String contextMenuItemTagCorrectSpellingAutomatically(); + virtual String contextMenuItemTagSubstitutionsMenu(); + virtual String contextMenuItemTagShowSubstitutions(bool show); + virtual String contextMenuItemTagSmartCopyPaste(); + virtual String contextMenuItemTagSmartQuotes(); + virtual String contextMenuItemTagSmartDashes(); + virtual String contextMenuItemTagSmartLinks(); + virtual String contextMenuItemTagTextReplacement(); + virtual String contextMenuItemTagTransformationsMenu(); + virtual String contextMenuItemTagMakeUpperCase(); + virtual String contextMenuItemTagMakeLowerCase(); + virtual String contextMenuItemTagCapitalize(); + virtual String contextMenuItemTagChangeBack(const String& replacedString); +#endif + virtual String contextMenuItemTagInspectElement(); + virtual String contextMenuItemTagOpenVideoInNewWindow(); + virtual String contextMenuItemTagOpenAudioInNewWindow(); + virtual String contextMenuItemTagCopyVideoLinkToClipboard(); + virtual String contextMenuItemTagCopyAudioLinkToClipboard(); + virtual String contextMenuItemTagToggleMediaControls(); + virtual String contextMenuItemTagToggleMediaLoop(); + virtual String contextMenuItemTagEnterVideoFullscreen(); + virtual String contextMenuItemTagMediaPlay(); + virtual String contextMenuItemTagMediaPause(); + virtual String contextMenuItemTagMediaMute(); +#endif // ENABLE(CONTEXT_MENUS) + virtual String searchMenuNoRecentSearchesText(); + virtual String searchMenuRecentSearchesText(); + virtual String searchMenuClearRecentSearchesText(); + virtual String AXWebAreaText(); + virtual String AXLinkText(); + virtual String AXListMarkerText(); + virtual String AXImageMapText(); + virtual String AXHeadingText(); + virtual String AXDefinitionListTermText(); + virtual String AXDefinitionListDefinitionText(); +#if PLATFORM(MAC) + virtual String AXARIAContentGroupText(const String& ariaType); +#endif + virtual String AXButtonActionVerb(); + virtual String AXRadioButtonActionVerb(); + virtual String AXTextFieldActionVerb(); + virtual String AXCheckedCheckBoxActionVerb(); + virtual String AXUncheckedCheckBoxActionVerb(); + virtual String AXMenuListActionVerb(); + virtual String AXMenuListPopupActionVerb(); + virtual String AXLinkActionVerb(); + virtual String missingPluginText(); + virtual String crashedPluginText(); + virtual String multipleFileUploadText(unsigned numberOfFiles); + virtual String unknownFileSizeText(); +#if PLATFORM(WIN) + virtual String uploadFileText(); + virtual String allFilesText(); +#endif + virtual String imageTitle(const String& filename, const WebCore::IntSize& size); + virtual String mediaElementLoadingStateText(); + virtual String mediaElementLiveBroadcastStateText(); + virtual String localizedMediaControlElementString(const String&); + virtual String localizedMediaControlElementHelpText(const String&); + virtual String localizedMediaTimeDescription(float); + virtual String validationMessageValueMissingText(); + virtual String validationMessageTypeMismatchText(); + virtual String validationMessagePatternMismatchText(); + virtual String validationMessageTooLongText(); + virtual String validationMessageRangeUnderflowText(); + virtual String validationMessageRangeOverflowText(); + virtual String validationMessageStepMismatchText(); + + void populatePluginCache(); + + bool m_pluginCacheIsPopulated; + bool m_shouldRefreshPlugins; + Vector<WebCore::PluginInfo> m_cachedPlugins; + + // WebCore::VisitedLinkStrategy + virtual bool isLinkVisited(WebCore::Page*, WebCore::LinkHash); + virtual void addVisitedLink(WebCore::Page*, WebCore::LinkHash); +}; + +} // namespace WebKit + +#endif // USE(PLATFORM_STRATEGIES) + +#endif // WebPlatformStrategies_h diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.cpp new file mode 100644 index 0000000..ea0ad2d --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.cpp @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "WebPopupMenu.h" + +#include "PlatformPopupMenuData.h" +#include "WebCoreArgumentCoders.h" +#include "WebPage.h" +#include "WebPageProxyMessages.h" +#include "WebProcess.h" +#include <WebCore/FrameView.h> +#include <WebCore/PopupMenuClient.h> + +using namespace WebCore; + +namespace WebKit { + +PassRefPtr<WebPopupMenu> WebPopupMenu::create(WebPage* page, PopupMenuClient* client) +{ + return adoptRef(new WebPopupMenu(page, client)); +} + +WebPopupMenu::WebPopupMenu(WebPage* page, PopupMenuClient* client) + : m_popupClient(client) + , m_page(page) +{ +} + +WebPopupMenu::~WebPopupMenu() +{ +} + +void WebPopupMenu::disconnectClient() +{ + m_popupClient = 0; +} + +void WebPopupMenu::didChangeSelectedIndex(int newIndex) +{ + if (!m_popupClient) + return; + + m_popupClient->popupDidHide(); + if (newIndex >= 0) + m_popupClient->valueChanged(newIndex); +} + +void WebPopupMenu::setTextForIndex(int index) +{ + if (!m_popupClient) + return; + + m_popupClient->setTextFromItem(index); +} + +Vector<WebPopupItem> WebPopupMenu::populateItems() +{ + size_t size = m_popupClient->listSize(); + + Vector<WebPopupItem> items; + items.reserveInitialCapacity(size); + + for (size_t i = 0; i < size; ++i) { + if (m_popupClient->itemIsSeparator(i)) + items.append(WebPopupItem(WebPopupItem::Seperator)); + else { + // FIXME: Add support for styling the font. + // FIXME: Add support for styling the foreground and background colors. + // FIXME: Find a way to customize text color when an item is highlighted. + items.append(WebPopupItem(WebPopupItem::Item, m_popupClient->itemText(i), m_popupClient->itemToolTip(i), m_popupClient->itemAccessibilityText(i), m_popupClient->itemIsEnabled(i), m_popupClient->itemIsLabel(i))); + } + } + + return items; +} + +void WebPopupMenu::show(const IntRect& rect, FrameView* view, int index) +{ + // FIXME: We should probably inform the client to also close the menu. + Vector<WebPopupItem> items = populateItems(); + + if (items.isEmpty() || !m_page) { + m_popupClient->popupDidHide(); + return; + } + + m_page->setActivePopupMenu(this); + + // Move to page coordinates + IntRect pageCoordinates(view->contentsToWindow(rect.location()), rect.size()); + + PlatformPopupMenuData platformData; + setUpPlatformData(pageCoordinates, platformData); + + WebProcess::shared().connection()->send(Messages::WebPageProxy::ShowPopupMenu(pageCoordinates, items, index, platformData), m_page->pageID()); +} + +void WebPopupMenu::hide() +{ + if (!m_page || !m_popupClient) + return; + + WebProcess::shared().connection()->send(Messages::WebPageProxy::HidePopupMenu(), m_page->pageID()); + m_page->setActivePopupMenu(0); +} + +void WebPopupMenu::updateFromElement() +{ +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.h new file mode 100644 index 0000000..3083c94 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WebPopupMenu_h +#define WebPopupMenu_h + +#include "WebPopupItem.h" +#include <WebCore/PopupMenu.h> +#include <wtf/Forward.h> +#include <wtf/OwnPtr.h> +#include <wtf/Vector.h> + +namespace WebCore { +class PopupMenuClient; +} + +namespace WebKit { + +class WebPage; +struct PlatformPopupMenuData; +struct WebPopupItem; + +class WebPopupMenu : public WebCore::PopupMenu { +public: + static PassRefPtr<WebPopupMenu> create(WebPage*, WebCore::PopupMenuClient*); + ~WebPopupMenu(); + + void disconnectFromPage() { m_page = 0; } + void didChangeSelectedIndex(int newIndex); + void setTextForIndex(int newIndex); + + virtual void show(const WebCore::IntRect&, WebCore::FrameView*, int index); + virtual void hide(); + virtual void updateFromElement(); + virtual void disconnectClient(); + +private: + WebPopupMenu(WebPage*, WebCore::PopupMenuClient*); + + Vector<WebPopupItem> populateItems(); + void setUpPlatformData(const WebCore::IntRect& pageCoordinates, PlatformPopupMenuData&); + + WebCore::PopupMenuClient* m_popupClient; + WebPage* m_page; +}; + +} // namespace WebKit + +#endif // WebPopupMenu_h diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp new file mode 100644 index 0000000..acec5f2 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + + +#include "WebSearchPopupMenu.h" + +using namespace WebCore; + +namespace WebKit { + +PassRefPtr<WebSearchPopupMenu> WebSearchPopupMenu::create(WebPage* page, PopupMenuClient* client) +{ + return adoptRef(new WebSearchPopupMenu(page, client)); +} + +WebSearchPopupMenu::WebSearchPopupMenu(WebPage* page, PopupMenuClient* client) + : m_popup(WebPopupMenu::create(page, client)) +{ +} + +PopupMenu* WebSearchPopupMenu::popupMenu() +{ + return m_popup.get(); +} + +void WebSearchPopupMenu::saveRecentSearches(const AtomicString&, const Vector<String>&) +{ +} + +void WebSearchPopupMenu::loadRecentSearches(const AtomicString&, Vector<String>&) +{ +} + +bool WebSearchPopupMenu::enabled() +{ + return false; +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.h new file mode 100644 index 0000000..0221571 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WebSearchPopupMenu_h +#define WebSearchPopupMenu_h + +#include "WebPopupMenu.h" +#include <WebCore/SearchPopupMenu.h> + +namespace WebKit { + +class WebSearchPopupMenu : public WebCore::SearchPopupMenu { +public: + static PassRefPtr<WebSearchPopupMenu> create(WebPage*, WebCore::PopupMenuClient*); + + virtual WebCore::PopupMenu* popupMenu(); + virtual void saveRecentSearches(const WTF::AtomicString& name, const Vector<String>& searchItems); + virtual void loadRecentSearches(const WTF::AtomicString& name, Vector<String>& searchItems); + virtual bool enabled(); + +private: + WebSearchPopupMenu(WebPage*, WebCore::PopupMenuClient*); + + RefPtr<WebPopupMenu> m_popup; +}; + +} + +#endif // WebSearchPopupMenu_h diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebContextMenuClientGtk.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebContextMenuClientGtk.cpp new file mode 100644 index 0000000..db9500a --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebContextMenuClientGtk.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebContextMenuClient.h" + +#include "NotImplemented.h" + +using namespace WebCore; + +namespace WebKit { + +void WebContextMenuClient::lookUpInDictionary(Frame*) +{ + notImplemented(); +} + +bool WebContextMenuClient::isSpeaking() +{ + notImplemented(); + return false; +} + +void WebContextMenuClient::speak(const String&) +{ + notImplemented(); +} + +void WebContextMenuClient::stopSpeaking() +{ + notImplemented(); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDatabaseManagerGtk.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDatabaseManagerGtk.cpp new file mode 100644 index 0000000..b3c1289 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDatabaseManagerGtk.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebDatabaseManager.h" + +#include "NotImplemented.h" + +namespace WebKit { + +String WebDatabaseManager::databaseDirectory() const +{ + notImplemented(); + return String(); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebFrameNetworkingContext.h b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebFrameNetworkingContext.h new file mode 100644 index 0000000..1a2d611 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebFrameNetworkingContext.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebFrameNetworkingContext_h +#define WebFrameNetworkingContext_h + +#include <WebCore/FrameNetworkingContext.h> + +class WebFrameNetworkingContext : public WebCore::FrameNetworkingContext { +public: + static PassRefPtr<WebFrameNetworkingContext> create(WebCore::Frame*) + { + return 0; + } + +private: + WebFrameNetworkingContext(WebCore::Frame* frame) + : WebCore::FrameNetworkingContext(frame) + { + } + + virtual WTF::String userAgent() const; + virtual WTF::String referrer() const; + + WTF::String m_userAgent; +}; + +#endif // WebFrameNetworkingContext_h diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebPopupMenuGtk.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebPopupMenuGtk.cpp new file mode 100644 index 0000000..6cda476 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebPopupMenuGtk.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebPopupMenu.h" + +#include "NotImplemented.h" +#include "PlatformPopupMenuData.h" + +using namespace WebCore; + +namespace WebKit { + +void WebPopupMenu::setUpPlatformData(const IntRect&, PlatformPopupMenuData&) +{ + notImplemented(); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm new file mode 100644 index 0000000..32d08b2 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebContextMenuClient.h" + +#include "NotImplemented.h" +#include "WebPage.h" +#include <WebCore/Frame.h> +#include <WebCore/Page.h> +#include <wtf/text/WTFString.h> + +using namespace WebCore; + +namespace WebKit { + +void WebContextMenuClient::lookUpInDictionary(Frame*) +{ + // FIXME: <rdar://problem/8750610> - Implement + notImplemented(); +} + +bool WebContextMenuClient::isSpeaking() +{ + return m_page->isSpeaking(); +} + +void WebContextMenuClient::speak(const String& string) +{ + m_page->speak(string); +} + +void WebContextMenuClient::stopSpeaking() +{ + m_page->stopSpeaking(); +} + +void WebContextMenuClient::searchWithSpotlight() +{ + // FIXME: Why do we need to search all the frames like this? + // Isn't there any function in WebCore that can do this? + // If not, can we find a place in WebCore to put this? + + Frame* mainFrame = m_page->corePage()->mainFrame(); + + Frame* selectionFrame = mainFrame; + for (; selectionFrame; selectionFrame = selectionFrame->tree()->traverseNext(mainFrame)) { + if (selectionFrame->selection()->isRange()) + break; + } + if (!selectionFrame) + selectionFrame = mainFrame; + + String selectedString = selectionFrame->displayStringModifiedByEncoding(selectionFrame->editor()->selectedText()); + + if (selectedString.isEmpty()) + return; + + NSString *convertedSelectedString = selectedString; + + [[NSWorkspace sharedWorkspace] showSearchResultsForQueryString:convertedSelectedString]; +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDatabaseManagerMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDatabaseManagerMac.mm new file mode 100644 index 0000000..d4eb3ac --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDatabaseManagerMac.mm @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebDatabaseManager.h" + +namespace WebKit { + +NSString *WebDatabaseDirectoryDefaultsKey = @"WebDatabaseDirectory"; + +String WebDatabaseManager::databaseDirectory() const +{ + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSString *databasesDirectory = [defaults objectForKey:WebDatabaseDirectoryDefaultsKey]; + if (!databasesDirectory || ![databasesDirectory isKindOfClass:[NSString class]]) + databasesDirectory = @"~/Library/WebKit/Databases"; + + return [databasesDirectory stringByStandardizingPath]; +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm new file mode 100644 index 0000000..ce33890 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm @@ -0,0 +1,268 @@ +/* + * Copyright (C) 2006, 2010, 2011 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "WebEditorClient.h" + +#define DISABLE_NOT_IMPLEMENTED_WARNINGS 1 +#include "NotImplemented.h" + +#include "WebCoreArgumentCoders.h" +#include "WebPage.h" +#include "WebFrame.h" +#include "WebPageProxyMessages.h" +#include "WebProcess.h" +#include <WebCore/ArchiveResource.h> +#include <WebCore/DocumentFragment.h> +#include <WebCore/DOMDocumentFragmentInternal.h> +#include <WebCore/DOMDocumentInternal.h> +#include <WebCore/FocusController.h> +#include <WebCore/Frame.h> +#include <WebCore/KeyboardEvent.h> +#include <WebCore/Page.h> +#include <WebKit/WebResource.h> +#include <WebKit/WebNSURLExtras.h> +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +#import <AppKit/NSTextChecker.h> +#endif + +using namespace WebCore; + +@interface NSAttributedString (WebNSAttributedStringDetails) +- (DOMDocumentFragment*)_documentFromRange:(NSRange)range document:(DOMDocument*)document documentAttributes:(NSDictionary *)dict subresources:(NSArray **)subresources; +@end + +@interface WebResource (WebResourceInternal) +- (WebCore::ArchiveResource*)_coreResource; +@end + +namespace WebKit { + +void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event) +{ + if (m_page->interceptEditingKeyboardEvent(event, false)) + event->setDefaultHandled(); +} + +void WebEditorClient::handleInputMethodKeydown(KeyboardEvent* event) +{ + if (m_page->interceptEditingKeyboardEvent(event, true)) + event->setDefaultHandled(); +} + +NSString *WebEditorClient::userVisibleString(NSURL *url) +{ + return [url _web_userVisibleString]; +} + +NSURL *WebEditorClient::canonicalizeURL(NSURL *url) +{ + return [url _webkit_canonicalize]; +} + +NSURL *WebEditorClient::canonicalizeURLString(NSString *URLString) +{ + NSURL *URL = nil; + if ([URLString _webkit_looksLikeAbsoluteURL]) + URL = [[NSURL _web_URLWithUserTypedString:URLString] _webkit_canonicalize]; + return URL; +} + +static NSArray *createExcludedElementsForAttributedStringConversion() +{ + NSArray *elements = [[NSArray alloc] initWithObjects: + // Omit style since we want style to be inline so the fragment can be easily inserted. + @"style", + // Omit xml so the result is not XHTML. + @"xml", + // Omit tags that will get stripped when converted to a fragment anyway. + @"doctype", @"html", @"head", @"body", + // Omit deprecated tags. + @"applet", @"basefont", @"center", @"dir", @"font", @"isindex", @"menu", @"s", @"strike", @"u", + // Omit object so no file attachments are part of the fragment. + @"object", nil]; + CFRetain(elements); + return elements; +} + +DocumentFragment* WebEditorClient::documentFragmentFromAttributedString(NSAttributedString *string, Vector<RefPtr<ArchiveResource> >& resources) +{ + static NSArray *excludedElements = createExcludedElementsForAttributedStringConversion(); + + NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: excludedElements, + NSExcludedElementsDocumentAttribute, nil, @"WebResourceHandler", nil]; + + NSArray *subResources; + DOMDocumentFragment* fragment = [string _documentFromRange:NSMakeRange(0, [string length]) + document:kit(m_page->mainFrame()->coreFrame()->document()) + documentAttributes:dictionary + subresources:&subResources]; + for (WebResource* resource in subResources) + resources.append([resource _coreResource]); + + [dictionary release]; + return core(fragment); +} + +void WebEditorClient::setInsertionPasteboard(NSPasteboard *) +{ + // This is used only by Mail, no need to implement it now. + notImplemented(); +} + +#ifdef BUILDING_ON_TIGER +NSArray *WebEditorClient::pasteboardTypesForSelection(Frame*) +{ + notImplemented(); + return nil; +} +#endif + +static void changeWordCase(WebPage* page, SEL selector) +{ + Frame* frame = page->corePage()->focusController()->focusedOrMainFrame(); + if (!frame->editor()->canEdit()) + return; + + frame->editor()->command("selectWord").execute(); + + NSString *selectedString = frame->displayStringModifiedByEncoding(frame->editor()->selectedText()); + page->replaceSelectionWithText(frame, [selectedString performSelector:selector]); +} + +void WebEditorClient::uppercaseWord() +{ + changeWordCase(m_page, @selector(uppercaseString)); +} + +void WebEditorClient::lowercaseWord() +{ + changeWordCase(m_page, @selector(lowercaseString)); +} + +void WebEditorClient::capitalizeWord() +{ + changeWordCase(m_page, @selector(capitalizedString)); +} + +void WebEditorClient::showSubstitutionsPanel(bool) +{ + notImplemented(); +} + +bool WebEditorClient::substitutionsPanelIsShowing() +{ + notImplemented(); + return false; +} + +void WebEditorClient::toggleSmartInsertDelete() +{ + // This is handled in the UI process. + ASSERT_NOT_REACHED(); +} + +bool WebEditorClient::isAutomaticQuoteSubstitutionEnabled() +{ + return WebProcess::shared().textCheckerState().isAutomaticQuoteSubstitutionEnabled; +} + +void WebEditorClient::toggleAutomaticQuoteSubstitution() +{ + // This is handled in the UI process. + ASSERT_NOT_REACHED(); +} + +bool WebEditorClient::isAutomaticLinkDetectionEnabled() +{ + return WebProcess::shared().textCheckerState().isAutomaticLinkDetectionEnabled; +} + +void WebEditorClient::toggleAutomaticLinkDetection() +{ + // This is handled in the UI process. + ASSERT_NOT_REACHED(); +} + +bool WebEditorClient::isAutomaticDashSubstitutionEnabled() +{ + return WebProcess::shared().textCheckerState().isAutomaticDashSubstitutionEnabled; +} + +void WebEditorClient::toggleAutomaticDashSubstitution() +{ + // This is handled in the UI process. + ASSERT_NOT_REACHED(); +} + +bool WebEditorClient::isAutomaticTextReplacementEnabled() +{ + return WebProcess::shared().textCheckerState().isAutomaticTextReplacementEnabled; +} + +void WebEditorClient::toggleAutomaticTextReplacement() +{ + // This is handled in the UI process. + ASSERT_NOT_REACHED(); +} + +bool WebEditorClient::isAutomaticSpellingCorrectionEnabled() +{ + return WebProcess::shared().textCheckerState().isAutomaticSpellingCorrectionEnabled; +} + +void WebEditorClient::toggleAutomaticSpellingCorrection() +{ + notImplemented(); +} + +void WebEditorClient::checkTextOfParagraph(const UChar* text, int length, uint64_t checkingTypes, Vector<TextCheckingResult>& results) +{ + // FIXME: It would be nice if we wouldn't have to copy the text here. + m_page->sendSync(Messages::WebPageProxy::CheckTextOfParagraph(String(text, length), checkingTypes), Messages::WebPageProxy::CheckTextOfParagraph::Reply(results)); +} + +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType type, const WebCore::FloatRect& boundingBoxOfReplacedString, const WTF::String& replacedString, const WTF::String& replacementString, const Vector<String>& alternativeReplacementStrings, WebCore::Editor*) +{ + notImplemented(); +} + +void WebEditorClient::dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel) +{ + notImplemented(); +} + +bool WebEditorClient::isShowingCorrectionPanel() +{ + notImplemented(); + return false; +} +#endif + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm new file mode 100644 index 0000000..549d7ee --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm @@ -0,0 +1,178 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebErrors.h" + +#include "WKError.h" +#include "WebError.h" +#include <WebCore/ResourceRequest.h> +#include <WebCore/ResourceResponse.h> +#include <pthread.h> + +using namespace WebCore; +using namespace WebKit; + +// FIXME: We probably don't need to use NSErrors here. + +static NSString * const WebKitErrorMIMETypeKey = @"WebKitErrorMIMETypeKey"; +static NSString * const WebKitErrorPlugInNameKey = @"WebKitErrorPlugInNameKey"; +static NSString * const WebKitErrorPlugInPageURLStringKey = @"WebKitErrorPlugInPageURLStringKey"; + +// FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized +#define UI_STRING(__str, __desc) [NSString stringWithUTF8String:__str] + +// Policy errors +#define WebKitErrorDescriptionCannotShowMIMEType UI_STRING("Content with specified MIME type can’t be shown", "WebKitErrorCannotShowMIMEType description") +#define WebKitErrorDescriptionCannotShowURL UI_STRING("The URL can’t be shown", "WebKitErrorCannotShowURL description") +#define WebKitErrorDescriptionFrameLoadInterruptedByPolicyChange UI_STRING("Frame load interrupted", "WebKitErrorFrameLoadInterruptedByPolicyChange description") +#define WebKitErrorDescriptionCannotUseRestrictedPort UI_STRING("Not allowed to use restricted network port", "WebKitErrorCannotUseRestrictedPort description") + +// Plug-in and java errors +#define WebKitErrorDescriptionCannotFindPlugin UI_STRING("The plug-in can’t be found", "WebKitErrorCannotFindPlugin description") +#define WebKitErrorDescriptionCannotLoadPlugin UI_STRING("The plug-in can’t be loaded", "WebKitErrorCannotLoadPlugin description") +#define WebKitErrorDescriptionJavaUnavailable UI_STRING("Java is unavailable", "WebKitErrorJavaUnavailable description") +#define WebKitErrorDescriptionPlugInCancelledConnection UI_STRING("Plug-in cancelled", "WebKitErrorPlugInCancelledConnection description") +#define WebKitErrorDescriptionPlugInWillHandleLoad UI_STRING("Plug-in handled load", "WebKitErrorPlugInWillHandleLoad description") + +static pthread_once_t registerErrorsControl = PTHREAD_ONCE_INIT; +static void registerErrors(void); + +@interface NSError (WebKitExtras) ++ (NSError *)_webKitErrorWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL; +@end + +@implementation NSError (WebKitExtras) + +static NSMutableDictionary *descriptions = nil; + ++ (void)_registerWebKitErrors +{ + pthread_once(®isterErrorsControl, registerErrors); +} + +-(id)_webkit_initWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL +{ + NSDictionary *descriptionsDict; + NSString *localizedDesc; + NSDictionary *dict; + // insert a localized string here for those folks not savvy to our category methods + descriptionsDict = [descriptions objectForKey:domain]; + localizedDesc = descriptionsDict ? [descriptionsDict objectForKey:[NSNumber numberWithInt:code]] : nil; + dict = [NSDictionary dictionaryWithObjectsAndKeys: + URL, @"NSErrorFailingURLKey", + [URL absoluteString], @"NSErrorFailingURLStringKey", + localizedDesc, NSLocalizedDescriptionKey, + nil]; + return [self initWithDomain:domain code:code userInfo:dict]; +} + ++(id)_webkit_errorWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL +{ + return [[[self alloc] _webkit_initWithDomain:domain code:code URL:URL] autorelease]; +} + ++ (NSError *)_webKitErrorWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL +{ + [self _registerWebKitErrors]; + return [self _webkit_errorWithDomain:domain code:code URL:URL]; +} + ++ (NSError *)_webKitErrorWithCode:(int)code failingURL:(NSString *)URLString +{ + return [self _webKitErrorWithDomain:WebError::webKitErrorDomain() code:code URL:[NSURL URLWithString:URLString]]; +} + ++ (void)_webkit_addErrorsWithCodesAndDescriptions:(NSDictionary *)dictionary inDomain:(NSString *)domain +{ + if (!descriptions) + descriptions = [[NSMutableDictionary alloc] init]; + + [descriptions setObject:dictionary forKey:domain]; +} + +static void registerErrors() +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: + // Policy errors + WebKitErrorDescriptionCannotShowMIMEType, [NSNumber numberWithInt: kWKErrorCodeCannotShowMIMEType], + WebKitErrorDescriptionCannotShowURL, [NSNumber numberWithInt: kWKErrorCodeCannotShowURL], + WebKitErrorDescriptionFrameLoadInterruptedByPolicyChange, [NSNumber numberWithInt: kWKErrorCodeFrameLoadInterruptedByPolicyChange], + WebKitErrorDescriptionCannotUseRestrictedPort, [NSNumber numberWithInt: kWKErrorCodeCannotUseRestrictedPort], + + // Plug-in and java errors + WebKitErrorDescriptionCannotFindPlugin, [NSNumber numberWithInt: kWKErrorCodeCannotFindPlugIn], + WebKitErrorDescriptionCannotLoadPlugin, [NSNumber numberWithInt: kWKErrorCodeCannotLoadPlugIn], + WebKitErrorDescriptionJavaUnavailable, [NSNumber numberWithInt: kWKErrorCodeJavaUnavailable], + WebKitErrorDescriptionPlugInCancelledConnection, [NSNumber numberWithInt: kWKErrorCodePlugInCancelledConnection], + WebKitErrorDescriptionPlugInWillHandleLoad, [NSNumber numberWithInt: kWKErrorCodePlugInWillHandleLoad], + nil]; + + [NSError _webkit_addErrorsWithCodesAndDescriptions:dict inDomain:WebError::webKitErrorDomain()]; + + [pool drain]; +} + +@end + +namespace WebKit { + +ResourceError cancelledError(const ResourceRequest& request) +{ + return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled URL:request.url()]; +} + +ResourceError blockedError(const ResourceRequest& request) +{ + return [NSError _webKitErrorWithDomain:WebError::webKitErrorDomain() code:kWKErrorCodeCannotUseRestrictedPort URL:request.url()]; +} + +ResourceError cannotShowURLError(const ResourceRequest& request) +{ + return [NSError _webKitErrorWithDomain:WebError::webKitErrorDomain() code:kWKErrorCodeCannotShowURL URL:request.url()]; +} + +ResourceError interruptForPolicyChangeError(const ResourceRequest& request) +{ + return [NSError _webKitErrorWithDomain:WebError::webKitErrorDomain() code:kWKErrorCodeFrameLoadInterruptedByPolicyChange URL:request.url()]; +} + +ResourceError cannotShowMIMETypeError(const ResourceResponse& response) +{ + return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:kWKErrorCodeCannotShowMIMEType URL:response.url()]; +} + +ResourceError fileDoesNotExistError(const ResourceResponse& response) +{ + return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist URL:response.url()]; +} + +ResourceError pluginWillHandleLoadError(const ResourceResponse& response) +{ + return [NSError _webKitErrorWithDomain:WebError::webKitErrorDomain() code:kWKErrorCodePlugInWillHandleLoad URL:response.url()]; +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h new file mode 100644 index 0000000..994d285 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef WebFrameNetworkingContext_h +#define WebFrameNetworkingContext_h + +#import <WebCore/FrameNetworkingContext.h> + +namespace WebKit { + +class WebFrameNetworkingContext : public WebCore::FrameNetworkingContext { +public: + static PassRefPtr<WebFrameNetworkingContext> create(WebCore::Frame* frame) + { + return adoptRef(new WebFrameNetworkingContext(frame)); + } + +private: + WebFrameNetworkingContext(WebCore::Frame* frame) + : WebCore::FrameNetworkingContext(frame) + { + } + + virtual bool needsSiteSpecificQuirks() const; + virtual bool localFileContentSniffingEnabled() const; + virtual WebCore::SchedulePairHashSet* scheduledRunLoopPairs() const; + virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const; +}; + +} + +#endif diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm new file mode 100644 index 0000000..570d351 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm @@ -0,0 +1,50 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#import "WebFrameNetworkingContext.h" + +#import <WebCore/Page.h> +#import <WebCore/ResourceError.h> +#import <WebCore/Settings.h> + +using namespace WebCore; + +namespace WebKit { + +bool WebFrameNetworkingContext::needsSiteSpecificQuirks() const +{ + return frame() && frame()->settings() && frame()->settings()->needsSiteSpecificQuirks(); +} + +bool WebFrameNetworkingContext::localFileContentSniffingEnabled() const +{ + return frame() && frame()->settings() && frame()->settings()->localFileContentSniffingEnabled(); +} + +SchedulePairHashSet* WebFrameNetworkingContext::scheduledRunLoopPairs() const +{ + return frame() && frame()->page() ? frame()->page()->scheduledRunLoopPairs() : 0; +} + +ResourceError WebFrameNetworkingContext::blockedError(const ResourceRequest& request) const +{ + return frame()->loader()->blockedError(request); +} + +} diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm new file mode 100644 index 0000000..4d3d167 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebPopupMenu.h" + +#include "PlatformPopupMenuData.h" + +using namespace WebCore; + +namespace WebKit { + +void WebPopupMenu::setUpPlatformData(const IntRect&, PlatformPopupMenuData&) +{ +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.h b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.h new file mode 100644 index 0000000..da0c2dd --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebSystemInterface_h +#define WebSystemInterface_h + +void InitWebCoreSystemInterface(void); + +#endif /* WebSystemInterface_h */ diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm new file mode 100644 index 0000000..90b9a64 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "WebSystemInterface.h" + +#import <WebCore/WebCoreSystemInterface.h> +#import <WebKitSystemInterface.h> + +#define INIT(function) wk##function = WK##function + +void InitWebCoreSystemInterface(void) +{ + static dispatch_once_t initOnce; + + dispatch_once(&initOnce, ^{ + INIT(AdvanceDefaultButtonPulseAnimation); + INIT(CopyCFLocalizationPreferredName); + INIT(CGContextGetShouldSmoothFonts); + INIT(CopyCONNECTProxyResponse); + INIT(CopyNSURLResponseStatusLine); + INIT(CreateCTLineWithUniCharProvider); + INIT(CreateCustomCFReadStream); + INIT(CreateNSURLConnectionDelegateProxy); + INIT(DrawBezeledTextArea); + INIT(DrawBezeledTextFieldCell); + INIT(DrawCapsLockIndicator); + INIT(DrawFocusRing); + INIT(DrawMediaSliderTrack); + INIT(DrawMediaUIPart); + INIT(DrawTextFieldCellFocusRing); + INIT(GetExtensionsForMIMEType); + INIT(GetFontInLanguageForCharacter); + INIT(GetFontInLanguageForRange); + INIT(GetGlyphTransformedAdvances); + INIT(GetGlyphsForCharacters); + INIT(GetMIMETypeForExtension); + INIT(GetNSURLResponseLastModifiedDate); + INIT(GetPreferredExtensionForMIMEType); + INIT(GetUserToBaseCTM); + INIT(GetWheelEventDeltas); + INIT(HitTestMediaUIPart); + INIT(InitializeMaximumHTTPConnectionCountPerHost); + INIT(IsLatchingWheelEvent); + INIT(MeasureMediaUIPart); + INIT(MediaControllerThemeAvailable); + INIT(PopupMenu); + INIT(QTIncludeOnlyModernMediaFileTypes); + INIT(QTMovieDataRate); + INIT(QTMovieDisableComponent); + INIT(QTMovieGetType); + INIT(QTMovieHasClosedCaptions); + INIT(QTMovieMaxTimeLoaded); + INIT(QTMovieMaxTimeLoadedChangeNotification); + INIT(QTMovieMaxTimeSeekable); + INIT(QTMovieSelectPreferredAlternates); + INIT(QTMovieSetShowClosedCaptions); + INIT(QTMovieViewSetDrawSynchronously); + INIT(SetCGFontRenderingMode); + INIT(SetCONNECTProxyAuthorizationForStream); + INIT(SetCONNECTProxyForStream); + INIT(SetCookieStoragePrivateBrowsingEnabled); + INIT(SetDragImage); + INIT(SetNSURLConnectionDefersCallbacks); + INIT(SetNSURLRequestShouldContentSniff); + INIT(SetPatternBaseCTM); + INIT(SetPatternPhaseInUserSpace); + INIT(SetUpFontCache); + INIT(SignalCFReadStreamEnd); + INIT(SignalCFReadStreamError); + INIT(SignalCFReadStreamHasBytes); + +#if !defined(BUILDING_ON_SNOW_LEOPARD) + INIT(CreateCTTypesetterWithUniCharProviderAndOptions); +#else + INIT(GetHyphenationLocationBeforeIndex); +#endif + }); +} diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebContextMenuClientQt.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebContextMenuClientQt.cpp new file mode 100644 index 0000000..abfb70a --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebContextMenuClientQt.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebContextMenuClient.h" + +#include "NotImplemented.h" + +using namespace WebCore; + +namespace WebKit { + +void WebContextMenuClient::lookUpInDictionary(Frame*) +{ + notImplemented(); +} + +bool WebContextMenuClient::isSpeaking() +{ + notImplemented(); + return false; +} + +void WebContextMenuClient::speak(const String&) +{ + notImplemented(); +} + +void WebContextMenuClient::stopSpeaking() +{ + notImplemented(); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebDatabaseManagerQt.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebDatabaseManagerQt.cpp new file mode 100644 index 0000000..11f929c --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebDatabaseManagerQt.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebDatabaseManager.h" + +namespace WebKit { + +String WebDatabaseManager::databaseDirectory() const +{ + // FIXME: Implement. + return ""; +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebErrorsQt.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebErrorsQt.cpp new file mode 100644 index 0000000..cee6842 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebErrorsQt.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebErrors.h" + +#include <WebCore/ResourceRequest.h> +#include <WebCore/ResourceResponse.h> + +#include <QCoreApplication> +#include <QNetworkReply> + +using namespace WebCore; + +namespace WebKit { + +// copied from WebKit/Misc/WebKitErrors[Private].h +enum { + WebKitErrorCannotShowMIMEType = 100, + WebKitErrorCannotShowURL = 101, + WebKitErrorFrameLoadInterruptedByPolicyChange = 102, + WebKitErrorCannotUseRestrictedPort = 103, + WebKitErrorCannotFindPlugIn = 200, + WebKitErrorCannotLoadPlugIn = 201, + WebKitErrorJavaUnavailable = 202, + WebKitErrorPluginWillHandleLoad = 203 +}; + +ResourceError cancelledError(const ResourceRequest& request) +{ + ResourceError error = ResourceError("QtNetwork", QNetworkReply::OperationCanceledError, request.url().prettyURL(), + QCoreApplication::translate("QWebFrame", "Request cancelled", 0, QCoreApplication::UnicodeUTF8)); + error.setIsCancellation(true); + return error; +} + +ResourceError blockedError(const ResourceRequest& request) +{ + return ResourceError("WebKit", WebKitErrorCannotUseRestrictedPort, request.url().prettyURL(), + QCoreApplication::translate("QWebFrame", "Request blocked", 0, QCoreApplication::UnicodeUTF8)); +} + +ResourceError cannotShowURLError(const ResourceRequest& request) +{ + return ResourceError("WebKit", WebKitErrorCannotShowURL, request.url().string(), + QCoreApplication::translate("QWebFrame", "Cannot show URL", 0, QCoreApplication::UnicodeUTF8)); +} + +ResourceError interruptForPolicyChangeError(const ResourceRequest& request) +{ + return ResourceError("WebKit", WebKitErrorFrameLoadInterruptedByPolicyChange, request.url().string(), + QCoreApplication::translate("QWebFrame", "Frame load interrupted by policy change", 0, QCoreApplication::UnicodeUTF8)); +} + +ResourceError cannotShowMIMETypeError(const ResourceResponse& response) +{ + return ResourceError("WebKit", WebKitErrorCannotShowMIMEType, response.url().string(), + QCoreApplication::translate("QWebFrame", "Cannot show mimetype", 0, QCoreApplication::UnicodeUTF8)); +} + +ResourceError fileDoesNotExistError(const ResourceResponse& response) +{ + return ResourceError("QtNetwork", QNetworkReply::ContentNotFoundError, response.url().string(), + QCoreApplication::translate("QWebFrame", "File does not exist", 0, QCoreApplication::UnicodeUTF8)); +} + +ResourceError pluginWillHandleLoadError(const ResourceResponse& response) +{ + return ResourceError("WebKit", WebKitErrorPluginWillHandleLoad, response.url().string(), + QCoreApplication::translate("QWebFrame", "Loading is handled by the media engine", 0, QCoreApplication::UnicodeUTF8)); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.cpp new file mode 100644 index 0000000..55552e1 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.cpp @@ -0,0 +1,51 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" + +#include "WebFrameNetworkingContext.h" + +#include "WebProcess.h" +#include <QNetworkAccessManager> +#include <QObject> + +namespace WebCore { + +WebFrameNetworkingContext::WebFrameNetworkingContext(Frame* frame) + : FrameNetworkingContext(frame) + , m_originatingObject(0) +{ +} + +PassRefPtr<WebFrameNetworkingContext> WebFrameNetworkingContext::create(Frame* frame) +{ + return adoptRef(new WebFrameNetworkingContext(frame)); +} + +QObject* WebFrameNetworkingContext::originatingObject() const +{ + return m_originatingObject; +} + +QNetworkAccessManager* WebFrameNetworkingContext::networkAccessManager() const +{ + return WebKit::WebProcess::shared().networkAccessManager(); +} + +} diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.h b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.h new file mode 100644 index 0000000..9c87785 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef WebFrameNetworkingContext_h +#define WebFrameNetworkingContext_h + +#include <WebCore/FrameNetworkingContext.h> + +namespace WebCore { + +class WebFrameNetworkingContext : public FrameNetworkingContext { +public: + static PassRefPtr<WebFrameNetworkingContext> create(Frame*); + +private: + WebFrameNetworkingContext(Frame*); + + virtual QObject* originatingObject() const; + virtual QNetworkAccessManager* networkAccessManager() const; + + QObject* m_originatingObject; +}; + +} + +#endif // WebFrameNetworkingContext_h diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebPopupMenuQt.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebPopupMenuQt.cpp new file mode 100644 index 0000000..4d3d167 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebPopupMenuQt.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebPopupMenu.h" + +#include "PlatformPopupMenuData.h" + +using namespace WebCore; + +namespace WebKit { + +void WebPopupMenu::setUpPlatformData(const IntRect&, PlatformPopupMenuData&) +{ +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/win/WebContextMenuClientWin.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/win/WebContextMenuClientWin.cpp new file mode 100644 index 0000000..c16a4d6 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/win/WebContextMenuClientWin.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebContextMenuClient.h" +#include <WebCore/NotImplemented.h> + +using namespace WebCore; + +namespace WebKit { + +void WebContextMenuClient::lookUpInDictionary(Frame*) +{ + notImplemented(); +} + +bool WebContextMenuClient::isSpeaking() +{ + notImplemented(); + return false; +} + +void WebContextMenuClient::speak(const String&) +{ + notImplemented(); +} + +void WebContextMenuClient::stopSpeaking() +{ + notImplemented(); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/win/WebDatabaseManagerWin.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/win/WebDatabaseManagerWin.cpp new file mode 100644 index 0000000..b6d15fd --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/win/WebDatabaseManagerWin.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebDatabaseManager.h" + +#include <WebCore/FileSystem.h> + +using namespace WebCore; + +namespace WebKit { + +String WebDatabaseManager::databaseDirectory() const +{ + return WebCore::pathByAppendingComponent(WebCore::localUserSpecificStorageDirectory(), "Databases"); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/win/WebErrorsWin.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/win/WebErrorsWin.cpp new file mode 100644 index 0000000..b29b461 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/win/WebErrorsWin.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebErrors.h" + +#include "WKError.h" +#include "WebError.h" +#include <WebCore/ResourceRequest.h> +#include <WebCore/ResourceResponse.h> + +#if USE(CFNETWORK) +#include <CFNetwork/CFNetworkErrors.h> +#endif + +using namespace WebCore; + +namespace WebKit { + +ResourceError cancelledError(const ResourceRequest& request) +{ +#if USE(CFNETWORK) + return ResourceError(kCFErrorDomainCFNetwork, kCFURLErrorCancelled, request.url().string(), String()); +#else + return ResourceError(); // FIXME +#endif +} + +ResourceError blockedError(const ResourceRequest& request) +{ + return ResourceError(WebError::webKitErrorDomain(), kWKErrorCodeCannotUseRestrictedPort, request.url().string(), String()); +} + +ResourceError cannotShowURLError(const ResourceRequest& request) +{ + return ResourceError(WebError::webKitErrorDomain(), kWKErrorCodeCannotShowURL, request.url().string(), String()); +} + +ResourceError interruptForPolicyChangeError(const ResourceRequest& request) +{ + return ResourceError(WebError::webKitErrorDomain(), kWKErrorCodeFrameLoadInterruptedByPolicyChange, request.url().string(), String()); +} + +ResourceError cannotShowMIMETypeError(const ResourceResponse& response) +{ + return ResourceError(); +} + +ResourceError fileDoesNotExistError(const ResourceResponse& response) +{ + return ResourceError(); +} + +ResourceError pluginWillHandleLoadError(const ResourceResponse& response) +{ + return ResourceError(WebError::webKitErrorDomain(), kWKErrorCodePlugInWillHandleLoad, response.url().string(), String()); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/win/WebFrameNetworkingContext.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/win/WebFrameNetworkingContext.cpp new file mode 100644 index 0000000..6b20c1f --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/win/WebFrameNetworkingContext.cpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +// Checking this file in empty to get the build system work out of the way. +// Will put the code in here later. diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/win/WebFrameNetworkingContext.h b/Source/WebKit2/WebProcess/WebCoreSupport/win/WebFrameNetworkingContext.h new file mode 100644 index 0000000..016dcce --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/win/WebFrameNetworkingContext.h @@ -0,0 +1,47 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef WebFrameNetworkingContext_h +#define WebFrameNetworkingContext_h + +#include <WebCore/FrameNetworkingContext.h> +#include <WebCore/ResourceError.h> +#include <WebCore/ResourceRequest.h> + +class WebFrameNetworkingContext : public WebCore::FrameNetworkingContext { +public: + static PassRefPtr<WebFrameNetworkingContext> create(WebCore::Frame* frame) + { + return adoptRef(new WebFrameNetworkingContext(frame)); + } + +private: + WebFrameNetworkingContext(WebCore::Frame* frame) + : WebCore::FrameNetworkingContext(frame) + { + } + + virtual WTF::String userAgent() const; + virtual WTF::String referrer() const; + virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const; + + WTF::String m_userAgent; +}; + +#endif // WebFrameNetworkingContext_h diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp new file mode 100644 index 0000000..9c23133 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebPopupMenu.h" + +#include "PlatformPopupMenuData.h" +#include <WebCore/Font.h> +#include <WebCore/GraphicsContext.h> +#include <WebCore/TextRun.h> +#include <WebCore/PopupMenuClient.h> +#include <WebCore/PopupMenuStyle.h> +#include <WebCore/RenderTheme.h> + +using namespace WebCore; + +namespace WebKit { + +static const int separatorPadding = 4; +static const int separatorHeight = 1; +static const int popupWindowBorderWidth = 1; + +void WebPopupMenu::setUpPlatformData(const WebCore::IntRect& pageCoordinates, PlatformPopupMenuData& data) +{ + int itemCount = m_popupClient->listSize(); + + data.m_clientPaddingLeft = m_popupClient->clientPaddingLeft(); + data.m_clientPaddingRight = m_popupClient->clientPaddingRight(); + data.m_clientInsetLeft = m_popupClient->clientInsetLeft(); + data.m_clientInsetRight = m_popupClient->clientInsetRight(); + data.m_itemHeight = m_popupClient->menuStyle().font().height() + 1; + + int popupWidth = 0; + for (size_t i = 0; i < itemCount; ++i) { + String text = m_popupClient->itemText(i); + if (text.isEmpty()) + continue; + + Font itemFont = m_popupClient->menuStyle().font(); + if (m_popupClient->itemIsLabel(i)) { + FontDescription d = itemFont.fontDescription(); + d.setWeight(d.bolderWeight()); + itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing()); + itemFont.update(m_popupClient->fontSelector()); + } + + popupWidth = std::max(popupWidth, itemFont.width(TextRun(text.characters(), text.length()))); + } + + // FIXME: popupWidth should probably take into account monitor constraints as is done with WebPopupMenuProxyWin::calculatePositionAndSize. + + popupWidth += max(0, data.m_clientPaddingRight - data.m_clientInsetRight) + max(0, data.m_clientPaddingLeft - data.m_clientInsetLeft); + popupWidth += 2 * popupWindowBorderWidth; + data.m_popupWidth = popupWidth; + + // The backing stores should be drawn at least as wide as the control on the page to match the width of the popup window we'll create. + int backingStoreWidth = max(pageCoordinates.width() - m_popupClient->clientInsetLeft() - m_popupClient->clientInsetRight(), popupWidth); + + data.m_backingStoreSize = IntSize(backingStoreWidth, (itemCount * data.m_itemHeight)); + data.m_notSelectedBackingStore = ShareableBitmap::createShareable(data.m_backingStoreSize); + data.m_selectedBackingStore = ShareableBitmap::createShareable(data.m_backingStoreSize); + + OwnPtr<GraphicsContext> notSelectedBackingStoreContext = data.m_notSelectedBackingStore->createGraphicsContext(); + OwnPtr<GraphicsContext> selectedBackingStoreContext = data.m_selectedBackingStore->createGraphicsContext(); + + Color activeOptionBackgroundColor = RenderTheme::defaultTheme()->activeListBoxSelectionBackgroundColor(); + Color activeOptionTextColor = RenderTheme::defaultTheme()->activeListBoxSelectionForegroundColor(); + + for (int y = 0; y < data.m_backingStoreSize.height(); y += data.m_itemHeight) { + int index = y / data.m_itemHeight; + + PopupMenuStyle itemStyle = m_popupClient->itemStyle(index); + + Color optionBackgroundColor = itemStyle.backgroundColor(); + Color optionTextColor = itemStyle.foregroundColor(); + + IntRect itemRect(0, y, backingStoreWidth, data.m_itemHeight); + + // Draw the background for this menu item + if (itemStyle.isVisible()) { + notSelectedBackingStoreContext->fillRect(itemRect, optionBackgroundColor, ColorSpaceDeviceRGB); + selectedBackingStoreContext->fillRect(itemRect, activeOptionBackgroundColor, ColorSpaceDeviceRGB); + } + + if (m_popupClient->itemIsSeparator(index)) { + IntRect separatorRect(itemRect.x() + separatorPadding, itemRect.y() + (itemRect.height() - separatorHeight) / 2, itemRect.width() - 2 * separatorPadding, separatorHeight); + + notSelectedBackingStoreContext->fillRect(separatorRect, optionTextColor, ColorSpaceDeviceRGB); + selectedBackingStoreContext->fillRect(separatorRect, activeOptionTextColor, ColorSpaceDeviceRGB); + continue; + } + + String itemText = m_popupClient->itemText(index); + + unsigned length = itemText.length(); + const UChar* string = itemText.characters(); + TextRun textRun(string, length, false, 0, 0, itemText.defaultWritingDirection() == WTF::Unicode::RightToLeft); + + notSelectedBackingStoreContext->setFillColor(optionTextColor, ColorSpaceDeviceRGB); + selectedBackingStoreContext->setFillColor(activeOptionTextColor, ColorSpaceDeviceRGB); + + Font itemFont = m_popupClient->menuStyle().font(); + if (m_popupClient->itemIsLabel(index)) { + FontDescription d = itemFont.fontDescription(); + d.setWeight(d.bolderWeight()); + itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing()); + itemFont.update(m_popupClient->fontSelector()); + } + + // Draw the item text + if (itemStyle.isVisible()) { + int textX = std::max(0, data.m_clientPaddingLeft - data.m_clientInsetLeft); + if (RenderTheme::defaultTheme()->popupOptionSupportsTextIndent() && itemStyle.textDirection() == LTR) + textX += itemStyle.textIndent().calcMinValue(itemRect.width()); + int textY = itemRect.y() + itemFont.ascent() + (itemRect.height() - itemFont.height()) / 2; + + notSelectedBackingStoreContext->drawBidiText(itemFont, textRun, IntPoint(textX, textY)); + selectedBackingStoreContext->drawBidiText(itemFont, textRun, IntPoint(textX, textY)); + } + } +} + +} // namespace WebKit |
