diff options
author | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-05-30 12:48:17 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-05-30 12:48:17 +0200 |
commit | 881da28418d380042aa95a97f0cbd42560a64f7c (patch) | |
tree | a794dff3274695e99c651902dde93d934ea7a5af /Source/WebKit2/UIProcess/API/gtk | |
parent | 7e104c57a70fdf551bb3d22a5d637cdcbc69dbea (diff) | |
parent | 0fcedcd17cc00d3dd44c718b3cb36c1033319671 (diff) | |
download | qtwebkit-881da28418d380042aa95a97f0cbd42560a64f7c.tar.gz |
Merge 'wip/next' into dev
Change-Id: Iff9ee5e23bb326c4371ec8ed81d56f2f05d680e9
Diffstat (limited to 'Source/WebKit2/UIProcess/API/gtk')
184 files changed, 0 insertions, 35497 deletions
diff --git a/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp deleted file mode 100644 index bd214f3b6..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. - * Copyright (C) 2011 Igalia S.L. - * - * 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 "config.h" -#include "PageClientImpl.h" - -#include "DrawingAreaProxyImpl.h" -#include "NativeWebKeyboardEvent.h" -#include "NativeWebMouseEvent.h" -#include "NotImplemented.h" -#include "WebContext.h" -#include "WebContextMenuProxyGtk.h" -#include "WebEventFactory.h" -#include "WebKitWebViewBasePrivate.h" -#include "WebPageProxy.h" -#include "WebPopupMenuProxyGtk.h" -#include <WebCore/Cursor.h> -#include <WebCore/EventNames.h> -#include <WebCore/GtkUtilities.h> -#include <wtf/text/CString.h> -#include <wtf/text/WTFString.h> - -using namespace WebCore; - -namespace WebKit { - -PageClientImpl::PageClientImpl(GtkWidget* viewWidget) - : m_viewWidget(viewWidget) -{ -} - -PageClientImpl::~PageClientImpl() -{ -} - -void PageClientImpl::getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent& event, const AtomicString& eventType, Vector<WTF::String>& commandList) -{ - ASSERT(eventType == eventNames().keydownEvent || eventType == eventNames().keypressEvent); - - KeyBindingTranslator::EventType type = eventType == eventNames().keydownEvent ? - KeyBindingTranslator::KeyDown : KeyBindingTranslator::KeyPress; - m_keyBindingTranslator.getEditorCommandsForKeyEvent(const_cast<GdkEventKey*>(&event.nativeEvent()->key), type, commandList); -} - -// PageClient's pure virtual functions -PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy() -{ - return DrawingAreaProxyImpl::create(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_viewWidget))); -} - -void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect) -{ - gtk_widget_queue_draw_area(m_viewWidget, rect.x(), rect.y(), rect.width(), rect.height()); -} - -void PageClientImpl::displayView() -{ - notImplemented(); -} - -void PageClientImpl::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset) -{ - setViewNeedsDisplay(scrollRect); -} - -WebCore::IntSize PageClientImpl::viewSize() -{ - if (!gtk_widget_get_realized(m_viewWidget)) - return IntSize(); - GtkAllocation allocation; - gtk_widget_get_allocation(m_viewWidget, &allocation); - return IntSize(allocation.width, allocation.height); -} - -bool PageClientImpl::isViewWindowActive() -{ - return webkitWebViewBaseIsInWindowActive(WEBKIT_WEB_VIEW_BASE(m_viewWidget)); -} - -bool PageClientImpl::isViewFocused() -{ - return webkitWebViewBaseIsFocused(WEBKIT_WEB_VIEW_BASE(m_viewWidget)); -} - -bool PageClientImpl::isViewVisible() -{ - return webkitWebViewBaseIsVisible(WEBKIT_WEB_VIEW_BASE(m_viewWidget)); -} - -bool PageClientImpl::isViewInWindow() -{ - return webkitWebViewBaseIsInWindow(WEBKIT_WEB_VIEW_BASE(m_viewWidget)); -} - -void PageClientImpl::PageClientImpl::processDidCrash() -{ - notImplemented(); -} - -void PageClientImpl::didRelaunchProcess() -{ - notImplemented(); -} - -void PageClientImpl::takeFocus(bool) -{ - notImplemented(); -} - -void PageClientImpl::toolTipChanged(const String&, const String& newToolTip) -{ - webkitWebViewBaseSetTooltipText(WEBKIT_WEB_VIEW_BASE(m_viewWidget), newToolTip.utf8().data()); -} - -void PageClientImpl::setCursor(const Cursor& cursor) -{ - if (!gtk_widget_get_realized(m_viewWidget)) - return; - - // [GTK] Widget::setCursor() gets called frequently - // http://bugs.webkit.org/show_bug.cgi?id=16388 - // Setting the cursor may be an expensive operation in some backends, - // so don't re-set the cursor if it's already set to the target value. - GdkWindow* window = gtk_widget_get_window(m_viewWidget); - GdkCursor* currentCursor = gdk_window_get_cursor(window); - GdkCursor* newCursor = cursor.platformCursor().get(); - if (currentCursor != newCursor) - gdk_window_set_cursor(window, newCursor); -} - -void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves) -{ - notImplemented(); -} - -void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes&) -{ - notImplemented(); -} - -void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo) -{ - notImplemented(); -} - -void PageClientImpl::clearAllEditCommands() -{ - notImplemented(); -} - -bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo) -{ - notImplemented(); - return false; -} - -void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo) -{ - notImplemented(); -} - -FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& viewRect) -{ - notImplemented(); - return viewRect; -} - -FloatRect PageClientImpl::convertToUserSpace(const FloatRect& viewRect) -{ - notImplemented(); - return viewRect; -} - -IntPoint PageClientImpl::screenToWindow(const IntPoint& point) -{ - IntPoint widgetPositionOnScreen = convertWidgetPointToScreenPoint(m_viewWidget, IntPoint()); - IntPoint result(point); - result.move(-widgetPositionOnScreen.x(), -widgetPositionOnScreen.y()); - return result; -} - -IntRect PageClientImpl::windowToScreen(const IntRect& rect) -{ - return IntRect(convertWidgetPointToScreenPoint(m_viewWidget, rect.location()), rect.size()); -} - -void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool wasEventHandled) -{ - if (wasEventHandled) - return; - if (event.isFakeEventForComposition()) - return; - - WebKitWebViewBase* webkitWebViewBase = WEBKIT_WEB_VIEW_BASE(m_viewWidget); - webkitWebViewBaseForwardNextKeyEvent(webkitWebViewBase); - gtk_main_do_event(event.nativeEvent()); -} - -PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page) -{ - return WebPopupMenuProxyGtk::create(m_viewWidget, page); -} - -PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page) -{ - return WebContextMenuProxyGtk::create(m_viewWidget, page); -} - -#if ENABLE(INPUT_TYPE_COLOR) -PassRefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy*, const WebCore::Color&, const WebCore::IntRect&) -{ - notImplemented(); - return 0; -} -#endif - -void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut, bool animate) -{ - notImplemented(); -} - -#if USE(ACCELERATED_COMPOSITING) -void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&) -{ - notImplemented(); -} - -void PageClientImpl::exitAcceleratedCompositingMode() -{ - notImplemented(); -} - -void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&) -{ - notImplemented(); -} -#endif // USE(ACCELERATED_COMPOSITING) - -void PageClientImpl::pageClosed() -{ - notImplemented(); -} - -void PageClientImpl::preferencesDidChange() -{ - notImplemented(); -} - -void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&) -{ - notImplemented(); -} - -void PageClientImpl::updateTextInputState() -{ - webkitWebViewBaseUpdateTextInputState(WEBKIT_WEB_VIEW_BASE(m_viewWidget)); -} - -void PageClientImpl::startDrag(const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap> dragImage) -{ - webkitWebViewBaseStartDrag(WEBKIT_WEB_VIEW_BASE(m_viewWidget), dragData, dragImage); -} - -void PageClientImpl::handleDownloadRequest(DownloadProxy* download) -{ - webkitWebViewBaseHandleDownloadRequest(WEBKIT_WEB_VIEW_BASE(m_viewWidget), download); -} - -} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h b/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h deleted file mode 100644 index a7469cdbf..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. - * Copyright (C) 2011 Igalia S.L. - * - * 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 PageClientImpl_h -#define PageClientImpl_h - -#include "KeyBindingTranslator.h" -#include "PageClient.h" -#include "WebPageProxy.h" -#include "WindowsKeyboardCodes.h" -#include <WebCore/IntSize.h> -#include <gtk/gtk.h> - -namespace WebKit { - -class DrawingAreaProxy; -class WebPageNamespace; - -class PageClientImpl : public PageClient { -public: - ~PageClientImpl(); - static PassOwnPtr<PageClientImpl> create(GtkWidget* viewWidget) - { - return adoptPtr(new PageClientImpl(viewWidget)); - } - - GtkWidget* viewWidget() { return m_viewWidget; } - -private: - explicit PageClientImpl(GtkWidget*); - - virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy(); - virtual void setViewNeedsDisplay(const WebCore::IntRect&); - virtual void displayView(); - virtual bool canScrollView() { return false; } - virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); - virtual WebCore::IntSize viewSize(); - virtual bool isViewWindowActive(); - virtual bool isViewFocused(); - virtual bool isViewVisible(); - virtual bool isViewInWindow(); - virtual void processDidCrash(); - virtual void didRelaunchProcess(); - virtual void pageClosed(); - virtual void preferencesDidChange(); - virtual void takeFocus(bool direction); - virtual void toolTipChanged(const WTF::String&, const WTF::String&); - virtual void setCursor(const WebCore::Cursor&); - virtual void setCursorHiddenUntilMouseMoves(bool); - virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&); - virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo); - virtual void clearAllEditCommands(); - virtual bool canUndoRedo(WebPageProxy::UndoOrRedo); - virtual void executeUndoRedo(WebPageProxy::UndoOrRedo); - virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&); - virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&); - virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&); - virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&); - virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled); - virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*); - virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*); -#if ENABLE(INPUT_TYPE_COLOR) - virtual PassRefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& intialColor, const WebCore::IntRect&); -#endif - virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut, bool animate); - virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects); - virtual void getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent&, const AtomicString&, Vector<WTF::String>&); - virtual void updateTextInputState(); - virtual void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage); - -#if USE(ACCELERATED_COMPOSITING) - virtual void enterAcceleratedCompositingMode(const LayerTreeContext&); - virtual void exitAcceleratedCompositingMode(); - virtual void updateAcceleratedCompositingMode(const LayerTreeContext&); -#endif - - virtual void handleDownloadRequest(DownloadProxy*); - - // Members of PageClientImpl class - GtkWidget* m_viewWidget; - WebCore::KeyBindingTranslator m_keyBindingTranslator; -}; - -} // namespace WebKit - -#endif // PageClientImpl_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.cpp deleted file mode 100644 index 0699da7ee..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitAuthenticationDialog.h" - -#include "AuthenticationDecisionListener.h" -#include "WebCredential.h" -#include "WebKitPrivate.h" - -using namespace WebKit; - -struct _WebKitAuthenticationDialogPrivate { - RefPtr<AuthenticationChallengeProxy> authenticationChallenge; - - GtkWidget* authWidget; - GtkWidget* defaultButton; - GRefPtr<GtkStyleContext> styleContext; -}; - -WEBKIT_DEFINE_TYPE(WebKitAuthenticationDialog, webkit_authentication_dialog, GTK_TYPE_EVENT_BOX) - -static void webkitAuthenticationDialogAuthenticate(WebKitAuthenticationDialog* authDialog, WebCredential* credential) -{ - WebKitAuthenticationDialogPrivate* priv = authDialog->priv; - priv->authenticationChallenge->listener()->useCredential(credential); - gtk_widget_destroy(GTK_WIDGET(authDialog)); -} - -static void okButtonClicked(GtkButton*, WebKitAuthenticationDialog* authDialog) -{ - WebKitAuthenticationDialogPrivate* priv = authDialog->priv; - RefPtr<WebCredential> webCredential = WebCredential::create(webkitAuthenticationWidgetCreateCredential(WEBKIT_AUTHENTICATION_WIDGET(priv->authWidget))); - webkitAuthenticationDialogAuthenticate(authDialog, webCredential.get()); -} - -static void cancelButtonClicked(GtkButton*, WebKitAuthenticationDialog* authDialog) -{ - webkitAuthenticationDialogAuthenticate(authDialog, 0); -} - -static void webkitAuthenticationDialogInitialize(WebKitAuthenticationDialog* authDialog, CredentialStorageMode credentialStorageMode) -{ - GtkWidget* frame = gtk_frame_new(0); - gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); - - GtkWidget* vBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6); - gtk_container_set_border_width(GTK_CONTAINER(vBox), 5); - - GtkWidget* buttonBox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL); - gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonBox), GTK_BUTTONBOX_END); - gtk_container_set_border_width(GTK_CONTAINER(buttonBox), 5); - gtk_box_set_spacing(GTK_BOX(buttonBox), 6); - - GtkWidget* button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); - g_signal_connect(button, "clicked", G_CALLBACK(cancelButtonClicked), authDialog); - gtk_box_pack_end(GTK_BOX(buttonBox), button, FALSE, TRUE, 0); - gtk_widget_show(button); - - button = gtk_button_new_from_stock(GTK_STOCK_OK); - authDialog->priv->defaultButton = button; - g_signal_connect(button, "clicked", G_CALLBACK(okButtonClicked), authDialog); - gtk_widget_set_can_default(button, TRUE); - gtk_box_pack_end(GTK_BOX(buttonBox), button, FALSE, TRUE, 0); - gtk_widget_show(button); - - authDialog->priv->authWidget = webkitAuthenticationWidgetNew(authDialog->priv->authenticationChallenge->core(), credentialStorageMode); - gtk_box_pack_start(GTK_BOX(vBox), authDialog->priv->authWidget, TRUE, TRUE, 0); - gtk_widget_show(authDialog->priv->authWidget); - - gtk_box_pack_end(GTK_BOX(vBox), buttonBox, FALSE, TRUE, 0); - gtk_widget_show(buttonBox); - - gtk_container_add(GTK_CONTAINER(frame), vBox); - gtk_widget_show(vBox); - - gtk_container_add(GTK_CONTAINER(authDialog), frame); - gtk_widget_show(frame); -} - -static gboolean webkitAuthenticationDialogDraw(GtkWidget* widget, cairo_t* cr) -{ - WebKitAuthenticationDialogPrivate* priv = WEBKIT_AUTHENTICATION_DIALOG(widget)->priv; - - gtk_style_context_save(priv->styleContext.get()); - gtk_style_context_add_class(priv->styleContext.get(), GTK_STYLE_CLASS_BACKGROUND); - gtk_render_background(priv->styleContext.get(), cr, 0, 0, gtk_widget_get_allocated_width(widget), gtk_widget_get_allocated_height(widget)); - gtk_style_context_restore(priv->styleContext.get()); - - GTK_WIDGET_CLASS(webkit_authentication_dialog_parent_class)->draw(widget, cr); - - return FALSE; -} - -static void webkitAuthenticationDialogMap(GtkWidget* widget) -{ - WebKitAuthenticationDialogPrivate* priv = WEBKIT_AUTHENTICATION_DIALOG(widget)->priv; - gtk_widget_grab_default(priv->defaultButton); - - GTK_WIDGET_CLASS(webkit_authentication_dialog_parent_class)->map(widget); -} - -static void webkitAuthenticationDialogConstructed(GObject* object) -{ - G_OBJECT_CLASS(webkit_authentication_dialog_parent_class)->constructed(object); - - WebKitAuthenticationDialogPrivate* priv = WEBKIT_AUTHENTICATION_DIALOG(object)->priv; - priv->styleContext = adoptGRef(gtk_style_context_new()); - GtkWidgetPath* path = gtk_widget_path_new(); - gtk_widget_path_append_type(path, GTK_TYPE_WINDOW); - gtk_style_context_set_path(priv->styleContext.get(), path); - gtk_widget_path_free(path); -} - -static void webkit_authentication_dialog_class_init(WebKitAuthenticationDialogClass* klass) -{ - GObjectClass* objectClass = G_OBJECT_CLASS(klass); - objectClass->constructed = webkitAuthenticationDialogConstructed; - - GtkWidgetClass* widgetClass = GTK_WIDGET_CLASS(klass); - widgetClass->draw = webkitAuthenticationDialogDraw; - widgetClass->map = webkitAuthenticationDialogMap; -} - -GtkWidget* webkitAuthenticationDialogNew(AuthenticationChallengeProxy* authenticationChallenge, CredentialStorageMode mode) -{ - WebKitAuthenticationDialog* authDialog = WEBKIT_AUTHENTICATION_DIALOG(g_object_new(WEBKIT_TYPE_AUTHENTICATION_DIALOG, NULL)); - authDialog->priv->authenticationChallenge = authenticationChallenge; - webkitAuthenticationDialogInitialize(authDialog, mode); - return GTK_WIDGET(authDialog); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.h b/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.h deleted file mode 100644 index 7d4de2a6d..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitAuthenticationDialog_h -#define WebKitAuthenticationDialog_h - -#include "AuthenticationChallengeProxy.h" -#include "WebKitAuthenticationWidget.h" -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_AUTHENTICATION_DIALOG (webkit_authentication_dialog_get_type()) -#define WEBKIT_AUTHENTICATION_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_AUTHENTICATION_DIALOG, WebKitAuthenticationDialog)) -#define WEBKIT_IS_AUTHENTICATION_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_AUTHENTICATION_DIALOG)) -#define WEBKIT_AUTHENTICATION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_AUTHENTICATION_DIALOG, WebKitAuthenticationDialogClass)) -#define WEBKIT_IS_AUTHENTICATION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_AUTHENTICATION_DIALOG)) -#define WEBKIT_AUTHENTICATION_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_AUTHENTICATION_DIALOG, WebKitAuthenticationDialogClass)) - -typedef struct _WebKitAuthenticationDialog WebKitAuthenticationDialog; -typedef struct _WebKitAuthenticationDialogClass WebKitAuthenticationDialogClass; -typedef struct _WebKitAuthenticationDialogPrivate WebKitAuthenticationDialogPrivate; - -struct _WebKitAuthenticationDialog { - GtkEventBox parent; - - WebKitAuthenticationDialogPrivate* priv; -}; - -struct _WebKitAuthenticationDialogClass { - GtkEventBoxClass parentClass; -}; - -GType webkit_authentication_dialog_get_type(); -GtkWidget* webkitAuthenticationDialogNew(WebKit::AuthenticationChallengeProxy*, CredentialStorageMode); - -G_END_DECLS - -#endif // WebKitAuthenticationDialog_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.cpp deleted file mode 100644 index 47aaa4cc8..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 "WebKitBackForwardList.h" - -#include "WebKitBackForwardListPrivate.h" -#include "WebKitMarshal.h" -#include "WebKitPrivate.h" -#include <wtf/gobject/GRefPtr.h> - -/** - * SECTION: WebKitBackForwardList - * @Short_description: List of visited pages - * @Title: WebKitBackForwardList - * @See_also: #WebKitWebView, #WebKitBackForwardListItem - * - * WebKitBackForwardList maintains a list of visited pages used to - * navigate to recent pages. Items are inserted in the list in the - * order they are visited. - * - * WebKitBackForwardList also maintains the notion of the current item - * (which is always at index 0), the preceding item (which is at index -1), - * and the following item (which is at index 1). - * Methods webkit_web_view_go_back() and webkit_web_view_go_forward() move - * the current item backward or forward by one. Method - * webkit_web_view_go_to_back_forward_list_item() sets the current item to the - * specified item. All other methods returning #WebKitBackForwardListItem<!-- -->s - * do not change the value of the current item, they just return the requested - * item or items. - */ - -using namespace WebKit; - -enum { - CHANGED, - - LAST_SIGNAL -}; - -typedef HashMap<WebBackForwardListItem*, GRefPtr<WebKitBackForwardListItem> > BackForwardListItemsMap; - -struct _WebKitBackForwardListPrivate { - WebBackForwardList* backForwardItems; - BackForwardListItemsMap itemsMap; -}; - -static guint signals[LAST_SIGNAL] = { 0, }; - -WEBKIT_DEFINE_TYPE(WebKitBackForwardList, webkit_back_forward_list, G_TYPE_OBJECT) - -static void webkit_back_forward_list_class_init(WebKitBackForwardListClass* listClass) -{ - /** - * WebKitBackForwardList::changed: - * @back_forward_list: the #WebKitBackForwardList on which the signal was emitted - * @item_added: (allow-none): the #WebKitBackForwardListItem added or %NULL - * @items_removed: a #GList of #WebKitBackForwardListItem<!-- -->s - * - * This signal is emitted when @back_forward_list changes. This happens - * when the current item is updated, a new item is added or one or more - * items are removed. Note that both @item_added and @items_removed can - * %NULL when only the current item is updated. Items are only removed - * when the list is cleared or the maximum items limit is reached. - */ - signals[CHANGED] = - g_signal_new("changed", - G_TYPE_FROM_CLASS(listClass), - G_SIGNAL_RUN_LAST, - 0, 0, 0, - webkit_marshal_VOID__OBJECT_POINTER, - G_TYPE_NONE, 2, - WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM, - G_TYPE_POINTER); -} - -static WebKitBackForwardListItem* webkitBackForwardListGetOrCreateItem(WebKitBackForwardList* list, WebBackForwardListItem* webListItem) -{ - if (!webListItem) - return 0; - - WebKitBackForwardListPrivate* priv = list->priv; - GRefPtr<WebKitBackForwardListItem> listItem = priv->itemsMap.get(webListItem); - if (listItem) - return listItem.get(); - - listItem = webkitBackForwardListItemGetOrCreate(webListItem); - priv->itemsMap.set(webListItem, listItem); - - return listItem.get(); -} - -static GList* webkitBackForwardListCreateList(WebKitBackForwardList* list, ImmutableArray* backForwardItems) -{ - if (!backForwardItems) - return 0; - - GList* returnValue = 0; - for (size_t i = 0; i < backForwardItems->size(); ++i) { - WebBackForwardListItem* webItem = static_cast<WebBackForwardListItem*>(backForwardItems->at(i)); - returnValue = g_list_prepend(returnValue, webkitBackForwardListGetOrCreateItem(list, webItem)); - } - - return returnValue; -} - -WebKitBackForwardList* webkitBackForwardListCreate(WebBackForwardList* backForwardItems) -{ - WebKitBackForwardList* list = WEBKIT_BACK_FORWARD_LIST(g_object_new(WEBKIT_TYPE_BACK_FORWARD_LIST, NULL)); - list->priv->backForwardItems = backForwardItems; - - return list; -} - -void webkitBackForwardListChanged(WebKitBackForwardList* backForwardList, WebBackForwardListItem* webAddedItem, ImmutableArray* webRemovedItems) -{ - WebKitBackForwardListItem* addedItem = webkitBackForwardListGetOrCreateItem(backForwardList, webAddedItem); - GList* removedItems = 0; - - size_t removedItemsSize = webRemovedItems ? webRemovedItems->size() : 0; - WebKitBackForwardListPrivate* priv = backForwardList->priv; - for (size_t i = 0; i < removedItemsSize; ++i) { - WebBackForwardListItem* webItem = static_cast<WebBackForwardListItem*>(webRemovedItems->at(i)); - removedItems = g_list_prepend(removedItems, g_object_ref(G_OBJECT(priv->itemsMap.get(webItem).get()))); - priv->itemsMap.remove(webItem); - } - - g_signal_emit(backForwardList, signals[CHANGED], 0, addedItem, removedItems, NULL); - g_list_free_full(removedItems, static_cast<GDestroyNotify>(g_object_unref)); -} - -/** - * webkit_back_forward_list_get_current_item: - * @back_forward_list: a #WebKitBackForwardList - * - * Returns the current item in @back_forward_list. - * - * Returns: (transfer none): a #WebKitBackForwardListItem - * or %NULL if @back_forward_list is empty. - */ -WebKitBackForwardListItem* webkit_back_forward_list_get_current_item(WebKitBackForwardList* backForwardList) -{ - g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0); - - return webkitBackForwardListGetOrCreateItem(backForwardList, backForwardList->priv->backForwardItems->currentItem()); -} - -/** - * webkit_back_forward_list_get_back_item: - * @back_forward_list: a #WebKitBackForwardList - * - * Returns the item that precedes the current item. - * - * Returns: (transfer none): the #WebKitBackForwardListItem - * preceding the current item or %NULL. - */ -WebKitBackForwardListItem* webkit_back_forward_list_get_back_item(WebKitBackForwardList* backForwardList) -{ - g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0); - - return webkitBackForwardListGetOrCreateItem(backForwardList, backForwardList->priv->backForwardItems->backItem()); -} - -/** - * webkit_back_forward_list_get_forward_item: - * @back_forward_list: a #WebKitBackForwardList - * - * Returns the item that follows the current item. - * - * Returns: (transfer none): the #WebKitBackForwardListItem - * following the current item or %NULL. - */ -WebKitBackForwardListItem* webkit_back_forward_list_get_forward_item(WebKitBackForwardList* backForwardList) -{ - g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0); - - return webkitBackForwardListGetOrCreateItem(backForwardList, backForwardList->priv->backForwardItems->forwardItem()); -} - -/** - * webkit_back_forward_list_get_nth_item: - * @back_forward_list: a #WebKitBackForwardList - * @index: the index of the item - * - * Returns the item at a given index relative to the current item. - * - * Returns: (transfer none): the #WebKitBackForwardListItem - * located at the specified index relative to the current item. - */ -WebKitBackForwardListItem* webkit_back_forward_list_get_nth_item(WebKitBackForwardList* backForwardList, gint index) -{ - g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0); - - return webkitBackForwardListGetOrCreateItem(backForwardList, backForwardList->priv->backForwardItems->itemAtIndex(index)); -} - -/** - * webkit_back_forward_list_get_length: - * @back_forward_list: a #WebKitBackForwardList - * - * Returns: the length of @back_forward_list. - */ -guint webkit_back_forward_list_get_length(WebKitBackForwardList* backForwardList) -{ - g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0); - - WebKitBackForwardListPrivate* priv = backForwardList->priv; - guint currentItem = webkit_back_forward_list_get_current_item(backForwardList) ? 1 : 0; - return priv->backForwardItems->backListCount() + priv->backForwardItems->forwardListCount() + currentItem; -} - -/** - * webkit_back_forward_list_get_back_list: - * @back_forward_list: a #WebKitBackForwardList - * - * Returns: (element-type WebKit2.BackForwardListItem) (transfer container): a #GList of - * items preceding the current item. - */ -GList* webkit_back_forward_list_get_back_list(WebKitBackForwardList* backForwardList) -{ - g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0); - - return webkit_back_forward_list_get_back_list_with_limit(backForwardList, backForwardList->priv->backForwardItems->backListCount()); -} - -/** - * webkit_back_forward_list_get_back_list_with_limit: - * @back_forward_list: a #WebKitBackForwardList - * @limit: the number of items to retrieve - * - * Returns: (element-type WebKit2.BackForwardListItem) (transfer container): a #GList of - * items preceding the current item limited by @limit. - */ -GList* webkit_back_forward_list_get_back_list_with_limit(WebKitBackForwardList* backForwardList, guint limit) -{ - g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0); - - WebKitBackForwardListPrivate* priv = backForwardList->priv; - RefPtr<ImmutableArray> immutableArray = priv->backForwardItems->backListAsImmutableArrayWithLimit(limit); - return webkitBackForwardListCreateList(backForwardList, immutableArray.get()); -} - -/** - * webkit_back_forward_list_get_forward_list: - * @back_forward_list: a #WebKitBackForwardList - * - * Returns: (element-type WebKit2.BackForwardListItem) (transfer container): a #GList of - * items following the current item. - */ -GList* webkit_back_forward_list_get_forward_list(WebKitBackForwardList* backForwardList) -{ - g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0); - - return webkit_back_forward_list_get_forward_list_with_limit(backForwardList, backForwardList->priv->backForwardItems->forwardListCount()); -} - -/** - * webkit_back_forward_list_get_forward_list_with_limit: - * @back_forward_list: a #WebKitBackForwardList - * @limit: the number of items to retrieve - * - * Returns: (element-type WebKit2.BackForwardListItem) (transfer container): a #GList of - * items following the current item limited by @limit. - */ -GList* webkit_back_forward_list_get_forward_list_with_limit(WebKitBackForwardList* backForwardList, guint limit) -{ - g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0); - - WebKitBackForwardListPrivate* priv = backForwardList->priv; - RefPtr<ImmutableArray> immutableArray = priv->backForwardItems->forwardListAsImmutableArrayWithLimit(limit); - return webkitBackForwardListCreateList(backForwardList, immutableArray.get()); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.h b/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.h deleted file mode 100644 index 6fbd42ab0..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitBackForwardList_h -#define WebKitBackForwardList_h - -#include <glib-object.h> -#include <webkit2/WebKitBackForwardListItem.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_BACK_FORWARD_LIST (webkit_back_forward_list_get_type()) -#define WEBKIT_BACK_FORWARD_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_BACK_FORWARD_LIST, WebKitBackForwardList)) -#define WEBKIT_BACK_FORWARD_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_BACK_FORWARD_LIST, WebKitBackForwardListClass)) -#define WEBKIT_IS_BACK_FORWARD_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_BACK_FORWARD_LIST)) -#define WEBKIT_IS_BACK_FORWARD_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_BACK_FORWARD_LIST)) -#define WEBKIT_BACK_FORWARD_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_BACK_FORWARD_LIST, WebKitBackForwardListClass)) - -typedef struct _WebKitBackForwardList WebKitBackForwardList; -typedef struct _WebKitBackForwardListClass WebKitBackForwardListClass; -typedef struct _WebKitBackForwardListPrivate WebKitBackForwardListPrivate; - -struct _WebKitBackForwardList { - GObject parent; - - WebKitBackForwardListPrivate *priv; -}; - -struct _WebKitBackForwardListClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_back_forward_list_get_type (void); - -WEBKIT_API WebKitBackForwardListItem * -webkit_back_forward_list_get_current_item (WebKitBackForwardList *back_forward_list); - -WEBKIT_API WebKitBackForwardListItem * -webkit_back_forward_list_get_back_item (WebKitBackForwardList *back_forward_list); - -WEBKIT_API WebKitBackForwardListItem * -webkit_back_forward_list_get_forward_item (WebKitBackForwardList *back_forward_list); - -WEBKIT_API WebKitBackForwardListItem * -webkit_back_forward_list_get_nth_item (WebKitBackForwardList *back_forward_list, - gint index); -WEBKIT_API guint -webkit_back_forward_list_get_length (WebKitBackForwardList *back_forward_list); - -WEBKIT_API GList * -webkit_back_forward_list_get_back_list (WebKitBackForwardList *back_forward_list); - -WEBKIT_API GList * -webkit_back_forward_list_get_back_list_with_limit (WebKitBackForwardList *back_forward_list, - guint limit); - -WEBKIT_API GList * -webkit_back_forward_list_get_forward_list (WebKitBackForwardList *back_forward_list); - -WEBKIT_API GList * -webkit_back_forward_list_get_forward_list_with_limit (WebKitBackForwardList *back_forward_list, - guint limit); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.cpp deleted file mode 100644 index ae18b05ec..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 "WebKitBackForwardListItem.h" - -#include "WebKitBackForwardListPrivate.h" -#include "WebKitPrivate.h" -#include <wtf/HashMap.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -using namespace WebKit; - -/** - * SECTION: WebKitBackForwardListItem - * @Short_description: One item of the #WebKitBackForwardList - * @Title: WebKitBackForwardListItem - * @See_also: #WebKitBackForwardList - * - * A history item is part of the #WebKitBackForwardList and consists - * out of a title and a URI. - * - */ - -struct _WebKitBackForwardListItemPrivate { - RefPtr<WebBackForwardListItem> webListItem; - CString uri; - CString title; - CString originalURI; -}; - -WEBKIT_DEFINE_TYPE(WebKitBackForwardListItem, webkit_back_forward_list_item, G_TYPE_INITIALLY_UNOWNED) - -static void webkit_back_forward_list_item_class_init(WebKitBackForwardListItemClass* listItemClass) -{ -} - -typedef HashMap<WebBackForwardListItem*, WebKitBackForwardListItem*> HistoryItemsMap; - -static HistoryItemsMap& historyItemsMap() -{ - DEFINE_STATIC_LOCAL(HistoryItemsMap, itemsMap, ()); - return itemsMap; -} - -static void webkitBackForwardListItemFinalized(gpointer webListItem, GObject* finalizedListItem) -{ - ASSERT(G_OBJECT(historyItemsMap().get(static_cast<WebBackForwardListItem*>(webListItem))) == finalizedListItem); - historyItemsMap().remove(static_cast<WebBackForwardListItem*>(webListItem)); -} - -WebKitBackForwardListItem* webkitBackForwardListItemGetOrCreate(WebBackForwardListItem* webListItem) -{ - if (!webListItem) - return 0; - - WebKitBackForwardListItem* listItem = historyItemsMap().get(webListItem); - if (listItem) - return listItem; - - listItem = WEBKIT_BACK_FORWARD_LIST_ITEM(g_object_new(WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM, NULL)); - listItem->priv->webListItem = webListItem; - - g_object_weak_ref(G_OBJECT(listItem), webkitBackForwardListItemFinalized, webListItem); - historyItemsMap().set(webListItem, listItem); - - return listItem; -} - -WebBackForwardListItem* webkitBackForwardListItemGetItem(WebKitBackForwardListItem* listItem) -{ - return listItem->priv->webListItem.get(); -} - -/** - * webkit_back_forward_list_item_get_uri: - * @list_item: a #WebKitBackForwardListItem - * - * This URI may differ from the original URI if the page was, - * for example, redirected to a new location. - * See also webkit_back_forward_list_item_get_original_uri(). - * - * Returns: the URI of @list_item or %NULL - * when the URI is empty. - */ -const gchar* webkit_back_forward_list_item_get_uri(WebKitBackForwardListItem* listItem) -{ - g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(listItem), 0); - - WebKitBackForwardListItemPrivate* priv = listItem->priv; - String url = priv->webListItem->url(); - if (url.isEmpty()) - return 0; - - priv->uri = url.utf8(); - return priv->uri.data(); -} - -/** - * webkit_back_forward_list_item_get_title: - * @list_item: a #WebKitBackForwardListItem - * - * Returns: the page title of @list_item or %NULL - * when the title is empty. - */ -const gchar* webkit_back_forward_list_item_get_title(WebKitBackForwardListItem* listItem) -{ - g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(listItem), 0); - - WebKitBackForwardListItemPrivate* priv = listItem->priv; - String title = priv->webListItem->title(); - if (title.isEmpty()) - return 0; - - priv->title = title.utf8(); - return priv->title.data(); -} - -/** - * webkit_back_forward_list_item_get_original_uri: - * @list_item: a #WebKitBackForwardListItem - * - * See also webkit_back_forward_list_item_get_uri(). - * - * Returns: the original URI of @list_item or %NULL - * when the original URI is empty. - */ -const gchar* webkit_back_forward_list_item_get_original_uri(WebKitBackForwardListItem* listItem) -{ - g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(listItem), 0); - - WebKitBackForwardListItemPrivate* priv = listItem->priv; - String originalURL = priv->webListItem->originalURL(); - if (originalURL.isEmpty()) - return 0; - - priv->originalURI = originalURL.utf8(); - return priv->originalURI.data(); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.h b/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.h deleted file mode 100644 index 5090e516c..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitBackForwardListItem_h -#define WebKitBackForwardListItem_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM (webkit_back_forward_list_item_get_type()) -#define WEBKIT_BACK_FORWARD_LIST_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM, WebKitBackForwardListItem)) -#define WEBKIT_BACK_FORWARD_LIST_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM, WebKitBackForwardListItemClass)) -#define WEBKIT_IS_BACK_FORWARD_LIST_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM)) -#define WEBKIT_IS_BACK_FORWARD_LIST_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM)) -#define WEBKIT_BACK_FORWARD_LIST_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM, WebKitBackForwardListItemClass)) - -typedef struct _WebKitBackForwardListItem WebKitBackForwardListItem; -typedef struct _WebKitBackForwardListItemClass WebKitBackForwardListItemClass; -typedef struct _WebKitBackForwardListItemPrivate WebKitBackForwardListItemPrivate; - -struct _WebKitBackForwardListItem { - GInitiallyUnowned parent; - - WebKitBackForwardListItemPrivate *priv; -}; - -struct _WebKitBackForwardListItemClass { - GInitiallyUnownedClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_back_forward_list_item_get_type (void); - -WEBKIT_API const gchar * -webkit_back_forward_list_item_get_uri (WebKitBackForwardListItem* list_item); - -WEBKIT_API const gchar * -webkit_back_forward_list_item_get_title (WebKitBackForwardListItem* list_item); - -WEBKIT_API const gchar * -webkit_back_forward_list_item_get_original_uri (WebKitBackForwardListItem* list_item); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListPrivate.h deleted file mode 100644 index 540f66594..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListPrivate.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 WebKitBackForwardListPrivate_h -#define WebKitBackForwardListPrivate_h - -#include "WebBackForwardList.h" -#include "WebKitBackForwardList.h" - -WebKitBackForwardList* webkitBackForwardListCreate(WebKit::WebBackForwardList*); -WebKitBackForwardListItem* webkitBackForwardListItemGetOrCreate(WebKit::WebBackForwardListItem*); -WebKit::WebBackForwardListItem* webkitBackForwardListItemGetItem(WebKitBackForwardListItem*); -void webkitBackForwardListChanged(WebKitBackForwardList*, WebKit::WebBackForwardListItem* webAddedItem, WebKit::ImmutableArray* webRemovedItems); - -#endif // WebKitBackForwardListPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenu.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenu.cpp deleted file mode 100644 index 0ab6edba6..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenu.cpp +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitContextMenu.h" - -#include "ImmutableArray.h" -#include "WebContextMenuItem.h" -#include "WebKitContextMenuItemPrivate.h" -#include "WebKitContextMenuPrivate.h" - -using namespace WebKit; -using namespace WebCore; - -/** - * SECTION: WebKitContextMenu - * @Short_description: Represents the context menu in a #WebKitWebView - * @Title: WebKitContextMenu - * - * #WebKitContextMenu represents a context menu containing - * #WebKitContextMenuItem<!-- -->s in a #WebKitWebView. - * - * When a #WebKitWebView is about to display the context menu, it - * emits the #WebKitWebView::context-menu signal, which has the - * #WebKitContextMenu as an argument. You can modify it, adding new - * submenus that you can create with webkit_context_menu_new(), adding - * new #WebKitContextMenuItem<!-- -->s with - * webkit_context_menu_prepend(), webkit_context_menu_append() or - * webkit_context_menu_insert(), maybe after having removed the - * existing ones with webkit_context_menu_remove_all(). - * - */ - -struct _WebKitContextMenuPrivate { - GList* items; - WebKitContextMenuItem* parentItem; -}; - -WEBKIT_DEFINE_TYPE(WebKitContextMenu, webkit_context_menu, G_TYPE_OBJECT) - -static void webkitContextMenuDispose(GObject* object) -{ - webkit_context_menu_remove_all(WEBKIT_CONTEXT_MENU(object)); - G_OBJECT_CLASS(webkit_context_menu_parent_class)->dispose(object); -} - -static void webkit_context_menu_class_init(WebKitContextMenuClass* listClass) -{ - GObjectClass* gObjectClass = G_OBJECT_CLASS(listClass); - gObjectClass->dispose = webkitContextMenuDispose; -} - -void webkitContextMenuPopulate(WebKitContextMenu* menu, Vector<ContextMenuItem>& contextMenuItems) -{ - for (GList* item = menu->priv->items; item; item = g_list_next(item)) { - WebKitContextMenuItem* menuItem = WEBKIT_CONTEXT_MENU_ITEM(item->data); - contextMenuItems.append(ContextMenuItem(webkitContextMenuItemRelease(menuItem))); - } -} - -WebKitContextMenu* webkitContextMenuCreate(ImmutableArray* items) -{ - WebKitContextMenu* menu = webkit_context_menu_new(); - for (size_t i = 0; i < items->size(); ++i) { - WebContextMenuItem* item = static_cast<WebContextMenuItem*>(items->at(i)); - webkit_context_menu_prepend(menu, webkitContextMenuItemCreate(item)); - } - menu->priv->items = g_list_reverse(menu->priv->items); - - return menu; -} - -void webkitContextMenuSetParentItem(WebKitContextMenu* menu, WebKitContextMenuItem* item) -{ - menu->priv->parentItem = item; -} - -WebKitContextMenuItem* webkitContextMenuGetParentItem(WebKitContextMenu* menu) -{ - return menu->priv->parentItem; -} - -/** - * webkit_context_menu_new: - * - * Creates a new #WebKitContextMenu object to be used as a submenu of an existing - * #WebKitContextMenu. The context menu of a #WebKitWebView is created by the view - * and passed as an argument of #WebKitWebView::context-menu signal. - * To add items to the menu use webkit_context_menu_prepend(), - * webkit_context_menu_append() or webkit_context_menu_insert(). - * See also webkit_context_menu_new_with_items() to create a #WebKitContextMenu with - * a list of initial items. - * - * Returns: The newly created #WebKitContextMenu object - */ -WebKitContextMenu* webkit_context_menu_new() -{ - return WEBKIT_CONTEXT_MENU(g_object_new(WEBKIT_TYPE_CONTEXT_MENU, NULL)); -} - -/** - * webkit_context_menu_new_with_items: - * @items: (element-type WebKitContextMenuItem): a #GList of #WebKitContextMenuItem - * - * Creates a new #WebKitContextMenu object to be used as a submenu of an existing - * #WebKitContextMenu with the given initial items. - * See also webkit_context_menu_new() - * - * Returns: The newly created #WebKitContextMenu object - */ -WebKitContextMenu* webkit_context_menu_new_with_items(GList* items) -{ - WebKitContextMenu* menu = webkit_context_menu_new(); - g_list_foreach(items, reinterpret_cast<GFunc>(g_object_ref_sink), 0); - menu->priv->items = g_list_copy(items); - - return menu; -} - -/** - * webkit_context_menu_prepend: - * @menu: a #WebKitContextMenu - * @item: the #WebKitContextMenuItem to add - * - * Adds @item at the beginning of the @menu. - */ -void webkit_context_menu_prepend(WebKitContextMenu* menu, WebKitContextMenuItem* item) -{ - webkit_context_menu_insert(menu, item, 0); -} - -/** - * webkit_context_menu_append: - * @menu: a #WebKitContextMenu - * @item: the #WebKitContextMenuItem to add - * - * Adds @item at the end of the @menu. - */ -void webkit_context_menu_append(WebKitContextMenu* menu, WebKitContextMenuItem* item) -{ - webkit_context_menu_insert(menu, item, -1); -} - -/** - * webkit_context_menu_insert: - * @menu: a #WebKitContextMenu - * @item: the #WebKitContextMenuItem to add - * @position: the position to insert the item - * - * Inserts @item into the @menu at the given position. - * If @position is negative, or is larger than the number of items - * in the #WebKitContextMenu, the item is added on to the end of - * the @menu. The first position is 0. - */ -void webkit_context_menu_insert(WebKitContextMenu* menu, WebKitContextMenuItem* item, int position) -{ - g_return_if_fail(WEBKIT_IS_CONTEXT_MENU(menu)); - g_return_if_fail(WEBKIT_IS_CONTEXT_MENU_ITEM(item)); - - g_object_ref_sink(item); - menu->priv->items = g_list_insert(menu->priv->items, item, position); -} - -/** - * webkit_context_menu_move_item: - * @menu: a #WebKitContextMenu - * @item: the #WebKitContextMenuItem to add - * @position: the new position to move the item - * - * Moves @item to the given position in the @menu. - * If @position is negative, or is larger than the number of items - * in the #WebKitContextMenu, the item is added on to the end of - * the @menu. - * The first position is 0. - */ -void webkit_context_menu_move_item(WebKitContextMenu* menu, WebKitContextMenuItem* item, int position) -{ - g_return_if_fail(WEBKIT_IS_CONTEXT_MENU(menu)); - g_return_if_fail(WEBKIT_IS_CONTEXT_MENU_ITEM(item)); - - if (!g_list_find(menu->priv->items, item)) - return; - - menu->priv->items = g_list_remove(menu->priv->items, item); - menu->priv->items = g_list_insert(menu->priv->items, item, position); -} - -/** - * webkit_context_menu_get_items: - * @menu: a #WebKitContextMenu - * - * Returns the item list of @menu. - * - * Returns: (element-type WebKitContextMenuItem) (transfer none): a #GList of - * #WebKitContextMenuItem<!-- -->s - */ -GList* webkit_context_menu_get_items(WebKitContextMenu* menu) -{ - g_return_val_if_fail(WEBKIT_IS_CONTEXT_MENU(menu), 0); - - return menu->priv->items; -} - -/** - * webkit_context_menu_get_n_items: - * @menu: a #WebKitContextMenu - * - * Gets the length of the @menu. - * - * Returns: the number of #WebKitContextMenuItem<!-- -->s in @menu - */ -guint webkit_context_menu_get_n_items(WebKitContextMenu* menu) -{ - g_return_val_if_fail(WEBKIT_IS_CONTEXT_MENU(menu), 0); - - return g_list_length(menu->priv->items); -} - -/** - * webkit_context_menu_first: - * @menu: a #WebKitContextMenu - * - * Gets the first item in the @menu. - * - * Returns: (transfer none): the first #WebKitContextMenuItem of @menu, - * or %NULL if the #WebKitContextMenu is empty. - */ -WebKitContextMenuItem* webkit_context_menu_first(WebKitContextMenu* menu) -{ - g_return_val_if_fail(WEBKIT_IS_CONTEXT_MENU(menu), 0); - - return menu->priv->items ? WEBKIT_CONTEXT_MENU_ITEM(menu->priv->items->data) : 0; -} - -/** - * webkit_context_menu_last: - * @menu: a #WebKitContextMenu - * - * Gets the last item in the @menu. - * - * Returns: (transfer none): the last #WebKitContextMenuItem of @menu, - * or %NULL if the #WebKitContextMenu is empty. - */ -WebKitContextMenuItem* webkit_context_menu_last(WebKitContextMenu* menu) -{ - g_return_val_if_fail(WEBKIT_IS_CONTEXT_MENU(menu), 0); - - GList* last = g_list_last(menu->priv->items); - return last ? WEBKIT_CONTEXT_MENU_ITEM(last->data) : 0; -} - -/** - * webkit_context_menu_get_item_at_position: - * @menu: a #WebKitContextMenu - * @position: the position of the item, counting from 0 - * - * Gets the item at the given position in the @menu. - * - * Returns: (transfer none): the #WebKitContextMenuItem at position @position in @menu, - * or %NULL if the position is off the end of the @menu. - */ -WebKitContextMenuItem* webkit_context_menu_get_item_at_position(WebKitContextMenu* menu, unsigned position) -{ - g_return_val_if_fail(WEBKIT_IS_CONTEXT_MENU(menu), 0); - - gpointer item = g_list_nth_data(menu->priv->items, position); - return item ? WEBKIT_CONTEXT_MENU_ITEM(item) : 0; -} - -/** - * webkit_context_menu_remove: - * @menu: a #WebKitContextMenu - * @item: the #WebKitContextMenuItem to remove - * - * Removes @item from the @menu. - * See also webkit_context_menu_remove_all() to remove all items. - */ -void webkit_context_menu_remove(WebKitContextMenu* menu, WebKitContextMenuItem* item) -{ - g_return_if_fail(WEBKIT_IS_CONTEXT_MENU(menu)); - g_return_if_fail(WEBKIT_IS_CONTEXT_MENU_ITEM(item)); - - if (!g_list_find(menu->priv->items, item)) - return; - - menu->priv->items = g_list_remove(menu->priv->items, item); - g_object_unref(item); -} - -/** - * webkit_context_menu_remove_all: - * @menu: a #WebKitContextMenu - * - * Removes all items of the @menu. - */ -void webkit_context_menu_remove_all(WebKitContextMenu* menu) -{ - g_return_if_fail(WEBKIT_IS_CONTEXT_MENU(menu)); - - g_list_free_full(menu->priv->items, reinterpret_cast<GDestroyNotify>(g_object_unref)); - menu->priv->items = 0; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenu.h b/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenu.h deleted file mode 100644 index 22f4bef29..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenu.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitContextMenu_h -#define WebKitContextMenu_h - -#include <glib-object.h> -#include <webkit2/WebKitContextMenuItem.h> -#include <webkit2/WebKitDefines.h> -#include <webkit2/WebKitForwardDeclarations.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_CONTEXT_MENU (webkit_context_menu_get_type()) -#define WEBKIT_CONTEXT_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_CONTEXT_MENU, WebKitContextMenu)) -#define WEBKIT_IS_CONTEXT_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_CONTEXT_MENU)) -#define WEBKIT_CONTEXT_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_CONTEXT_MENU, WebKitContextMenuClass)) -#define WEBKIT_IS_CONTEXT_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_CONTEXT_MENU)) -#define WEBKIT_CONTEXT_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_CONTEXT_MENU, WebKitContextMenuClass)) - -typedef struct _WebKitContextMenuClass WebKitContextMenuClass; -typedef struct _WebKitContextMenuPrivate WebKitContextMenuPrivate; - -struct _WebKitContextMenu { - GObject parent; - - WebKitContextMenuPrivate *priv; -}; - -struct _WebKitContextMenuClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_context_menu_get_type (void); - -WEBKIT_API WebKitContextMenu * -webkit_context_menu_new (void); - -WEBKIT_API WebKitContextMenu * -webkit_context_menu_new_with_items (GList *items); - -WEBKIT_API void -webkit_context_menu_prepend (WebKitContextMenu *menu, - WebKitContextMenuItem *item); - -WEBKIT_API void -webkit_context_menu_append (WebKitContextMenu *menu, - WebKitContextMenuItem *item); - -WEBKIT_API void -webkit_context_menu_insert (WebKitContextMenu *menu, - WebKitContextMenuItem *item, - gint position); - -WEBKIT_API void -webkit_context_menu_move_item (WebKitContextMenu *menu, - WebKitContextMenuItem *item, - gint position); -WEBKIT_API GList * -webkit_context_menu_get_items (WebKitContextMenu *menu); - -WEBKIT_API guint -webkit_context_menu_get_n_items (WebKitContextMenu *menu); - -WEBKIT_API WebKitContextMenuItem * -webkit_context_menu_first (WebKitContextMenu *menu); - -WEBKIT_API WebKitContextMenuItem * -webkit_context_menu_last (WebKitContextMenu *menu); - -WEBKIT_API WebKitContextMenuItem * -webkit_context_menu_get_item_at_position (WebKitContextMenu *menu, - guint position); - -WEBKIT_API void -webkit_context_menu_remove (WebKitContextMenu *menu, - WebKitContextMenuItem *item); - -WEBKIT_API void -webkit_context_menu_remove_all (WebKitContextMenu *menu); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuActions.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuActions.cpp deleted file mode 100644 index 3793d7c0f..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuActions.cpp +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitContextMenuActions.h" - -#include "WebKitContextMenuActionsPrivate.h" -#include <WebCore/LocalizedStrings.h> - -using namespace WebCore; - -bool webkitContextMenuActionIsCheckable(WebKitContextMenuAction action) -{ - switch (action) { - case WEBKIT_CONTEXT_MENU_ACTION_BOLD: - case WEBKIT_CONTEXT_MENU_ACTION_ITALIC: - case WEBKIT_CONTEXT_MENU_ACTION_UNDERLINE: - case WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_CONTROLS: - case WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_LOOP: - return true; - default: - return false; - } -} - -ContextMenuAction webkitContextMenuActionGetActionTag(WebKitContextMenuAction action) -{ - switch (action) { - case WEBKIT_CONTEXT_MENU_ACTION_NO_ACTION: - return ContextMenuItemTagNoAction; - case WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK: - return ContextMenuItemTagOpenLink; - case WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK_IN_NEW_WINDOW: - return ContextMenuItemTagOpenLinkInNewWindow; - case WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_LINK_TO_DISK: - return ContextMenuItemTagDownloadLinkToDisk; - case WEBKIT_CONTEXT_MENU_ACTION_COPY_LINK_TO_CLIPBOARD: - return ContextMenuItemTagCopyLinkToClipboard; - case WEBKIT_CONTEXT_MENU_ACTION_OPEN_IMAGE_IN_NEW_WINDOW: - return ContextMenuItemTagOpenImageInNewWindow; - case WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_IMAGE_TO_DISK: - return ContextMenuItemTagDownloadImageToDisk; - case WEBKIT_CONTEXT_MENU_ACTION_COPY_IMAGE_TO_CLIPBOARD: - return ContextMenuItemTagCopyImageToClipboard; - case WEBKIT_CONTEXT_MENU_ACTION_COPY_IMAGE_URL_TO_CLIPBOARD: - return ContextMenuItemTagCopyImageUrlToClipboard; - case WEBKIT_CONTEXT_MENU_ACTION_OPEN_FRAME_IN_NEW_WINDOW: - return ContextMenuItemTagOpenFrameInNewWindow; - case WEBKIT_CONTEXT_MENU_ACTION_GO_BACK: - return ContextMenuItemTagGoBack; - case WEBKIT_CONTEXT_MENU_ACTION_GO_FORWARD: - return ContextMenuItemTagGoForward; - case WEBKIT_CONTEXT_MENU_ACTION_STOP: - return ContextMenuItemTagStop; - case WEBKIT_CONTEXT_MENU_ACTION_RELOAD: - return ContextMenuItemTagReload; - case WEBKIT_CONTEXT_MENU_ACTION_COPY: - return ContextMenuItemTagCopy; - case WEBKIT_CONTEXT_MENU_ACTION_CUT: - return ContextMenuItemTagCut; - case WEBKIT_CONTEXT_MENU_ACTION_PASTE: - return ContextMenuItemTagPaste; - case WEBKIT_CONTEXT_MENU_ACTION_DELETE: - return ContextMenuItemTagDelete; - case WEBKIT_CONTEXT_MENU_ACTION_SELECT_ALL: - return ContextMenuItemTagSelectAll; - case WEBKIT_CONTEXT_MENU_ACTION_INPUT_METHODS: - return ContextMenuItemTagInputMethods; - case WEBKIT_CONTEXT_MENU_ACTION_UNICODE: - return ContextMenuItemTagUnicode; - case WEBKIT_CONTEXT_MENU_ACTION_SPELLING_GUESS: - return ContextMenuItemTagSpellingGuess; - case WEBKIT_CONTEXT_MENU_ACTION_NO_GUESSES_FOUND: - return ContextMenuItemTagNoGuessesFound; - case WEBKIT_CONTEXT_MENU_ACTION_IGNORE_SPELLING: - return ContextMenuItemTagIgnoreSpelling; - case WEBKIT_CONTEXT_MENU_ACTION_LEARN_SPELLING: - return ContextMenuItemTagLearnSpelling; - case WEBKIT_CONTEXT_MENU_ACTION_IGNORE_GRAMMAR: - return ContextMenuItemTagIgnoreGrammar; - case WEBKIT_CONTEXT_MENU_ACTION_FONT_MENU: - return ContextMenuItemTagFontMenu; - case WEBKIT_CONTEXT_MENU_ACTION_BOLD: - return ContextMenuItemTagBold; - case WEBKIT_CONTEXT_MENU_ACTION_ITALIC: - return ContextMenuItemTagItalic; - case WEBKIT_CONTEXT_MENU_ACTION_UNDERLINE: - return ContextMenuItemTagUnderline; - case WEBKIT_CONTEXT_MENU_ACTION_OUTLINE: - return ContextMenuItemTagOutline; - case WEBKIT_CONTEXT_MENU_ACTION_INSPECT_ELEMENT: - return ContextMenuItemTagInspectElement; - case WEBKIT_CONTEXT_MENU_ACTION_OPEN_VIDEO_IN_NEW_WINDOW: - case WEBKIT_CONTEXT_MENU_ACTION_OPEN_AUDIO_IN_NEW_WINDOW: - return ContextMenuItemTagOpenMediaInNewWindow; - case WEBKIT_CONTEXT_MENU_ACTION_COPY_VIDEO_LINK_TO_CLIPBOARD: - case WEBKIT_CONTEXT_MENU_ACTION_COPY_AUDIO_LINK_TO_CLIPBOARD: - return ContextMenuItemTagCopyMediaLinkToClipboard; - case WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_CONTROLS: - return ContextMenuItemTagToggleMediaControls; - case WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_LOOP: - return ContextMenuItemTagToggleMediaLoop; - case WEBKIT_CONTEXT_MENU_ACTION_ENTER_VIDEO_FULLSCREEN: - return ContextMenuItemTagEnterVideoFullscreen; - case WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PLAY: - case WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PAUSE: - return ContextMenuItemTagMediaPlayPause; - case WEBKIT_CONTEXT_MENU_ACTION_MEDIA_MUTE: - return ContextMenuItemTagMediaMute; - case WEBKIT_CONTEXT_MENU_ACTION_CUSTOM: - return ContextMenuItemBaseApplicationTag; - default: - ASSERT_NOT_REACHED(); - } - - return ContextMenuItemBaseApplicationTag; -} - -WebKitContextMenuAction webkitContextMenuActionGetForContextMenuItem(ContextMenuItem* menuItem) -{ - switch (menuItem->action()) { - case ContextMenuItemTagNoAction: - return WEBKIT_CONTEXT_MENU_ACTION_NO_ACTION; - case ContextMenuItemTagOpenLink: - return WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK; - case ContextMenuItemTagOpenLinkInNewWindow: - return WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK_IN_NEW_WINDOW; - case ContextMenuItemTagDownloadLinkToDisk: - return WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_LINK_TO_DISK; - case ContextMenuItemTagCopyLinkToClipboard: - return WEBKIT_CONTEXT_MENU_ACTION_COPY_LINK_TO_CLIPBOARD; - case ContextMenuItemTagOpenImageInNewWindow: - return WEBKIT_CONTEXT_MENU_ACTION_OPEN_IMAGE_IN_NEW_WINDOW; - case ContextMenuItemTagDownloadImageToDisk: - return WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_IMAGE_TO_DISK; - case ContextMenuItemTagCopyImageToClipboard: - return WEBKIT_CONTEXT_MENU_ACTION_COPY_IMAGE_TO_CLIPBOARD; - case ContextMenuItemTagCopyImageUrlToClipboard: - return WEBKIT_CONTEXT_MENU_ACTION_COPY_IMAGE_URL_TO_CLIPBOARD; - case ContextMenuItemTagOpenFrameInNewWindow: - return WEBKIT_CONTEXT_MENU_ACTION_OPEN_FRAME_IN_NEW_WINDOW; - case ContextMenuItemTagGoBack: - return WEBKIT_CONTEXT_MENU_ACTION_GO_BACK; - case ContextMenuItemTagGoForward: - return WEBKIT_CONTEXT_MENU_ACTION_GO_FORWARD; - case ContextMenuItemTagStop: - return WEBKIT_CONTEXT_MENU_ACTION_STOP; - case ContextMenuItemTagReload: - return WEBKIT_CONTEXT_MENU_ACTION_RELOAD; - case ContextMenuItemTagCopy: - return WEBKIT_CONTEXT_MENU_ACTION_COPY; - case ContextMenuItemTagCut: - return WEBKIT_CONTEXT_MENU_ACTION_CUT; - case ContextMenuItemTagPaste: - return WEBKIT_CONTEXT_MENU_ACTION_PASTE; - case ContextMenuItemTagDelete: - return WEBKIT_CONTEXT_MENU_ACTION_DELETE; - case ContextMenuItemTagSelectAll: - return WEBKIT_CONTEXT_MENU_ACTION_SELECT_ALL; - case ContextMenuItemTagInputMethods: - return WEBKIT_CONTEXT_MENU_ACTION_INPUT_METHODS; - case ContextMenuItemTagUnicode: - return WEBKIT_CONTEXT_MENU_ACTION_UNICODE; - case ContextMenuItemTagSpellingGuess: - return WEBKIT_CONTEXT_MENU_ACTION_SPELLING_GUESS; - case ContextMenuItemTagIgnoreSpelling: - return WEBKIT_CONTEXT_MENU_ACTION_IGNORE_SPELLING; - case ContextMenuItemTagLearnSpelling: - return WEBKIT_CONTEXT_MENU_ACTION_LEARN_SPELLING; - case ContextMenuItemTagIgnoreGrammar: - return WEBKIT_CONTEXT_MENU_ACTION_IGNORE_GRAMMAR; - case ContextMenuItemTagFontMenu: - return WEBKIT_CONTEXT_MENU_ACTION_FONT_MENU; - case ContextMenuItemTagBold: - return WEBKIT_CONTEXT_MENU_ACTION_BOLD; - case ContextMenuItemTagItalic: - return WEBKIT_CONTEXT_MENU_ACTION_ITALIC; - case ContextMenuItemTagUnderline: - return WEBKIT_CONTEXT_MENU_ACTION_UNDERLINE; - case ContextMenuItemTagOutline: - return WEBKIT_CONTEXT_MENU_ACTION_OUTLINE; - case ContextMenuItemTagInspectElement: - return WEBKIT_CONTEXT_MENU_ACTION_INSPECT_ELEMENT; - case ContextMenuItemTagOpenMediaInNewWindow: - return menuItem->title() == contextMenuItemTagOpenVideoInNewWindow() ? - WEBKIT_CONTEXT_MENU_ACTION_OPEN_VIDEO_IN_NEW_WINDOW : WEBKIT_CONTEXT_MENU_ACTION_OPEN_AUDIO_IN_NEW_WINDOW; - case ContextMenuItemTagCopyMediaLinkToClipboard: - return menuItem->title() == contextMenuItemTagCopyVideoLinkToClipboard() ? - WEBKIT_CONTEXT_MENU_ACTION_COPY_VIDEO_LINK_TO_CLIPBOARD : WEBKIT_CONTEXT_MENU_ACTION_COPY_AUDIO_LINK_TO_CLIPBOARD; - case ContextMenuItemTagToggleMediaControls: - return WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_CONTROLS; - case ContextMenuItemTagToggleMediaLoop: - return WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_LOOP; - case ContextMenuItemTagEnterVideoFullscreen: - return WEBKIT_CONTEXT_MENU_ACTION_ENTER_VIDEO_FULLSCREEN; - case ContextMenuItemTagMediaPlayPause: - return menuItem->title() == contextMenuItemTagMediaPlay() ? - WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PLAY : WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PAUSE; - case ContextMenuItemTagMediaMute: - return WEBKIT_CONTEXT_MENU_ACTION_MEDIA_MUTE; - case ContextMenuItemBaseApplicationTag: - return WEBKIT_CONTEXT_MENU_ACTION_CUSTOM; - default: - ASSERT_NOT_REACHED(); - } - - return WEBKIT_CONTEXT_MENU_ACTION_CUSTOM; -} - -String webkitContextMenuActionGetLabel(WebKitContextMenuAction action) -{ - switch (action) { - case WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK: - return contextMenuItemTagOpenLink(); - case WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK_IN_NEW_WINDOW: - return contextMenuItemTagOpenLinkInNewWindow(); - case WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_LINK_TO_DISK: - return contextMenuItemTagDownloadLinkToDisk(); - case WEBKIT_CONTEXT_MENU_ACTION_COPY_LINK_TO_CLIPBOARD: - return contextMenuItemTagCopyLinkToClipboard(); - case WEBKIT_CONTEXT_MENU_ACTION_OPEN_IMAGE_IN_NEW_WINDOW: - return contextMenuItemTagOpenImageInNewWindow(); - case WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_IMAGE_TO_DISK: - return contextMenuItemTagDownloadImageToDisk(); - case WEBKIT_CONTEXT_MENU_ACTION_COPY_IMAGE_TO_CLIPBOARD: - return contextMenuItemTagCopyImageToClipboard(); - case WEBKIT_CONTEXT_MENU_ACTION_COPY_IMAGE_URL_TO_CLIPBOARD: - return contextMenuItemTagCopyImageUrlToClipboard(); - case WEBKIT_CONTEXT_MENU_ACTION_OPEN_FRAME_IN_NEW_WINDOW: - return contextMenuItemTagOpenFrameInNewWindow(); - case WEBKIT_CONTEXT_MENU_ACTION_GO_BACK: - return contextMenuItemTagGoBack(); - case WEBKIT_CONTEXT_MENU_ACTION_GO_FORWARD: - return contextMenuItemTagGoForward(); - case WEBKIT_CONTEXT_MENU_ACTION_STOP: - return contextMenuItemTagStop(); - case WEBKIT_CONTEXT_MENU_ACTION_RELOAD: - return contextMenuItemTagReload(); - case WEBKIT_CONTEXT_MENU_ACTION_COPY: - return contextMenuItemTagCopy(); - case WEBKIT_CONTEXT_MENU_ACTION_CUT: - return contextMenuItemTagCut(); - case WEBKIT_CONTEXT_MENU_ACTION_PASTE: - return contextMenuItemTagPaste(); - case WEBKIT_CONTEXT_MENU_ACTION_DELETE: - return contextMenuItemTagDelete(); - case WEBKIT_CONTEXT_MENU_ACTION_SELECT_ALL: - return contextMenuItemTagSelectAll(); - case WEBKIT_CONTEXT_MENU_ACTION_INPUT_METHODS: - return contextMenuItemTagInputMethods(); - case WEBKIT_CONTEXT_MENU_ACTION_UNICODE: - return contextMenuItemTagUnicode(); - case WEBKIT_CONTEXT_MENU_ACTION_NO_GUESSES_FOUND: - return contextMenuItemTagNoGuessesFound(); - case WEBKIT_CONTEXT_MENU_ACTION_IGNORE_SPELLING: - return contextMenuItemTagIgnoreSpelling(); - case WEBKIT_CONTEXT_MENU_ACTION_LEARN_SPELLING: - return contextMenuItemTagLearnSpelling(); - case WEBKIT_CONTEXT_MENU_ACTION_IGNORE_GRAMMAR: - return contextMenuItemTagIgnoreGrammar(); - case WEBKIT_CONTEXT_MENU_ACTION_FONT_MENU: - return contextMenuItemTagFontMenu(); - case WEBKIT_CONTEXT_MENU_ACTION_BOLD: - return contextMenuItemTagBold(); - case WEBKIT_CONTEXT_MENU_ACTION_ITALIC: - return contextMenuItemTagItalic(); - case WEBKIT_CONTEXT_MENU_ACTION_UNDERLINE: - return contextMenuItemTagUnderline(); - case WEBKIT_CONTEXT_MENU_ACTION_OUTLINE: - return contextMenuItemTagOutline(); - case WEBKIT_CONTEXT_MENU_ACTION_INSPECT_ELEMENT: - return contextMenuItemTagInspectElement(); - case WEBKIT_CONTEXT_MENU_ACTION_OPEN_VIDEO_IN_NEW_WINDOW: - return contextMenuItemTagOpenVideoInNewWindow(); - case WEBKIT_CONTEXT_MENU_ACTION_OPEN_AUDIO_IN_NEW_WINDOW: - return contextMenuItemTagOpenAudioInNewWindow(); - case WEBKIT_CONTEXT_MENU_ACTION_COPY_VIDEO_LINK_TO_CLIPBOARD: - return contextMenuItemTagCopyVideoLinkToClipboard(); - case WEBKIT_CONTEXT_MENU_ACTION_COPY_AUDIO_LINK_TO_CLIPBOARD: - return contextMenuItemTagCopyAudioLinkToClipboard(); - case WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_CONTROLS: - return contextMenuItemTagToggleMediaControls(); - case WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_LOOP: - return contextMenuItemTagToggleMediaLoop(); - case WEBKIT_CONTEXT_MENU_ACTION_ENTER_VIDEO_FULLSCREEN: - return contextMenuItemTagEnterVideoFullscreen(); - case WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PLAY: - return contextMenuItemTagMediaPlay(); - case WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PAUSE: - return contextMenuItemTagMediaPause(); - case WEBKIT_CONTEXT_MENU_ACTION_MEDIA_MUTE: - return contextMenuItemTagMediaMute(); - case WEBKIT_CONTEXT_MENU_ACTION_NO_ACTION: - case WEBKIT_CONTEXT_MENU_ACTION_CUSTOM: - case WEBKIT_CONTEXT_MENU_ACTION_SPELLING_GUESS: - return String(); - default: - ASSERT_NOT_REACHED(); - } - - return String(); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuActions.h b/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuActions.h deleted file mode 100644 index 185bd251f..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuActions.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#include <glib.h> - -#ifndef WebKitContextMenuActions_h -#define WebKitContextMenuActions_h - -G_BEGIN_DECLS - -/** - * WebKitContextMenuAction: - * @WEBKIT_CONTEXT_MENU_ACTION_NO_ACTION: No action, used by separator menu items. - * @WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK: Open current link. - * @WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK_IN_NEW_WINDOW: Open current link in a new window. - * @WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_LINK_TO_DISK: Download link destination. - * @WEBKIT_CONTEXT_MENU_ACTION_COPY_LINK_TO_CLIPBOARD: Copy link location to the clipboard. - * @WEBKIT_CONTEXT_MENU_ACTION_OPEN_IMAGE_IN_NEW_WINDOW: Open current image in a new window. - * @WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_IMAGE_TO_DISK: Download current image. - * @WEBKIT_CONTEXT_MENU_ACTION_COPY_IMAGE_TO_CLIPBOARD: Copy current image to the clipboard. - * @WEBKIT_CONTEXT_MENU_ACTION_COPY_IMAGE_URL_TO_CLIPBOARD: Copy curent image location to the clipboard. - * @WEBKIT_CONTEXT_MENU_ACTION_OPEN_FRAME_IN_NEW_WINDOW: Open current frame in a new window. - * @WEBKIT_CONTEXT_MENU_ACTION_GO_BACK: Load the previous history item. - * @WEBKIT_CONTEXT_MENU_ACTION_GO_FORWARD: Load the next history item. - * @WEBKIT_CONTEXT_MENU_ACTION_STOP: Stop any ongoing loading operation. - * @WEBKIT_CONTEXT_MENU_ACTION_RELOAD: Reload the conents of current view. - * @WEBKIT_CONTEXT_MENU_ACTION_COPY: Copy current selection the clipboard. - * @WEBKIT_CONTEXT_MENU_ACTION_CUT: Cut current selection to the clipboard. - * @WEBKIT_CONTEXT_MENU_ACTION_PASTE: Paste clipboard contents. - * @WEBKIT_CONTEXT_MENU_ACTION_DELETE: Delete current selection. - * @WEBKIT_CONTEXT_MENU_ACTION_SELECT_ALL: Select all text. - * @WEBKIT_CONTEXT_MENU_ACTION_INPUT_METHODS: Input methods menu. - * @WEBKIT_CONTEXT_MENU_ACTION_UNICODE: Unicode menu. - * @WEBKIT_CONTEXT_MENU_ACTION_SPELLING_GUESS: A proposed replacement for a misspelled word. - * @WEBKIT_CONTEXT_MENU_ACTION_NO_GUESSES_FOUND: An indicator that spellchecking found no proposed replacements. - * @WEBKIT_CONTEXT_MENU_ACTION_IGNORE_SPELLING: Causes the spellchecker to ignore the word for this session. - * @WEBKIT_CONTEXT_MENU_ACTION_LEARN_SPELLING: Causes the spellchecker to add the word to the dictionary. - * @WEBKIT_CONTEXT_MENU_ACTION_IGNORE_GRAMMAR: Ignore grammar. - * @WEBKIT_CONTEXT_MENU_ACTION_FONT_MENU: Font options menu. - * @WEBKIT_CONTEXT_MENU_ACTION_BOLD: Bold. - * @WEBKIT_CONTEXT_MENU_ACTION_ITALIC: Italic. - * @WEBKIT_CONTEXT_MENU_ACTION_UNDERLINE: Underline. - * @WEBKIT_CONTEXT_MENU_ACTION_OUTLINE: Outline. - * @WEBKIT_CONTEXT_MENU_ACTION_INSPECT_ELEMENT: Open current element in the inspector. - * @WEBKIT_CONTEXT_MENU_ACTION_OPEN_VIDEO_IN_NEW_WINDOW: Open current video element in a new window. - * @WEBKIT_CONTEXT_MENU_ACTION_OPEN_AUDIO_IN_NEW_WINDOW: Open current audio element in a new window. - * @WEBKIT_CONTEXT_MENU_ACTION_COPY_VIDEO_LINK_TO_CLIPBOARD: Copy video link location in to the clipboard. - * @WEBKIT_CONTEXT_MENU_ACTION_COPY_AUDIO_LINK_TO_CLIPBOARD: Copy audio link location in to the clipboard. - * @WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_CONTROLS: Enable or disable media controls. - * @WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_LOOP: Enable or disable media loop. - * @WEBKIT_CONTEXT_MENU_ACTION_ENTER_VIDEO_FULLSCREEN: Show current video element in fullscreen mode. - * @WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PLAY: Play current media element. - * @WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PAUSE: Pause current media element. - * @WEBKIT_CONTEXT_MENU_ACTION_MEDIA_MUTE: Mute current media element. - * @WEBKIT_CONTEXT_MENU_ACTION_CUSTOM: Custom action defined by applications. - * - * Enum values used to denote the stock actions for - * #WebKitContextMenuItem<!-- -->s - */ -typedef enum { - WEBKIT_CONTEXT_MENU_ACTION_NO_ACTION = 0, - - WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK, - WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK_IN_NEW_WINDOW, - WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_LINK_TO_DISK, - WEBKIT_CONTEXT_MENU_ACTION_COPY_LINK_TO_CLIPBOARD, - WEBKIT_CONTEXT_MENU_ACTION_OPEN_IMAGE_IN_NEW_WINDOW, - WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_IMAGE_TO_DISK, - WEBKIT_CONTEXT_MENU_ACTION_COPY_IMAGE_TO_CLIPBOARD, - WEBKIT_CONTEXT_MENU_ACTION_COPY_IMAGE_URL_TO_CLIPBOARD, - WEBKIT_CONTEXT_MENU_ACTION_OPEN_FRAME_IN_NEW_WINDOW, - WEBKIT_CONTEXT_MENU_ACTION_GO_BACK, - WEBKIT_CONTEXT_MENU_ACTION_GO_FORWARD, - WEBKIT_CONTEXT_MENU_ACTION_STOP, - WEBKIT_CONTEXT_MENU_ACTION_RELOAD, - WEBKIT_CONTEXT_MENU_ACTION_COPY, - WEBKIT_CONTEXT_MENU_ACTION_CUT, - WEBKIT_CONTEXT_MENU_ACTION_PASTE, - WEBKIT_CONTEXT_MENU_ACTION_DELETE, - WEBKIT_CONTEXT_MENU_ACTION_SELECT_ALL, - WEBKIT_CONTEXT_MENU_ACTION_INPUT_METHODS, - WEBKIT_CONTEXT_MENU_ACTION_UNICODE, - WEBKIT_CONTEXT_MENU_ACTION_SPELLING_GUESS, - WEBKIT_CONTEXT_MENU_ACTION_NO_GUESSES_FOUND, - WEBKIT_CONTEXT_MENU_ACTION_IGNORE_SPELLING, - WEBKIT_CONTEXT_MENU_ACTION_LEARN_SPELLING, - WEBKIT_CONTEXT_MENU_ACTION_IGNORE_GRAMMAR, - WEBKIT_CONTEXT_MENU_ACTION_FONT_MENU, - WEBKIT_CONTEXT_MENU_ACTION_BOLD, - WEBKIT_CONTEXT_MENU_ACTION_ITALIC, - WEBKIT_CONTEXT_MENU_ACTION_UNDERLINE, - WEBKIT_CONTEXT_MENU_ACTION_OUTLINE, - WEBKIT_CONTEXT_MENU_ACTION_INSPECT_ELEMENT, - WEBKIT_CONTEXT_MENU_ACTION_OPEN_VIDEO_IN_NEW_WINDOW, - WEBKIT_CONTEXT_MENU_ACTION_OPEN_AUDIO_IN_NEW_WINDOW, - WEBKIT_CONTEXT_MENU_ACTION_COPY_VIDEO_LINK_TO_CLIPBOARD, - WEBKIT_CONTEXT_MENU_ACTION_COPY_AUDIO_LINK_TO_CLIPBOARD, - WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_CONTROLS, - WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_LOOP, - WEBKIT_CONTEXT_MENU_ACTION_ENTER_VIDEO_FULLSCREEN, - WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PLAY, - WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PAUSE, - WEBKIT_CONTEXT_MENU_ACTION_MEDIA_MUTE, - - WEBKIT_CONTEXT_MENU_ACTION_CUSTOM = 10000 -} WebKitContextMenuAction; - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuActionsPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuActionsPrivate.h deleted file mode 100644 index f753bb97c..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuActionsPrivate.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitContextMenuActionsPrivate_h -#define WebKitContextMenuActionsPrivate_h - -#include "WebKitContextMenuActions.h" -#include <WebCore/ContextMenuItem.h> - -bool webkitContextMenuActionIsCheckable(WebKitContextMenuAction); -WebCore::ContextMenuAction webkitContextMenuActionGetActionTag(WebKitContextMenuAction); -WebKitContextMenuAction webkitContextMenuActionGetForContextMenuItem(WebCore::ContextMenuItem*); -String webkitContextMenuActionGetLabel(WebKitContextMenuAction); - -#endif // WebKitPrintOperationPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuClient.cpp deleted file mode 100644 index f50c52aea..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuClient.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitContextMenuClient.h" - -#include "WebKitPrivate.h" -#include "WebKitWebViewBasePrivate.h" -#include "WebKitWebViewPrivate.h" - -using namespace WebKit; - -static void getContextMenuFromProposedMenu(WKPageRef, WKArrayRef proposedMenu, WKArrayRef*, WKHitTestResultRef hitTestResult, WKTypeRef userData, const void* clientInfo) -{ - webkitWebViewPopulateContextMenu(WEBKIT_WEB_VIEW(clientInfo), toImpl(proposedMenu), toImpl(hitTestResult)); -} - -void attachContextMenuClientToView(WebKitWebView* webView) -{ - WKPageContextMenuClient wkContextMenuClient = { - kWKPageContextMenuClientCurrentVersion, - webView, // clientInfo - 0, // getContextMenuFromProposedMenu_deprecatedForUseWithV0 - 0, // customContextMenuItemSelected - 0, // contextMenuDismissed - getContextMenuFromProposedMenu, - 0, // showContextMenu - 0, // hideContextMenu - }; - WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))); - WKPageSetPageContextMenuClient(wkPage, &wkContextMenuClient); -} - diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuClient.h b/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuClient.h deleted file mode 100644 index 9b28bf998..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuClient.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitContextMenuClient_h -#define WebKitContextMenuClient_h - -#include "WebKitWebView.h" - -void attachContextMenuClientToView(WebKitWebView*); - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuItem.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuItem.cpp deleted file mode 100644 index d98cc548e..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuItem.cpp +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitContextMenuItem.h" - -#include "MutableArray.h" -#include "WebContextMenuItem.h" -#include "WebContextMenuItemData.h" -#include "WebKitContextMenuActionsPrivate.h" -#include "WebKitContextMenuItemPrivate.h" -#include "WebKitContextMenuPrivate.h" -#include <WebCore/ContextMenu.h> -#include <WebCore/ContextMenuItem.h> -#include <gtk/gtk.h> -#include <wtf/OwnPtr.h> -#include <wtf/PassOwnPtr.h> -#include <wtf/gobject/GOwnPtr.h> -#include <wtf/gobject/GRefPtr.h> - -using namespace WebKit; -using namespace WebCore; - -/** - * SECTION: WebKitContextMenuItem - * @Short_description: One item of the #WebKitContextMenu - * @Title: WebKitContextMenuItem - * - * The #WebKitContextMenu is composed of #WebKitContextMenuItem<!-- - * -->s. These items can be created from a #GtkAction, from a - * #WebKitContextMenuAction or from a #WebKitContextMenuAction and a - * label. These #WebKitContextMenuAction<!-- -->s denote stock actions - * for the items. You can also create separators and submenus. - * - */ - -struct _WebKitContextMenuItemPrivate { - ~_WebKitContextMenuItemPrivate() - { - if (subMenu) - webkitContextMenuSetParentItem(subMenu.get(), 0); - } - - OwnPtr<ContextMenuItem> menuItem; - GRefPtr<WebKitContextMenu> subMenu; -}; - -WEBKIT_DEFINE_TYPE(WebKitContextMenuItem, webkit_context_menu_item, G_TYPE_INITIALLY_UNOWNED) - -static void webkit_context_menu_item_class_init(WebKitContextMenuItemClass* itemClass) -{ -} - -static bool checkAndWarnIfMenuHasParentItem(WebKitContextMenu* menu) -{ - if (menu && webkitContextMenuGetParentItem(menu)) { - g_warning("Attempting to set a WebKitContextMenu as submenu of " - "a WebKitContextMenuItem, but the menu is already " - "a submenu of a WebKitContextMenuItem"); - return true; - } - - return false; -} - -static void webkitContextMenuItemSetSubMenu(WebKitContextMenuItem* item, GRefPtr<WebKitContextMenu> subMenu) -{ - if (checkAndWarnIfMenuHasParentItem(subMenu.get())) - return; - - if (item->priv->subMenu) - webkitContextMenuSetParentItem(item->priv->subMenu.get(), 0); - item->priv->subMenu = subMenu; - if (subMenu) - webkitContextMenuSetParentItem(subMenu.get(), item); -} - -WebKitContextMenuItem* webkitContextMenuItemCreate(WebContextMenuItem* webItem) -{ - WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(g_object_new(WEBKIT_TYPE_CONTEXT_MENU_ITEM, NULL)); - WebContextMenuItemData* itemData = webItem->data(); - item->priv->menuItem = WTF::adoptPtr(new ContextMenuItem(itemData->type(), itemData->action(), itemData->title(), itemData->enabled(), itemData->checked())); - const Vector<WebContextMenuItemData>& subMenu = itemData->submenu(); - if (!subMenu.size()) - return item; - - RefPtr<MutableArray> subMenuItems = MutableArray::create(); - subMenuItems->reserveCapacity(subMenu.size()); - for (size_t i = 0; i < subMenu.size(); ++i) - subMenuItems->append(WebContextMenuItem::create(subMenu[i]).get()); - webkitContextMenuItemSetSubMenu(item, adoptGRef(webkitContextMenuCreate(subMenuItems.get()))); - - return item; -} - -static WebKitContextMenuItem* webkitContextMenuItemCreateForGtkItem(GtkMenuItem* menuItem) -{ - WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(g_object_new(WEBKIT_TYPE_CONTEXT_MENU_ITEM, NULL)); - item->priv->menuItem = WTF::adoptPtr(new ContextMenuItem(menuItem)); - webkitContextMenuItemSetSubMenuFromGtkMenu(item, GTK_MENU(gtk_menu_item_get_submenu(menuItem))); - - return item; -} - -void webkitContextMenuItemSetSubMenuFromGtkMenu(WebKitContextMenuItem* item, GtkMenu* subMenu) -{ - if (!subMenu) - return; - - GOwnPtr<GList> children(gtk_container_get_children(GTK_CONTAINER(subMenu))); - if (!g_list_length(children.get())) - return; - - webkitContextMenuItemSetSubMenu(item, adoptGRef(webkit_context_menu_new())); - for (GList* listItem = children.get(); listItem; listItem = g_list_next(listItem)) { - GRefPtr<GtkWidget> widget = GTK_WIDGET(listItem->data); - if (!GTK_IS_MENU_ITEM(widget.get())) - continue; - - gtk_container_remove(GTK_CONTAINER(subMenu), widget.get()); - GtkMenuItem* menuItem = GTK_MENU_ITEM(widget.leakRef()); - g_object_force_floating(G_OBJECT(menuItem)); - webkit_context_menu_append(item->priv->subMenu.get(), webkitContextMenuItemCreateForGtkItem(menuItem)); - } -} - -GtkMenuItem* webkitContextMenuItemRelease(WebKitContextMenuItem* item) -{ - if (item->priv->subMenu) { - Vector<ContextMenuItem> subMenuItems; - webkitContextMenuPopulate(item->priv->subMenu.get(), subMenuItems); - ContextMenu subMenu(platformMenuDescription(subMenuItems)); - item->priv->menuItem->setSubMenu(&subMenu); - } - - return item->priv->menuItem->releasePlatformDescription(); -} - -/** - * webkit_context_menu_item_new: - * @action: a #GtkAction - * - * Creates a new #WebKitContextMenuItem for the given @action. - * - * Returns: the newly created #WebKitContextMenuItem object. - */ -WebKitContextMenuItem* webkit_context_menu_item_new(GtkAction* action) -{ - g_return_val_if_fail(GTK_IS_ACTION(action), 0); - - WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(g_object_new(WEBKIT_TYPE_CONTEXT_MENU_ITEM, NULL)); - item->priv->menuItem = WTF::adoptPtr(new ContextMenuItem(GTK_MENU_ITEM(gtk_action_create_menu_item(action)))); - item->priv->menuItem->setAction(ContextMenuItemBaseApplicationTag); - - return item; -} - -/** - * webkit_context_menu_item_new_from_stock_action: - * @action: a #WebKitContextMenuAction stock action - * - * Creates a new #WebKitContextMenuItem for the given stock action. - * Stock actions are handled automatically by WebKit so that, for example, - * when a menu item created with a %WEBKIT_CONTEXT_MENU_ACTION_STOP is - * activated the action associated will be handled by WebKit and the current - * load operation will be stopped. You can get the #GtkAction of a - * #WebKitContextMenuItem created with a #WebKitContextMenuAction with - * webkit_context_menu_item_get_action() and connect to #GtkAction::activate signal - * to be notified when the item is activated. But you can't prevent the asociated - * action from being performed. - * - * Returns: the newly created #WebKitContextMenuItem object. - */ -WebKitContextMenuItem* webkit_context_menu_item_new_from_stock_action(WebKitContextMenuAction action) -{ - g_return_val_if_fail(action > WEBKIT_CONTEXT_MENU_ACTION_NO_ACTION && action < WEBKIT_CONTEXT_MENU_ACTION_CUSTOM, 0); - - WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(g_object_new(WEBKIT_TYPE_CONTEXT_MENU_ITEM, NULL)); - ContextMenuItemType type = webkitContextMenuActionIsCheckable(action) ? CheckableActionType : ActionType; - item->priv->menuItem = WTF::adoptPtr(new ContextMenuItem(type, webkitContextMenuActionGetActionTag(action), webkitContextMenuActionGetLabel(action))); - - return item; -} - -/** - * webkit_context_menu_item_new_from_stock_action_with_label: - * @action: a #WebKitContextMenuAction stock action - * @label: a custom label text to use instead of the predefined one - * - * Creates a new #WebKitContextMenuItem for the given stock action using the given @label. - * Stock actions have a predefined label, this method can be used to create a - * #WebKitContextMenuItem for a #WebKitContextMenuAction but using a custom label. - * - * Returns: the newly created #WebKitContextMenuItem object. - */ -WebKitContextMenuItem* webkit_context_menu_item_new_from_stock_action_with_label(WebKitContextMenuAction action, const gchar* label) -{ - g_return_val_if_fail(action > WEBKIT_CONTEXT_MENU_ACTION_NO_ACTION && action < WEBKIT_CONTEXT_MENU_ACTION_CUSTOM, 0); - - WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(g_object_new(WEBKIT_TYPE_CONTEXT_MENU_ITEM, NULL)); - ContextMenuItemType type = webkitContextMenuActionIsCheckable(action) ? CheckableActionType : ActionType; - item->priv->menuItem = WTF::adoptPtr(new ContextMenuItem(type, webkitContextMenuActionGetActionTag(action), String::fromUTF8(label))); - - return item; -} - -/** - * webkit_context_menu_item_new_with_submenu: - * @label: the menu item label text - * @submenu: a #WebKitContextMenu to set - * - * Creates a new #WebKitContextMenuItem using the given @label with a submenu. - * - * Returns: the newly created #WebKitContextMenuItem object. - */ -WebKitContextMenuItem* webkit_context_menu_item_new_with_submenu(const gchar* label, WebKitContextMenu* submenu) -{ - g_return_val_if_fail(label, 0); - g_return_val_if_fail(WEBKIT_IS_CONTEXT_MENU(submenu), 0); - - if (checkAndWarnIfMenuHasParentItem(submenu)) - return 0; - - WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(g_object_new(WEBKIT_TYPE_CONTEXT_MENU_ITEM, NULL)); - item->priv->menuItem = WTF::adoptPtr(new ContextMenuItem(SubmenuType, ContextMenuItemBaseApplicationTag, String::fromUTF8(label))); - item->priv->subMenu = submenu; - webkitContextMenuSetParentItem(submenu, item); - - return item; -} - -/** - * webkit_context_menu_item_new_separator: - * - * Creates a new #WebKitContextMenuItem representing a separator. - * - * Returns: the newly created #WebKitContextMenuItem object. - */ -WebKitContextMenuItem* webkit_context_menu_item_new_separator(void) -{ - WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(g_object_new(WEBKIT_TYPE_CONTEXT_MENU_ITEM, NULL)); - item->priv->menuItem = WTF::adoptPtr(new ContextMenuItem(SeparatorType, ContextMenuItemTagNoAction, String())); - - return item; -} - -/** - * webkit_context_menu_item_get_action: - * @item: a #WebKitContextMenuItem - * - * Gets the action associated to @item. - * - * Returns: (transfer none): the #GtkAction associated to the #WebKitContextMenuItem, - * or %NULL if @item is a separator. - */ -GtkAction* webkit_context_menu_item_get_action(WebKitContextMenuItem* item) -{ - g_return_val_if_fail(WEBKIT_IS_CONTEXT_MENU_ITEM(item), 0); - - return item->priv->menuItem->gtkAction(); -} - -/** - * webkit_context_menu_item_get_stock_action: - * @item: a #WebKitContextMenuItem - * - * Gets the #WebKitContextMenuAction of @item. If the #WebKitContextMenuItem was not - * created for a stock action %WEBKIT_CONTEXT_MENU_ACTION_CUSTOM will be - * returned. If the #WebKitContextMenuItem is a separator %WEBKIT_CONTEXT_MENU_ACTION_NO_ACTION - * will be returned. - * - * Returns: the #WebKitContextMenuAction of @item - */ -WebKitContextMenuAction webkit_context_menu_item_get_stock_action(WebKitContextMenuItem* item) -{ - g_return_val_if_fail(WEBKIT_IS_CONTEXT_MENU_ITEM(item), WEBKIT_CONTEXT_MENU_ACTION_NO_ACTION); - - return webkitContextMenuActionGetForContextMenuItem(item->priv->menuItem.get()); -} - -/** - * webkit_context_menu_item_is_separator: - * @item: a #WebKitContextMenuItem - * - * Checks whether @item is a separator. - * - * Returns: %TRUE is @item is a separator or %FALSE otherwise - */ -gboolean webkit_context_menu_item_is_separator(WebKitContextMenuItem* item) -{ - g_return_val_if_fail(WEBKIT_IS_CONTEXT_MENU_ITEM(item), FALSE); - - return item->priv->menuItem->type() == SeparatorType; -} - -/** - * webkit_context_menu_item_set_submenu: - * @item: a #WebKitContextMenuItem - * @submenu: (allow-none): a #WebKitContextMenu - * - * Sets or replaces the @item submenu. If @submenu is %NULL the current - * submenu of @item is removed. - */ -void webkit_context_menu_item_set_submenu(WebKitContextMenuItem* item, WebKitContextMenu* submenu) -{ - g_return_if_fail(WEBKIT_IS_CONTEXT_MENU_ITEM(item)); - - if (item->priv->subMenu == submenu) - return; - - webkitContextMenuItemSetSubMenu(item, submenu); -} - -/** - * webkit_context_menu_item_get_submenu: - * @item: a #WebKitContextMenuItem - * - * Gets the submenu of @item. - * - * Returns: (transfer none): the #WebKitContextMenu representing the submenu of - * @item or %NULL if @item doesn't have a submenu. - */ -WebKitContextMenu* webkit_context_menu_item_get_submenu(WebKitContextMenuItem* item) -{ - g_return_val_if_fail(WEBKIT_IS_CONTEXT_MENU_ITEM(item), 0); - - return item->priv->subMenu.get(); -} - diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuItem.h b/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuItem.h deleted file mode 100644 index 75d60d7d6..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuItem.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitContextMenuItem_h -#define WebKitContextMenuItem_h - -#include <gtk/gtk.h> -#include <webkit2/WebKitDefines.h> -#include <webkit2/WebKitContextMenu.h> -#include <webkit2/WebKitContextMenuActions.h> -#include <webkit2/WebKitForwardDeclarations.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_CONTEXT_MENU_ITEM (webkit_context_menu_item_get_type()) -#define WEBKIT_CONTEXT_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_CONTEXT_MENU_ITEM, WebKitContextMenuItem)) -#define WEBKIT_IS_CONTEXT_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_CONTEXT_MENU_ITEM)) -#define WEBKIT_CONTEXT_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_CONTEXT_MENU_ITEM, WebKitContextMenuItemClass)) -#define WEBKIT_IS_CONTEXT_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_CONTEXT_MENU_ITEM)) -#define WEBKIT_CONTEXT_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_CONTEXT_MENU_ITEM, WebKitContextMenuItemClass)) - -typedef struct _WebKitContextMenuItemClass WebKitContextMenuItemClass; -typedef struct _WebKitContextMenuItemPrivate WebKitContextMenuItemPrivate; - -struct _WebKitContextMenuItem { - GInitiallyUnowned parent; - - WebKitContextMenuItemPrivate *priv; -}; - -struct _WebKitContextMenuItemClass { - GInitiallyUnownedClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_context_menu_item_get_type (void); - -WEBKIT_API WebKitContextMenuItem * -webkit_context_menu_item_new (GtkAction *action); - -WEBKIT_API WebKitContextMenuItem * -webkit_context_menu_item_new_from_stock_action (WebKitContextMenuAction action); - -WEBKIT_API WebKitContextMenuItem * -webkit_context_menu_item_new_from_stock_action_with_label (WebKitContextMenuAction action, - const gchar *label); - -WEBKIT_API WebKitContextMenuItem * -webkit_context_menu_item_new_with_submenu (const gchar *label, - WebKitContextMenu *submenu); - -WEBKIT_API WebKitContextMenuItem * -webkit_context_menu_item_new_separator (void); - -WEBKIT_API GtkAction * -webkit_context_menu_item_get_action (WebKitContextMenuItem *item); - -WEBKIT_API WebKitContextMenuAction -webkit_context_menu_item_get_stock_action (WebKitContextMenuItem *item); - -WEBKIT_API gboolean -webkit_context_menu_item_is_separator (WebKitContextMenuItem *item); - -WEBKIT_API void -webkit_context_menu_item_set_submenu (WebKitContextMenuItem *item, - WebKitContextMenu *submenu); - -WEBKIT_API WebKitContextMenu * -webkit_context_menu_item_get_submenu (WebKitContextMenuItem *item); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuItemPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuItemPrivate.h deleted file mode 100644 index 18f8c1a87..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuItemPrivate.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitContextMenuItemPrivate_h -#define WebKitContextMenuItemPrivate_h - -#include "WebKitContextMenuItem.h" -#include "WebKitPrivate.h" - -WebKitContextMenuItem* webkitContextMenuItemCreate(WebKit::WebContextMenuItem*); -GtkMenuItem* webkitContextMenuItemRelease(WebKitContextMenuItem*); -void webkitContextMenuItemSetSubMenuFromGtkMenu(WebKitContextMenuItem*, GtkMenu*); - -#endif // WebKitContextMenuItemPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuPrivate.h deleted file mode 100644 index 5556e9f72..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuPrivate.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitContextMenuPrivate_h -#define WebKitContextMenuPrivate_h - -#include "WebKitContextMenu.h" -#include "WebKitPrivate.h" - -WebKitContextMenu* webkitContextMenuCreate(WebKit::ImmutableArray* items); -void webkitContextMenuPopulate(WebKitContextMenu*, Vector<WebCore::ContextMenuItem>&); -void webkitContextMenuSetParentItem(WebKitContextMenu*, WebKitContextMenuItem*); -WebKitContextMenuItem* webkitContextMenuGetParentItem(WebKitContextMenu*); - -#endif // WebKitContextMenuPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitCookieManager.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitCookieManager.cpp deleted file mode 100644 index daf79fe3b..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitCookieManager.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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 "WebKitCookieManager.h" - -#include "SoupCookiePersistentStorageType.h" -#include "WebCookieManagerProxy.h" -#include "WebKitCookieManagerPrivate.h" -#include "WebKitEnumTypes.h" -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -using namespace WebKit; - -/** - * SECTION: WebKitCookieManager - * @Short_description: Defines how to handle cookies in a #WebKitWebContext - * @Title: WebKitCookieManager - * - * The #WebKitCookieManager defines how to handle cookies in a - * #WebKitWebContext. Get it from the context with - * webkit_web_context_get_cookie_manager(), and use it to set where to - * store cookies, with webkit_cookie_manager_set_persistent_storage(), - * to get the list of domains with cookies, with - * webkit_cookie_manager_get_domains_with_cookies(), or to set the - * acceptance policy, with webkit_cookie_manager_get_accept_policy() - * (among other actions). - * - */ - -enum { - CHANGED, - - LAST_SIGNAL -}; - -struct _WebKitCookieManagerPrivate { - ~_WebKitCookieManagerPrivate() - { - webCookieManager->stopObservingCookieChanges(); - } - - RefPtr<WebCookieManagerProxy> webCookieManager; -}; - -static guint signals[LAST_SIGNAL] = { 0, }; - -WEBKIT_DEFINE_TYPE(WebKitCookieManager, webkit_cookie_manager, G_TYPE_OBJECT) - -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT, SoupCookiePersistentStorageText); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE, SoupCookiePersistentStorageSQLite); - -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS, HTTPCookieAcceptPolicyAlways); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_COOKIE_POLICY_ACCEPT_NEVER, HTTPCookieAcceptPolicyNever); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY, HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain); - -static void webkit_cookie_manager_class_init(WebKitCookieManagerClass* findClass) -{ - GObjectClass* gObjectClass = G_OBJECT_CLASS(findClass); - - /** - * WebKitCookieManager::changed: - * @cookie_manager: the #WebKitCookieManager - * - * This signal is emitted when cookies are added, removed or modified. - */ - signals[CHANGED] = - g_signal_new("changed", - G_TYPE_FROM_CLASS(gObjectClass), - G_SIGNAL_RUN_LAST, - 0, 0, 0, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - -static void cookiesDidChange(WKCookieManagerRef, const void* clientInfo) -{ - g_signal_emit(WEBKIT_COOKIE_MANAGER(clientInfo), signals[CHANGED], 0); -} - -WebKitCookieManager* webkitCookieManagerCreate(WebCookieManagerProxy* webCookieManager) -{ - WebKitCookieManager* manager = WEBKIT_COOKIE_MANAGER(g_object_new(WEBKIT_TYPE_COOKIE_MANAGER, NULL)); - manager->priv->webCookieManager = webCookieManager; - - WKCookieManagerClient wkCookieManagerClient = { - kWKCookieManagerClientCurrentVersion, - manager, // clientInfo - cookiesDidChange - }; - WKCookieManagerSetClient(toAPI(webCookieManager), &wkCookieManagerClient); - manager->priv->webCookieManager->startObservingCookieChanges(); - - return manager; -} - -/** - * webkit_cookie_manager_set_persistent_storage: - * @cookie_manager: a #WebKitCookieManager - * @filename: the filename to read to/write from - * @storage: a #WebKitCookiePersistentStorage - * - * Set the @filename where non-session cookies are stored persistently using - * @storage as the format to read/write the cookies. - * Cookies are initially read from @filename to create an initial set of cookies. - * Then, non-session cookies will be written to @filename when the WebKitCookieManager::changed - * signal is emitted. - * By default, @cookie_manager doesn't store the cookies persistenly, so you need to call this - * method to keep cookies saved across sessions. - */ -void webkit_cookie_manager_set_persistent_storage(WebKitCookieManager* manager, const char* filename, WebKitCookiePersistentStorage storage) -{ - g_return_if_fail(WEBKIT_IS_COOKIE_MANAGER(manager)); - g_return_if_fail(filename); - - manager->priv->webCookieManager->stopObservingCookieChanges(); - manager->priv->webCookieManager->setCookiePersistentStorage(String::fromUTF8(filename), storage); - manager->priv->webCookieManager->startObservingCookieChanges(); -} - -/** - * webkit_cookie_manager_set_accept_policy: - * @cookie_manager: a #WebKitCookieManager - * @policy: a #WebKitCookieAcceptPolicy - * - * Set the cookie acceptance policy of @cookie_manager as @policy. - */ -void webkit_cookie_manager_set_accept_policy(WebKitCookieManager* manager, WebKitCookieAcceptPolicy policy) -{ - g_return_if_fail(WEBKIT_IS_COOKIE_MANAGER(manager)); - - manager->priv->webCookieManager->setHTTPCookieAcceptPolicy(policy); -} - -static void webkitCookieManagerGetAcceptPolicyCallback(WKHTTPCookieAcceptPolicy policy, WKErrorRef, void* context) -{ - GRefPtr<GTask> task = adoptGRef(G_TASK(context)); - g_task_return_int(task.get(), policy); -} - -/** - * webkit_cookie_manager_get_accept_policy: - * @cookie_manager: a #WebKitCookieManager - * @cancellable: (allow-none): a #GCancellable or %NULL to ignore - * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied - * @user_data: (closure): the data to pass to callback function - * - * Asynchronously get the cookie acceptance policy of @cookie_manager. - * - * When the operation is finished, @callback will be called. You can then call - * webkit_cookie_manager_get_accept_policy_finish() to get the result of the operation. - */ -void webkit_cookie_manager_get_accept_policy(WebKitCookieManager* manager, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData) -{ - g_return_if_fail(WEBKIT_IS_COOKIE_MANAGER(manager)); - - GTask* task = g_task_new(manager, cancellable, callback, userData); - manager->priv->webCookieManager->getHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicyCallback::create(task, webkitCookieManagerGetAcceptPolicyCallback)); -} - -/** - * webkit_cookie_manager_get_accept_policy_finish: - * @cookie_manager: a #WebKitCookieManager - * @result: a #GAsyncResult - * @error: return location for error or %NULL to ignore - * - * Finish an asynchronous operation started with webkit_cookie_manager_get_accept_policy(). - * - * Returns: the cookie acceptance policy of @cookie_manager as a #WebKitCookieAcceptPolicy. - */ -WebKitCookieAcceptPolicy webkit_cookie_manager_get_accept_policy_finish(WebKitCookieManager* manager, GAsyncResult* result, GError** error) -{ - g_return_val_if_fail(WEBKIT_IS_COOKIE_MANAGER(manager), WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY); - g_return_val_if_fail(g_task_is_valid(result, manager), WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY); - - gssize returnValue = g_task_propagate_int(G_TASK(result), error); - return returnValue == -1 ? WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY : static_cast<WebKitCookieAcceptPolicy>(returnValue); -} - -static void webkitCookieManagerGetDomainsWithCookiesCallback(WKArrayRef wkDomains, WKErrorRef, void* context) -{ - GRefPtr<GTask> task = adoptGRef(G_TASK(context)); - if (g_task_return_error_if_cancelled(task.get())) - return; - - ImmutableArray* domains = toImpl(wkDomains); - GPtrArray* returnValue = g_ptr_array_sized_new(domains->size()); - for (size_t i = 0; i < domains->size(); ++i) { - WebString* domainString = static_cast<WebString*>(domains->at(i)); - String domain = domainString->string(); - if (domain.isEmpty()) - continue; - g_ptr_array_add(returnValue, g_strdup(domain.utf8().data())); - } - g_ptr_array_add(returnValue, 0); - g_task_return_pointer(task.get(), g_ptr_array_free(returnValue, FALSE), reinterpret_cast<GDestroyNotify>(g_strfreev)); -} - -/** - * webkit_cookie_manager_get_domains_with_cookies: - * @cookie_manager: a #WebKitCookieManager - * @cancellable: (allow-none): a #GCancellable or %NULL to ignore - * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied - * @user_data: (closure): the data to pass to callback function - * - * Asynchronously get the list of domains for which @cookie_manager contains cookies. - * - * When the operation is finished, @callback will be called. You can then call - * webkit_cookie_manager_get_domains_with_cookies_finish() to get the result of the operation. - */ -void webkit_cookie_manager_get_domains_with_cookies(WebKitCookieManager* manager, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData) -{ - g_return_if_fail(WEBKIT_IS_COOKIE_MANAGER(manager)); - - GTask* task = g_task_new(manager, cancellable, callback, userData); - manager->priv->webCookieManager->getHostnamesWithCookies(ArrayCallback::create(task, webkitCookieManagerGetDomainsWithCookiesCallback)); -} - -/** - * webkit_cookie_manager_get_domains_with_cookies_finish: - * @cookie_manager: a #WebKitCookieManager - * @result: a #GAsyncResult - * @error: return location for error or %NULL to ignore - * - * Finish an asynchronous operation started with webkit_cookie_manager_get_domains_with_cookies(). - * The return value is a %NULL terminated list of strings which should - * be released with g_strfreev(). - * - * Returns: (transfer full) (array zero-terminated=1): A %NULL terminated array of domain names - * or %NULL in case of error. - */ -gchar** webkit_cookie_manager_get_domains_with_cookies_finish(WebKitCookieManager* manager, GAsyncResult* result, GError** error) -{ - g_return_val_if_fail(WEBKIT_IS_COOKIE_MANAGER(manager), 0); - g_return_val_if_fail(g_task_is_valid(result, manager), 0); - - return reinterpret_cast<char**>(g_task_propagate_pointer(G_TASK(result), error)); -} - -/** - * webkit_cookie_manager_delete_cookies_for_domain: - * @cookie_manager: a #WebKitCookieManager - * @domain: a domain name - * - * Remove all cookies of @cookie_manager for the given @domain. - */ -void webkit_cookie_manager_delete_cookies_for_domain(WebKitCookieManager* manager, const gchar* domain) -{ - g_return_if_fail(WEBKIT_IS_COOKIE_MANAGER(manager)); - g_return_if_fail(domain); - - manager->priv->webCookieManager->deleteCookiesForHostname(String::fromUTF8(domain)); -} - -/** - * webkit_cookie_manager_delete_all_cookies: - * @cookie_manager: a #WebKitCookieManager - * - * Delete all cookies of @cookie_manager - */ -void webkit_cookie_manager_delete_all_cookies(WebKitCookieManager* manager) -{ - g_return_if_fail(WEBKIT_IS_COOKIE_MANAGER(manager)); - - manager->priv->webCookieManager->deleteAllCookies(); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitCookieManager.h b/Source/WebKit2/UIProcess/API/gtk/WebKitCookieManager.h deleted file mode 100644 index f25f1a2b0..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitCookieManager.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitCookieManager_h -#define WebKitCookieManager_h - -#include <gio/gio.h> -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_COOKIE_MANAGER (webkit_cookie_manager_get_type()) -#define WEBKIT_COOKIE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_COOKIE_MANAGER, WebKitCookieManager)) -#define WEBKIT_IS_COOKIE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_COOKIE_MANAGER)) -#define WEBKIT_COOKIE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_COOKIE_MANAGER, WebKitCookieManagerClass)) -#define WEBKIT_IS_COOKIE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_COOKIE_MANAGER)) -#define WEBKIT_COOKIE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_COOKIE_MANAGER, WebKitCookieManagerClass)) - -typedef struct _WebKitCookieManager WebKitCookieManager; -typedef struct _WebKitCookieManagerClass WebKitCookieManagerClass; -typedef struct _WebKitCookieManagerPrivate WebKitCookieManagerPrivate; - -/** - * WebKitCookiePersistentStorage: - * @WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT: Cookies are stored in a text - * file in the Mozilla "cookies.txt" format. - * @WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE: Cookies are stored in a SQLite - * file in the current Mozilla format. - * - * Enum values used to denote the cookie persistent storage types. - */ -typedef enum { - WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT, - WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE -} WebKitCookiePersistentStorage; - -/** - * WebKitCookieAcceptPolicy: - * @WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS: Accept all cookies unconditionally. - * @WEBKIT_COOKIE_POLICY_ACCEPT_NEVER: Reject all cookies unconditionally. - * @WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY: Accept only cookies set by the main document loaded. - * - * Enum values used to denote the cookie acceptance policies. - */ -typedef enum { - WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS, - WEBKIT_COOKIE_POLICY_ACCEPT_NEVER, - WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY -} WebKitCookieAcceptPolicy; - -struct _WebKitCookieManager { - GObject parent; - - WebKitCookieManagerPrivate *priv; -}; - -struct _WebKitCookieManagerClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_cookie_manager_get_type (void); - -WEBKIT_API void -webkit_cookie_manager_set_persistent_storage (WebKitCookieManager *cookie_manager, - const gchar *filename, - WebKitCookiePersistentStorage storage); - -WEBKIT_API void -webkit_cookie_manager_set_accept_policy (WebKitCookieManager *cookie_manager, - WebKitCookieAcceptPolicy policy); - -WEBKIT_API void -webkit_cookie_manager_get_accept_policy (WebKitCookieManager *cookie_manager, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -WEBKIT_API WebKitCookieAcceptPolicy -webkit_cookie_manager_get_accept_policy_finish (WebKitCookieManager *cookie_manager, - GAsyncResult *result, - GError **error); - -WEBKIT_API void -webkit_cookie_manager_get_domains_with_cookies (WebKitCookieManager *cookie_manager, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -WEBKIT_API gchar ** -webkit_cookie_manager_get_domains_with_cookies_finish (WebKitCookieManager *cookie_manager, - GAsyncResult *result, - GError **error); - -WEBKIT_API void -webkit_cookie_manager_delete_cookies_for_domain (WebKitCookieManager *cookie_manager, - const gchar *domain); - -WEBKIT_API void -webkit_cookie_manager_delete_all_cookies (WebKitCookieManager *cookie_manager); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitCookieManagerPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitCookieManagerPrivate.h deleted file mode 100644 index 6be84afae..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitCookieManagerPrivate.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitCookieManagerPrivate_h -#define WebKitCookieManagerPrivate_h - -#include "WebKitCookieManager.h" -#include "WebKitPrivate.h" - -WebKitCookieManager* webkitCookieManagerCreate(WebKit::WebCookieManagerProxy*); - -#endif // WebKitCookieManagerPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitDefines.h b/Source/WebKit2/UIProcess/API/gtk/WebKitDefines.h deleted file mode 100644 index 8b637652b..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitDefines.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) && !defined(__WEBKIT_WEB_EXTENSION_H_INSIDE__) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitDefines_h -#define WebKitDefines_h - -#include <glib.h> - -#ifdef G_OS_WIN32 -# ifdef BUILDING_WEBKIT -# define WEBKIT_API __declspec(dllexport) -# else -# define WEBKIT_API __declspec(dllimport) -# endif -# define WEBKIT_OBSOLETE_API WEBKIT_API -#else -# define WEBKIT_API __attribute__((visibility("default"))) -# define WEBKIT_OBSOLETE_API WEBKIT_API __attribute__((deprecated)) -#endif - -#endif // WebKitDefines_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp deleted file mode 100644 index e9524c209..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp +++ /dev/null @@ -1,570 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitDownload.h" - -#include "DownloadProxy.h" -#include "WebKitDownloadPrivate.h" -#include "WebKitMarshal.h" -#include "WebKitURIRequestPrivate.h" -#include "WebKitURIResponsePrivate.h" -#include <WebCore/ErrorsGtk.h> -#include <WebCore/ResourceResponse.h> -#include <glib/gi18n-lib.h> -#include <wtf/gobject/GOwnPtr.h> -#include <wtf/gobject/GRefPtr.h> - -using namespace WebKit; -using namespace WebCore; - -/** - * SECTION: WebKitDownload - * @Short_description: Object used to communicate with the application when downloading - * @Title: WebKitDownload - * - * #WebKitDownload carries information about a download request and - * response, including a #WebKitURIRequest and a #WebKitURIResponse - * objects. The application may use this object to control the - * download process, or to simply figure out what is to be downloaded, - * and handle the download process itself. - * - */ - -enum { - RECEIVED_DATA, - FINISHED, - FAILED, - DECIDE_DESTINATION, - CREATED_DESTINATION, - - LAST_SIGNAL -}; - -enum { - PROP_0, - - PROP_DESTINATION, - PROP_RESPONSE, - PROP_ESTIMATED_PROGRESS -}; - -struct _WebKitDownloadPrivate { - ~_WebKitDownloadPrivate() - { - if (webView) - g_object_remove_weak_pointer(G_OBJECT(webView), reinterpret_cast<void**>(&webView)); - } - - RefPtr<DownloadProxy> download; - - GRefPtr<WebKitURIRequest> request; - GRefPtr<WebKitURIResponse> response; - WebKitWebView* webView; - CString destinationURI; - guint64 currentSize; - bool isCancelled; - GOwnPtr<GTimer> timer; - gdouble lastProgress; - gdouble lastElapsed; -}; - -static guint signals[LAST_SIGNAL] = { 0, }; - -WEBKIT_DEFINE_TYPE(WebKitDownload, webkit_download, G_TYPE_OBJECT) - -static void webkitDownloadGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) -{ - WebKitDownload* download = WEBKIT_DOWNLOAD(object); - - switch (propId) { - case PROP_DESTINATION: - g_value_set_string(value, webkit_download_get_destination(download)); - break; - case PROP_RESPONSE: - g_value_set_object(value, webkit_download_get_response(download)); - break; - case PROP_ESTIMATED_PROGRESS: - g_value_set_double(value, webkit_download_get_estimated_progress(download)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static gboolean webkitDownloadDecideDestination(WebKitDownload* download, const gchar* suggestedFilename) -{ - if (!download->priv->destinationURI.isNull()) - return FALSE; - - GOwnPtr<char> filename(g_strdelimit(g_strdup(suggestedFilename), G_DIR_SEPARATOR_S, '_')); - const gchar *downloadsDir = g_get_user_special_dir(G_USER_DIRECTORY_DOWNLOAD); - if (!downloadsDir) { - // If we don't have XDG user dirs info, set just to HOME. - downloadsDir = g_get_home_dir(); - } - GOwnPtr<char> destination(g_build_filename(downloadsDir, filename.get(), NULL)); - GOwnPtr<char> destinationURI(g_filename_to_uri(destination.get(), 0, 0)); - download->priv->destinationURI = destinationURI.get(); - g_object_notify(G_OBJECT(download), "destination"); - return TRUE; -} - -static void webkit_download_class_init(WebKitDownloadClass* downloadClass) -{ - GObjectClass* objectClass = G_OBJECT_CLASS(downloadClass); - objectClass->get_property = webkitDownloadGetProperty; - - downloadClass->decide_destination = webkitDownloadDecideDestination; - - /** - * WebKitDownload:destination: - * - * The local URI to where the download will be saved. - */ - g_object_class_install_property(objectClass, - PROP_DESTINATION, - g_param_spec_string("destination", - _("Destination"), - _("The local URI to where the download will be saved"), - 0, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitDownload:response: - * - * The #WebKitURIResponse associated with this download. - */ - g_object_class_install_property(objectClass, - PROP_RESPONSE, - g_param_spec_object("response", - _("Response"), - _("The response of the download"), - WEBKIT_TYPE_URI_RESPONSE, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitDownload:estimated-progress: - * - * An estimate of the percent completion for the download operation. - * This value will range from 0.0 to 1.0. The value is an estimate - * based on the total number of bytes expected to be received for - * a download. - * If you need a more accurate progress information you can connect to - * #WebKitDownload::received-data signal to track the progress. - */ - g_object_class_install_property(objectClass, - PROP_ESTIMATED_PROGRESS, - g_param_spec_double("estimated-progress", - _("Estimated Progress"), - _("Determines the current progress of the download"), - 0.0, 1.0, 1.0, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitDownload::received-data: - * @download: the #WebKitDownload - * @data_length: the length of data received in bytes - * - * This signal is emitted after response is received, - * every time new data has been written to the destination. It's - * useful to know the progress of the download operation. - */ - signals[RECEIVED_DATA] = - g_signal_new("received-data", - G_TYPE_FROM_CLASS(objectClass), - G_SIGNAL_RUN_LAST, - 0, 0, 0, - webkit_marshal_VOID__UINT64, - G_TYPE_NONE, 1, - G_TYPE_UINT64); - - /** - * WebKitDownload::finished: - * @download: the #WebKitDownload - * - * This signal is emitted when download finishes successfully or due to an error. - * In case of errors #WebKitDownload::failed signal is emitted before this one. - */ - signals[FINISHED] = - g_signal_new("finished", - G_TYPE_FROM_CLASS(objectClass), - G_SIGNAL_RUN_LAST, - 0, 0, 0, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /** - * WebKitDownload::failed: - * @download: the #WebKitDownload - * @error: the #GError that was triggered - * - * This signal is emitted when an error occurs during the download - * operation. The given @error, of the domain %WEBKIT_DOWNLOAD_ERROR, - * contains further details of the failure. If the download is cancelled - * with webkit_download_cancel(), this signal is emitted with error - * %WEBKIT_DOWNLOAD_ERROR_CANCELLED_BY_USER. The download operation finishes - * after an error and #WebKitDownload::finished signal is emitted after this one. - */ - signals[FAILED] = - g_signal_new("failed", - G_TYPE_FROM_CLASS(objectClass), - G_SIGNAL_RUN_LAST, - 0, 0, 0, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); - - /** - * WebKitDownload::decide-destination: - * @download: the #WebKitDownload - * @suggested_filename: the filename suggested for the download - * - * This signal is emitted after response is received to - * decide a destination URI for the download. If this signal is not - * handled the file will be downloaded to %G_USER_DIRECTORY_DOWNLOAD - * directory using @suggested_filename. - * - * Returns: %TRUE to stop other handlers from being invoked for the event. - * %FALSE to propagate the event further. - */ - signals[DECIDE_DESTINATION] = - g_signal_new("decide-destination", - G_TYPE_FROM_CLASS(objectClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitDownloadClass, decide_destination), - g_signal_accumulator_true_handled, NULL, - webkit_marshal_BOOLEAN__STRING, - G_TYPE_BOOLEAN, 1, - G_TYPE_STRING); - - /** - * WebKitDownload::created-destination: - * @download: the #WebKitDownload - * @destination: the destination URI - * - * This signal is emitted after #WebKitDownload::decide-destination and before - * #WebKitDownload::received-data to notify that destination file has been - * created successfully at @destination. - */ - signals[CREATED_DESTINATION] = - g_signal_new("created-destination", - G_TYPE_FROM_CLASS(objectClass), - G_SIGNAL_RUN_LAST, - 0, 0, 0, - g_cclosure_marshal_VOID__STRING, - G_TYPE_BOOLEAN, 1, - G_TYPE_STRING); -} - -WebKitDownload* webkitDownloadCreate(DownloadProxy* downloadProxy) -{ - ASSERT(downloadProxy); - WebKitDownload* download = WEBKIT_DOWNLOAD(g_object_new(WEBKIT_TYPE_DOWNLOAD, NULL)); - download->priv->download = downloadProxy; - return download; -} - -WebKitDownload* webkitDownloadCreateForRequest(DownloadProxy* downloadProxy, const ResourceRequest& request) -{ - WebKitDownload* download = webkitDownloadCreate(downloadProxy); - download->priv->request = adoptGRef(webkitURIRequestCreateForResourceRequest(request)); - return download; -} - -void webkitDownloadSetResponse(WebKitDownload* download, WebKitURIResponse* response) -{ - download->priv->response = response; - g_object_notify(G_OBJECT(download), "response"); -} - -void webkitDownloadSetWebView(WebKitDownload* download, WebKitWebView* webView) -{ - download->priv->webView = webView; - g_object_add_weak_pointer(G_OBJECT(webView), reinterpret_cast<void**>(&download->priv->webView)); -} - -bool webkitDownloadIsCancelled(WebKitDownload* download) -{ - return download->priv->isCancelled; -} - -void webkitDownloadNotifyProgress(WebKitDownload* download, guint64 bytesReceived) -{ - WebKitDownloadPrivate* priv = download->priv; - if (priv->isCancelled) - return; - - if (!download->priv->timer) - download->priv->timer.set(g_timer_new()); - - priv->currentSize += bytesReceived; - g_signal_emit(download, signals[RECEIVED_DATA], 0, bytesReceived); - - // Throttle progress notification to not consume high amounts of - // CPU on fast links, except when the last notification occured - // more than 0.016 secs ago (60 FPS), or the last notified progress - // is passed in 1% or we reached the end. - gdouble currentElapsed = g_timer_elapsed(priv->timer.get(), 0); - gdouble currentProgress = webkit_download_get_estimated_progress(download); - - if (priv->lastElapsed - && priv->lastProgress - && (currentElapsed - priv->lastElapsed) < 0.016 - && (currentProgress - priv->lastProgress) < 0.01 - && currentProgress < 1.0) { - return; - } - priv->lastElapsed = currentElapsed; - priv->lastProgress = currentProgress; - g_object_notify(G_OBJECT(download), "estimated-progress"); -} - -void webkitDownloadFailed(WebKitDownload* download, const ResourceError& resourceError) -{ - GOwnPtr<GError> webError(g_error_new_literal(g_quark_from_string(resourceError.domain().utf8().data()), - resourceError.errorCode(), - resourceError.localizedDescription().utf8().data())); - if (download->priv->timer) - g_timer_stop(download->priv->timer.get()); - - g_signal_emit(download, signals[FAILED], 0, webError.get()); - g_signal_emit(download, signals[FINISHED], 0, NULL); -} - -void webkitDownloadCancelled(WebKitDownload* download) -{ - WebKitDownloadPrivate* priv = download->priv; - webkitDownloadFailed(download, downloadCancelledByUserError(priv->response ? webkitURIResponseGetResourceResponse(priv->response.get()) : ResourceResponse())); -} - -void webkitDownloadFinished(WebKitDownload* download) -{ - if (download->priv->isCancelled) { - // Since cancellation is asynchronous, didFinish might be called even - // if the download was cancelled. User cancelled the download, - // so we should fail with cancelled error even if the download - // actually finished successfully. - webkitDownloadCancelled(download); - return; - } - if (download->priv->timer) - g_timer_stop(download->priv->timer.get()); - g_signal_emit(download, signals[FINISHED], 0, NULL); -} - -CString webkitDownloadDecideDestinationWithSuggestedFilename(WebKitDownload* download, const CString& suggestedFilename) -{ - if (download->priv->isCancelled) - return ""; - gboolean returnValue; - g_signal_emit(download, signals[DECIDE_DESTINATION], 0, suggestedFilename.data(), &returnValue); - return download->priv->destinationURI; -} - -void webkitDownloadDestinationCreated(WebKitDownload* download, const CString& destinationURI) -{ - if (download->priv->isCancelled) - return; - gboolean returnValue; - g_signal_emit(download, signals[CREATED_DESTINATION], 0, destinationURI.data(), &returnValue); -} - -/** - * webkit_download_get_request: - * @download: a #WebKitDownload - * - * Retrieves the #WebKitURIRequest object that backs the download - * process. - * - * Returns: (transfer none): the #WebKitURIRequest of @download - */ -WebKitURIRequest* webkit_download_get_request(WebKitDownload* download) -{ - g_return_val_if_fail(WEBKIT_IS_DOWNLOAD(download), 0); - - WebKitDownloadPrivate* priv = download->priv; - if (!priv->request) - priv->request = adoptGRef(webkitURIRequestCreateForResourceRequest(priv->download->request())); - return priv->request.get(); -} - -/** - * webkit_download_get_destination: - * @download: a #WebKitDownload - * - * Obtains the URI to which the downloaded file will be written. You - * can connect to #WebKitDownload::created-destination to make - * sure this method returns a valid destination. - * - * Returns: the destination URI or %NULL - */ -const gchar* webkit_download_get_destination(WebKitDownload* download) -{ - g_return_val_if_fail(WEBKIT_IS_DOWNLOAD(download), 0); - - return download->priv->destinationURI.data(); -} - -/** - * webkit_download_set_destination: - * @download: a #WebKitDownload - * @uri: the destination URI - * - * Sets the URI to which the downloaded file will be written. - * This method should be called before the download transfer - * starts or it will not have any effect on the ongoing download - * operation. To set the destination using the filename suggested - * by the server connect to #WebKitDownload::decide-destination - * signal and call webkit_download_set_destination(). If you want to - * set a fixed destination URI that doesn't depend on the suggested - * filename you can connect to notify::response signal and call - * webkit_download_set_destination(). - * If #WebKitDownload::decide-destination signal is not handled - * and destination URI is not set when the download tranfer starts, - * the file will be saved with the filename suggested by the server in - * %G_USER_DIRECTORY_DOWNLOAD directory. - */ -void webkit_download_set_destination(WebKitDownload* download, const gchar* uri) -{ - g_return_if_fail(WEBKIT_IS_DOWNLOAD(download)); - g_return_if_fail(uri); - - WebKitDownloadPrivate* priv = download->priv; - if (priv->destinationURI == uri) - return; - - priv->destinationURI = uri; - g_object_notify(G_OBJECT(download), "destination"); -} - -/** - * webkit_download_get_response: - * @download: a #WebKitDownload - * - * Retrieves the #WebKitURIResponse object that backs the download - * process. This method returns %NULL if called before the response - * is received from the server. You can connect to notify::response - * signal to be notified when the response is received. - * - * Returns: (transfer none): the #WebKitURIResponse, or %NULL if - * the response hasn't been received yet. - */ -WebKitURIResponse* webkit_download_get_response(WebKitDownload* download) -{ - g_return_val_if_fail(WEBKIT_IS_DOWNLOAD(download), 0); - - return download->priv->response.get(); -} - -/** - * webkit_download_cancel: - * @download: a #WebKitDownload - * - * Cancels the download. When the ongoing download - * operation is effectively cancelled the signal - * #WebKitDownload::failed is emitted with - * %WEBKIT_DOWNLOAD_ERROR_CANCELLED_BY_USER error. - */ -void webkit_download_cancel(WebKitDownload* download) -{ - g_return_if_fail(WEBKIT_IS_DOWNLOAD(download)); - - download->priv->isCancelled = true; - download->priv->download->cancel(); -} - -/** - * webkit_download_get_estimated_progress: - * @download: a #WebKitDownload - * - * Gets the value of the #WebKitDownload:estimated-progress property. - * You can monitor the estimated progress of the download operation by - * connecting to the notify::estimated-progress signal of @download. - * - * Returns: an estimate of the of the percent complete for a download - * as a range from 0.0 to 1.0. - */ -gdouble webkit_download_get_estimated_progress(WebKitDownload* download) -{ - g_return_val_if_fail(WEBKIT_IS_DOWNLOAD(download), 0); - - WebKitDownloadPrivate* priv = download->priv; - if (!priv->response) - return 0; - - guint64 contentLength = webkit_uri_response_get_content_length(priv->response.get()); - if (!contentLength) - return 0; - - return static_cast<gdouble>(priv->currentSize) / static_cast<gdouble>(contentLength); -} - -/** - * webkit_download_get_elapsed_time: - * @download: a #WebKitDownload - * - * Gets the elapsed time in seconds, including any fractional part. - * If the download finished, had an error or was cancelled this is - * the time between its start and the event. - * - * Returns: seconds since the download was started - */ -gdouble webkit_download_get_elapsed_time(WebKitDownload* download) -{ - g_return_val_if_fail(WEBKIT_IS_DOWNLOAD(download), 0); - - WebKitDownloadPrivate* priv = download->priv; - if (!priv->timer) - return 0; - - return g_timer_elapsed(priv->timer.get(), 0); -} - -/** - * webkit_download_get_received_data_length: - * @download: a #WebKitDownload - * - * Gets the length of the data already downloaded for @download - * in bytes. - * - * Returns: the amount of bytes already downloaded. - */ -guint64 webkit_download_get_received_data_length(WebKitDownload* download) -{ - g_return_val_if_fail(WEBKIT_IS_DOWNLOAD(download), 0); - - return download->priv->currentSize; -} - -/** - * webkit_download_get_web_view: - * @download: a #WebKitDownload - * - * Get the #WebKitWebView that initiated the download. - * - * Returns: (transfer none): the #WebKitWebView that initiated @download, - * or %NULL if @download was not initiated by a #WebKitWebView. - */ -WebKitWebView* webkit_download_get_web_view(WebKitDownload* download) -{ - g_return_val_if_fail(WEBKIT_IS_DOWNLOAD(download), 0); - - return download->priv->webView; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.h b/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.h deleted file mode 100644 index 493bfea40..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitDownload_h -#define WebKitDownload_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> -#include <webkit2/WebKitForwardDeclarations.h> -#include <webkit2/WebKitURIRequest.h> -#include <webkit2/WebKitURIResponse.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_DOWNLOAD (webkit_download_get_type()) -#define WEBKIT_DOWNLOAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOWNLOAD, WebKitDownload)) -#define WEBKIT_IS_DOWNLOAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DOWNLOAD)) -#define WEBKIT_DOWNLOAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DOWNLOAD, WebKitDownloadClass)) -#define WEBKIT_IS_DOWNLOAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_DOWNLOAD)) -#define WEBKIT_DOWNLOAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_DOWNLOAD, WebKitDownloadClass)) - -typedef struct _WebKitDownload WebKitDownload; -typedef struct _WebKitDownloadClass WebKitDownloadClass; -typedef struct _WebKitDownloadPrivate WebKitDownloadPrivate; - -struct _WebKitDownload { - GObject parent; - - WebKitDownloadPrivate *priv; -}; - -struct _WebKitDownloadClass { - GObjectClass parent_class; - - gboolean (* decide_destination) (WebKitDownload *download, - const gchar *suggested_filename); - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_download_get_type (void); - -WEBKIT_API WebKitURIRequest * -webkit_download_get_request (WebKitDownload *download); - -WEBKIT_API const gchar * -webkit_download_get_destination (WebKitDownload *download); - -WEBKIT_API void -webkit_download_set_destination (WebKitDownload *download, - const gchar *uri); - -WEBKIT_API WebKitURIResponse* -webkit_download_get_response (WebKitDownload *download); - -WEBKIT_API void -webkit_download_cancel (WebKitDownload *download); - -WEBKIT_API gdouble -webkit_download_get_estimated_progress (WebKitDownload *download); - -WEBKIT_API gdouble -webkit_download_get_elapsed_time (WebKitDownload *download); - -WEBKIT_API guint64 -webkit_download_get_received_data_length (WebKitDownload *download); - -WEBKIT_API WebKitWebView * -webkit_download_get_web_view (WebKitDownload *download); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadClient.cpp deleted file mode 100644 index 79c1c3e2a..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadClient.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitDownloadClient.h" - -#include "WebContext.h" -#include "WebKitDownloadPrivate.h" -#include "WebKitURIResponsePrivate.h" -#include "WebKitWebContextPrivate.h" -#include "WebURLResponse.h" -#include <WebKit2/WKString.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -using namespace WebCore; -using namespace WebKit; - -static void didStart(WKContextRef, WKDownloadRef wkDownload, const void* clientInfo) -{ - GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); - webkitWebContextDownloadStarted(WEBKIT_WEB_CONTEXT(clientInfo), download.get()); -} - -static void didReceiveResponse(WKContextRef, WKDownloadRef wkDownload, WKURLResponseRef wkResponse, const void* clientInfo) -{ - GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); - if (webkitDownloadIsCancelled(download.get())) - return; - - GRefPtr<WebKitURIResponse> response = adoptGRef(webkitURIResponseCreateForResourceResponse(toImpl(wkResponse)->resourceResponse())); - webkitDownloadSetResponse(download.get(), response.get()); -} - -static void didReceiveData(WKContextRef, WKDownloadRef wkDownload, uint64_t length, const void* clientInfo) -{ - GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); - webkitDownloadNotifyProgress(download.get(), length); -} - -static WKStringRef decideDestinationWithSuggestedFilename(WKContextRef, WKDownloadRef wkDownload, WKStringRef filename, bool* allowOverwrite, const void* clientInfo) -{ - GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); - CString destinationURI = webkitDownloadDecideDestinationWithSuggestedFilename(download.get(), - toImpl(filename)->string().utf8()); - return WKStringCreateWithUTF8CString(destinationURI.data()); -} - -static void didCreateDestination(WKContextRef, WKDownloadRef wkDownload, WKStringRef path, const void* clientInfo) -{ - GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); - webkitDownloadDestinationCreated(download.get(), toImpl(path)->string().utf8()); -} - -static void didFail(WKContextRef, WKDownloadRef wkDownload, WKErrorRef error, const void *clientInfo) -{ - GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); - if (webkitDownloadIsCancelled(download.get())) { - // Cancellation takes precedence over other errors. - webkitDownloadCancelled(download.get()); - } else - webkitDownloadFailed(download.get(), toImpl(error)->platformError()); - webkitWebContextRemoveDownload(toImpl(wkDownload)); -} - -static void didCancel(WKContextRef, WKDownloadRef wkDownload, const void *clientInfo) -{ - GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); - webkitDownloadCancelled(download.get()); - webkitWebContextRemoveDownload(toImpl(wkDownload)); -} - -static void didFinish(WKContextRef wkContext, WKDownloadRef wkDownload, const void *clientInfo) -{ - GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); - webkitDownloadFinished(download.get()); - webkitWebContextRemoveDownload(toImpl(wkDownload)); -} - -void attachDownloadClientToContext(WebKitWebContext* webContext) -{ - WKContextDownloadClient wkDownloadClient = { - kWKContextDownloadClientCurrentVersion, - webContext, // ClientInfo - didStart, - 0, // didReceiveAuthenticationChallenge - didReceiveResponse, - didReceiveData, - 0, // shouldDecodeSourceDataOfMIMEType - decideDestinationWithSuggestedFilename, - didCreateDestination, - didFinish, - didFail, - didCancel, - 0, // processDidCrash - }; - WKContextSetDownloadClient(toAPI(webkitWebContextGetContext(webContext)), &wkDownloadClient); -} - diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadClient.h b/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadClient.h deleted file mode 100644 index c2566e897..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadClient.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitDownloadClient_h -#define WebKitDownloadClient_h - -#include "WebKitWebContext.h" - -void attachDownloadClientToContext(WebKitWebContext*); - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadPrivate.h deleted file mode 100644 index 980ad732b..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadPrivate.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitDownloadPrivate_h -#define WebKitDownloadPrivate_h - -#include "WebKitDownload.h" -#include "WebKitPrivate.h" -#include <WebCore/ResourceError.h> -#include <WebCore/ResourceRequest.h> -#include <wtf/text/CString.h> - -WebKitDownload* webkitDownloadCreate(WebKit::DownloadProxy*); -WebKitDownload* webkitDownloadCreateForRequest(WebKit::DownloadProxy*, const WebCore::ResourceRequest&); -bool webkitDownloadIsCancelled(WebKitDownload*); -void webkitDownloadSetResponse(WebKitDownload*, WebKitURIResponse*); -void webkitDownloadSetWebView(WebKitDownload*, WebKitWebView*); -void webkitDownloadNotifyProgress(WebKitDownload*, guint64 bytesReceived); -void webkitDownloadFailed(WebKitDownload*, const WebCore::ResourceError&); -void webkitDownloadCancelled(WebKitDownload*); -void webkitDownloadFinished(WebKitDownload*); -CString webkitDownloadDecideDestinationWithSuggestedFilename(WebKitDownload*, const CString& suggestedFilename); -void webkitDownloadDestinationCreated(WebKitDownload*, const CString& destinationURI); - -#endif // WebKitDownloadPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitEditingCommands.h b/Source/WebKit2/UIProcess/API/gtk/WebKitEditingCommands.h deleted file mode 100644 index 437395710..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitEditingCommands.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitEditingCommands_h -#define WebKitEditingCommands_h - -G_BEGIN_DECLS - -/** - * WEBKIT_EDITING_COMMAND_CUT: - * - * The cut clipboard command. Copies the current selection inside - * a #WebKitWebView to the clipboard and deletes the selected content. - * You can check whether it's possible to execute the command with - * webkit_web_view_can_execute_editing_command(). In general it's - * possible to cut to the clipboard when the #WebKitWebView content is - * editable and there is an active selection. - */ -#define WEBKIT_EDITING_COMMAND_CUT "Cut" - -/** - * WEBKIT_EDITING_COMMAND_COPY: - * - * The copy clipboard command. Copies the current selection inside - * a #WebKitWebView to the clipboard. - * You can check whether it's possible to execute the command with - * webkit_web_view_can_execute_editing_command(). In general it's - * possible to copy to the clipboard when there is an active selection - * inside the #WebKitWebView. - */ -#define WEBKIT_EDITING_COMMAND_COPY "Copy" - -/** - * WEBKIT_EDITING_COMMAND_PASTE: - * - * The paste clipboard command. Pastes the contents of the clipboard to - * a #WebKitWebView. - * You can check whether it's possible to execute the command with - * webkit_web_view_can_execute_editing_command(). In general it's possible - * to paste from the clipboard when the #WebKitWebView content is editable - * and clipboard is not empty. - */ -#define WEBKIT_EDITING_COMMAND_PASTE "Paste" - -/** - * WEBKIT_EDITING_COMMAND_SELECT_ALL: - * - * The select all command. Selects all the content of the current text field in - * a #WebKitWebView. - * It is always possible to select all text, no matter whether the - * #WebKitWebView content is editable or not. You can still check it - * with webkit_web_view_can_execute_editing_command(). - */ -#define WEBKIT_EDITING_COMMAND_SELECT_ALL "SelectAll" - -/** - * WEBKIT_EDITING_COMMAND_UNDO: - * - * The undo command. Undoes the last editing command in a #WebKitWebView. - * You can check whether it's possible to execute the command with - * webkit_web_view_can_execute_editing_command(). It's only possible - * to undo a command after a previously executed editing operation. - */ -#define WEBKIT_EDITING_COMMAND_UNDO "Undo" - -/** - * WEBKIT_EDITING_COMMAND_REDO: - * - * The redo command. Redoes a previously undone editing command in - * a #WebKitWebView. - * You can check whether it's possible to execute the command with - * webkit_web_view_can_execute_editing_command(). It's only possible - * to redo a command when it has been previously undone. - */ -#define WEBKIT_EDITING_COMMAND_REDO "Redo" - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitEnumTypes.cpp.template b/Source/WebKit2/UIProcess/API/gtk/WebKitEnumTypes.cpp.template deleted file mode 100644 index 292e1e556..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitEnumTypes.cpp.template +++ /dev/null @@ -1,62 +0,0 @@ -/*** BEGIN file-header ***/ -/* - * Copyright (C) 2013 Igalia S.L. - * - * 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 "WebKitEnumTypes.h" - -#include <webkit2/webkit2.h> -extern "C" { -/*** END file-header ***/ - - -/*** BEGIN file-production ***/ -// Enumerations from @filename@. -/*** END file-production ***/ - - -/*** BEGIN value-header ***/ -GType @enum_name@_get_type() -{ - static const G@Type@Value values[] = { -/*** END value-header ***/ - - -/*** BEGIN value-production ***/ - { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, -/*** END value-production ***/ - - -/*** BEGIN value-tail ***/ - { 0, NULL, NULL } - }; - - static GType type = 0; - if (G_UNLIKELY(!type)) - type = g_@type@_register_static("@EnumName@", values); - - return type; -} - -/*** END value-tail ***/ - - -/*** BEGIN file-tail ***/ -} -/*** END file-tail ***/ diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitEnumTypes.h.template b/Source/WebKit2/UIProcess/API/gtk/WebKitEnumTypes.h.template deleted file mode 100644 index 1283e0bbd..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitEnumTypes.h.template +++ /dev/null @@ -1,54 +0,0 @@ -/*** BEGIN file-header ***/ -/* - * Copyright (C) 2013 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WEBKIT_ENUM_TYPES_H -#define WEBKIT_ENUM_TYPES_H - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS -/*** END file-header ***/ - - -/*** BEGIN file-production ***/ -/* Enumerations from @filename@. */ -/*** END file-production ***/ - - -/*** BEGIN enumeration-production ***/ -#define WEBKIT_TYPE_@ENUMSHORT@ @enum_name@_get_type () - -WEBKIT_API GType -@enum_name@_get_type (void); - -/*** END enumeration-production ***/ - - -/*** BEGIN file-tail ***/ -G_END_DECLS - -#endif -/*** END file-tail ***/ - diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitError.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitError.cpp deleted file mode 100644 index c06dc61a5..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitError.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * Copyright (C) 2008 Luca Bruno <lethalman88@gmail.com> - * - * 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 "WebKitError.h" - -#include "WebKitPrivate.h" -#include <WebCore/ErrorsGtk.h> - -using namespace WebCore; - -/** - * SECTION: WebKitError - * @Short_description: Categorized WebKit errors - * @Title: WebKitError - * - * Categorized WebKit errors. - * - */ - -GQuark webkit_network_error_quark() -{ - return g_quark_from_static_string(WebCore::errorDomainNetwork); -} - -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_FAILED, NetworkErrorFailed); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_TRANSPORT, NetworkErrorTransport); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL, NetworkErrorUnknownProtocol); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_CANCELLED, NetworkErrorCancelled); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST, NetworkErrorFileDoesNotExist); - -GQuark webkit_policy_error_quark() -{ - return g_quark_from_static_string(WebCore::errorDomainPolicy); -} - -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_FAILED, PolicyErrorFailed); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE, PolicyErrorCannotShowMimeType); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_CANNOT_SHOW_URI, PolicyErrorCannotShowURL); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE, PolicyErrorFrameLoadInterruptedByPolicyChange); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT, PolicyErrorCannotUseRestrictedPort); - -GQuark webkit_plugin_error_quark() -{ - return g_quark_from_static_string(WebCore::errorDomainPlugin); -} - -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_FAILED, PluginErrorFailed); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_CANNOT_FIND_PLUGIN, PluginErrorCannotFindPlugin); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_CANNOT_LOAD_PLUGIN, PluginErrorCannotLoadPlugin); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_JAVA_UNAVAILABLE, PluginErrorJavaUnavailable); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_CONNECTION_CANCELLED, PluginErrorConnectionCancelled); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD, PluginErrorWillHandleLoad); - -GQuark webkit_download_error_quark() -{ - return g_quark_from_static_string(WebCore::errorDomainDownload); -} - -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_DOWNLOAD_ERROR_NETWORK, DownloadErrorNetwork); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_DOWNLOAD_ERROR_CANCELLED_BY_USER, DownloadErrorCancelledByUser); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_DOWNLOAD_ERROR_DESTINATION, DownloadErrorDestination); - -GQuark webkit_print_error_quark() -{ - return g_quark_from_static_string(WebCore::errorDomainPrint); -} - -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PRINT_ERROR_GENERAL, PrintErrorGeneral); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PRINT_ERROR_PRINTER_NOT_FOUND, PrintErrorPrinterNotFound); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PRINT_ERROR_INVALID_PAGE_RANGE, PrintErrorInvalidPageRange); - -GQuark webkit_javascript_error_quark() -{ - return g_quark_from_static_string("WebKitJavascriptError"); -} - -GQuark webkit_snapshot_error_quark() -{ - return g_quark_from_static_string("WebKitSnapshotError"); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitError.h b/Source/WebKit2/UIProcess/API/gtk/WebKitError.h deleted file mode 100644 index e7de93bc2..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitError.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * Copyright (C) 2008 Luca Bruno <lethalman88@gmail.com> - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitError_h -#define WebKitError_h - -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_NETWORK_ERROR webkit_network_error_quark () -#define WEBKIT_POLICY_ERROR webkit_policy_error_quark () -#define WEBKIT_PLUGIN_ERROR webkit_plugin_error_quark () -#define WEBKIT_DOWNLOAD_ERROR webkit_download_error_quark () -#define WEBKIT_PRINT_ERROR webkit_print_error_quark () -#define WEBKIT_JAVASCRIPT_ERROR webkit_print_error_quark () -#define WEBKIT_SNAPSHOT_ERROR webkit_snapshot_error_quark () - -/** - * WebKitNetworkError: - * @WEBKIT_NETWORK_ERROR_FAILED: Generic load failure - * @WEBKIT_NETWORK_ERROR_TRANSPORT: Load failure due to transport error - * @WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL: Load failure due to unknown protocol - * @WEBKIT_NETWORK_ERROR_CANCELLED: Load failure due to cancellation - * @WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST: Load failure due to missing file - * - * Enum values used to denote the various network errors. - **/ -typedef enum { - WEBKIT_NETWORK_ERROR_FAILED = 399, - WEBKIT_NETWORK_ERROR_TRANSPORT = 300, - WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL = 301, - WEBKIT_NETWORK_ERROR_CANCELLED = 302, - WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST = 303 -} WebKitNetworkError; - -/** - * WebKitPolicyError: - * @WEBKIT_POLICY_ERROR_FAILED: Generic load failure due to policy error - * @WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE: Load failure due to unsupported mime type - * @WEBKIT_POLICY_ERROR_CANNOT_SHOW_URI: Load failure due to URI that can not be shown - * @WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE: Load failure due to frame load interruption by policy change - * @WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT: Load failure due to port restriction - * - * Enum values used to denote the various policy errors. - **/ -typedef enum { - WEBKIT_POLICY_ERROR_FAILED = 199, - WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE = 100, - WEBKIT_POLICY_ERROR_CANNOT_SHOW_URI = 101, - WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE = 102, - WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT = 103 -} WebKitPolicyError; - -/** - * WebKitPluginError: - * @WEBKIT_PLUGIN_ERROR_FAILED: Generic plugin load failure - * @WEBKIT_PLUGIN_ERROR_CANNOT_FIND_PLUGIN: Load failure due to missing plugin - * @WEBKIT_PLUGIN_ERROR_CANNOT_LOAD_PLUGIN: Load failure due to inability to load plugin - * @WEBKIT_PLUGIN_ERROR_JAVA_UNAVAILABLE: Load failue due to missing Java support that is required to load plugin - * @WEBKIT_PLUGIN_ERROR_CONNECTION_CANCELLED: Load failure due to connection cancellation - * @WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD: Load failure since plugin handles the load - * - * Enum values used to denote the various plugin errors. - **/ -typedef enum { - WEBKIT_PLUGIN_ERROR_FAILED = 299, - WEBKIT_PLUGIN_ERROR_CANNOT_FIND_PLUGIN = 200, - WEBKIT_PLUGIN_ERROR_CANNOT_LOAD_PLUGIN = 201, - WEBKIT_PLUGIN_ERROR_JAVA_UNAVAILABLE = 202, - WEBKIT_PLUGIN_ERROR_CONNECTION_CANCELLED = 203, - WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD = 204, -} WebKitPluginError; - -/** - * WebKitDownloadError: - * @WEBKIT_DOWNLOAD_ERROR_NETWORK: Download failure due to network error - * @WEBKIT_DOWNLOAD_ERROR_CANCELLED_BY_USER: Download was cancelled by user - * @WEBKIT_DOWNLOAD_ERROR_DESTINATION: Download failure due to destination error - * - * Enum values used to denote the various download errors. - */ -typedef enum { - WEBKIT_DOWNLOAD_ERROR_NETWORK = 499, - WEBKIT_DOWNLOAD_ERROR_CANCELLED_BY_USER = 400, - WEBKIT_DOWNLOAD_ERROR_DESTINATION = 401 -} WebKitDownloadError; - -/** - * WebKitPrintError: - * @WEBKIT_PRINT_ERROR_GENERAL: Unspecified error during a print operation - * @WEBKIT_PRINT_ERROR_PRINTER_NOT_FOUND: Selected printer cannot be found - * @WEBKIT_PRINT_ERROR_INVALID_PAGE_RANGE: Invalid page range - * - * Enum values used to denote the various print errors. - */ -typedef enum { - WEBKIT_PRINT_ERROR_GENERAL = 599, - WEBKIT_PRINT_ERROR_PRINTER_NOT_FOUND = 500, - WEBKIT_PRINT_ERROR_INVALID_PAGE_RANGE = 501 -} WebKitPrintError; - -/** - * WebKitJavascriptError: - * @WEBKIT_JAVASCRIPT_ERROR_SCRIPT_FAILED: An exception was raised in Javascript execution - * - * Enum values used to denote errors happending when executing Javascript - */ -typedef enum { - WEBKIT_JAVASCRIPT_ERROR_SCRIPT_FAILED = 699 -} WebKitJavascriptError; - -/** - * WebKitSnapshotError: - * @WEBKIT_SNAPSHOT_ERROR_FAILED_TO_CREATE: An error occurred when creating a webpage snapshot. - * - * Enum values used to denote errors happending when creating snapshots of #WebKitWebView - */ -typedef enum { - WEBKIT_SNAPSHOT_ERROR_FAILED_TO_CREATE = 799 -} WebKitSnapshotError; - -WEBKIT_API GQuark -webkit_network_error_quark (void); - -WEBKIT_API GQuark -webkit_policy_error_quark (void); - -WEBKIT_API GQuark -webkit_plugin_error_quark (void); - -WEBKIT_API GQuark -webkit_download_error_quark (void); - -WEBKIT_API GQuark -webkit_print_error_quark (void); - -WEBKIT_API GQuark -webkit_javascript_error_quark (void); - -WEBKIT_API GQuark -webkit_snapshot_error_quark (void); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabase.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabase.cpp deleted file mode 100644 index af274b97d..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabase.cpp +++ /dev/null @@ -1,381 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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 "WebKitFaviconDatabase.h" - -#include "WebKitFaviconDatabasePrivate.h" -#include "WebKitMarshal.h" -#include "WebKitPrivate.h" -#include <WebCore/FileSystem.h> -#include <WebCore/Image.h> -#include <WebCore/IntSize.h> -#include <WebCore/RefPtrCairo.h> -#include <glib/gi18n-lib.h> -#include <wtf/MainThread.h> -#include <wtf/gobject/GOwnPtr.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -using namespace WebKit; - -/** - * SECTION: WebKitFaviconDatabase - * @Short_description: A WebKit favicon database - * @Title: WebKitFaviconDatabase - * - * #WebKitFaviconDatabase provides access to the icons associated with - * web sites. - * - * WebKit will automatically look for available icons in <link> - * elements on opened pages as well as an existing favicon.ico and - * load the images found into a memory cache if possible. That cache - * is frozen to an on-disk database for persistence. - * - * If #WebKitSettings:enable-private-browsing is %TRUE, new icons - * won't be added to the on-disk database and no existing icons will - * be deleted from it. Nevertheless, WebKit will still store them in - * the in-memory cache during the current execution. - * - */ - -enum { - FAVICON_CHANGED, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0, }; - -typedef Vector<GRefPtr<GTask> > PendingIconRequestVector; -typedef HashMap<String, PendingIconRequestVector*> PendingIconRequestMap; - -struct _WebKitFaviconDatabasePrivate { - RefPtr<WebIconDatabase> iconDatabase; - PendingIconRequestMap pendingIconRequests; - HashMap<String, String> pageURLToIconURLMap; -}; - -WEBKIT_DEFINE_TYPE(WebKitFaviconDatabase, webkit_favicon_database, G_TYPE_OBJECT) - -static void webkitFaviconDatabaseDispose(GObject* object) -{ - WebKitFaviconDatabase* database = WEBKIT_FAVICON_DATABASE(object); - - WebKitFaviconDatabasePrivate* priv = database->priv; - if (priv->iconDatabase->isOpen()) - priv->iconDatabase->close(); - - G_OBJECT_CLASS(webkit_favicon_database_parent_class)->dispose(object); -} - -static void webkit_favicon_database_class_init(WebKitFaviconDatabaseClass* faviconDatabaseClass) -{ - GObjectClass* gObjectClass = G_OBJECT_CLASS(faviconDatabaseClass); - gObjectClass->dispose = webkitFaviconDatabaseDispose; - - /** - * WebKitFaviconDatabase::favicon-changed: - * @database: the object on which the signal is emitted - * @page_uri: the URI of the Web page containing the icon - * @favicon_uri: the URI of the favicon - * - * This signal is emitted when the favicon URI of @page_uri has - * been changed to @favicon_uri in the database. You can connect - * to this signal and call webkit_favicon_database_get_favicon() - * to get the favicon. If you are interested in the favicon of a - * #WebKitWebView it's easier to use the #WebKitWebView:favicon - * property. See webkit_web_view_get_favicon() for more details. - */ - signals[FAVICON_CHANGED] = - g_signal_new( - "favicon-changed", - G_TYPE_FROM_CLASS(faviconDatabaseClass), - G_SIGNAL_RUN_LAST, - 0, 0, 0, - webkit_marshal_VOID__STRING_STRING, - G_TYPE_NONE, 2, - G_TYPE_STRING, - G_TYPE_STRING); -} - -struct GetFaviconSurfaceAsyncData { - ~GetFaviconSurfaceAsyncData() - { - if (shouldReleaseIconForPageURL) - faviconDatabase->priv->iconDatabase->releaseIconForPageURL(pageURL); - } - - GRefPtr<WebKitFaviconDatabase> faviconDatabase; - String pageURL; - RefPtr<cairo_surface_t> icon; - GRefPtr<GCancellable> cancellable; - bool shouldReleaseIconForPageURL; -}; -WEBKIT_DEFINE_ASYNC_DATA_STRUCT(GetFaviconSurfaceAsyncData) - -static PassRefPtr<cairo_surface_t> getIconSurfaceSynchronously(WebKitFaviconDatabase* database, const String& pageURL, GError** error) -{ - ASSERT(isMainThread()); - - // The exact size we pass is irrelevant to the iconDatabase code. - // We must pass something greater than 0x0 to get an icon. - WebCore::Image* iconImage = database->priv->iconDatabase->imageForPageURL(pageURL, WebCore::IntSize(1, 1)); - if (!iconImage) { - g_set_error(error, WEBKIT_FAVICON_DATABASE_ERROR, WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_UNKNOWN, _("Unknown favicon for page %s"), pageURL.utf8().data()); - return 0; - } - - RefPtr<cairo_surface_t> surface = iconImage->nativeImageForCurrentFrame(); - if (!surface) { - g_set_error(error, WEBKIT_FAVICON_DATABASE_ERROR, WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_NOT_FOUND, _("Page %s does not have a favicon"), pageURL.utf8().data()); - return 0; - } - - return surface.release(); -} - -static void deletePendingIconRequests(WebKitFaviconDatabase* database, PendingIconRequestVector* requests, const String& pageURL) -{ - database->priv->pendingIconRequests.remove(pageURL); - delete requests; -} - -static void processPendingIconsForPageURL(WebKitFaviconDatabase* database, const String& pageURL) -{ - PendingIconRequestVector* pendingIconRequests = database->priv->pendingIconRequests.get(pageURL); - if (!pendingIconRequests) - return; - - GOwnPtr<GError> error; - RefPtr<cairo_surface_t> icon = getIconSurfaceSynchronously(database, pageURL, &error.outPtr()); - - for (size_t i = 0; i < pendingIconRequests->size(); ++i) { - GTask* task = pendingIconRequests->at(i).get(); - if (error) - g_task_return_error(task, error.release()); - else { - GetFaviconSurfaceAsyncData* data = static_cast<GetFaviconSurfaceAsyncData*>(g_task_get_task_data(task)); - data->icon = icon; - data->shouldReleaseIconForPageURL = false; - g_task_return_boolean(task, TRUE); - } - } - deletePendingIconRequests(database, pendingIconRequests, pageURL); -} - -static void didChangeIconForPageURLCallback(WKIconDatabaseRef wkIconDatabase, WKURLRef wkPageURL, const void* clientInfo) -{ - WebKitFaviconDatabase* database = WEBKIT_FAVICON_DATABASE(clientInfo); - if (!database->priv->iconDatabase->isUrlImportCompleted()) - return; - - // Wait until there's an icon record in the database for this page URL. - String pageURL = toImpl(wkPageURL)->string(); - WebCore::Image* iconImage = database->priv->iconDatabase->imageForPageURL(pageURL, WebCore::IntSize(1, 1)); - if (!iconImage || iconImage->isNull()) - return; - - String currentIconURL; - database->priv->iconDatabase->synchronousIconURLForPageURL(pageURL, currentIconURL); - const String& iconURL = database->priv->pageURLToIconURLMap.get(pageURL); - if (iconURL == currentIconURL) - return; - - database->priv->pageURLToIconURLMap.set(pageURL, currentIconURL); - g_signal_emit(database, signals[FAVICON_CHANGED], 0, pageURL.utf8().data(), currentIconURL.utf8().data()); -} - -static void iconDataReadyForPageURLCallback(WKIconDatabaseRef wkIconDatabase, WKURLRef wkPageURL, const void* clientInfo) -{ - ASSERT(isMainThread()); - processPendingIconsForPageURL(WEBKIT_FAVICON_DATABASE(clientInfo), toImpl(wkPageURL)->string()); -} - -WebKitFaviconDatabase* webkitFaviconDatabaseCreate(WebIconDatabase* iconDatabase) -{ - WebKitFaviconDatabase* faviconDatabase = WEBKIT_FAVICON_DATABASE(g_object_new(WEBKIT_TYPE_FAVICON_DATABASE, NULL)); - faviconDatabase->priv->iconDatabase = iconDatabase; - - WKIconDatabaseClient wkIconDatabaseClient = { - kWKIconDatabaseClientCurrentVersion, - faviconDatabase, // clientInfo - didChangeIconForPageURLCallback, - 0, // didRemoveAllIconsCallback - iconDataReadyForPageURLCallback, - }; - WKIconDatabaseSetIconDatabaseClient(toAPI(iconDatabase), &wkIconDatabaseClient); - return faviconDatabase; -} - -static PendingIconRequestVector* getOrCreatePendingIconRequests(WebKitFaviconDatabase* database, const String& pageURL) -{ - PendingIconRequestVector* icons = database->priv->pendingIconRequests.get(pageURL); - if (!icons) { - icons = new PendingIconRequestVector; - database->priv->pendingIconRequests.set(pageURL, icons); - } - - return icons; -} - -GQuark webkit_favicon_database_error_quark(void) -{ - return g_quark_from_static_string("WebKitFaviconDatabaseError"); -} - -/** - * webkit_favicon_database_get_favicon: - * @database: a #WebKitFaviconDatabase - * @page_uri: URI of the page for which we want to retrieve the favicon - * @cancellable: (allow-none): A #GCancellable or %NULL. - * @callback: (scope async): A #GAsyncReadyCallback to call when the request is - * satisfied or %NULL if you don't care about the result. - * @user_data: (closure): The data to pass to @callback. - * - * Asynchronously obtains a #cairo_surface_t of the favicon for the - * given page URI. It returns the cached icon if it's in the database - * asynchronously waiting for the icon to be read from the database. - * - * This is an asynchronous method. When the operation is finished, callback will - * be invoked. You can then call webkit_favicon_database_get_favicon_finish() - * to get the result of the operation. - */ -void webkit_favicon_database_get_favicon(WebKitFaviconDatabase* database, const gchar* pageURI, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData) -{ - g_return_if_fail(WEBKIT_IS_FAVICON_DATABASE(database)); - g_return_if_fail(pageURI); - - WebKitFaviconDatabasePrivate* priv = database->priv; - WebIconDatabase* iconDatabaseImpl = priv->iconDatabase.get(); - if (!iconDatabaseImpl->isOpen()) { - g_task_report_new_error(database, callback, userData, 0, - WEBKIT_FAVICON_DATABASE_ERROR, WEBKIT_FAVICON_DATABASE_ERROR_NOT_INITIALIZED, _("Favicons database not initialized yet")); - return; - } - - if (g_str_has_prefix(pageURI, "about:")) { - g_task_report_new_error(database, callback, userData, 0, - WEBKIT_FAVICON_DATABASE_ERROR, WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_NOT_FOUND, _("Page %s does not have a favicon"), pageURI); - return; - } - - GRefPtr<GTask> task = adoptGRef(g_task_new(database, cancellable, callback, userData)); - - GetFaviconSurfaceAsyncData* data = createGetFaviconSurfaceAsyncData(); - data->faviconDatabase = database; - data->pageURL = String::fromUTF8(pageURI); - g_task_set_task_data(task.get(), data, reinterpret_cast<GDestroyNotify>(destroyGetFaviconSurfaceAsyncData)); - - priv->iconDatabase->retainIconForPageURL(data->pageURL); - - // We ask for the icon directly. If we don't get the icon data now, - // we'll be notified later (even if the database is still importing icons). - GOwnPtr<GError> error; - data->icon = getIconSurfaceSynchronously(database, data->pageURL, &error.outPtr()); - if (data->icon) { - g_task_return_boolean(task.get(), TRUE); - return; - } - - // At this point we still don't know whether we will get a valid icon for pageURL. - data->shouldReleaseIconForPageURL = true; - - if (g_error_matches(error.get(), WEBKIT_FAVICON_DATABASE_ERROR, WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_NOT_FOUND)) { - g_task_return_error(task.get(), error.release()); - return; - } - - // If there's not a valid icon, but there's an iconURL registered, - // or it's still not registered but the import process hasn't - // finished yet, we need to wait for iconDataReadyForPage to be - // called before making and informed decision. - String iconURLForPageURL; - iconDatabaseImpl->synchronousIconURLForPageURL(data->pageURL, iconURLForPageURL); - if (!iconURLForPageURL.isEmpty() || !iconDatabaseImpl->isUrlImportCompleted()) { - PendingIconRequestVector* iconRequests = getOrCreatePendingIconRequests(database, data->pageURL); - ASSERT(iconRequests); - iconRequests->append(task); - return; - } - - g_task_return_new_error(task.get(), WEBKIT_FAVICON_DATABASE_ERROR, WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_UNKNOWN, - _("Unknown favicon for page %s"), pageURI); -} - -/** - * webkit_favicon_database_get_favicon_finish: - * @database: a #WebKitFaviconDatabase - * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to webkit_favicon_database_get_favicon() - * @error: (allow-none): Return location for error or %NULL. - * - * Finishes an operation started with webkit_favicon_database_get_favicon(). - * - * Returns: (transfer full): a new reference to a #cairo_surface_t, or - * %NULL in case of error. - */ -cairo_surface_t* webkit_favicon_database_get_favicon_finish(WebKitFaviconDatabase* database, GAsyncResult* result, GError** error) -{ - g_return_val_if_fail(WEBKIT_IS_FAVICON_DATABASE(database), 0); - g_return_val_if_fail(g_task_is_valid(result, database), 0); - - GTask* task = G_TASK(result); - if (!g_task_propagate_boolean(task, error)) - return 0; - - GetFaviconSurfaceAsyncData* data = static_cast<GetFaviconSurfaceAsyncData*>(g_task_get_task_data(task)); - return cairo_surface_reference(data->icon.get()); -} - -/** - * webkit_favicon_database_get_favicon_uri: - * @database: a #WebKitFaviconDatabase - * @page_uri: URI of the page containing the icon - * - * Obtains the URI of the favicon for the given @page_uri. - * - * Returns: a newly allocated URI for the favicon, or %NULL if the - * database doesn't have a favicon for @page_uri. - */ -gchar* webkit_favicon_database_get_favicon_uri(WebKitFaviconDatabase* database, const gchar* pageURL) -{ - g_return_val_if_fail(WEBKIT_IS_FAVICON_DATABASE(database), 0); - g_return_val_if_fail(pageURL, 0); - ASSERT(isMainThread()); - - String iconURLForPageURL; - database->priv->iconDatabase->synchronousIconURLForPageURL(String::fromUTF8(pageURL), iconURLForPageURL); - if (iconURLForPageURL.isEmpty()) - return 0; - - return g_strdup(iconURLForPageURL.utf8().data()); -} - -/** - * webkit_favicon_database_clear: - * @database: a #WebKitFaviconDatabase - * - * Clears all icons from the database. - */ -void webkit_favicon_database_clear(WebKitFaviconDatabase* database) -{ - g_return_if_fail(WEBKIT_IS_FAVICON_DATABASE(database)); - - database->priv->iconDatabase->removeAllIcons(); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabase.h b/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabase.h deleted file mode 100644 index 45fbb5d88..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabase.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitFaviconDatabase_h -#define WebKitFaviconDatabase_h - -#include <cairo.h> -#include <gio/gio.h> -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_FAVICON_DATABASE (webkit_favicon_database_get_type()) -#define WEBKIT_FAVICON_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_FAVICON_DATABASE, WebKitFaviconDatabase)) -#define WEBKIT_IS_FAVICON_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_FAVICON_DATABASE)) -#define WEBKIT_FAVICON_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_FAVICON_DATABASE, WebKitFaviconDatabaseClass)) -#define WEBKIT_IS_FAVICON_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_FAVICON_DATABASE)) -#define WEBKIT_FAVICON_DATABASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_FAVICON_DATABASE, WebKitFaviconDatabaseClass)) -#define WEBKIT_FAVICON_DATABASE_ERROR (webkit_favicon_database_error_quark()) - -typedef struct _WebKitFaviconDatabase WebKitFaviconDatabase; -typedef struct _WebKitFaviconDatabaseClass WebKitFaviconDatabaseClass; -typedef struct _WebKitFaviconDatabasePrivate WebKitFaviconDatabasePrivate; - -struct _WebKitFaviconDatabase { - GObject parent; - - WebKitFaviconDatabasePrivate *priv; -}; - -struct _WebKitFaviconDatabaseClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -/** - * WebKitFaviconDatabaseError: - * @WEBKIT_FAVICON_DATABASE_ERROR_NOT_INITIALIZED: The #WebKitFaviconDatabase has not been initialized yet - * @WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_NOT_FOUND: There is not an icon available for the requested URL - * @WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_UNKNOWN: There might be an icon for the requested URL, but its data is unknown at the moment - * - * Enum values used to denote the various errors related to the #WebKitFaviconDatabase. - **/ -typedef enum { - WEBKIT_FAVICON_DATABASE_ERROR_NOT_INITIALIZED, - WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_NOT_FOUND, - WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_UNKNOWN -} WebKitFaviconDatabaseError; - -WEBKIT_API GQuark -webkit_favicon_database_error_quark (void); - -WEBKIT_API GType -webkit_favicon_database_get_type (void); - -WEBKIT_API void -webkit_favicon_database_get_favicon (WebKitFaviconDatabase *database, - const gchar *page_uri, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -WEBKIT_API cairo_surface_t * -webkit_favicon_database_get_favicon_finish (WebKitFaviconDatabase *database, - GAsyncResult *result, - GError **error); -WEBKIT_API gchar * -webkit_favicon_database_get_favicon_uri (WebKitFaviconDatabase *database, - const gchar *page_uri); -WEBKIT_API void -webkit_favicon_database_clear (WebKitFaviconDatabase *database); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabasePrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabasePrivate.h deleted file mode 100644 index 0a99321a1..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabasePrivate.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitFaviconDatabasePrivate_h -#define WebKitFaviconDatabasePrivate_h - -#include "WebIconDatabase.h" -#include "WebKitFaviconDatabase.h" - -WebKitFaviconDatabase* webkitFaviconDatabaseCreate(WebKit::WebIconDatabase*); - -#endif // WebKitFaviconDatabasePrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.cpp deleted file mode 100644 index 217d06961..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.cpp +++ /dev/null @@ -1,380 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitFileChooserRequest.h" - -#include "ImmutableArray.h" -#include "WebKitFileChooserRequestPrivate.h" -#include "WebOpenPanelParameters.h" -#include "WebOpenPanelResultListenerProxy.h" -#include <WebCore/FileSystem.h> -#include <glib/gi18n-lib.h> -#include <wtf/gobject/GOwnPtr.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -using namespace WebKit; -using namespace WebCore; - -/** - * SECTION: WebKitFileChooserRequest - * @Short_description: A request to open a file chooser - * @Title: WebKitFileChooserRequest - * @See_also: #WebKitWebView - * - * Whenever the user interacts with an <input type='file' /> - * HTML element, WebKit will need to show a dialog to choose one or - * more files to be uploaded to the server along with the rest of the - * form data. For that to happen in a general way, instead of just - * opening a #GtkFileChooserDialog (which might be not desirable in - * some cases, which could prefer to use their own file chooser - * dialog), WebKit will fire the #WebKitWebView::run-file-chooser - * signal with a #WebKitFileChooserRequest object, which will allow - * the client application to specify the files to be selected, to - * inspect the details of the request (e.g. if multiple selection - * should be allowed) and to cancel the request, in case nothing was - * selected. - * - * In case the client application does not wish to handle this signal, - * WebKit will provide a default handler which will asynchronously run - * a regular #GtkFileChooserDialog for the user to interact with. - */ - -struct _WebKitFileChooserRequestPrivate { - RefPtr<WebOpenPanelParameters> parameters; - RefPtr<WebOpenPanelResultListenerProxy> listener; - GRefPtr<GtkFileFilter> filter; - GRefPtr<GPtrArray> mimeTypes; - GRefPtr<GPtrArray> selectedFiles; - bool handledRequest; -}; - -WEBKIT_DEFINE_TYPE(WebKitFileChooserRequest, webkit_file_chooser_request, G_TYPE_OBJECT) - -enum { - PROP_0, - PROP_FILTER, - PROP_MIME_TYPES, - PROP_SELECT_MULTIPLE, - PROP_SELECTED_FILES, -}; - -static void webkitFileChooserRequestDispose(GObject* object) -{ - WebKitFileChooserRequest* request = WEBKIT_FILE_CHOOSER_REQUEST(object); - - // Make sure the request is always handled before finalizing. - if (!request->priv->handledRequest) - webkit_file_chooser_request_cancel(request); - - G_OBJECT_CLASS(webkit_file_chooser_request_parent_class)->dispose(object); -} - -static void webkitFileChooserRequestGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) -{ - WebKitFileChooserRequest* request = WEBKIT_FILE_CHOOSER_REQUEST(object); - switch (propId) { - case PROP_FILTER: - g_value_set_object(value, webkit_file_chooser_request_get_mime_types_filter(request)); - break; - case PROP_MIME_TYPES: - g_value_set_boxed(value, webkit_file_chooser_request_get_mime_types(request)); - break; - case PROP_SELECT_MULTIPLE: - g_value_set_boolean(value, webkit_file_chooser_request_get_select_multiple(request)); - break; - case PROP_SELECTED_FILES: - g_value_set_boxed(value, webkit_file_chooser_request_get_selected_files(request)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - break; - } -} - -static void webkit_file_chooser_request_class_init(WebKitFileChooserRequestClass* requestClass) -{ - GObjectClass* objectClass = G_OBJECT_CLASS(requestClass); - objectClass->dispose = webkitFileChooserRequestDispose; - objectClass->get_property = webkitFileChooserRequestGetProperty; - - /** - * WebKitFileChooserRequest:filter: - * - * The filter currently associated with the request. See - * webkit_file_chooser_request_get_mime_types_filter() for more - * details. - */ - g_object_class_install_property(objectClass, - PROP_FILTER, - g_param_spec_object("filter", - _("MIME types filter"), - _("The filter currently associated with the request"), - GTK_TYPE_FILE_FILTER, - WEBKIT_PARAM_READABLE)); - /** - * WebKitFileChooserRequest:mime-types: - * - * A %NULL-terminated array of strings containing the list of MIME - * types the file chooser dialog should handle. See - * webkit_file_chooser_request_get_mime_types() for more details. - */ - g_object_class_install_property(objectClass, - PROP_MIME_TYPES, - g_param_spec_boxed("mime-types", - _("MIME types"), - _("The list of MIME types associated with the request"), - G_TYPE_STRV, - WEBKIT_PARAM_READABLE)); - /** - * WebKitFileChooserRequest:select-multiple: - * - * Whether the file chooser should allow selecting multiple - * files. See - * webkit_file_chooser_request_get_select_multiple() for - * more details. - */ - g_object_class_install_property(objectClass, - PROP_SELECT_MULTIPLE, - g_param_spec_boolean("select-multiple", - _("Select multiple files"), - _("Whether the file chooser should allow selecting multiple files"), - FALSE, - WEBKIT_PARAM_READABLE)); - /** - * WebKitFileChooserRequest:selected-files: - * - * A %NULL-terminated array of strings containing the list of - * selected files associated to the current request. See - * webkit_file_chooser_request_get_selected_files() for more details. - */ - g_object_class_install_property(objectClass, - PROP_SELECTED_FILES, - g_param_spec_boxed("selected-files", - _("Selected files"), - _("The list of selected files associated with the request"), - G_TYPE_STRV, - WEBKIT_PARAM_READABLE)); -} - -WebKitFileChooserRequest* webkitFileChooserRequestCreate(WebOpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener) -{ - WebKitFileChooserRequest* request = WEBKIT_FILE_CHOOSER_REQUEST(g_object_new(WEBKIT_TYPE_FILE_CHOOSER_REQUEST, NULL)); - request->priv->parameters = parameters; - request->priv->listener = listener; - return request; -} - -/** - * webkit_file_chooser_request_get_mime_types: - * @request: a #WebKitFileChooserRequest - * - * Get the list of MIME types the file chooser dialog should handle, - * in the format specified in RFC 2046 for "media types". Its contents - * depend on the value of the 'accept' attribute for HTML input - * elements. This function should normally be called before presenting - * the file chooser dialog to the user, to decide whether to allow the - * user to select multiple files at once or only one. - * - * Returns: (array zero-terminated=1) (transfer none): a - * %NULL-terminated array of strings if a list of accepted MIME types - * is defined or %NULL otherwise, meaning that any MIME type should be - * accepted. This array and its contents are owned by WebKitGTK+ and - * should not be modified or freed. - */ -const gchar* const* webkit_file_chooser_request_get_mime_types(WebKitFileChooserRequest* request) -{ - g_return_val_if_fail(WEBKIT_IS_FILE_CHOOSER_REQUEST(request), 0); - if (request->priv->mimeTypes) - return reinterpret_cast<gchar**>(request->priv->mimeTypes->pdata); - - RefPtr<ImmutableArray> mimeTypes = request->priv->parameters->acceptMIMETypes(); - size_t numOfMimeTypes = mimeTypes->size(); - if (!numOfMimeTypes) - return 0; - - request->priv->mimeTypes = adoptGRef(g_ptr_array_new_with_free_func(g_free)); - for (size_t i = 0; i < numOfMimeTypes; ++i) { - WebString* webMimeType = static_cast<WebString*>(mimeTypes->at(i)); - String mimeTypeString = webMimeType->string(); - if (mimeTypeString.isEmpty()) - continue; - g_ptr_array_add(request->priv->mimeTypes.get(), g_strdup(mimeTypeString.utf8().data())); - } - g_ptr_array_add(request->priv->mimeTypes.get(), 0); - - return reinterpret_cast<gchar**>(request->priv->mimeTypes->pdata); -} - -/** - * webkit_file_chooser_request_get_mime_types_filter: - * @request: a #WebKitFileChooserRequest - * - * Get the filter currently associated with the request, ready to be - * used by #GtkFileChooser. This function should normally be called - * before presenting the file chooser dialog to the user, to decide - * whether to apply a filter so the user would not be allowed to - * select files with other MIME types. - * - * See webkit_file_chooser_request_get_mime_types() if you are - * interested in getting the list of accepted MIME types. - * - * Returns: (transfer none): a #GtkFileFilter if a list of accepted - * MIME types is defined or %NULL otherwise. The returned object is - * owned by WebKitGTK+ should not be modified or freed. - */ -GtkFileFilter* webkit_file_chooser_request_get_mime_types_filter(WebKitFileChooserRequest* request) -{ - g_return_val_if_fail(WEBKIT_IS_FILE_CHOOSER_REQUEST(request), 0); - if (request->priv->filter) - return request->priv->filter.get(); - - RefPtr<ImmutableArray> mimeTypes = request->priv->parameters->acceptMIMETypes(); - size_t numOfMimeTypes = mimeTypes->size(); - if (!numOfMimeTypes) - return 0; - - // Do not use adoptGRef here, since we want to sink the floating - // reference for the new instance of GtkFileFilter, so we make - // sure we keep the ownership during the lifetime of the request. - request->priv->filter = gtk_file_filter_new(); - for (size_t i = 0; i < numOfMimeTypes; ++i) { - WebString* webMimeType = static_cast<WebString*>(mimeTypes->at(i)); - String mimeTypeString = webMimeType->string(); - if (mimeTypeString.isEmpty()) - continue; - gtk_file_filter_add_mime_type(request->priv->filter.get(), mimeTypeString.utf8().data()); - } - - return request->priv->filter.get(); -} - -/** - * webkit_file_chooser_request_get_select_multiple: - * @request: a #WebKitFileChooserRequest - * - * Determine whether the file chooser associated to this - * #WebKitFileChooserRequest should allow selecting multiple files, - * which depends on the HTML input element having a 'multiple' - * attribute defined. - * - * Returns: %TRUE if the file chooser should allow selecting multiple files or %FALSE otherwise. - */ -gboolean webkit_file_chooser_request_get_select_multiple(WebKitFileChooserRequest* request) -{ - g_return_val_if_fail(WEBKIT_IS_FILE_CHOOSER_REQUEST(request), FALSE); - return request->priv->parameters->allowMultipleFiles(); -} - -/** - * webkit_file_chooser_request_select_files: - * @request: a #WebKitFileChooserRequest - * @files: (array zero-terminated=1) (transfer none): a - * %NULL-terminated array of strings, containing paths to local files. - * - * Ask WebKit to select local files for upload and complete the - * request. - */ -void webkit_file_chooser_request_select_files(WebKitFileChooserRequest* request, const gchar* const* files) -{ - g_return_if_fail(WEBKIT_IS_FILE_CHOOSER_REQUEST(request)); - g_return_if_fail(files); - - GRefPtr<GPtrArray> selectedFiles = adoptGRef(g_ptr_array_new_with_free_func(g_free)); - Vector<RefPtr<APIObject> > choosenFiles; - for (int i = 0; files[i]; i++) { - GRefPtr<GFile> filename = adoptGRef(g_file_new_for_path(files[i])); - - // Make sure the file path is presented as an URI (escaped - // string, with the 'file://' prefix) to WebCore otherwise the - // FileChooser won't actually choose it. - GOwnPtr<char> uri(g_file_get_uri(filename.get())); - choosenFiles.append(WebURL::create(String::fromUTF8(uri.get()))); - - // Do not use the URI here because this won't reach WebCore. - g_ptr_array_add(selectedFiles.get(), g_strdup(files[i])); - } - g_ptr_array_add(selectedFiles.get(), 0); - - // Select the files in WebCore and update local private attributes. - request->priv->listener->chooseFiles(ImmutableArray::adopt(choosenFiles).get()); - request->priv->selectedFiles = selectedFiles; - request->priv->handledRequest = true; -} - -/** - * webkit_file_chooser_request_get_selected_files: - * @request: a #WebKitFileChooserRequest - * - * Get the list of selected files currently associated to the - * request. Initially, the return value of this method contains any - * files selected in previous file chooser requests for this HTML - * input element. Once webkit_file_chooser_request_select_files, the - * value will reflect whatever files are given. - * - * This function should normally be called only before presenting the - * file chooser dialog to the user, to decide whether to perform some - * extra action, like pre-selecting the files from a previous request. - * - * Returns: (array zero-terminated=1) (transfer none): a - * %NULL-terminated array of strings if there are selected files - * associated with the request or %NULL otherwise. This array and its - * contents are owned by WebKitGTK+ and should not be modified or - * freed. - */ -const gchar* const* webkit_file_chooser_request_get_selected_files(WebKitFileChooserRequest* request) -{ - g_return_val_if_fail(WEBKIT_IS_FILE_CHOOSER_REQUEST(request), 0); - if (request->priv->selectedFiles) - return reinterpret_cast<gchar**>(request->priv->selectedFiles->pdata); - - RefPtr<ImmutableArray> selectedFileNames = request->priv->parameters->selectedFileNames(); - size_t numOfFiles = selectedFileNames->size(); - if (!numOfFiles) - return 0; - - request->priv->selectedFiles = adoptGRef(g_ptr_array_new_with_free_func(g_free)); - for (size_t i = 0; i < numOfFiles; ++i) { - WebString* webFileName = static_cast<WebString*>(selectedFileNames->at(i)); - if (webFileName->isEmpty()) - continue; - CString filename = fileSystemRepresentation(webFileName->string()); - g_ptr_array_add(request->priv->selectedFiles.get(), g_strdup(filename.data())); - } - g_ptr_array_add(request->priv->selectedFiles.get(), 0); - - return reinterpret_cast<gchar**>(request->priv->selectedFiles->pdata); -} - -/** - * webkit_file_chooser_request_cancel: - * @request: a #WebKitFileChooserRequest - * - * Ask WebKit to cancel the request. It's important to do this in case - * no selection has been made in the client, otherwise the request - * won't be properly completed and the browser will keep the request - * pending forever, which might cause the browser to hang. - */ -void webkit_file_chooser_request_cancel(WebKitFileChooserRequest* request) -{ - g_return_if_fail(WEBKIT_IS_FILE_CHOOSER_REQUEST(request)); - request->priv->listener->cancel(); - request->priv->handledRequest = true; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.h b/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.h deleted file mode 100644 index 2b0069024..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitFileChooserRequest_h -#define WebKitFileChooserRequest_h - -#include <gtk/gtk.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_FILE_CHOOSER_REQUEST (webkit_file_chooser_request_get_type()) -#define WEBKIT_FILE_CHOOSER_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_FILE_CHOOSER_REQUEST, WebKitFileChooserRequest)) -#define WEBKIT_FILE_CHOOSER_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_FILE_CHOOSER_REQUEST, WebKitFileChooserRequestClass)) -#define WEBKIT_IS_FILE_CHOOSER_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_FILE_CHOOSER_REQUEST)) -#define WEBKIT_IS_FILE_CHOOSER_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_FILE_CHOOSER_REQUEST)) -#define WEBKIT_FILE_CHOOSER_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_FILE_CHOOSER_REQUEST, WebKitFileChooserRequestClass)) - -typedef struct _WebKitFileChooserRequest WebKitFileChooserRequest; -typedef struct _WebKitFileChooserRequestClass WebKitFileChooserRequestClass; -typedef struct _WebKitFileChooserRequestPrivate WebKitFileChooserRequestPrivate; - -struct _WebKitFileChooserRequest { - GObject parent; - - /*< private >*/ - WebKitFileChooserRequestPrivate *priv; -}; - -struct _WebKitFileChooserRequestClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_file_chooser_request_get_type (void); - -WEBKIT_API const gchar * const * -webkit_file_chooser_request_get_mime_types (WebKitFileChooserRequest *request); - -WEBKIT_API GtkFileFilter * -webkit_file_chooser_request_get_mime_types_filter (WebKitFileChooserRequest *request); - -WEBKIT_API gboolean -webkit_file_chooser_request_get_select_multiple (WebKitFileChooserRequest *request); - -WEBKIT_API void -webkit_file_chooser_request_select_files (WebKitFileChooserRequest *request, - const gchar * const *files); - -WEBKIT_API const gchar * const * -webkit_file_chooser_request_get_selected_files (WebKitFileChooserRequest *request); - -WEBKIT_API void -webkit_file_chooser_request_cancel (WebKitFileChooserRequest *request); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequestPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequestPrivate.h deleted file mode 100644 index 45d133e5b..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequestPrivate.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitFileChooserRequestPrivate_h -#define WebKitFileChooserRequestPrivate_h - -#include "WebKitFileChooserRequest.h" -#include "WebKitPrivate.h" - -WebKitFileChooserRequest* webkitFileChooserRequestCreate(WebKit::WebOpenPanelParameters*, WebKit::WebOpenPanelResultListenerProxy*); - -#endif // WebKitFileChooserRequestPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFindController.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitFindController.cpp deleted file mode 100644 index 516c58237..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitFindController.cpp +++ /dev/null @@ -1,485 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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 "WebKitFindController.h" - -#include "WebKitEnumTypes.h" -#include "WebKitPrivate.h" -#include "WebKitWebView.h" -#include "WebKitWebViewBasePrivate.h" -#include <glib/gi18n-lib.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -using namespace WebKit; -using namespace WebCore; - -/** - * SECTION: WebKitFindController - * @Short_description: Controls text search in a #WebKitWebView - * @Title: WebKitFindController - * - * A #WebKitFindController is used to search text in a #WebKitWebView. You - * can get a #WebKitWebView<!-- -->'s #WebKitFindController with - * webkit_web_view_get_find_controller(), and later use it to search - * for text using webkit_find_controller_search(), or get the - * number of matches using webkit_find_controller_count_matches(). The - * operations are asynchronous and trigger signals when ready, such as - * #WebKitFindController::found-text, - * #WebKitFindController::failed-to-find-text or - * #WebKitFindController::counted-matches<!-- -->. - * - */ - -enum { - FOUND_TEXT, - FAILED_TO_FIND_TEXT, - COUNTED_MATCHES, - - LAST_SIGNAL -}; - -enum { - PROP_0, - - PROP_TEXT, - PROP_OPTIONS, - PROP_MAX_MATCH_COUNT, - PROP_WEB_VIEW -}; - -typedef enum { - FindOperation, - FindNextPrevOperation, - CountOperation -} WebKitFindControllerOperation; - -struct _WebKitFindControllerPrivate { - CString searchText; - uint32_t findOptions; - unsigned maxMatchCount; - WebKitWebView* webView; -}; - -static guint signals[LAST_SIGNAL] = { 0, }; - -WEBKIT_DEFINE_TYPE(WebKitFindController, webkit_find_controller, G_TYPE_OBJECT) - -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE, FindOptionsCaseInsensitive); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_FIND_OPTIONS_AT_WORD_STARTS, FindOptionsAtWordStarts); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START, FindOptionsTreatMedialCapitalAsWordStart); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_FIND_OPTIONS_BACKWARDS, FindOptionsBackwards); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_FIND_OPTIONS_WRAP_AROUND, FindOptionsWrapAround); - -static void didFindString(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo) -{ - g_signal_emit(WEBKIT_FIND_CONTROLLER(clientInfo), signals[FOUND_TEXT], 0, matchCount); -} - -static void didFailToFindString(WKPageRef page, WKStringRef string, const void* clientInfo) -{ - g_signal_emit(WEBKIT_FIND_CONTROLLER(clientInfo), signals[FAILED_TO_FIND_TEXT], 0); -} - -static void didCountStringMatches(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo) -{ - g_signal_emit(WEBKIT_FIND_CONTROLLER(clientInfo), signals[COUNTED_MATCHES], 0, matchCount); -} - -static inline WebPageProxy* getPage(WebKitFindController* findController) -{ - return webkitWebViewBaseGetPage(reinterpret_cast<WebKitWebViewBase*>(findController->priv->webView)); -} - -static void webkitFindControllerConstructed(GObject* object) -{ - WebKitFindController* findController = WEBKIT_FIND_CONTROLLER(object); - WKPageFindClient wkFindClient = { - kWKPageFindClientCurrentVersion, - findController, // clientInfo - didFindString, - didFailToFindString, - didCountStringMatches - }; - - WKPageSetPageFindClient(toAPI(getPage(findController)), &wkFindClient); -} - -static void webkitFindControllerGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) -{ - WebKitFindController* findController = WEBKIT_FIND_CONTROLLER(object); - - switch (propId) { - case PROP_TEXT: - g_value_set_string(value, webkit_find_controller_get_search_text(findController)); - break; - case PROP_OPTIONS: - g_value_set_uint(value, webkit_find_controller_get_options(findController)); - break; - case PROP_MAX_MATCH_COUNT: - g_value_set_uint(value, webkit_find_controller_get_max_match_count(findController)); - break; - case PROP_WEB_VIEW: - g_value_set_object(value, webkit_find_controller_get_web_view(findController)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static void webkitFindControllerSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec) -{ - WebKitFindController* findController = WEBKIT_FIND_CONTROLLER(object); - - switch (propId) { - case PROP_WEB_VIEW: - findController->priv->webView = WEBKIT_WEB_VIEW(g_value_get_object(value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static void webkit_find_controller_class_init(WebKitFindControllerClass* findClass) -{ - GObjectClass* gObjectClass = G_OBJECT_CLASS(findClass); - gObjectClass->constructed = webkitFindControllerConstructed; - gObjectClass->get_property = webkitFindControllerGetProperty; - gObjectClass->set_property = webkitFindControllerSetProperty; - - /** - * WebKitFindController:text: - * - * The current search text for this #WebKitFindController. - */ - g_object_class_install_property(gObjectClass, - PROP_TEXT, - g_param_spec_string("text", - _("Search text"), - _("Text to search for in the view"), - 0, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitFindController:options: - * - * The options to be used in the search operation. - */ - g_object_class_install_property(gObjectClass, - PROP_OPTIONS, - g_param_spec_flags("options", - _("Search Options"), - _("Search options to be used in the search operation"), - WEBKIT_TYPE_FIND_OPTIONS, - WEBKIT_FIND_OPTIONS_NONE, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitFindController:max-match-count: - * - * The maximum number of matches to report for a given search. - */ - g_object_class_install_property(gObjectClass, - PROP_MAX_MATCH_COUNT, - g_param_spec_uint("max-match-count", - _("Maximum matches count"), - _("The maximum number of matches in a given text to report"), - 0, G_MAXUINT, 0, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitFindController:web-view: - * - * The #WebKitWebView this controller is associated to. - */ - g_object_class_install_property(gObjectClass, - PROP_WEB_VIEW, - g_param_spec_object("web-view", - _("WebView"), - _("The WebView associated with this find controller"), - WEBKIT_TYPE_WEB_VIEW, - static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY))); - - /** - * WebKitFindController::found-text: - * @find_controller: the #WebKitFindController - * @match_count: the number of matches found of the search text - * - * This signal is emitted when a given text is found in the web - * page text. It will be issued if the text is found - * asynchronously after a call to webkit_find_controller_search(), - * webkit_find_controller_search_next() or - * webkit_find_controller_search_previous(). - */ - signals[FOUND_TEXT] = - g_signal_new("found-text", - G_TYPE_FROM_CLASS(gObjectClass), - G_SIGNAL_RUN_LAST, - 0, 0, 0, - g_cclosure_marshal_VOID__UINT, - G_TYPE_NONE, 1, G_TYPE_UINT); - - /** - * WebKitFindController::failed-to-find-text: - * @find_controller: the #WebKitFindController - * - * This signal is emitted when a search operation does not find - * any result for the given text. It will be issued if the text - * is not found asynchronously after a call to - * webkit_find_controller_search(), webkit_find_controller_search_next() - * or webkit_find_controller_search_previous(). - */ - signals[FAILED_TO_FIND_TEXT] = - g_signal_new("failed-to-find-text", - G_TYPE_FROM_CLASS(gObjectClass), - G_SIGNAL_RUN_LAST, - 0, 0, 0, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /** - * WebKitFindController::counted-matches: - * @find_controller: the #WebKitFindController - * @match_count: the number of matches of the search text - * - * This signal is emitted when the #WebKitFindController has - * counted the number of matches for a given text after a call - * to webkit_find_controller_count_matches(). - */ - signals[COUNTED_MATCHES] = - g_signal_new("counted-matches", - G_TYPE_FROM_CLASS(gObjectClass), - G_SIGNAL_RUN_LAST, - 0, 0, 0, - g_cclosure_marshal_VOID__UINT, - G_TYPE_NONE, 1, G_TYPE_UINT); -} - -/** - * webkit_find_controller_get_search_text: - * @find_controller: the #WebKitFindController - * - * Gets the text that @find_controller is currently searching - * for. This text is passed to either - * webkit_find_controller_search() or - * webkit_find_controller_count_matches(). - * - * Returns: the text to look for in the #WebKitWebView. - */ -const char* webkit_find_controller_get_search_text(WebKitFindController* findController) -{ - g_return_val_if_fail(WEBKIT_IS_FIND_CONTROLLER(findController), 0); - - return findController->priv->searchText.data(); -} - -/** - * webkit_find_controller_get_options: - * @find_controller: the #WebKitFindController - * - * Gets a bitmask containing the #WebKitFindOptions associated with - * the current search. - * - * Returns: a bitmask containing the #WebKitFindOptions associated - * with the current search. - */ -guint32 webkit_find_controller_get_options(WebKitFindController* findController) -{ - g_return_val_if_fail(WEBKIT_IS_FIND_CONTROLLER(findController), WEBKIT_FIND_OPTIONS_NONE); - - return findController->priv->findOptions; -} - -/** - * webkit_find_controller_get_max_match_count: - * @find_controller: the #WebKitFindController - * - * Gets the maximum number of matches to report during a text - * lookup. This number is passed as the last argument of - * webkit_find_controller_search() or - * webkit_find_controller_count_matches(). - * - * Returns: the maximum number of matches to report. - */ -guint webkit_find_controller_get_max_match_count(WebKitFindController* findController) -{ - g_return_val_if_fail(WEBKIT_IS_FIND_CONTROLLER(findController), 0); - - return findController->priv->maxMatchCount; -} - -/** - * webkit_find_controller_get_web_view: - * @find_controller: the #WebKitFindController - * - * Gets the #WebKitWebView this find controller is associated to. Do - * not unref the returned instance as it belongs to the - * #WebKitFindController. - * - * Returns: (transfer none): the #WebKitWebView. - */ -WebKitWebView* webkit_find_controller_get_web_view(WebKitFindController* findController) -{ - g_return_val_if_fail(WEBKIT_IS_FIND_CONTROLLER(findController), 0); - - return findController->priv->webView; -} - -static void webKitFindControllerPerform(WebKitFindController* findController, WebKitFindControllerOperation operation) -{ - WebKitFindControllerPrivate* priv = findController->priv; - if (operation == CountOperation) { - getPage(findController)->countStringMatches(String::fromUTF8(priv->searchText.data()), - static_cast<WebKit::FindOptions>(priv->findOptions), priv->maxMatchCount); - return; - } - - uint32_t findOptions = priv->findOptions; - if (operation == FindOperation) - // Unconditionally highlight text matches when the search - // starts. WK1 API was forcing clients to enable/disable - // highlighting. Since most of them (all?) where using that - // feature we decided to simplify the WK2 API and - // unconditionally show highlights. Both search_next() and - // search_prev() should not enable highlighting to avoid an - // extra unmarkAllTextMatches() + markAllTextMatches() - findOptions |= FindOptionsShowHighlight; - - getPage(findController)->findString(String::fromUTF8(priv->searchText.data()), static_cast<WebKit::FindOptions>(findOptions), - priv->maxMatchCount); -} - -static inline void webKitFindControllerSetSearchData(WebKitFindController* findController, const gchar* searchText, guint32 findOptions, guint maxMatchCount) -{ - findController->priv->searchText = searchText; - findController->priv->findOptions = findOptions; - findController->priv->maxMatchCount = maxMatchCount; -} - -/** - * webkit_find_controller_search: - * @find_controller: the #WebKitFindController - * @search_text: the text to look for - * @find_options: a bitmask with the #WebKitFindOptions used in the search - * @max_match_count: the maximum number of matches allowed in the search - * - * Looks for @search_text in the #WebKitWebView associated with - * @find_controller since the beginning of the document highlighting - * up to @max_match_count matches. The outcome of the search will be - * asynchronously provided by the #WebKitFindController::found-text - * and #WebKitFindController::failed-to-find-text signals. - * - * To look for the next or previous occurrences of the same text - * with the same find options use webkit_find_controller_search_next() - * and/or webkit_find_controller_search_previous(). The - * #WebKitFindController will use the same text and options for the - * following searches unless they are modified by another call to this - * method. - * - * Note that if the number of matches is higher than @max_match_count - * then #WebKitFindController::found-text will report %G_MAXUINT matches - * instead of the actual number. - * - * Callers should call webkit_find_controller_search_finish() to - * finish the current search operation. - */ -void webkit_find_controller_search(WebKitFindController* findController, const gchar* searchText, guint findOptions, guint maxMatchCount) -{ - g_return_if_fail(WEBKIT_IS_FIND_CONTROLLER(findController)); - g_return_if_fail(searchText); - - webKitFindControllerSetSearchData(findController, searchText, findOptions, maxMatchCount); - webKitFindControllerPerform(findController, FindOperation); -} - -/** - * webkit_find_controller_search_next: - * @find_controller: the #WebKitFindController - * - * Looks for the next occurrence of the search text. - * - * Calling this method before webkit_find_controller_search() or - * webkit_find_controller_count_matches() is a programming error. - */ -void webkit_find_controller_search_next(WebKitFindController* findController) -{ - g_return_if_fail(WEBKIT_IS_FIND_CONTROLLER(findController)); - - findController->priv->findOptions &= ~WEBKIT_FIND_OPTIONS_BACKWARDS; - findController->priv->findOptions &= ~FindOptionsShowHighlight; - webKitFindControllerPerform(findController, FindNextPrevOperation); -} - -/** - * webkit_find_controller_search_previous: - * @find_controller: the #WebKitFindController - * - * Looks for the previous occurrence of the search text. - * - * Calling this method before webkit_find_controller_search() or - * webkit_find_controller_count_matches() is a programming error. - */ -void webkit_find_controller_search_previous(WebKitFindController* findController) -{ - g_return_if_fail(WEBKIT_IS_FIND_CONTROLLER(findController)); - - findController->priv->findOptions |= WEBKIT_FIND_OPTIONS_BACKWARDS; - findController->priv->findOptions &= ~FindOptionsShowHighlight; - webKitFindControllerPerform(findController, FindNextPrevOperation); -} - -/** - * webkit_find_controller_count_matches: - * @find_controller: the #WebKitFindController - * @search_text: the text to look for - * @find_options: a bitmask with the #WebKitFindOptions used in the search - * @max_match_count: the maximum number of matches allowed in the search - * - * Counts the number of matches for @search_text found in the - * #WebKitWebView with the provided @find_options. The number of - * matches will be provided by the - * #WebKitFindController::counted-matches signal. - */ -void webkit_find_controller_count_matches(WebKitFindController* findController, const gchar* searchText, guint32 findOptions, guint maxMatchCount) -{ - g_return_if_fail(WEBKIT_IS_FIND_CONTROLLER(findController)); - g_return_if_fail(searchText); - - webKitFindControllerSetSearchData(findController, searchText, findOptions, maxMatchCount); - webKitFindControllerPerform(findController, CountOperation); -} - -/** - * webkit_find_controller_search_finish: - * @find_controller: a #WebKitFindController - * - * Finishes a find operation started by - * webkit_find_controller_search(). It will basically unhighlight - * every text match found. - * - * This method will be typically called when the search UI is - * closed/hidden by the client application. - */ -void webkit_find_controller_search_finish(WebKitFindController* findController) -{ - g_return_if_fail(WEBKIT_IS_FIND_CONTROLLER(findController)); - - getPage(findController)->hideFindUI(); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFindController.h b/Source/WebKit2/UIProcess/API/gtk/WebKitFindController.h deleted file mode 100644 index 7bad1d051..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitFindController.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitFindController_h -#define WebKitFindController_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> -#include <webkit2/WebKitForwardDeclarations.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_FIND_CONTROLLER (webkit_find_controller_get_type()) -#define WEBKIT_FIND_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_FIND_CONTROLLER, WebKitFindController)) -#define WEBKIT_FIND_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_FIND_CONTROLLER, WebKitFindControllerClass)) -#define WEBKIT_IS_FIND_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_FIND_CONTROLLER)) -#define WEBKIT_IS_FIND_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_FIND_CONTROLLER)) -#define WEBKIT_FIND_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_FIND_CONTROLLER, WebKitFindControllerClass)) - -typedef struct _WebKitFindControllerPrivate WebKitFindControllerPrivate; -typedef struct _WebKitFindControllerClass WebKitFindControllerClass; - -/** - * WebKitFindOptions: - * @WEBKIT_FIND_OPTIONS_NONE: no search flags, this means a case - * sensitive, no wrap, forward only search. - * @WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE: case insensitive search. - * @WEBKIT_FIND_OPTIONS_AT_WORD_STARTS: search text only at the - * begining of the words. - * @WEBKIT_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START: treat - * capital letters in the middle of words as word start. - * @WEBKIT_FIND_OPTIONS_BACKWARDS: search backwards. - * @WEBKIT_FIND_OPTIONS_WRAP_AROUND: if not present search will stop - * at the end of the document. - * - * Enum values used to specify search options. - */ -typedef enum { - WEBKIT_FIND_OPTIONS_NONE, - - WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE = 1 << 0, - WEBKIT_FIND_OPTIONS_AT_WORD_STARTS = 1 << 1, - WEBKIT_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START = 1 << 2, - WEBKIT_FIND_OPTIONS_BACKWARDS = 1 << 3, - WEBKIT_FIND_OPTIONS_WRAP_AROUND = 1 << 4, -} WebKitFindOptions; - -struct _WebKitFindController { - GObject parent; - - /*< private >*/ - WebKitFindControllerPrivate *priv; -}; - -struct _WebKitFindControllerClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_find_controller_get_type (void); - -WEBKIT_API void -webkit_find_controller_search (WebKitFindController *find_controller, - const gchar *search_text, - guint32 find_options, - guint max_match_count); - -WEBKIT_API void -webkit_find_controller_search_finish (WebKitFindController *find_controller); - -WEBKIT_API void -webkit_find_controller_search_next (WebKitFindController *find_controller); - -WEBKIT_API void -webkit_find_controller_search_previous (WebKitFindController *find_controller); - -WEBKIT_API void -webkit_find_controller_count_matches (WebKitFindController *find_controller, - const gchar *search_text, - guint32 find_options, - guint max_match_count); - -WEBKIT_API const gchar * -webkit_find_controller_get_search_text (WebKitFindController *find_controller); - -WEBKIT_API guint32 -webkit_find_controller_get_options (WebKitFindController *find_controller); - -WEBKIT_API guint -webkit_find_controller_get_max_match_count (WebKitFindController *find_controller); - -WEBKIT_API WebKitWebView * -webkit_find_controller_get_web_view (WebKitFindController *find_controller); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.cpp deleted file mode 100644 index 75978cf13..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitFormClient.h" - -#include "WebKitFormSubmissionRequestPrivate.h" -#include "WebKitPrivate.h" -#include "WebKitWebViewBasePrivate.h" -#include "WebKitWebViewPrivate.h" -#include <wtf/gobject/GRefPtr.h> - -using namespace WebKit; - -static void willSubmitForm(WKPageRef page, WKFrameRef frame, WKFrameRef sourceFrame, WKDictionaryRef values, WKTypeRef userData, WKFormSubmissionListenerRef listener, const void* clientInfo) -{ - GRefPtr<WebKitFormSubmissionRequest> request = adoptGRef(webkitFormSubmissionRequestCreate(toImpl(values), toImpl(listener))); - webkitWebViewSubmitFormRequest(WEBKIT_WEB_VIEW(clientInfo), request.get()); -} - -void attachFormClientToView(WebKitWebView* webView) -{ - WKPageFormClient wkFormClient = { - kWKPageFormClientCurrentVersion, - webView, // clientInfo - willSubmitForm - }; - WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))); - WKPageSetPageFormClient(wkPage, &wkFormClient); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.h b/Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.h deleted file mode 100644 index a37022731..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitFormClient_h -#define WebKitFormClient_h - -#include "WebKitWebView.h" - -void attachFormClientToView(WebKitWebView*); - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.cpp deleted file mode 100644 index 92ee4586c..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitFormSubmissionRequest.h" - -#include "ImmutableDictionary.h" -#include "WebFormSubmissionListenerProxy.h" -#include "WebKitFormSubmissionRequestPrivate.h" -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -using namespace WebKit; - -/** - * SECTION: WebKitFormSubmissionRequest - * @Short_description: Represents a form submission request - * @Title: WebKitFormSubmissionRequest - * - * When a form is about to be submitted in a #WebKitWebView, the - * #WebKitWebView::submit-form signal is emitted. Its request argument - * contains information about the text fields of the form, that are - * typically used to store login information, returned in a - * #GHashTable by the webkit_form_submission_request_get_text_fields() - * method, and you can finally submit the form with - * webkit_form_submission_request_submit(). - * - */ - -struct _WebKitFormSubmissionRequestPrivate { - RefPtr<ImmutableDictionary> webValues; - RefPtr<WebFormSubmissionListenerProxy> listener; - GRefPtr<GHashTable> values; - bool handledRequest; -}; - -WEBKIT_DEFINE_TYPE(WebKitFormSubmissionRequest, webkit_form_submission_request, G_TYPE_OBJECT) - -static void webkitFormSubmissionRequestDispose(GObject* object) -{ - WebKitFormSubmissionRequest* request = WEBKIT_FORM_SUBMISSION_REQUEST(object); - - // Make sure the request is always handled before finalizing. - if (!request->priv->handledRequest) - webkit_form_submission_request_submit(request); - - G_OBJECT_CLASS(webkit_form_submission_request_parent_class)->dispose(object); -} - -static void webkit_form_submission_request_class_init(WebKitFormSubmissionRequestClass* requestClass) -{ - GObjectClass* objectClass = G_OBJECT_CLASS(requestClass); - objectClass->dispose = webkitFormSubmissionRequestDispose; -} - -WebKitFormSubmissionRequest* webkitFormSubmissionRequestCreate(ImmutableDictionary* values, WebFormSubmissionListenerProxy* listener) -{ - WebKitFormSubmissionRequest* request = WEBKIT_FORM_SUBMISSION_REQUEST(g_object_new(WEBKIT_TYPE_FORM_SUBMISSION_REQUEST, NULL)); - request->priv->webValues = values; - request->priv->listener = listener; - return request; -} - -/** - * webkit_form_submission_request_get_text_fields: - * @request: a #WebKitFormSubmissionRequest - * - * Get a #GHashTable with the values of the text fields contained in the form - * associated to @request. - * - * Returns: (transfer none): a #GHashTable with the form text fields, or %NULL if the - * form doesn't contain text fields. - */ -GHashTable* webkit_form_submission_request_get_text_fields(WebKitFormSubmissionRequest* request) -{ - g_return_val_if_fail(WEBKIT_IS_FORM_SUBMISSION_REQUEST(request), 0); - - if (request->priv->values) - return request->priv->values.get(); - - if (!request->priv->webValues->size()) - return 0; - - request->priv->values = adoptGRef(g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free)); - - const ImmutableDictionary::MapType& map = request->priv->webValues->map(); - ImmutableDictionary::MapType::const_iterator end = map.end(); - for (ImmutableDictionary::MapType::const_iterator it = map.begin(); it != end; ++it) { - WebString* value = static_cast<WebString*>(it->value.get()); - g_hash_table_insert(request->priv->values.get(), g_strdup(it->key.utf8().data()), g_strdup(value->string().utf8().data())); - } - - request->priv->webValues = 0; - - return request->priv->values.get(); -} - -/** - * webkit_form_submission_request_submit: - * @request: a #WebKitFormSubmissionRequest - * - * Continue the form submission. - */ -void webkit_form_submission_request_submit(WebKitFormSubmissionRequest* request) -{ - g_return_if_fail(WEBKIT_IS_FORM_SUBMISSION_REQUEST(request)); - - request->priv->listener->continueSubmission(); - request->priv->handledRequest = true; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.h b/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.h deleted file mode 100644 index e27779b34..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitFormSubmissionRequest_h -#define WebKitFormSubmissionRequest_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_FORM_SUBMISSION_REQUEST (webkit_form_submission_request_get_type()) -#define WEBKIT_FORM_SUBMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_FORM_SUBMISSION_REQUEST, WebKitFormSubmissionRequest)) -#define WEBKIT_IS_FORM_SUBMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_FORM_SUBMISSION_REQUEST)) -#define WEBKIT_FORM_SUBMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_FORM_SUBMISSION_REQUEST, WebKitFormSubmissionRequestClass)) -#define WEBKIT_IS_FORM_SUBMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_FORM_SUBMISSION_REQUEST)) -#define WEBKIT_FORM_SUBMISSION_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_FORM_SUBMISSION_REQUEST, WebKitFormSubmissionRequestClass)) - -typedef struct _WebKitFormSubmissionRequest WebKitFormSubmissionRequest; -typedef struct _WebKitFormSubmissionRequestClass WebKitFormSubmissionRequestClass; -typedef struct _WebKitFormSubmissionRequestPrivate WebKitFormSubmissionRequestPrivate; - -struct _WebKitFormSubmissionRequest { - GObject parent; - - /*< private >*/ - WebKitFormSubmissionRequestPrivate *priv; -}; - -struct _WebKitFormSubmissionRequestClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_form_submission_request_get_type (void); - -WEBKIT_API GHashTable * -webkit_form_submission_request_get_text_fields (WebKitFormSubmissionRequest *request); - -WEBKIT_API void -webkit_form_submission_request_submit (WebKitFormSubmissionRequest *request); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequestPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequestPrivate.h deleted file mode 100644 index 9fe4751d2..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequestPrivate.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitFormSubmissionRequestPrivate_h -#define WebKitFormSubmissionRequestPrivate_h - -#include "WebKitFormSubmissionRequest.h" -#include "WebKitPrivate.h" - -WebKitFormSubmissionRequest* webkitFormSubmissionRequestCreate(WebKit::ImmutableDictionary* values, WebKit::WebFormSubmissionListenerProxy*); - -#endif // WebKitFormSubmissionRequestPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitForwardDeclarations.h b/Source/WebKit2/UIProcess/API/gtk/WebKitForwardDeclarations.h deleted file mode 100644 index a9898de48..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitForwardDeclarations.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2013 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitForward_h -#define WebKitForward_h - -typedef struct _WebKitPrintOperation WebKitPrintOperation; -typedef struct _WebKitFindController WebKitFindController; -typedef struct _WebKitWebView WebKitWebView; -typedef struct _WebKitContextMenu WebKitContextMenu; -typedef struct _WebKitContextMenuItem WebKitContextMenuItem; - -#endif // WebKitForward_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFullscreenClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitFullscreenClient.cpp deleted file mode 100644 index 75b51e25d..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitFullscreenClient.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitFullscreenClient.h" - -#include "WebKitPrivate.h" -#include "WebKitWebViewPrivate.h" - -using namespace WebKit; - -static bool willEnterFullScreen(const void* clientInfo) -{ - return webkitWebViewEnterFullScreen(WEBKIT_WEB_VIEW(clientInfo)); -} - -static bool willExitFullScreen(const void* clientInfo) -{ - return webkitWebViewLeaveFullScreen(WEBKIT_WEB_VIEW(clientInfo)); -} - -void attachFullScreenClientToView(WebKitWebView* webView) -{ - WKFullScreenClientGtk wkFullScreenClient = { - kWKFullScreenClientGtkCurrentVersion, - webView, // clientInfo - willEnterFullScreen, - willExitFullScreen - }; - WKViewSetFullScreenClientGtk(toAPI(WEBKIT_WEB_VIEW_BASE(webView)), &wkFullScreenClient); -} - diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFullscreenClient.h b/Source/WebKit2/UIProcess/API/gtk/WebKitFullscreenClient.h deleted file mode 100644 index 187c067af..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitFullscreenClient.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitFullscreenClient_h -#define WebKitFullscreenClient_h - -#include "WebKitWebView.h" - -void attachFullScreenClientToView(WebKitWebView*); - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.cpp deleted file mode 100644 index f780dafb2..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitGeolocationPermissionRequest.h" - -#include "GeolocationPermissionRequestProxy.h" -#include "WebKitGeolocationPermissionRequestPrivate.h" -#include "WebKitPermissionRequest.h" - -using namespace WebKit; - -/** - * SECTION: WebKitGeolocationPermissionRequest - * @Short_description: A permission request for sharing user's location - * @Title: WebKitGeolocationPermissionRequest - * @See_also: #WebKitPermissionRequest, #WebKitWebView - * - * WebKitGeolocationPermissionRequest represents a request for - * permission to decide whether WebKit should provide the user's - * location to a website when requested throught the Geolocation API. - */ - -static void webkit_permission_request_interface_init(WebKitPermissionRequestIface*); - -struct _WebKitGeolocationPermissionRequestPrivate { - RefPtr<GeolocationPermissionRequestProxy> request; - bool madeDecision; -}; - -WEBKIT_DEFINE_TYPE_WITH_CODE( - WebKitGeolocationPermissionRequest, webkit_geolocation_permission_request, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(WEBKIT_TYPE_PERMISSION_REQUEST, webkit_permission_request_interface_init)) - -static void webkitGeolocationPermissionRequestAllow(WebKitPermissionRequest* request) -{ - ASSERT(WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST(request)); - - WebKitGeolocationPermissionRequestPrivate* priv = WEBKIT_GEOLOCATION_PERMISSION_REQUEST(request)->priv; - - // Only one decision at a time. - if (priv->madeDecision) - return; - - priv->request->allow(); - priv->madeDecision = true; -} - -static void webkitGeolocationPermissionRequestDeny(WebKitPermissionRequest* request) -{ - ASSERT(WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST(request)); - - WebKitGeolocationPermissionRequestPrivate* priv = WEBKIT_GEOLOCATION_PERMISSION_REQUEST(request)->priv; - - // Only one decision at a time. - if (priv->madeDecision) - return; - - priv->request->deny(); - priv->madeDecision = true; -} - -static void webkit_permission_request_interface_init(WebKitPermissionRequestIface* iface) -{ - iface->allow = webkitGeolocationPermissionRequestAllow; - iface->deny = webkitGeolocationPermissionRequestDeny; -} - -static void webkitGeolocationPermissionRequestDispose(GObject* object) -{ - // Default behaviour when no decision has been made is denying the request. - webkitGeolocationPermissionRequestDeny(WEBKIT_PERMISSION_REQUEST(object)); - G_OBJECT_CLASS(webkit_geolocation_permission_request_parent_class)->dispose(object); -} - -static void webkit_geolocation_permission_request_class_init(WebKitGeolocationPermissionRequestClass* klass) -{ - GObjectClass* objectClass = G_OBJECT_CLASS(klass); - objectClass->dispose = webkitGeolocationPermissionRequestDispose; -} - -WebKitGeolocationPermissionRequest* webkitGeolocationPermissionRequestCreate(GeolocationPermissionRequestProxy* request) -{ - WebKitGeolocationPermissionRequest* geolocationPermissionRequest = WEBKIT_GEOLOCATION_PERMISSION_REQUEST(g_object_new(WEBKIT_TYPE_GEOLOCATION_PERMISSION_REQUEST, NULL)); - geolocationPermissionRequest->priv->request = request; - return geolocationPermissionRequest; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.h b/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.h deleted file mode 100644 index 4b44af09f..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitGeolocationPermissionRequest_h -#define WebKitGeolocationPermissionRequest_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_GEOLOCATION_PERMISSION_REQUEST (webkit_geolocation_permission_request_get_type()) -#define WEBKIT_GEOLOCATION_PERMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_GEOLOCATION_PERMISSION_REQUEST, WebKitGeolocationPermissionRequest)) -#define WEBKIT_GEOLOCATION_PERMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_GEOLOCATION_PERMISSION_REQUEST, WebKitGeolocationPermissionRequestClass)) -#define WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_GEOLOCATION_PERMISSION_REQUEST)) -#define WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_GEOLOCATION_PERMISSION_REQUEST)) -#define WEBKIT_GEOLOCATION_PERMISSION_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_GEOLOCATION_PERMISSION_REQUEST, WebKitGeolocationPermissionRequestClass)) - -typedef struct _WebKitGeolocationPermissionRequest WebKitGeolocationPermissionRequest; -typedef struct _WebKitGeolocationPermissionRequestClass WebKitGeolocationPermissionRequestClass; -typedef struct _WebKitGeolocationPermissionRequestPrivate WebKitGeolocationPermissionRequestPrivate; - -struct _WebKitGeolocationPermissionRequest { - GObject parent; - - /*< private >*/ - WebKitGeolocationPermissionRequestPrivate *priv; -}; - -struct _WebKitGeolocationPermissionRequestClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_geolocation_permission_request_get_type (void); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequestPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequestPrivate.h deleted file mode 100644 index dd0e95821..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequestPrivate.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitGeolocationPermissionRequestPrivate_h -#define WebKitGeolocationPermissionRequestPrivate_h - -#include "WebKitGeolocationPermissionRequest.h" -#include "WebKitPrivate.h" - -WebKitGeolocationPermissionRequest* webkitGeolocationPermissionRequestCreate(WebKit::GeolocationPermissionRequestProxy*); - -#endif // WebKitGeolocationPermissionRequestPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationProvider.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationProvider.cpp deleted file mode 100644 index cdeac917d..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationProvider.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "config.h" -#include "WebKitGeolocationProvider.h" - -#include "WebGeolocationManagerProxy.h" -#include "WebGeolocationPosition.h" - -using namespace WebKit; - -#if ENABLE(GEOLOCATION) - -static inline WebKitGeolocationProvider* toGeolocationProvider(const void* clientInfo) -{ - return static_cast<WebKitGeolocationProvider*>(const_cast<void*>(clientInfo)); -} - -static void startUpdatingCallback(WKGeolocationManagerRef geolocationManager, const void* clientInfo) -{ - toGeolocationProvider(clientInfo)->startUpdating(); -} - -static void stopUpdatingCallback(WKGeolocationManagerRef geolocationManager, const void* clientInfo) -{ - toGeolocationProvider(clientInfo)->stopUpdating(); -} - -WebKitGeolocationProvider::~WebKitGeolocationProvider() -{ - m_provider.stopUpdating(); -} - -PassRefPtr<WebKitGeolocationProvider> WebKitGeolocationProvider::create(WebGeolocationManagerProxy* geolocationManager) -{ - return adoptRef(new WebKitGeolocationProvider(geolocationManager)); -} - -WebKitGeolocationProvider::WebKitGeolocationProvider(WebGeolocationManagerProxy* geolocationManager) - : m_geolocationManager(geolocationManager) - , m_provider(this) -{ - ASSERT(geolocationManager); - - WKGeolocationProvider wkGeolocationProvider = { - kWKGeolocationProviderCurrentVersion, - this, // clientInfo - startUpdatingCallback, - stopUpdatingCallback - }; - WKGeolocationManagerSetProvider(toAPI(geolocationManager), &wkGeolocationProvider); -} - -void WebKitGeolocationProvider::startUpdating() -{ - m_provider.startUpdating(); -} - -void WebKitGeolocationProvider::stopUpdating() -{ - m_provider.stopUpdating(); -} - -void WebKitGeolocationProvider::notifyPositionChanged(int timestamp, double latitude, double longitude, double altitude, double accuracy, double altitudeAccuracy) -{ - RefPtr<WebGeolocationPosition> position = WebGeolocationPosition::create(timestamp, latitude, longitude, accuracy, true, altitude, true, altitudeAccuracy, false, 0, false, 0); - m_geolocationManager->providerDidChangePosition(position.get()); -} - -void WebKitGeolocationProvider::notifyErrorOccurred(const char* message) -{ - m_geolocationManager->providerDidFailToDeterminePosition(); -} - -#endif // ENABLE(GEOLOCATION) diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationProvider.h b/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationProvider.h deleted file mode 100644 index e6be3eac2..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationProvider.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitGeolocationProvider_h -#define WebKitGeolocationProvider_h - -#if ENABLE(GEOLOCATION) - -#include "WebKitPrivate.h" -#include <WebCore/GeolocationProviderGeoclue.h> -#include <WebCore/GeolocationProviderGeoclueClient.h> -#include <wtf/PassRefPtr.h> -#include <wtf/RefCounted.h> - -namespace WebKit { - -class WebKitGeolocationProvider : public RefCounted<WebKitGeolocationProvider>, public WebCore::GeolocationProviderGeoclueClient { -public: - virtual ~WebKitGeolocationProvider(); - static PassRefPtr<WebKitGeolocationProvider> create(WebGeolocationManagerProxy*); - - void startUpdating(); - void stopUpdating(); - -private: - WebKitGeolocationProvider(WebGeolocationManagerProxy*); - - // GeolocationProviderGeoclueClient interface. - virtual void notifyPositionChanged(int, double, double, double, double, double); - virtual void notifyErrorOccurred(const char*); - - RefPtr<WebGeolocationManagerProxy> m_geolocationManager; - WebCore::GeolocationProviderGeoclue m_provider; -}; - -} // namespace WebKit - -#endif // ENABLE(GEOLOCATION) - -#endif // WebKitGeolocationProvider_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp deleted file mode 100644 index 918d316c0..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp +++ /dev/null @@ -1,456 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitHitTestResult.h" - -#include "WebHitTestResult.h" -#include "WebKitHitTestResultPrivate.h" -#include <glib/gi18n-lib.h> -#include <wtf/text/CString.h> - -using namespace WebKit; - -/** - * SECTION: WebKitHitTestResult - * @Short_description: Result of a Hit Test - * @Title: WebKitHitTestResult - * @See_also: #WebKitWebView - * - * A Hit Test is an operation to get context information about a given - * point in a #WebKitWebView. #WebKitHitTestResult represents the - * result of a Hit Test. It provides context information about what is - * at the coordinates of the Hit Test, such as if there's a link, - * an image or a media. - * - * You can get the context of the HitTestResult with - * webkit_hit_test_result_get_context() that returns a bitmask of - * #WebKitHitTestResultContext flags. You can also use - * webkit_hit_test_result_context_is_link(), webkit_hit_test_result_context_is_image() and - * webkit_hit_test_result_context_is_media() to determine whether there's - * a link, image or a media element at the coordinates of the Hit Test. - * Note that it's possible that several #WebKitHitTestResultContext flags - * are active at the same time, for example if there's a link containing an image. - * - * When the mouse is moved over a #WebKitWebView a Hit Test is performed - * for the mouse coordinates and #WebKitWebView::mouse-target-changed - * signal is emitted with a #WebKitHitTestResult. - * - */ - -enum { - PROP_0, - - PROP_CONTEXT, - PROP_LINK_URI, - PROP_LINK_TITLE, - PROP_LINK_LABEL, - PROP_IMAGE_URI, - PROP_MEDIA_URI -}; - -struct _WebKitHitTestResultPrivate { - unsigned int context; - CString linkURI; - CString linkTitle; - CString linkLabel; - CString imageURI; - CString mediaURI; -}; - -WEBKIT_DEFINE_TYPE(WebKitHitTestResult, webkit_hit_test_result, G_TYPE_OBJECT) - -static void webkitHitTestResultGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) -{ - WebKitHitTestResult* hitTestResult = WEBKIT_HIT_TEST_RESULT(object); - - switch (propId) { - case PROP_CONTEXT: - g_value_set_uint(value, webkit_hit_test_result_get_context(hitTestResult)); - break; - case PROP_LINK_URI: - g_value_set_string(value, webkit_hit_test_result_get_link_uri(hitTestResult)); - break; - case PROP_LINK_TITLE: - g_value_set_string(value, webkit_hit_test_result_get_link_title(hitTestResult)); - break; - case PROP_LINK_LABEL: - g_value_set_string(value, webkit_hit_test_result_get_link_label(hitTestResult)); - break; - case PROP_IMAGE_URI: - g_value_set_string(value, webkit_hit_test_result_get_image_uri(hitTestResult)); - break; - case PROP_MEDIA_URI: - g_value_set_string(value, webkit_hit_test_result_get_media_uri(hitTestResult)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static void webkitHitTestResultSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec) -{ - WebKitHitTestResult* hitTestResult = WEBKIT_HIT_TEST_RESULT(object); - - switch (propId) { - case PROP_CONTEXT: - hitTestResult->priv->context = g_value_get_uint(value); - break; - case PROP_LINK_URI: - hitTestResult->priv->linkURI = g_value_get_string(value); - break; - case PROP_LINK_TITLE: - hitTestResult->priv->linkTitle = g_value_get_string(value); - break; - case PROP_LINK_LABEL: - hitTestResult->priv->linkLabel = g_value_get_string(value); - break; - case PROP_IMAGE_URI: - hitTestResult->priv->imageURI = g_value_get_string(value); - break; - case PROP_MEDIA_URI: - hitTestResult->priv->mediaURI = g_value_get_string(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static void webkit_hit_test_result_class_init(WebKitHitTestResultClass* hitTestResultClass) -{ - GObjectClass* objectClass = G_OBJECT_CLASS(hitTestResultClass); - objectClass->get_property = webkitHitTestResultGetProperty; - objectClass->set_property = webkitHitTestResultSetProperty; - - GParamFlags paramFlags = static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); - - /** - * WebKitHitTestResult:context: - * - * Bitmask of #WebKitHitTestResultContext flags representing - * the context of the #WebKitHitTestResult. - */ - g_object_class_install_property(objectClass, - PROP_CONTEXT, - g_param_spec_uint("context", - _("Context"), - _("Flags with the context of the WebKitHitTestResult"), - 0, G_MAXUINT, 0, - paramFlags)); - - /** - * WebKitHitTestResult:link-uri: - * - * The URI of the link if flag %WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK - * is present in #WebKitHitTestResult:context - */ - g_object_class_install_property(objectClass, - PROP_LINK_URI, - g_param_spec_string("link-uri", - _("Link URI"), - _("The link URI"), - 0, - paramFlags)); - /** - * WebKitHitTestResult:link-title: - * - * The title of the link if flag %WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK - * is present in #WebKitHitTestResult:context - */ - g_object_class_install_property(objectClass, - PROP_LINK_TITLE, - g_param_spec_string("link-title", - _("Link Title"), - _("The link title"), - 0, - paramFlags)); - /** - * WebKitHitTestResult:link-label: - * - * The label of the link if flag %WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK - * is present in #WebKitHitTestResult:context - */ - g_object_class_install_property(objectClass, - PROP_LINK_LABEL, - g_param_spec_string("link-label", - _("Link Label"), - _("The link label"), - 0, - paramFlags)); - /** - * WebKitHitTestResult:image-uri: - * - * The URI of the image if flag %WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE - * is present in #WebKitHitTestResult:context - */ - g_object_class_install_property(objectClass, - PROP_IMAGE_URI, - g_param_spec_string("image-uri", - _("Image URI"), - _("The image URI"), - 0, - paramFlags)); - /** - * WebKitHitTestResult:media-uri: - * - * The URI of the media if flag %WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA - * is present in #WebKitHitTestResult:context - */ - g_object_class_install_property(objectClass, - PROP_MEDIA_URI, - g_param_spec_string("media-uri", - _("Media URI"), - _("The media URI"), - 0, - paramFlags)); -} - -WebKitHitTestResult* webkitHitTestResultCreate(WebHitTestResult* hitTestResult) -{ - unsigned context = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT; - - const String& linkURL = hitTestResult->absoluteLinkURL(); - if (!linkURL.isEmpty()) - context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK; - - const String& imageURL = hitTestResult->absoluteImageURL(); - if (!imageURL.isEmpty()) - context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE; - - const String& mediaURL = hitTestResult->absoluteMediaURL(); - if (!mediaURL.isEmpty()) - context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA; - - if (hitTestResult->isContentEditable()) - context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE; - - if (hitTestResult->isScrollbar()) - context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR; - - const String& linkTitle = hitTestResult->linkTitle(); - const String& linkLabel = hitTestResult->linkLabel(); - - return WEBKIT_HIT_TEST_RESULT(g_object_new(WEBKIT_TYPE_HIT_TEST_RESULT, - "context", context, - "link-uri", !linkURL.isEmpty() ? linkURL.utf8().data() : 0, - "image-uri", !imageURL.isEmpty() ? imageURL.utf8().data() : 0, - "media-uri", !mediaURL.isEmpty() ? mediaURL.utf8().data() : 0, - "link-title", !linkTitle.isEmpty() ? linkTitle.utf8().data() : 0, - "link-label", !linkLabel.isEmpty() ? linkLabel.utf8().data() : 0, - NULL)); -} - -static bool stringIsEqualToCString(const String& string, const CString& cString) -{ - return ((string.isEmpty() && cString.isNull()) || (string.utf8() == cString)); -} - -bool webkitHitTestResultCompare(WebKitHitTestResult* hitTestResult, WebHitTestResult* webHitTestResult) -{ - WebKitHitTestResultPrivate* priv = hitTestResult->priv; - return webHitTestResult->isContentEditable() == webkit_hit_test_result_context_is_editable(hitTestResult) - && webHitTestResult->isScrollbar() == webkit_hit_test_result_context_is_scrollbar(hitTestResult) - && stringIsEqualToCString(webHitTestResult->absoluteLinkURL(), priv->linkURI) - && stringIsEqualToCString(webHitTestResult->linkTitle(), priv->linkTitle) - && stringIsEqualToCString(webHitTestResult->linkLabel(), priv->linkLabel) - && stringIsEqualToCString(webHitTestResult->absoluteImageURL(), priv->imageURI) - && stringIsEqualToCString(webHitTestResult->absoluteMediaURL(), priv->mediaURI); -} - -/** - * webkit_hit_test_result_get_context: - * @hit_test_result: a #WebKitHitTestResult - * - * Gets the value of the #WebKitHitTestResult:context property. - * - * Returns: a bitmask of #WebKitHitTestResultContext flags - */ -guint webkit_hit_test_result_get_context(WebKitHitTestResult* hitTestResult) -{ - g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), 0); - - return hitTestResult->priv->context; -} - -/** - * webkit_hit_test_result_context_is_link: - * @hit_test_result: a #WebKitHitTestResult - * - * Gets whether %WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK flag is present in - * #WebKitHitTestResult:context. - * - * Returns: %TRUE if there's a link element in the coordinates of the Hit Test, - * or %FALSE otherwise - */ -gboolean webkit_hit_test_result_context_is_link(WebKitHitTestResult* hitTestResult) -{ - g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), FALSE); - - return hitTestResult->priv->context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK; -} - -/** - * webkit_hit_test_result_context_is_image: - * @hit_test_result: a #WebKitHitTestResult - * - * Gets whether %WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE flag is present in - * #WebKitHitTestResult:context. - * - * Returns: %TRUE if there's an image element in the coordinates of the Hit Test, - * or %FALSE otherwise - */ -gboolean webkit_hit_test_result_context_is_image(WebKitHitTestResult* hitTestResult) -{ - g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), FALSE); - - return hitTestResult->priv->context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE; -} - -/** - * webkit_hit_test_result_context_is_media: - * @hit_test_result: a #WebKitHitTestResult - * - * Gets whether %WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA flag is present in - * #WebKitHitTestResult:context. - * - * Returns: %TRUE if there's a media element in the coordinates of the Hit Test, - * or %FALSE otherwise - */ -gboolean webkit_hit_test_result_context_is_media(WebKitHitTestResult* hitTestResult) -{ - g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), FALSE); - - return hitTestResult->priv->context & WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA; -} - -/** - * webkit_hit_test_result_context_is_editable: - * @hit_test_result: a #WebKitHitTestResult - * - * Gets whether %WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE flag is present in - * #WebKitHitTestResult:context. - * - * Returns: %TRUE if there's an editable element at the coordinates of the @hit_test_result, - * or %FALSE otherwise - */ -gboolean webkit_hit_test_result_context_is_editable(WebKitHitTestResult* hitTestResult) -{ - g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), FALSE); - - return hitTestResult->priv->context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE; -} - -/** - * webkit_hit_test_result_get_link_uri: - * @hit_test_result: a #WebKitHitTestResult - * - * Gets the value of the #WebKitHitTestResult:link-uri property. - * - * Returns: the URI of the link element in the coordinates of the Hit Test, - * or %NULL if there ins't a link element in @hit_test_result context - */ -const gchar* webkit_hit_test_result_get_link_uri(WebKitHitTestResult* hitTestResult) -{ - g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), 0); - - return hitTestResult->priv->linkURI.data(); -} - -/** - * webkit_hit_test_result_get_link_title: - * @hit_test_result: a #WebKitHitTestResult - * - * Gets the value of the #WebKitHitTestResult:link-title property. - * - * Returns: the title of the link element in the coordinates of the Hit Test, - * or %NULL if there ins't a link element in @hit_test_result context or the - * link element doesn't have a title - */ -const gchar* webkit_hit_test_result_get_link_title(WebKitHitTestResult* hitTestResult) -{ - g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), 0); - - return hitTestResult->priv->linkTitle.data(); -} - -/** - * webkit_hit_test_result_get_link_label: - * @hit_test_result: a #WebKitHitTestResult - * - * Gets the value of the #WebKitHitTestResult:link-label property. - * - * Returns: the label of the link element in the coordinates of the Hit Test, - * or %NULL if there ins't a link element in @hit_test_result context or the - * link element doesn't have a label - */ -const gchar* webkit_hit_test_result_get_link_label(WebKitHitTestResult* hitTestResult) -{ - g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), 0); - - return hitTestResult->priv->linkLabel.data(); -} - -/** - * webkit_hit_test_result_get_image_uri: - * @hit_test_result: a #WebKitHitTestResult - * - * Gets the value of the #WebKitHitTestResult:image-uri property. - * - * Returns: the URI of the image element in the coordinates of the Hit Test, - * or %NULL if there ins't an image element in @hit_test_result context - */ -const gchar* webkit_hit_test_result_get_image_uri(WebKitHitTestResult* hitTestResult) -{ - g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), 0); - - return hitTestResult->priv->imageURI.data(); -} - -/** - * webkit_hit_test_result_get_media_uri: - * @hit_test_result: a #WebKitHitTestResult - * - * Gets the value of the #WebKitHitTestResult:media-uri property. - * - * Returns: the URI of the media element in the coordinates of the Hit Test, - * or %NULL if there ins't a media element in @hit_test_result context - */ -const gchar* webkit_hit_test_result_get_media_uri(WebKitHitTestResult* hitTestResult) -{ - g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), 0); - - return hitTestResult->priv->mediaURI.data(); -} - -/** - * webkit_hit_test_result_context_is_scrollbar: - * @hit_test_result: a #WebKitHitTestResult - * - * Gets whether %WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR flag is present in - * #WebKitHitTestResult:context. - * - * Returns: %TRUE if there's a scrollbar element at the coordinates of the @hit_test_result, - * or %FALSE otherwise - */ -gboolean webkit_hit_test_result_context_is_scrollbar(WebKitHitTestResult* hitTestResult) -{ - g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), FALSE); - - return hitTestResult->priv->context & WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.h b/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.h deleted file mode 100644 index 54611ba92..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitHitTestResult_h -#define WebKitHitTestResult_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_HIT_TEST_RESULT (webkit_hit_test_result_get_type()) -#define WEBKIT_HIT_TEST_RESULT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_HIT_TEST_RESULT, WebKitHitTestResult)) -#define WEBKIT_IS_HIT_TEST_RESULT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_HIT_TEST_RESULT)) -#define WEBKIT_HIT_TEST_RESULT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_HIT_TEST_RESULT, WebKitHitTestResultClass)) -#define WEBKIT_IS_HIT_TEST_RESULT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_HIT_TEST_RESULT)) -#define WEBKIT_HIT_TEST_RESULT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_HIT_TEST_RESULT, WebKitHitTestResultClass)) - -typedef struct _WebKitHitTestResult WebKitHitTestResult; -typedef struct _WebKitHitTestResultClass WebKitHitTestResultClass; -typedef struct _WebKitHitTestResultPrivate WebKitHitTestResultPrivate; - -/** - * WebKitHitTestResultContext: - * @WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT: anywhere in the document. - * @WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK: a hyperlink element. - * @WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE: an image element. - * @WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA: a video or audio element. - * @WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE: an editable element - * @WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR: a scrollbar element. - * - * Enum values with flags representing the context of a #WebKitHitTestResult. - */ -typedef enum -{ - WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT = 1 << 1, - WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK = 1 << 2, - WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE = 1 << 3, - WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA = 1 << 4, - WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE = 1 << 5, - WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR = 1 << 6 -} WebKitHitTestResultContext; - -struct _WebKitHitTestResult { - GObject parent; - - WebKitHitTestResultPrivate *priv; -}; - -struct _WebKitHitTestResultClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_hit_test_result_get_type (void); - -WEBKIT_API guint -webkit_hit_test_result_get_context (WebKitHitTestResult *hit_test_result); - -WEBKIT_API gboolean -webkit_hit_test_result_context_is_link (WebKitHitTestResult *hit_test_result); - -WEBKIT_API gboolean -webkit_hit_test_result_context_is_image (WebKitHitTestResult *hit_test_result); - -WEBKIT_API gboolean -webkit_hit_test_result_context_is_media (WebKitHitTestResult *hit_test_result); - -WEBKIT_API gboolean -webkit_hit_test_result_context_is_editable (WebKitHitTestResult *hit_test_result); - -WEBKIT_API const gchar * -webkit_hit_test_result_get_link_uri (WebKitHitTestResult *hit_test_result); - -WEBKIT_API const gchar * -webkit_hit_test_result_get_link_title (WebKitHitTestResult *hit_test_result); - -WEBKIT_API const gchar * -webkit_hit_test_result_get_link_label (WebKitHitTestResult *hit_test_result); - -WEBKIT_API const gchar * -webkit_hit_test_result_get_image_uri (WebKitHitTestResult *hit_test_result); - -WEBKIT_API const gchar * -webkit_hit_test_result_get_media_uri (WebKitHitTestResult *hit_test_result); - -WEBKIT_API gboolean -webkit_hit_test_result_context_is_scrollbar (WebKitHitTestResult *hit_test_result); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResultPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResultPrivate.h deleted file mode 100644 index 7ba2c3871..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResultPrivate.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitHitTestResultPrivate_h -#define WebKitHitTestResultPrivate_h - -#include "WebKitHitTestResult.h" -#include "WebKitPrivate.h" - -WebKitHitTestResult* webkitHitTestResultCreate(WebKit::WebHitTestResult*); -bool webkitHitTestResultCompare(WebKitHitTestResult*, WebKit::WebHitTestResult*); - -#endif // WebKitHitTestResultPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitInjectedBundleClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitInjectedBundleClient.cpp deleted file mode 100644 index 26a6f8f10..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitInjectedBundleClient.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 2013 Igalia S.L. - * - * 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 "WebKitInjectedBundleClient.h" - -#include "WebImage.h" -#include "WebKitURIRequestPrivate.h" -#include "WebKitURIResponsePrivate.h" -#include "WebKitWebContextPrivate.h" -#include "WebKitWebResourcePrivate.h" -#include "WebKitWebViewPrivate.h" -#include <wtf/gobject/GOwnPtr.h> - -using namespace WebKit; -using namespace WebCore; - -static void didReceiveWebViewMessageFromInjectedBundle(WebKitWebView* webView, const char* messageName, ImmutableDictionary& message) -{ - if (g_str_equal(messageName, "DidInitiateLoadForResource")) { - WebFrameProxy* frame = static_cast<WebFrameProxy*>(message.get(String::fromUTF8("Frame"))); - WebUInt64* resourceIdentifier = static_cast<WebUInt64*>(message.get(String::fromUTF8("Identifier"))); - WebURLRequest* webRequest = static_cast<WebURLRequest*>(message.get(String::fromUTF8("Request"))); - GRefPtr<WebKitURIRequest> request = adoptGRef(webkitURIRequestCreateForResourceRequest(webRequest->resourceRequest())); - - webkitWebViewResourceLoadStarted(webView, frame, resourceIdentifier->value(), request.get()); - } else if (g_str_equal(messageName, "DidSendRequestForResource")) { - WebUInt64* resourceIdentifier = static_cast<WebUInt64*>(message.get(String::fromUTF8("Identifier"))); - GRefPtr<WebKitWebResource> resource = webkitWebViewGetLoadingWebResource(webView, resourceIdentifier->value()); - if (!resource) - return; - - WebURLRequest* webRequest = static_cast<WebURLRequest*>(message.get(String::fromUTF8("Request"))); - GRefPtr<WebKitURIRequest> request = adoptGRef(webkitURIRequestCreateForResourceRequest(webRequest->resourceRequest())); - WebURLResponse* webRedirectResponse = static_cast<WebURLResponse*>(message.get(String::fromUTF8("RedirectResponse"))); - GRefPtr<WebKitURIResponse> redirectResponse = webRedirectResponse ? adoptGRef(webkitURIResponseCreateForResourceResponse(webRedirectResponse->resourceResponse())) : 0; - - webkitWebResourceSentRequest(resource.get(), request.get(), redirectResponse.get()); - } else if (g_str_equal(messageName, "DidReceiveResponseForResource")) { - WebUInt64* resourceIdentifier = static_cast<WebUInt64*>(message.get(String::fromUTF8("Identifier"))); - GRefPtr<WebKitWebResource> resource = webkitWebViewGetLoadingWebResource(webView, resourceIdentifier->value()); - if (!resource) - return; - - WebURLResponse* webResponse = static_cast<WebURLResponse*>(message.get(String::fromUTF8("Response"))); - GRefPtr<WebKitURIResponse> response = adoptGRef(webkitURIResponseCreateForResourceResponse(webResponse->resourceResponse())); - - webkitWebResourceSetResponse(resource.get(), response.get()); - } else if (g_str_equal(messageName, "DidReceiveContentLengthForResource")) { - WebUInt64* resourceIdentifier = static_cast<WebUInt64*>(message.get(String::fromUTF8("Identifier"))); - GRefPtr<WebKitWebResource> resource = webkitWebViewGetLoadingWebResource(webView, resourceIdentifier->value()); - if (!resource) - return; - - WebUInt64* contentLength = static_cast<WebUInt64*>(message.get(String::fromUTF8("ContentLength"))); - webkitWebResourceNotifyProgress(resource.get(), contentLength->value()); - } else if (g_str_equal(messageName, "DidFinishLoadForResource")) { - WebUInt64* resourceIdentifier = static_cast<WebUInt64*>(message.get(String::fromUTF8("Identifier"))); - GRefPtr<WebKitWebResource> resource = webkitWebViewGetLoadingWebResource(webView, resourceIdentifier->value()); - if (!resource) - return; - - webkitWebResourceFinished(resource.get()); - webkitWebViewRemoveLoadingWebResource(webView, resourceIdentifier->value()); - } else if (g_str_equal(messageName, "DidFailLoadForResource")) { - WebUInt64* resourceIdentifier = static_cast<WebUInt64*>(message.get(String::fromUTF8("Identifier"))); - GRefPtr<WebKitWebResource> resource = webkitWebViewGetLoadingWebResource(webView, resourceIdentifier->value()); - if (!resource) - return; - - WebError* webError = static_cast<WebError*>(message.get(String::fromUTF8("Error"))); - const ResourceError& platformError = webError->platformError(); - GOwnPtr<GError> resourceError(g_error_new_literal(g_quark_from_string(platformError.domain().utf8().data()), - platformError.errorCode(), platformError.localizedDescription().utf8().data())); - - webkitWebResourceFailed(resource.get(), resourceError.get()); - webkitWebViewRemoveLoadingWebResource(webView, resourceIdentifier->value()); - } else if (g_str_equal(messageName, "DidGetSnapshot")) { - WebUInt64* callbackID = static_cast<WebUInt64*>(message.get("CallbackID")); - WebImage* image = static_cast<WebImage*>(message.get("Snapshot")); - webKitWebViewDidReceiveSnapshot(webView, callbackID->value(), image); - } else - ASSERT_NOT_REACHED(); -} - -static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, const void* clientInfo) -{ - ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); - ImmutableDictionary& message = *toImpl(static_cast<WKDictionaryRef>(messageBody)); - - CString messageNameCString = toImpl(messageName)->string().utf8(); - const char* messageNameUTF8 = messageNameCString.data(); - - if (g_str_has_prefix(messageNameUTF8, "WebPage.")) { - WebPageProxy* page = static_cast<WebPageProxy*>(message.get(String::fromUTF8("Page"))); - WebKitWebView* webView = webkitWebContextGetWebViewForPage(WEBKIT_WEB_CONTEXT(clientInfo), page); - if (!webView) - return; - - didReceiveWebViewMessageFromInjectedBundle(webView, messageNameUTF8 + strlen("WebPage."), message); - } else - ASSERT_NOT_REACHED(); -} - -void attachInjectedBundleClientToContext(WebKitWebContext* webContext) -{ - WKContextInjectedBundleClient wkInjectedBundleClient = { - kWKContextInjectedBundleClientCurrentVersion, - webContext, // clientInfo - didReceiveMessageFromInjectedBundle, - 0, // didReceiveSynchronousMessageFromInjectedBundle - 0 // getInjectedBundleInitializationUserData - }; - WKContextSetInjectedBundleClient(toAPI(webkitWebContextGetContext(webContext)), &wkInjectedBundleClient); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitInjectedBundleClient.h b/Source/WebKit2/UIProcess/API/gtk/WebKitInjectedBundleClient.h deleted file mode 100644 index 7f7c79179..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitInjectedBundleClient.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2013 Igalia S.L. - * - * 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 WebKitInjectedBundleClient_h -#define WebKitInjectedBundleClient_h - -#include "WebKitWebContext.h" - -void attachInjectedBundleClientToContext(WebKitWebContext*); - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResult.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResult.cpp deleted file mode 100644 index 9bbd3f4ed..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResult.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitJavascriptResult.h" - -#include "WebKitJavascriptResultPrivate.h" -#include "WebSerializedScriptValue.h" -#include <wtf/gobject/GRefPtr.h> - -using namespace WebKit; - -struct _WebKitJavascriptResult { - _WebKitJavascriptResult(WebKitWebView* view, WebSerializedScriptValue* serializedScriptValue) - : webView(view) - , referenceCount(1) - { - value = serializedScriptValue->deserialize(webkit_web_view_get_javascript_global_context(view), 0); - } - - GRefPtr<WebKitWebView> webView; - JSValueRef value; - - int referenceCount; -}; - -G_DEFINE_BOXED_TYPE(WebKitJavascriptResult, webkit_javascript_result, webkit_javascript_result_ref, webkit_javascript_result_unref) - -WebKitJavascriptResult* webkitJavascriptResultCreate(WebKitWebView* webView, WebSerializedScriptValue* serializedScriptValue) -{ - WebKitJavascriptResult* result = g_slice_new(WebKitJavascriptResult); - new (result) WebKitJavascriptResult(webView, serializedScriptValue); - return result; -} - -/** - * webkit_javascript_result_ref: - * @js_result: a #WebKitJavascriptResult - * - * Atomically increments the reference count of @js_result by one. This - * function is MT-safe and may be called from any thread. - * - * Returns: The passed in #WebKitJavascriptResult - */ -WebKitJavascriptResult* webkit_javascript_result_ref(WebKitJavascriptResult* javascriptResult) -{ - g_atomic_int_inc(&javascriptResult->referenceCount); - return javascriptResult; -} - -/** - * webkit_javascript_result_unref: - * @js_result: a #WebKitJavascriptResult - * - * Atomically decrements the reference count of @js_result by one. If the - * reference count drops to 0, all memory allocated by the #WebKitJavascriptResult is - * released. This function is MT-safe and may be called from any - * thread. - */ -void webkit_javascript_result_unref(WebKitJavascriptResult* javascriptResult) -{ - if (g_atomic_int_dec_and_test(&javascriptResult->referenceCount)) { - javascriptResult->~WebKitJavascriptResult(); - g_slice_free(WebKitJavascriptResult, javascriptResult); - } -} - -/** - * webkit_javascript_result_get_global_context: - * @js_result: a #WebKitJavascriptResult - * - * Get the global Javascript context that should be used with the - * <function>JSValueRef</function> returned by webkit_javascript_result_get_value(). - * - * Returns: the <function>JSGlobalContextRef</function> for the #WebKitJavascriptResult - */ -JSGlobalContextRef webkit_javascript_result_get_global_context(WebKitJavascriptResult* javascriptResult) -{ - return webkit_web_view_get_javascript_global_context(javascriptResult->webView.get()); -} - -/** - * webkit_javascript_result_get_value: - * @js_result: a #WebKitJavascriptResult - * - * Get the value of @js_result. You should use the <function>JSGlobalContextRef</function> - * returned by webkit_javascript_result_get_global_context() to use the <function>JSValueRef</function>. - * - * Returns: the <function>JSValueRef</function> of the #WebKitJavascriptResult - */ -JSValueRef webkit_javascript_result_get_value(WebKitJavascriptResult* javascriptResult) -{ - return javascriptResult->value; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResult.h b/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResult.h deleted file mode 100644 index 5a9f7389f..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResult.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitJavascriptResult_h -#define WebKitJavascriptResult_h - -#include <JavaScriptCore/JSBase.h> -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_JAVASCRIPT_RESULT (webkit_javascript_result_get_type()) - -typedef struct _WebKitJavascriptResult WebKitJavascriptResult; - - -WEBKIT_API GType -webkit_javascript_result_get_type (void); - -WEBKIT_API WebKitJavascriptResult * -webkit_javascript_result_ref (WebKitJavascriptResult *js_result); - -WEBKIT_API void -webkit_javascript_result_unref (WebKitJavascriptResult *js_result); - -WEBKIT_API JSGlobalContextRef -webkit_javascript_result_get_global_context (WebKitJavascriptResult *js_result); - -WEBKIT_API JSValueRef -webkit_javascript_result_get_value (WebKitJavascriptResult *js_result); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResultPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResultPrivate.h deleted file mode 100644 index e47e94c1b..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResultPrivate.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitJavascriptResultPrivate_h -#define WebKitJavascriptResultPrivate_h - -#include "WebKitJavascriptResult.h" -#include "WebKitPrivate.h" -#include "WebKitWebView.h" - -WebKitJavascriptResult* webkitJavascriptResultCreate(WebKitWebView*, WebKit::WebSerializedScriptValue*); - -#endif // WebKitJavascriptResultPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp deleted file mode 100644 index 36cd6c0e6..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * Portions Copyright (c) 2011 Motorola Mobility, 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 "config.h" -#include "WebKitLoaderClient.h" - -#include "WebKitBackForwardListPrivate.h" -#include "WebKitURIResponsePrivate.h" -#include "WebKitWebViewBasePrivate.h" -#include "WebKitWebViewPrivate.h" -#include <wtf/gobject/GOwnPtr.h> -#include <wtf/text/CString.h> - -using namespace WebKit; -using namespace WebCore; - -static void didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) -{ - if (!WKFrameIsMainFrame(frame)) - return; - - webkitWebViewLoadChanged(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_LOAD_STARTED); -} - -static void didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) -{ - if (!WKFrameIsMainFrame(frame)) - return; - - webkitWebViewLoadChanged(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_LOAD_REDIRECTED); -} - -static void didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo) -{ - if (!WKFrameIsMainFrame(frame)) - return; - - const ResourceError& resourceError = toImpl(error)->platformError(); - GOwnPtr<GError> webError(g_error_new_literal(g_quark_from_string(resourceError.domain().utf8().data()), - resourceError.errorCode(), - resourceError.localizedDescription().utf8().data())); - if (resourceError.tlsErrors()) { - webkitWebViewLoadFailedWithTLSErrors(WEBKIT_WEB_VIEW(clientInfo), resourceError.failingURL().utf8().data(), webError.get(), - static_cast<GTlsCertificateFlags>(resourceError.tlsErrors()), resourceError.certificate()); - } else - webkitWebViewLoadFailed(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_LOAD_STARTED, resourceError.failingURL().utf8().data(), webError.get()); -} - -static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) -{ - if (!WKFrameIsMainFrame(frame)) - return; - - webkitWebViewLoadChanged(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_LOAD_COMMITTED); -} - -static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) -{ - if (!WKFrameIsMainFrame(frame)) - return; - - webkitWebViewLoadChanged(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_LOAD_FINISHED); -} - -static void didFailLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef, const void* clientInfo) -{ - if (!WKFrameIsMainFrame(frame)) - return; - - const ResourceError& resourceError = toImpl(error)->platformError(); - GOwnPtr<GError> webError(g_error_new_literal(g_quark_from_string(resourceError.domain().utf8().data()), - resourceError.errorCode(), - resourceError.localizedDescription().utf8().data())); - webkitWebViewLoadFailed(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_LOAD_COMMITTED, - resourceError.failingURL().utf8().data(), webError.get()); -} - -static void didSameDocumentNavigationForFrame(WKPageRef page, WKFrameRef frame, WKSameDocumentNavigationType, WKTypeRef, const void* clientInfo) -{ - if (!WKFrameIsMainFrame(frame)) - return; - - webkitWebViewUpdateURI(WEBKIT_WEB_VIEW(clientInfo)); -} - -static void didReceiveTitleForFrame(WKPageRef page, WKStringRef titleRef, WKFrameRef frameRef, WKTypeRef, const void* clientInfo) -{ - if (!WKFrameIsMainFrame(frameRef)) - return; - - webkitWebViewSetTitle(WEBKIT_WEB_VIEW(clientInfo), toImpl(titleRef)->string().utf8()); -} - -static void didDisplayInsecureContentForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo) -{ - webkitWebViewInsecureContentDetected(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_INSECURE_CONTENT_DISPLAYED); -} - -static void didRunInsecureContentForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo) -{ - webkitWebViewInsecureContentDetected(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_INSECURE_CONTENT_RUN); -} - -static void didChangeProgress(WKPageRef page, const void* clientInfo) -{ - webkitWebViewSetEstimatedLoadProgress(WEBKIT_WEB_VIEW(clientInfo), WKPageGetEstimatedProgress(page)); -} - -static void didChangeBackForwardList(WKPageRef page, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void* clientInfo) -{ - webkitBackForwardListChanged(webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(clientInfo)), toImpl(addedItem), toImpl(removedItems)); -} - -static void didReceiveAuthenticationChallengeInFrame(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo) -{ - webkitWebViewHandleAuthenticationChallenge(WEBKIT_WEB_VIEW(clientInfo), toImpl(authenticationChallenge)); -} - -static void processDidCrash(WKPageRef page, const void* clientInfo) -{ - webkitWebViewWebProcessCrashed(WEBKIT_WEB_VIEW(clientInfo)); -} - -void attachLoaderClientToView(WebKitWebView* webView) -{ - WKPageLoaderClient wkLoaderClient = { - kWKPageLoaderClientCurrentVersion, - webView, // clientInfo - didStartProvisionalLoadForFrame, - didReceiveServerRedirectForProvisionalLoadForFrame, - didFailProvisionalLoadWithErrorForFrame, - didCommitLoadForFrame, - 0, // didFinishDocumentLoadForFrame - didFinishLoadForFrame, - didFailLoadWithErrorForFrame, - didSameDocumentNavigationForFrame, - didReceiveTitleForFrame, - 0, // didFirstLayoutForFrame - 0, // didFirstVisuallyNonEmptyLayoutForFrame - 0, // didRemoveFrameFromHierarchy - didDisplayInsecureContentForFrame, - didRunInsecureContentForFrame, - 0, // canAuthenticateAgainstProtectionSpaceInFrame - didReceiveAuthenticationChallengeInFrame, - didChangeProgress, // didStartProgress - didChangeProgress, - didChangeProgress, // didFinishProgress - 0, // didBecomeUnresponsive - 0, // didBecomeResponsive - processDidCrash, - didChangeBackForwardList, - 0, // shouldGoToBackForwardListItem - 0, // didFailToInitializePlugin - 0, // didDetectXSSForFrame - 0, // didFirstVisuallyNonEmptyLayoutForFrame - 0, // willGoToBackForwardListItem - 0, // interactionOccurredWhileProcessUnresponsive - 0, // pluginDidFail_deprecatedForUseWithV1 - 0, // didReceiveIntentForFrame - 0, // registerIntentServiceForFrame - 0, // didLayout - 0, // pluginLoadPolicy - 0, // pluginDidFail - }; - WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))); - WKPageSetPageLoaderClient(wkPage, &wkLoaderClient); -} - diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.h b/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.h deleted file mode 100644 index dfac3c86f..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 WebKitLoaderClient_h -#define WebKitLoaderClient_h - -#include "WebKitWebView.h" - -void attachLoaderClientToView(WebKitWebView*); - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfo.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfo.cpp deleted file mode 100644 index 2282ede37..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfo.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitMimeInfo.h" - -#include "WebKitMimeInfoPrivate.h" -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -struct _WebKitMimeInfo { - _WebKitMimeInfo(const WebCore::MimeClassInfo& mimeInfo) - : mimeInfo(mimeInfo) - { - } - - WebCore::MimeClassInfo mimeInfo; - CString mimeType; - CString description; - GRefPtr<GPtrArray> extensions; - - int referenceCount; -}; - -G_DEFINE_BOXED_TYPE(WebKitMimeInfo, webkit_mime_info, webkit_mime_info_ref, webkit_mime_info_unref) - -WebKitMimeInfo* webkitMimeInfoCreate(const WebCore::MimeClassInfo& mimeInfo) -{ - WebKitMimeInfo* info = g_slice_new(WebKitMimeInfo); - new (info) WebKitMimeInfo(mimeInfo); - return info; -} - -/** - * webkit_mime_info_ref: - * @info: a #WebKitMimeInfo - * - * Atomically increments the reference count of @info by one. This - * function is MT-safe and may be called from any thread. - * - * Returns: The passed in #WebKitMimeInfo - */ -WebKitMimeInfo* webkit_mime_info_ref(WebKitMimeInfo* info) -{ - g_atomic_int_inc(&info->referenceCount); - return info; -} - -/** - * webkit_mime_info_unref: - * @info: a #WebKitMimeInfo - * - * Atomically decrements the reference count of @info by one. If the - * reference count drops to 0, all memory allocated by the #WebKitMimeInfo is - * released. This function is MT-safe and may be called from any - * thread. - */ -void webkit_mime_info_unref(WebKitMimeInfo* info) -{ - if (g_atomic_int_dec_and_test(&info->referenceCount)) { - info->~WebKitMimeInfo(); - g_slice_free(WebKitMimeInfo, info); - } -} - -/** - * webkit_mime_info_get_mime_type: - * @info: a #WebKitMimeInfo - * - * Returns: the MIME type of @info - */ -const char* webkit_mime_info_get_mime_type(WebKitMimeInfo* info) -{ - if (!info->mimeType.isNull()) - return info->mimeType.data(); - - if (info->mimeInfo.type.isEmpty()) - return 0; - - info->mimeType = info->mimeInfo.type.utf8(); - return info->mimeType.data(); -} - -/** - * webkit_mime_info_get_description: - * @info: a #WebKitMimeInfo - * - * Returns: the description of the MIME type of @info - */ -const char* webkit_mime_info_get_description(WebKitMimeInfo* info) -{ - if (!info->description.isNull()) - return info->description.data(); - - if (info->mimeInfo.desc.isEmpty()) - return 0; - - info->description = info->mimeInfo.desc.utf8(); - return info->description.data(); -} - -/** - * webkit_mime_info_get_extensions: - * @info: a #WebKitMimeInfo - * - * Get the list of file extensions associated to the - * MIME type of @info - * - * Returns: (array zero-terminated=1) (transfer none): a - * %NULL-terminated array of strings - */ -const char* const* webkit_mime_info_get_extensions(WebKitMimeInfo* info) -{ - if (info->extensions) - return reinterpret_cast<gchar**>(info->extensions->pdata); - - if (info->mimeInfo.extensions.isEmpty()) - return 0; - - info->extensions = adoptGRef(g_ptr_array_new_with_free_func(g_free)); - for (size_t i = 0; i < info->mimeInfo.extensions.size(); ++i) { - if (info->mimeInfo.extensions[i].isEmpty()) - continue; - g_ptr_array_add(info->extensions.get(), g_strdup(info->mimeInfo.extensions[i].utf8().data())); - } - g_ptr_array_add(info->extensions.get(), 0); - - return reinterpret_cast<gchar**>(info->extensions->pdata); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfo.h b/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfo.h deleted file mode 100644 index 7ec8e69c5..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfo.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitMimeInfo_h -#define WebKitMimeInfo_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_MIME_INFO (webkit_mime_info_get_type()) - -typedef struct _WebKitMimeInfo WebKitMimeInfo; - - -WEBKIT_API GType -webkit_mime_info_get_type (void); - -WEBKIT_API WebKitMimeInfo * -webkit_mime_info_ref (WebKitMimeInfo *info); - -WEBKIT_API void -webkit_mime_info_unref (WebKitMimeInfo *info); - -WEBKIT_API const gchar * -webkit_mime_info_get_mime_type (WebKitMimeInfo *info); - -WEBKIT_API const gchar * -webkit_mime_info_get_description (WebKitMimeInfo *info); - -WEBKIT_API const gchar * const * -webkit_mime_info_get_extensions (WebKitMimeInfo *info); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfoPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfoPrivate.h deleted file mode 100644 index 0ccc007b3..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitMimeInfoPrivate.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitMimeInfoPrivate_h -#define WebKitMimeInfoPrivate_h - -#include "WebKitMimeInfo.h" -#include "WebKitPrivate.h" -#include <WebCore/PluginData.h> - -WebKitMimeInfo* webkitMimeInfoCreate(const WebCore::MimeClassInfo&); - -#endif // WebKitMimeInfoPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecision.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecision.cpp deleted file mode 100644 index deef50c55..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecision.cpp +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitNavigationPolicyDecision.h" - -#include "WebEvent.h" -#include "WebKitEnumTypes.h" -#include "WebKitPolicyDecisionPrivate.h" -#include "WebKitURIRequestPrivate.h" -#include "WebURLRequest.h" -#include <glib/gi18n-lib.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -using namespace WebKit; -using namespace WebCore; - -/** - * SECTION: WebKitNavigationPolicyDecision - * @Short_description: A policy decision for navigation actions - * @Title: WebKitNavigationPolicyDecision - * @See_also: #WebKitPolicyDecision, #WebKitWebView - * - * WebKitNavigationPolicyDecision represents a policy decision for events associated with - * navigations. If the value of #WebKitNavigationPolicyDecision:mouse-button is not 0, then - * the navigation was triggered by a mouse event. - */ - -struct _WebKitNavigationPolicyDecisionPrivate { - WebKitNavigationType navigationType; - unsigned modifiers; - unsigned mouseButton; - GRefPtr<WebKitURIRequest> request; - CString frameName; -}; - -WEBKIT_DEFINE_TYPE(WebKitNavigationPolicyDecision, webkit_navigation_policy_decision, WEBKIT_TYPE_POLICY_DECISION) - -enum { - PROP_0, - PROP_NAVIGATION_TYPE, - PROP_MOUSE_BUTTON, - PROP_MODIFIERS, - PROP_REQUEST, - PROP_FRAME_NAME, -}; - -static void webkitNavigationPolicyDecisionGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) -{ - WebKitNavigationPolicyDecision* decision = WEBKIT_NAVIGATION_POLICY_DECISION(object); - switch (propId) { - case PROP_NAVIGATION_TYPE: - g_value_set_enum(value, webkit_navigation_policy_decision_get_navigation_type(decision)); - break; - case PROP_MOUSE_BUTTON: - g_value_set_enum(value, webkit_navigation_policy_decision_get_mouse_button(decision)); - break; - case PROP_MODIFIERS: - g_value_set_uint(value, webkit_navigation_policy_decision_get_modifiers(decision)); - break; - case PROP_REQUEST: - g_value_set_object(value, webkit_navigation_policy_decision_get_request(decision)); - break; - case PROP_FRAME_NAME: - g_value_set_string(value, webkit_navigation_policy_decision_get_frame_name(decision)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - break; - } -} - -static void webkit_navigation_policy_decision_class_init(WebKitNavigationPolicyDecisionClass* decisionClass) -{ - GObjectClass* objectClass = G_OBJECT_CLASS(decisionClass); - objectClass->get_property = webkitNavigationPolicyDecisionGetProperty; - - /** - * WebKitNavigationPolicyDecision:navigation-type: - * - * The type of navigation that triggered this policy decision. This is - * useful for enacting different policies depending on what type of user - * action caused the navigation. - */ - g_object_class_install_property(objectClass, - PROP_NAVIGATION_TYPE, - g_param_spec_enum("navigation-type", - _("Navigation type"), - _("The type of navigation triggering this decision"), - WEBKIT_TYPE_NAVIGATION_TYPE, - WEBKIT_NAVIGATION_TYPE_LINK_CLICKED, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitNavigationPolicyDecision:mouse-button: - * - * If the navigation associated with this policy decision was originally - * triggered by a mouse event, this property contains non-zero button number - * of the button triggering that event. The button numbers match those from GDK. - * If the navigation was not triggered by a mouse event, the value of this - * property will be 0. - */ - g_object_class_install_property(objectClass, - PROP_MOUSE_BUTTON, - g_param_spec_uint("mouse-button", - _("Mouse button"), - _("The mouse button used if this decision was triggered by a mouse event"), - 0, G_MAXUINT, 0, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitNavigationPolicyDecision:modifiers: - * - * If the navigation associated with this policy decision was originally - * triggered by a mouse event, this property contains a bitmask of various - * #GdkModifierType values describing the modifiers used for that click. - * If the navigation was not triggered by a mouse event or no modifiers - * were active, the value of this property will be zero. - */ - g_object_class_install_property(objectClass, - PROP_MODIFIERS, - g_param_spec_uint("modifiers", - _("Mouse event modifiers"), - _("The modifiers active if this decision was triggered by a mouse event"), - 0, G_MAXUINT, 0, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitNavigationPolicyDecision:request: - * - * This property contains the #WebKitURIRequest associated with this - * navigation. - */ - g_object_class_install_property(objectClass, - PROP_REQUEST, - g_param_spec_object("request", - _("Navigation URI request"), - _("The URI request that is associated with this navigation"), - WEBKIT_TYPE_URI_REQUEST, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitNavigationPolicyDecision:frame-name: - * - * If this navigation request targets a new frame, this property contains - * the name of that frame. For example if the decision was triggered by clicking a - * link with a target attribute equal to "_blank", this property will contain the - * value of that attribute. In all other cases, this value will be %NULL. - */ - g_object_class_install_property(objectClass, - PROP_FRAME_NAME, - g_param_spec_string("frame-name", - _("Frame name"), - _("The name of the new frame this navigation action targets"), - 0, - WEBKIT_PARAM_READABLE)); -} - -/** - * webkit_navigation_policy_decision_get_navigation_type: - * @decision: a #WebKitNavigationPolicyDecision - * - * Gets the value of the #WebKitNavigationPolicyDecision:navigation-type property. - * - * Returns: The type of navigation triggering this policy decision. - */ -WebKitNavigationType webkit_navigation_policy_decision_get_navigation_type(WebKitNavigationPolicyDecision* decision) -{ - g_return_val_if_fail(WEBKIT_IS_NAVIGATION_POLICY_DECISION(decision), WEBKIT_NAVIGATION_TYPE_OTHER); - return decision->priv->navigationType; -} - -/** - * webkit_navigation_policy_decision_get_mouse_button: - * @decision: a #WebKitNavigationPolicyDecision - * - * Gets the value of the #WebKitNavigationPolicyDecision:mouse-button property. - * - * Returns: The mouse button used if this decision was triggered by a mouse event or 0 otherwise - */ -guint webkit_navigation_policy_decision_get_mouse_button(WebKitNavigationPolicyDecision* decision) -{ - g_return_val_if_fail(WEBKIT_IS_NAVIGATION_POLICY_DECISION(decision), 0); - return decision->priv->mouseButton; -} - -/** - * webkit_navigation_policy_decision_get_modifiers: - * @decision: a #WebKitNavigationPolicyDecision - * - * Gets the value of the #WebKitNavigationPolicyDecision:modifiers property. - * - * Returns: The modifiers active if this decision was triggered by a mouse event - */ -unsigned webkit_navigation_policy_decision_get_modifiers(WebKitNavigationPolicyDecision* decision) -{ - g_return_val_if_fail(WEBKIT_IS_NAVIGATION_POLICY_DECISION(decision), 0); - return decision->priv->modifiers; -} - -/** - * webkit_navigation_policy_decision_get_request: - * @decision: a #WebKitNavigationPolicyDecision - * - * Gets the value of the #WebKitNavigationPolicyDecision:request property. - * - * Returns: (transfer none): The URI request that is associated with this navigation - */ -WebKitURIRequest* webkit_navigation_policy_decision_get_request(WebKitNavigationPolicyDecision* decision) -{ - g_return_val_if_fail(WEBKIT_IS_NAVIGATION_POLICY_DECISION(decision), 0); - return decision->priv->request.get(); -} - -/** - * webkit_navigation_policy_decision_get_frame_name: - * @decision: a #WebKitNavigationPolicyDecision - * - * Gets the value of the #WebKitNavigationPolicyDecision:frame-name property. - * - * Returns: The name of the new frame this navigation action targets or %NULL - */ -const char* webkit_navigation_policy_decision_get_frame_name(WebKitNavigationPolicyDecision* decision) -{ - g_return_val_if_fail(WEBKIT_IS_NAVIGATION_POLICY_DECISION(decision), 0); - return decision->priv->frameName.data(); -} - -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NAVIGATION_TYPE_LINK_CLICKED, NavigationTypeLinkClicked); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED, NavigationTypeFormSubmitted); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NAVIGATION_TYPE_BACK_FORWARD, NavigationTypeBackForward); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NAVIGATION_TYPE_RELOAD, NavigationTypeReload); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED, NavigationTypeFormResubmitted); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NAVIGATION_TYPE_OTHER, NavigationTypeOther); - -WebKitNavigationPolicyDecision* webkitNavigationPolicyDecisionCreate(WebKitNavigationType navigationType, unsigned mouseButton, unsigned modifiers, WebURLRequest* request, const char* frameName, WebFramePolicyListenerProxy* listener) -{ - WebKitNavigationPolicyDecision* decision = WEBKIT_NAVIGATION_POLICY_DECISION(g_object_new(WEBKIT_TYPE_NAVIGATION_POLICY_DECISION, NULL)); - decision->priv->navigationType = navigationType; - decision->priv->mouseButton = mouseButton; - decision->priv->modifiers = modifiers; - decision->priv->request = adoptGRef(webkitURIRequestCreateForResourceRequest(request->resourceRequest())); - decision->priv->frameName = frameName; - webkitPolicyDecisionSetListener(WEBKIT_POLICY_DECISION(decision), listener); - return decision; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecision.h b/Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecision.h deleted file mode 100644 index 751397731..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecision.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitNavigationPolicyDecision_h -#define WebKitNavigationPolicyDecision_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> -#include <webkit2/WebKitPolicyDecision.h> -#include <webkit2/WebKitURIRequest.h> - -G_BEGIN_DECLS - -/** - * WebKitNavigationType: - * @WEBKIT_NAVIGATION_TYPE_LINK_CLICKED: The navigation was triggered by clicking a link. - * @WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED: The navigation was triggered by submitting a form. - * @WEBKIT_NAVIGATION_TYPE_BACK_FORWARD: The navigation was triggered by navigating forward or backward. - * @WEBKIT_NAVIGATION_TYPE_RELOAD: The navigation was triggered by reloading. - * @WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED: The navigation was triggered by resubmitting a form. - * @WEBKIT_NAVIGATION_TYPE_OTHER: The navigation was triggered by some other action. - * - * Enum values used to denote the various navigation types. - */ -typedef enum { - WEBKIT_NAVIGATION_TYPE_LINK_CLICKED, - WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED, - WEBKIT_NAVIGATION_TYPE_BACK_FORWARD, - WEBKIT_NAVIGATION_TYPE_RELOAD, - WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED, - WEBKIT_NAVIGATION_TYPE_OTHER, -} WebKitNavigationType; - -#define WEBKIT_TYPE_NAVIGATION_POLICY_DECISION (webkit_navigation_policy_decision_get_type()) -#define WEBKIT_NAVIGATION_POLICY_DECISION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_NAVIGATION_POLICY_DECISION, WebKitNavigationPolicyDecision)) -#define WEBKIT_NAVIGATION_POLICY_DECISION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_NAVIGATION_POLICY_DECISION, WebKitNavigationPolicyDecisionClass)) -#define WEBKIT_IS_NAVIGATION_POLICY_DECISION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_NAVIGATION_POLICY_DECISION)) -#define WEBKIT_IS_NAVIGATION_POLICY_DECISION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_NAVIGATION_POLICY_DECISION)) -#define WEBKIT_NAVIGATION_POLICY_DECISION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_NAVIGATION_POLICY_DECISION, WebKitNavigationPolicyDecisionClass)) - -typedef struct _WebKitNavigationPolicyDecision WebKitNavigationPolicyDecision; -typedef struct _WebKitNavigationPolicyDecisionClass WebKitNavigationPolicyDecisionClass; -typedef struct _WebKitNavigationPolicyDecisionPrivate WebKitNavigationPolicyDecisionPrivate; - -struct _WebKitNavigationPolicyDecision { - WebKitPolicyDecision parent; - - /*< private >*/ - WebKitNavigationPolicyDecisionPrivate *priv; -}; - -struct _WebKitNavigationPolicyDecisionClass { - WebKitPolicyDecisionClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_navigation_policy_decision_get_type (void); - -WEBKIT_API WebKitNavigationType -webkit_navigation_policy_decision_get_navigation_type (WebKitNavigationPolicyDecision *decision); -WEBKIT_API guint -webkit_navigation_policy_decision_get_mouse_button (WebKitNavigationPolicyDecision *decision); -WEBKIT_API guint -webkit_navigation_policy_decision_get_modifiers (WebKitNavigationPolicyDecision *decision); -WEBKIT_API WebKitURIRequest * -webkit_navigation_policy_decision_get_request (WebKitNavigationPolicyDecision *decision); -WEBKIT_API const gchar * -webkit_navigation_policy_decision_get_frame_name (WebKitNavigationPolicyDecision *decision); -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecisionPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecisionPrivate.h deleted file mode 100644 index d90f1c6c8..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecisionPrivate.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitNavigationPolicyDecisionPrivate_h -#define WebKitNavigationPolicyDecisionPrivate_h - -#include "WebKitNavigationPolicyDecision.h" -#include "WebKitPrivate.h" - -WebKitNavigationPolicyDecision* webkitNavigationPolicyDecisionCreate(WebKitNavigationType, unsigned mouseButton, unsigned modifiers, WebKit::WebURLRequest*, const char* frameName, WebKit::WebFramePolicyListenerProxy*); - -#endif // WebKitNavigationPolicyDecisionPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.cpp deleted file mode 100644 index 92235cef1..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitPermissionRequest.h" - -/** - * SECTION: WebKitPermissionRequest - * @Short_description: A permission request - * @Title: WebKitPermissionRequest - * @See_also: #WebKitWebView - * - * There are situations where an embedder would need to ask the user - * for permission to do certain types of operations, such as switching - * to fullscreen mode or reporting the user's location through the - * standard Geolocation API. In those cases, WebKit will emit a - * #WebKitWebView::permission-request signal with a - * #WebKitPermissionRequest object attached to it. - */ - -typedef WebKitPermissionRequestIface WebKitPermissionRequestInterface; -G_DEFINE_INTERFACE(WebKitPermissionRequest, webkit_permission_request, G_TYPE_OBJECT) - -static void webkit_permission_request_default_init(WebKitPermissionRequestIface*) -{ -} - -/** - * webkit_permission_request_allow: - * @request: a #WebKitPermissionRequest - * - * Allow the action which triggered this request. - */ -void webkit_permission_request_allow(WebKitPermissionRequest* request) -{ - g_return_if_fail(WEBKIT_IS_PERMISSION_REQUEST(request)); - - WebKitPermissionRequestIface* iface = WEBKIT_PERMISSION_REQUEST_GET_IFACE(request); - if (iface->allow) - iface->allow(request); -} - -/** - * webkit_permission_request_deny: - * @request: a #WebKitPermissionRequest - * - * Deny the action which triggered this request. - */ -void webkit_permission_request_deny(WebKitPermissionRequest* request) -{ - g_return_if_fail(WEBKIT_IS_PERMISSION_REQUEST(request)); - - WebKitPermissionRequestIface* iface = WEBKIT_PERMISSION_REQUEST_GET_IFACE(request); - if (iface->deny) - iface->deny(request); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.h deleted file mode 100644 index a62f1f1a5..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitPermissionRequest_h -#define WebKitPermissionRequest_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_PERMISSION_REQUEST (webkit_permission_request_get_type()) -#define WEBKIT_PERMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_PERMISSION_REQUEST, WebKitPermissionRequest)) -#define WEBKIT_IS_PERMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_PERMISSION_REQUEST)) -#define WEBKIT_PERMISSION_REQUEST_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), WEBKIT_TYPE_PERMISSION_REQUEST, WebKitPermissionRequestIface)) - -typedef struct _WebKitPermissionRequest WebKitPermissionRequest; -typedef struct _WebKitPermissionRequestIface WebKitPermissionRequestIface; - -struct _WebKitPermissionRequestIface { - GTypeInterface parent_interface; - - void (* allow) (WebKitPermissionRequest *request); - void (* deny) (WebKitPermissionRequest *request); -}; - -WEBKIT_API GType -webkit_permission_request_get_type (void); - -WEBKIT_API void -webkit_permission_request_allow (WebKitPermissionRequest *request); - -WEBKIT_API void -webkit_permission_request_deny (WebKitPermissionRequest *request); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPlugin.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitPlugin.cpp deleted file mode 100644 index 977afa450..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPlugin.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitPlugin.h" - -#include "WebKitMimeInfoPrivate.h" -#include "WebKitPluginPrivate.h" -#include <wtf/text/CString.h> - -using namespace WebKit; - -/** - * SECTION: WebKitPlugin - * @Short_description: Represents a plugin, enabling fine-grained control - * @Title: WebKitPlugin - * - * This object represents a single plugin, found while scanning the - * various platform plugin directories. This object can be used to get - * more information about a plugin, and enable/disable it, allowing - * fine-grained control of plugins. The list of available plugins can - * be obtained from the #WebKitWebContext, with - * webkit_web_context_get_plugins(). - * - */ - -struct _WebKitPluginPrivate { - ~_WebKitPluginPrivate() - { - g_list_free_full(mimeInfoList, reinterpret_cast<GDestroyNotify>(webkit_mime_info_unref)); - } - - PluginModuleInfo pluginInfo; - CString name; - CString description; - CString path; - GList* mimeInfoList; -}; - -WEBKIT_DEFINE_TYPE(WebKitPlugin, webkit_plugin, G_TYPE_OBJECT) - -static void webkit_plugin_class_init(WebKitPluginClass* pluginClass) -{ -} - -WebKitPlugin* webkitPluginCreate(const PluginModuleInfo& pluginInfo) -{ - WebKitPlugin* plugin = WEBKIT_PLUGIN(g_object_new(WEBKIT_TYPE_PLUGIN, NULL)); - plugin->priv->pluginInfo = pluginInfo; - return plugin; -} - -/** - * webkit_plugin_get_name: - * @plugin: a #WebKitPlugin - * - * Returns: the name of the plugin. - */ -const char* webkit_plugin_get_name(WebKitPlugin* plugin) -{ - g_return_val_if_fail(WEBKIT_IS_PLUGIN(plugin), 0); - - if (!plugin->priv->name.isNull()) - return plugin->priv->name.data(); - - if (plugin->priv->pluginInfo.info.name.isEmpty()) - return 0; - - plugin->priv->name = plugin->priv->pluginInfo.info.name.utf8(); - return plugin->priv->name.data(); -} - -/** - * webkit_plugin_get_description: - * @plugin: a #WebKitPlugin - * - * Returns: the description of the plugin. - */ -const char* webkit_plugin_get_description(WebKitPlugin* plugin) -{ - g_return_val_if_fail(WEBKIT_IS_PLUGIN(plugin), 0); - - if (!plugin->priv->description.isNull()) - plugin->priv->description.data(); - - if (plugin->priv->pluginInfo.info.desc.isEmpty()) - return 0; - - plugin->priv->description = plugin->priv->pluginInfo.info.desc.utf8(); - return plugin->priv->description.data(); -} - -/** - * webkit_plugin_get_path: - * @plugin: a #WebKitPlugin - * - * Returns: the absolute path where the plugin is installed. - */ -const char* webkit_plugin_get_path(WebKitPlugin* plugin) -{ - g_return_val_if_fail(WEBKIT_IS_PLUGIN(plugin), 0); - - if (!plugin->priv->path.isNull()) - return plugin->priv->path.data(); - - if (plugin->priv->pluginInfo.path.isEmpty()) - return 0; - - plugin->priv->path = plugin->priv->pluginInfo.path.utf8(); - return plugin->priv->path.data(); -} - -/** - * webkit_plugin_get_mime_info_list: - * @plugin: a #WebKitPlugin - * - * Get information about MIME types handled by the plugin, - * as a list of #WebKitMimeInfo. - * - * Returns: (element-type WebKitMimeInfo) (transfer none): a #GList of #WebKitMimeInfo. - */ -GList* webkit_plugin_get_mime_info_list(WebKitPlugin* plugin) -{ - g_return_val_if_fail(WEBKIT_IS_PLUGIN(plugin), 0); - - if (plugin->priv->mimeInfoList) - return plugin->priv->mimeInfoList; - - if (plugin->priv->pluginInfo.info.mimes.isEmpty()) - return 0; - - for (size_t i = 0; i < plugin->priv->pluginInfo.info.mimes.size(); ++i) - plugin->priv->mimeInfoList = g_list_prepend(plugin->priv->mimeInfoList, webkitMimeInfoCreate(plugin->priv->pluginInfo.info.mimes[i])); - return plugin->priv->mimeInfoList; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPlugin.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPlugin.h deleted file mode 100644 index d7533c920..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPlugin.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitPlugin_h -#define WebKitPlugin_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_PLUGIN (webkit_plugin_get_type()) -#define WEBKIT_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_PLUGIN, WebKitPlugin)) -#define WEBKIT_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_PLUGIN)) -#define WEBKIT_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_PLUGIN, WebKitPluginClass)) -#define WEBKIT_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_PLUGIN)) -#define WEBKIT_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_PLUGIN, WebKitPluginClass)) - -typedef struct _WebKitPlugin WebKitPlugin; -typedef struct _WebKitPluginClass WebKitPluginClass; -typedef struct _WebKitPluginPrivate WebKitPluginPrivate; - -struct _WebKitPlugin { - GObject parent; - - WebKitPluginPrivate *priv; -}; - -struct _WebKitPluginClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_plugin_get_type (void); - -WEBKIT_API const gchar * -webkit_plugin_get_name (WebKitPlugin *plugin); - -WEBKIT_API const gchar * -webkit_plugin_get_description (WebKitPlugin *plugin); - -WEBKIT_API const gchar * -webkit_plugin_get_path (WebKitPlugin *plugin); - -WEBKIT_API GList * -webkit_plugin_get_mime_info_list (WebKitPlugin *plugin); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPluginPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPluginPrivate.h deleted file mode 100644 index 3fe2ac0bf..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPluginPrivate.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitPluginPrivate_h -#define WebKitPluginPrivate_h - -#include "PluginModuleInfo.h" -#include "WebKitPlugin.h" -#include "WebKitPrivate.h" - -WebKitPlugin* webkitPluginCreate(const WebKit::PluginModuleInfo&); - -#endif // WebKitPluginPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyClient.cpp deleted file mode 100644 index 72a5266cc..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyClient.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitPolicyClient.h" - -#include "WebKitNavigationPolicyDecisionPrivate.h" -#include "WebKitResponsePolicyDecisionPrivate.h" -#include "WebKitWebViewBasePrivate.h" -#include "WebKitWebViewPrivate.h" -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -using namespace WebKit; - -static void decidePolicyForNavigationActionCallback(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo) -{ - GRefPtr<WebKitNavigationPolicyDecision> decision = - adoptGRef(webkitNavigationPolicyDecisionCreate(static_cast<WebKitNavigationType>(navigationType), - wkEventMouseButtonToWebKitMouseButton(mouseButton), - wkEventModifiersToGdkModifiers(modifiers), - toImpl(request), - 0, /* frame name */ - toImpl(listener))); - webkitWebViewMakePolicyDecision(WEBKIT_WEB_VIEW(clientInfo), - WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION, - WEBKIT_POLICY_DECISION(decision.get())); -} - -static void decidePolicyForNewWindowActionCallback(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKStringRef frameName, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo) -{ - GRefPtr<WebKitNavigationPolicyDecision> decision = - adoptGRef(webkitNavigationPolicyDecisionCreate(static_cast<WebKitNavigationType>(navigationType), - wkEventMouseButtonToWebKitMouseButton(mouseButton), - wkEventModifiersToGdkModifiers(modifiers), - toImpl(request), - toImpl(frameName)->string().utf8().data(), - toImpl(listener))); - webkitWebViewMakePolicyDecision(WEBKIT_WEB_VIEW(clientInfo), - WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION, - WEBKIT_POLICY_DECISION(decision.get())); -} - -static void decidePolicyForResponseCallback(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo) -{ - GRefPtr<WebKitResponsePolicyDecision> decision = - adoptGRef(webkitResponsePolicyDecisionCreate(toImpl(request), toImpl(response), toImpl(listener))); - webkitWebViewMakePolicyDecision(WEBKIT_WEB_VIEW(clientInfo), - WEBKIT_POLICY_DECISION_TYPE_RESPONSE, - WEBKIT_POLICY_DECISION(decision.get())); -} - -void attachPolicyClientToView(WebKitWebView* webView) -{ - WKPagePolicyClient policyClient = { - kWKPagePolicyClientCurrentVersion, - webView, // clientInfo - decidePolicyForNavigationActionCallback, - decidePolicyForNewWindowActionCallback, - decidePolicyForResponseCallback, - 0, // unableToImplementPolicy - }; - WKPageSetPagePolicyClient(toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))), &policyClient); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyClient.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyClient.h deleted file mode 100644 index 23dfcbb52..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyClient.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitPolicyClient_h -#define WebKitPolicyClient_h - -#include "WebKitWebView.h" - -void attachPolicyClientToView(WebKitWebView*); - -#endif // WebKitPolicyClient_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecision.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecision.cpp deleted file mode 100644 index ee44eaebb..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecision.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitPolicyDecision.h" - -#include "WebFramePolicyListenerProxy.h" -#include "WebKitPolicyDecisionPrivate.h" - -using namespace WebKit; - -/** - * SECTION: WebKitPolicyDecision - * @Short_description: A pending policy decision - * @Title: WebKitPolicyDecision - * @See_also: #WebKitWebView - * - * Often WebKit allows the client to decide the policy for certain - * operations. For instance, a client may want to open a link in a new - * tab, block a navigation entirely, query the user or trigger a download - * instead of a navigation. In these cases WebKit will fire the - * #WebKitWebView::decide-policy signal with a #WebKitPolicyDecision - * object. If the signal handler does nothing, WebKit will act as if - * webkit_policy_decision_use() was called as soon as signal handling - * completes. To make a policy decision asynchronously, simply increment - * the reference count of the #WebKitPolicyDecision object. - */ - -struct _WebKitPolicyDecisionPrivate { - RefPtr<WebFramePolicyListenerProxy> listener; - bool madePolicyDecision; -}; - -WEBKIT_DEFINE_ABSTRACT_TYPE(WebKitPolicyDecision, webkit_policy_decision, G_TYPE_OBJECT) - -static void webkitPolicyDecisionDispose(GObject* object) -{ - webkit_policy_decision_use(WEBKIT_POLICY_DECISION(object)); - G_OBJECT_CLASS(webkit_policy_decision_parent_class)->dispose(object); -} - -void webkitPolicyDecisionSetListener(WebKitPolicyDecision* decision, WebFramePolicyListenerProxy* listener) -{ - decision->priv->listener = listener; -} - -static void webkit_policy_decision_class_init(WebKitPolicyDecisionClass* decisionClass) -{ - GObjectClass* objectClass = G_OBJECT_CLASS(decisionClass); - objectClass->dispose = webkitPolicyDecisionDispose; -} - -/** - * webkit_policy_decision_use: - * @decision: a #WebKitPolicyDecision - * - * Accept the action which triggerd this decision. - */ -void webkit_policy_decision_use(WebKitPolicyDecision* decision) -{ - g_return_if_fail(WEBKIT_IS_POLICY_DECISION(decision)); - - if (decision->priv->madePolicyDecision) - return; - - decision->priv->listener->use(); - decision->priv->madePolicyDecision = true; -} - -/** - * webkit_policy_decision_ignore: - * @decision: a #WebKitPolicyDecision - * - * Ignore the action which triggerd this decision. For instance, for a - * #WebKitResponsePolicyDecision, this would cancel the request. - */ -void webkit_policy_decision_ignore(WebKitPolicyDecision* decision) -{ - g_return_if_fail(WEBKIT_IS_POLICY_DECISION(decision)); - - if (decision->priv->madePolicyDecision) - return; - - decision->priv->listener->ignore(); - decision->priv->madePolicyDecision = true; -} - -/** - * webkit_policy_decision_download: - * @decision: a #WebKitPolicyDecision - * - * Spawn a download from this decision. - */ -void webkit_policy_decision_download(WebKitPolicyDecision* decision) -{ - g_return_if_fail(WEBKIT_IS_POLICY_DECISION(decision)); - - if (decision->priv->madePolicyDecision) - return; - - decision->priv->listener->download(); - decision->priv->madePolicyDecision = true; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecision.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecision.h deleted file mode 100644 index f192a1d37..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecision.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitPolicyDecision_h -#define WebKitPolicyDecision_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_POLICY_DECISION (webkit_policy_decision_get_type()) -#define WEBKIT_POLICY_DECISION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_POLICY_DECISION, WebKitPolicyDecision)) -#define WEBKIT_POLICY_DECISION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_POLICY_DECISION, WebKitPolicyDecisionClass)) -#define WEBKIT_IS_POLICY_DECISION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_POLICY_DECISION)) -#define WEBKIT_IS_POLICY_DECISION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_POLICY_DECISION)) -#define WEBKIT_POLICY_DECISION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_POLICY_DECISION, WebKitPolicyDecisionClass)) - -typedef struct _WebKitPolicyDecision WebKitPolicyDecision; -typedef struct _WebKitPolicyDecisionClass WebKitPolicyDecisionClass; -typedef struct _WebKitPolicyDecisionPrivate WebKitPolicyDecisionPrivate; - -struct _WebKitPolicyDecision { - GObject parent; - - /*< private >*/ - WebKitPolicyDecisionPrivate *priv; -}; - -struct _WebKitPolicyDecisionClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_policy_decision_get_type (void); - -WEBKIT_API void -webkit_policy_decision_use (WebKitPolicyDecision *decision); - -WEBKIT_API void -webkit_policy_decision_ignore (WebKitPolicyDecision *decision); - -WEBKIT_API void -webkit_policy_decision_download (WebKitPolicyDecision *decision); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecisionPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecisionPrivate.h deleted file mode 100644 index 0af6081ed..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecisionPrivate.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitPolicyDecisionPrivate_h -#define WebKitPolicyDecisionPrivate_h - -#include "WebKitPolicyDecision.h" -#include "WebKitPrivate.h" - -void webkitPolicyDecisionSetListener(WebKitPolicyDecision*, WebKit::WebFramePolicyListenerProxy*); - -#endif // WebKitResponsePolicyDecisionPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp deleted file mode 100644 index 068a28cdd..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp +++ /dev/null @@ -1,439 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitPrintOperation.h" - -#include "PrintInfo.h" -#include "WebKitPrintOperationPrivate.h" -#include "WebKitPrivate.h" -#include "WebKitWebViewBasePrivate.h" -#include "WebPageProxy.h" -#include <WebCore/GtkUtilities.h> -#include <WebCore/NotImplemented.h> -#include <glib/gi18n-lib.h> -#include <wtf/gobject/GOwnPtr.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -#ifdef HAVE_GTK_UNIX_PRINTING -#include <gtk/gtkunixprint.h> -#endif - -using namespace WebKit; - -/** - * SECTION: WebKitPrintOperation - * @Short_description: Controls a print operation - * @Title: WebKitPrintOperation - * - * A #WebKitPrintOperation controls a print operation in WebKit. With - * a similar API to #GtkPrintOperation, it lets you set the print - * settings with webkit_print_operation_set_print_settings() or - * display the print dialog with webkit_print_operation_run_dialog(). - * - */ - -enum { - PROP_0, - - PROP_WEB_VIEW, - PROP_PRINT_SETTINGS, - PROP_PAGE_SETUP -}; - -enum { - FINISHED, - FAILED, - - LAST_SIGNAL -}; - -struct _WebKitPrintOperationPrivate { - ~_WebKitPrintOperationPrivate() - { - g_signal_handler_disconnect(webView, webViewDestroyedId); - } - - WebKitWebView* webView; - gulong webViewDestroyedId; - - GRefPtr<GtkPrintSettings> printSettings; - GRefPtr<GtkPageSetup> pageSetup; -}; - -static guint signals[LAST_SIGNAL] = { 0, }; - -WEBKIT_DEFINE_TYPE(WebKitPrintOperation, webkit_print_operation, G_TYPE_OBJECT) - -static void webViewDestroyed(GtkWidget* webView, GObject* printOperation) -{ - g_object_unref(printOperation); -} - -static void webkitPrintOperationConstructed(GObject* object) -{ - WebKitPrintOperation* printOperation = WEBKIT_PRINT_OPERATION(object); - WebKitPrintOperationPrivate* priv = printOperation->priv; - - if (G_OBJECT_CLASS(webkit_print_operation_parent_class)->constructed) - G_OBJECT_CLASS(webkit_print_operation_parent_class)->constructed(object); - - priv->webViewDestroyedId = g_signal_connect(priv->webView, "destroy", G_CALLBACK(webViewDestroyed), printOperation); -} - -static void webkitPrintOperationGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) -{ - WebKitPrintOperation* printOperation = WEBKIT_PRINT_OPERATION(object); - - switch (propId) { - case PROP_WEB_VIEW: - g_value_take_object(value, printOperation->priv->webView); - break; - case PROP_PRINT_SETTINGS: - g_value_set_object(value, printOperation->priv->printSettings.get()); - break; - case PROP_PAGE_SETUP: - g_value_set_object(value, printOperation->priv->pageSetup.get()); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static void webkitPrintOperationSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec) -{ - WebKitPrintOperation* printOperation = WEBKIT_PRINT_OPERATION(object); - - switch (propId) { - case PROP_WEB_VIEW: - printOperation->priv->webView = WEBKIT_WEB_VIEW(g_value_get_object(value)); - break; - case PROP_PRINT_SETTINGS: - webkit_print_operation_set_print_settings(printOperation, GTK_PRINT_SETTINGS(g_value_get_object(value))); - break; - case PROP_PAGE_SETUP: - webkit_print_operation_set_page_setup(printOperation, GTK_PAGE_SETUP(g_value_get_object(value))); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static void webkit_print_operation_class_init(WebKitPrintOperationClass* printOperationClass) -{ - GObjectClass* gObjectClass = G_OBJECT_CLASS(printOperationClass); - gObjectClass->constructed = webkitPrintOperationConstructed; - gObjectClass->get_property = webkitPrintOperationGetProperty; - gObjectClass->set_property = webkitPrintOperationSetProperty; - - /** - * WebKitPrintOperation:web-view: - * - * The #WebKitWebView that will be printed. - */ - g_object_class_install_property(gObjectClass, - PROP_WEB_VIEW, - g_param_spec_object("web-view", - _("Web View"), - _("The web view that will be printed"), - WEBKIT_TYPE_WEB_VIEW, - static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY))); - - /** - * WebKitPrintOperation:print-settings: - * - * The initial #GtkPrintSettings for the print operation. - */ - g_object_class_install_property(gObjectClass, - PROP_PRINT_SETTINGS, - g_param_spec_object("print-settings", - _("Print Settings"), - _("The initial print settings for the print operation"), - GTK_TYPE_PRINT_SETTINGS, - WEBKIT_PARAM_READWRITE)); - /** - * WebKitPrintOperation:page-setup: - * - * The initial #GtkPageSetup for the print operation. - */ - g_object_class_install_property(gObjectClass, - PROP_PAGE_SETUP, - g_param_spec_object("page-setup", - _("Page Setup"), - _("The initial page setup for the print operation"), - GTK_TYPE_PAGE_SETUP, - WEBKIT_PARAM_READWRITE)); - - /** - * WebKitPrintOperation::finished: - * @print_operation: the #WebKitPrintOperation on which the signal was emitted - * - * Emitted when the print operation has finished doing everything - * required for printing. - */ - signals[FINISHED] = - g_signal_new("finished", - G_TYPE_FROM_CLASS(gObjectClass), - G_SIGNAL_RUN_LAST, - 0, 0, 0, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /** - * WebKitPrintOperation::failed: - * @print_operation: the #WebKitPrintOperation on which the signal was emitted - * @error: the #GError that was triggered - * - * Emitted when an error occurs while printing. The given @error, of the domain - * %WEBKIT_PRINT_ERROR, contains further details of the failure. - * The #WebKitPrintOperation::finished signal is emitted after this one. - */ - signals[FAILED] = - g_signal_new("failed", - G_TYPE_FROM_CLASS(gObjectClass), - G_SIGNAL_RUN_LAST, - 0, 0, 0, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); -} - -#ifdef HAVE_GTK_UNIX_PRINTING -static WebKitPrintOperationResponse webkitPrintOperationRunDialog(WebKitPrintOperation* printOperation, GtkWindow* parent) -{ - GtkPrintUnixDialog* printDialog = GTK_PRINT_UNIX_DIALOG(gtk_print_unix_dialog_new(0, parent)); - gtk_print_unix_dialog_set_manual_capabilities(printDialog, static_cast<GtkPrintCapabilities>(GTK_PRINT_CAPABILITY_NUMBER_UP - | GTK_PRINT_CAPABILITY_NUMBER_UP_LAYOUT - | GTK_PRINT_CAPABILITY_PAGE_SET - | GTK_PRINT_CAPABILITY_REVERSE - | GTK_PRINT_CAPABILITY_COPIES - | GTK_PRINT_CAPABILITY_COLLATE - | GTK_PRINT_CAPABILITY_SCALE)); - - WebKitPrintOperationPrivate* priv = printOperation->priv; - if (priv->printSettings) - gtk_print_unix_dialog_set_settings(printDialog, priv->printSettings.get()); - - if (priv->pageSetup) - gtk_print_unix_dialog_set_page_setup(printDialog, priv->pageSetup.get()); - - gtk_print_unix_dialog_set_embed_page_setup(printDialog, TRUE); - - WebKitPrintOperationResponse returnValue = WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL; - if (gtk_dialog_run(GTK_DIALOG(printDialog)) == GTK_RESPONSE_OK) { - priv->printSettings = adoptGRef(gtk_print_unix_dialog_get_settings(printDialog)); - priv->pageSetup = gtk_print_unix_dialog_get_page_setup(printDialog); - returnValue = WEBKIT_PRINT_OPERATION_RESPONSE_PRINT; - } - - gtk_widget_destroy(GTK_WIDGET(printDialog)); - - return returnValue; -} -#else -// TODO: We need to add an implementation for Windows. -static WebKitPrintOperationResponse webkitPrintOperationRunDialog(WebKitPrintOperation*, GtkWindow*) -{ - notImplemented(); - return WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL; -} -#endif - -static void drawPagesForPrintingCompleted(WKErrorRef wkPrintError, WKErrorRef, void* context) -{ - GRefPtr<WebKitPrintOperation> printOperation = adoptGRef(WEBKIT_PRINT_OPERATION(context)); - WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(printOperation->priv->webView)); - page->endPrinting(); - - const WebCore::ResourceError& resourceError = toImpl(wkPrintError)->platformError(); - if (!resourceError.isNull()) { - GOwnPtr<GError> printError(g_error_new_literal(g_quark_from_string(resourceError.domain().utf8().data()), - resourceError.errorCode(), - resourceError.localizedDescription().utf8().data())); - g_signal_emit(printOperation.get(), signals[FAILED], 0, printError.get()); - } - g_signal_emit(printOperation.get(), signals[FINISHED], 0, NULL); -} - -static void webkitPrintOperationPrintPagesForFrame(WebKitPrintOperation* printOperation, WebFrameProxy* webFrame, GtkPrintSettings* printSettings, GtkPageSetup* pageSetup) -{ - PrintInfo printInfo(printSettings, pageSetup); - WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(printOperation->priv->webView)); - page->drawPagesForPrinting(webFrame, printInfo, PrintFinishedCallback::create(g_object_ref(printOperation), &drawPagesForPrintingCompleted)); -} - -WebKitPrintOperationResponse webkitPrintOperationRunDialogForFrame(WebKitPrintOperation* printOperation, GtkWindow* parent, WebFrameProxy* webFrame) -{ - WebKitPrintOperationPrivate* priv = printOperation->priv; - if (!parent) { - GtkWidget* toplevel = gtk_widget_get_toplevel(GTK_WIDGET(priv->webView)); - if (WebCore::widgetIsOnscreenToplevelWindow(toplevel)) - parent = GTK_WINDOW(toplevel); - } - - WebKitPrintOperationResponse response = webkitPrintOperationRunDialog(printOperation, parent); - if (response == WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL) - return response; - - webkitPrintOperationPrintPagesForFrame(printOperation, webFrame, priv->printSettings.get(), priv->pageSetup.get()); - return response; -} - -/** - * webkit_print_operation_new: - * @web_view: a #WebKitWebView - * - * Create a new #WebKitPrintOperation to print @web_view contents. - * - * Returns: (transfer full): a new #WebKitPrintOperation. - */ -WebKitPrintOperation* webkit_print_operation_new(WebKitWebView* webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - - return WEBKIT_PRINT_OPERATION(g_object_new(WEBKIT_TYPE_PRINT_OPERATION, "web-view", webView, NULL)); -} - -/** - * webkit_print_operation_get_print_settings: - * @print_operation: a #WebKitPrintOperation - * - * Return the current print settings of @print_operation. It returns %NULL until - * either webkit_print_operation_set_print_settings() or webkit_print_operation_run_dialog() - * have been called. - * - * Returns: (transfer none): the current #GtkPrintSettings of @print_operation. - */ -GtkPrintSettings* webkit_print_operation_get_print_settings(WebKitPrintOperation* printOperation) -{ - g_return_val_if_fail(WEBKIT_IS_PRINT_OPERATION(printOperation), 0); - - return printOperation->priv->printSettings.get(); -} - -/** - * webkit_print_operation_set_print_settings: - * @print_operation: a #WebKitPrintOperation - * @print_settings: a #GtkPrintSettings to set - * - * Set the current print settings of @print_operation. Current print settings are used for - * the initial values of the print dialog when webkit_print_operation_run_dialog() is called. - */ -void webkit_print_operation_set_print_settings(WebKitPrintOperation* printOperation, GtkPrintSettings* printSettings) -{ - g_return_if_fail(WEBKIT_IS_PRINT_OPERATION(printOperation)); - g_return_if_fail(GTK_IS_PRINT_SETTINGS(printSettings)); - - if (printOperation->priv->printSettings.get() == printSettings) - return; - - printOperation->priv->printSettings = printSettings; - g_object_notify(G_OBJECT(printOperation), "print-settings"); -} - -/** - * webkit_print_operation_get_page_setup: - * @print_operation: a #WebKitPrintOperation - * - * Return the current page setup of @print_operation. It returns %NULL until - * either webkit_print_operation_set_print_settings() or webkit_print_operation_run_dialog() - * have been called. - * - * Returns: (transfer none): the current #GtkPageSetup of @print_operation. - */ -GtkPageSetup* webkit_print_operation_get_page_setup(WebKitPrintOperation* printOperation) -{ - g_return_val_if_fail(WEBKIT_IS_PRINT_OPERATION(printOperation), 0); - - return printOperation->priv->pageSetup.get(); -} - -/** - * webkit_print_operation_set_page_setup: - * @print_operation: a #WebKitPrintOperation - * @page_setup: a #GtkPageSetup to set - * - * Set the current page setup of @print_operation. Current page setup is used for the - * initial values of the print dialog when webkit_print_operation_run_dialog() is called. - */ -void webkit_print_operation_set_page_setup(WebKitPrintOperation* printOperation, GtkPageSetup* pageSetup) -{ - g_return_if_fail(WEBKIT_IS_PRINT_OPERATION(printOperation)); - g_return_if_fail(GTK_IS_PAGE_SETUP(pageSetup)); - - if (printOperation->priv->pageSetup.get() == pageSetup) - return; - - printOperation->priv->pageSetup = pageSetup; - g_object_notify(G_OBJECT(printOperation), "page-setup"); -} - -/** - * webkit_print_operation_run_dialog: - * @print_operation: a #WebKitPrintOperation - * @parent: (allow-none): transient parent of the print dialog - * - * Run the print dialog and start printing using the options selected by - * the user. This method returns when the print dialog is closed. - * If the print dialog is cancelled %WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL - * is returned. If the user clicks on the print button, %WEBKIT_PRINT_OPERATION_RESPONSE_PRINT - * is returned and the print operation starts. In this case, the #WebKitPrintOperation::finished - * signal is emitted when the operation finishes. If an error occurs while printing, the signal - * #WebKitPrintOperation::failed is emitted before #WebKitPrintOperation::finished. - * If the print dialog is not cancelled current print settings and page setup of @print_operation - * are updated with options selected by the user when Print button is pressed in print dialog. - * You can get the updated print settings and page setup by calling - * webkit_print_operation_get_print_settings() and webkit_print_operation_get_page_setup() - * after this method. - * - * Returns: the #WebKitPrintOperationResponse of the print dialog - */ -WebKitPrintOperationResponse webkit_print_operation_run_dialog(WebKitPrintOperation* printOperation, GtkWindow* parent) -{ - g_return_val_if_fail(WEBKIT_IS_PRINT_OPERATION(printOperation), WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL); - - WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(printOperation->priv->webView)); - return webkitPrintOperationRunDialogForFrame(printOperation, parent, page->mainFrame()); -} - -/** - * webkit_print_operation_print: - * @print_operation: a #WebKitPrintOperation - * - * Start a print operation using current print settings and page setup - * without showing the print dialog. If either print settings or page setup - * are not set with webkit_print_operation_set_print_settings() and - * webkit_print_operation_set_page_setup(), the default options will be used - * and the print job will be sent to the default printer. - * The #WebKitPrintOperation::finished signal is emitted when the printing - * operation finishes. If an error occurs while printing the signal - * #WebKitPrintOperation::failed is emitted before #WebKitPrintOperation::finished. - */ -void webkit_print_operation_print(WebKitPrintOperation* printOperation) -{ - g_return_if_fail(WEBKIT_IS_PRINT_OPERATION(printOperation)); - - WebKitPrintOperationPrivate* priv = printOperation->priv; - GRefPtr<GtkPrintSettings> printSettings = priv->printSettings ? priv->printSettings : adoptGRef(gtk_print_settings_new()); - GRefPtr<GtkPageSetup> pageSetup = priv->pageSetup ? priv->pageSetup : adoptGRef(gtk_page_setup_new()); - - WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(printOperation->priv->webView)); - webkitPrintOperationPrintPagesForFrame(printOperation, page->mainFrame(), printSettings.get(), pageSetup.get()); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.h deleted file mode 100644 index b7159b8c6..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitPrintOperation_h -#define WebKitPrintOperation_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> -#include <webkit2/WebKitForwardDeclarations.h> -#include <webkit2/WebKitWebView.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_PRINT_OPERATION (webkit_print_operation_get_type()) -#define WEBKIT_PRINT_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_PRINT_OPERATION, WebKitPrintOperation)) -#define WEBKIT_IS_PRINT_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_PRINT_OPERATION)) -#define WEBKIT_PRINT_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_PRINT_OPERATION, WebKitPrintOperationClass)) -#define WEBKIT_IS_PRINT_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_PRINT_OPERATION)) -#define WEBKIT_PRINT_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_PRINT_OPERATION, WebKitPrintOperationClass)) - -typedef struct _WebKitPrintOperationClass WebKitPrintOperationClass; -typedef struct _WebKitPrintOperationPrivate WebKitPrintOperationPrivate; - -/** - * WebKitPrintOperationResponse: - * @WEBKIT_PRINT_OPERATION_RESPONSE_PRINT: Print button was cliked in print dialog - * @WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL: Print dialog was cancelled - * - * Enum values representing the response of the print dialog shown with - * webkit_print_operation_run_dialog(). - */ -typedef enum { - WEBKIT_PRINT_OPERATION_RESPONSE_PRINT, - WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL -} WebKitPrintOperationResponse; - -struct _WebKitPrintOperation { - GObject parent; - - WebKitPrintOperationPrivate *priv; -}; - -struct _WebKitPrintOperationClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_print_operation_get_type (void); - -WEBKIT_API WebKitPrintOperation * -webkit_print_operation_new (WebKitWebView *web_view); - -WEBKIT_API GtkPrintSettings * -webkit_print_operation_get_print_settings (WebKitPrintOperation *print_operation); - -WEBKIT_API void -webkit_print_operation_set_print_settings (WebKitPrintOperation *print_operation, - GtkPrintSettings *print_settings); - -WEBKIT_API GtkPageSetup * -webkit_print_operation_get_page_setup (WebKitPrintOperation *print_operation); - -WEBKIT_API void -webkit_print_operation_set_page_setup (WebKitPrintOperation *print_operation, - GtkPageSetup *page_setup); - -WEBKIT_API WebKitPrintOperationResponse -webkit_print_operation_run_dialog (WebKitPrintOperation *print_operation, - GtkWindow *parent); - -WEBKIT_API void -webkit_print_operation_print (WebKitPrintOperation *print_operation); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperationPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperationPrivate.h deleted file mode 100644 index 7a4fb4e43..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperationPrivate.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitPrintOperationPrivate_h -#define WebKitPrintOperationPrivate_h - -#include "WebFrameProxy.h" -#include "WebKitPrintOperation.h" - -WebKitPrintOperationResponse webkitPrintOperationRunDialogForFrame(WebKitPrintOperation*, GtkWindow* parent, WebKit::WebFrameProxy*); - -#endif // WebKitPrintOperationPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.cpp deleted file mode 100644 index d34b9c471..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitPrivate.h" - -#include <gdk/gdk.h> - -unsigned wkEventModifiersToGdkModifiers(WKEventModifiers wkModifiers) -{ - unsigned modifiers = 0; - if (wkModifiers & kWKEventModifiersShiftKey) - modifiers |= GDK_SHIFT_MASK; - if (wkModifiers & kWKEventModifiersControlKey) - modifiers |= GDK_CONTROL_MASK; - if (wkModifiers & kWKEventModifiersAltKey) - modifiers |= GDK_MOD1_MASK; - if (wkModifiers & kWKEventModifiersMetaKey) - modifiers |= GDK_META_MASK; - return modifiers; -} - -unsigned wkEventMouseButtonToWebKitMouseButton(WKEventMouseButton wkButton) -{ - switch (wkButton) { - case kWKEventMouseButtonNoButton: - return 0; - case kWKEventMouseButtonLeftButton: - return 1; - case kWKEventMouseButtonMiddleButton: - return 2; - case kWKEventMouseButtonRightButton: - return 3; - } - ASSERT_NOT_REACHED(); - return 0; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h deleted file mode 100644 index 83904ad9a..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 WebKitPrivate_h -#define WebKitPrivate_h - -#include <WebKit2/WKAPICast.h> -#include <WebKit2/WKContextSoup.h> -#include <WebKit2/WKDownload.h> -#include <WebKit2/WKFindOptions.h> -#include <WebKit2/WKFullScreenClientGtk.h> -#include <WebKit2/WKGeolocationManager.h> -#include <WebKit2/WKGeolocationPermissionRequest.h> -#include <WebKit2/WKGeolocationPosition.h> -#include <WebKit2/WKIconDatabase.h> -#include <WebKit2/WKInspector.h> -#include <WebKit2/WKInspectorClientGtk.h> -#include <WebKit2/WKRetainPtr.h> -#include <WebKit2/WKSerializedScriptValue.h> -#include <WebKit2/WKSoupRequestManager.h> -#include <WebKit2/WKString.h> -#include <WebKit2/WKTextChecker.h> -#include <WebKit2/WebKit2_C.h> -#include <glib.h> -#include <wtf/Assertions.h> - -#define WEBKIT_PARAM_READABLE (static_cast<GParamFlags>(G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)) -#define WEBKIT_PARAM_WRITABLE (static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)) -#define WEBKIT_PARAM_READWRITE (static_cast<GParamFlags>(G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)) - -#define COMPILE_ASSERT_MATCHING_ENUM(webkitName, webcoreName) \ - COMPILE_ASSERT(int(webkitName) == int(webcoreName), mismatchingEnums) - -#define WEBKIT_DEFINE_ASYNC_DATA_STRUCT(structName) \ -static structName* create##structName() \ -{ \ - structName* data = g_slice_new0(structName); \ - new (data) structName(); \ - return data; \ -} \ -static void destroy##structName(structName* data) \ -{ \ - data->~structName(); \ - g_slice_free(structName, data); \ -} - -#define WEBKIT_DEFINE_TYPE(TypeName, type_name, TYPE_PARENT) _WEBKIT_DEFINE_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, 0, { }) -#define WEBKIT_DEFINE_ABSTRACT_TYPE(TypeName, type_name, TYPE_PARENT) _WEBKIT_DEFINE_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, G_TYPE_FLAG_ABSTRACT, { }) -#define WEBKIT_DEFINE_TYPE_WITH_CODE(TypeName, type_name, TYPE_PARENT, Code) _WEBKIT_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, 0) {Code;} _WEBKIT_DEFINE_TYPE_EXTENDED_END() - -#define _WEBKIT_DEFINE_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, flags, Code) _WEBKIT_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) {Code;} _WEBKIT_DEFINE_TYPE_EXTENDED_END() -#define _WEBKIT_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) \ -\ -static void type_name##_class_init(TypeName##Class* klass); \ -static gpointer type_name##_parent_class = 0; \ -static void type_name##_finalize(GObject* object) \ -{ \ - TypeName* self = (TypeName*)object; \ - self->priv->~TypeName##Private(); \ - G_OBJECT_CLASS(type_name##_parent_class)->finalize(object); \ -} \ -\ -static void type_name##_class_intern_init(gpointer klass) \ -{ \ - GObjectClass* gObjectClass = G_OBJECT_CLASS(klass); \ - g_type_class_add_private(klass, sizeof(TypeName##Private)); \ - type_name##_parent_class = g_type_class_peek_parent(klass); \ - type_name##_class_init((TypeName##Class*)klass); \ - gObjectClass->finalize = type_name##_finalize; \ -} \ -\ -static void type_name##_init(TypeName* self) \ -{ \ - TypeName##Private* priv = G_TYPE_INSTANCE_GET_PRIVATE(self, type_name##_get_type(), TypeName##Private); \ - self->priv = priv; \ - new (priv) TypeName##Private(); \ -}\ -GType type_name##_get_type(void) \ -{ \ - static volatile gsize g_define_type_id__volatile = 0; \ - if (g_once_init_enter(&g_define_type_id__volatile)) { \ - GType g_define_type_id = \ - g_type_register_static_simple( \ - TYPE_PARENT, \ - g_intern_static_string(#TypeName), \ - sizeof(TypeName##Class), \ - (GClassInitFunc)type_name##_class_intern_init, \ - sizeof(TypeName), \ - (GInstanceInitFunc)type_name##_init, \ - (GTypeFlags)flags); \ - // Custom code follows. -#define _WEBKIT_DEFINE_TYPE_EXTENDED_END() \ - g_once_init_leave(&g_define_type_id__volatile, g_define_type_id); \ - } \ - return g_define_type_id__volatile; \ -} // Closes type_name##_get_type(). - -unsigned wkEventModifiersToGdkModifiers(WKEventModifiers); -unsigned wkEventMouseButtonToWebKitMouseButton(WKEventMouseButton); - -enum SnapshotRegion { - SnapshotRegionVisible, - SnapshotRegionFullDocument -}; - -#endif // WebKitPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.cpp deleted file mode 100644 index 3bb2434ce..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitRequestManagerClient.h" - -#include "WebKitURISchemeRequestPrivate.h" -#include "WebKitWebContextPrivate.h" -#include <wtf/gobject/GRefPtr.h> - -using namespace WebKit; - -static void didReceiveURIRequest(WKSoupRequestManagerRef soupRequestManagerRef, WKURLRef urlRef, WKPageRef initiatingPageRef, uint64_t requestID, const void* clientInfo) -{ - WebKitWebContext* webContext = WEBKIT_WEB_CONTEXT(clientInfo); - GRefPtr<WebKitURISchemeRequest> request = adoptGRef(webkitURISchemeRequestCreate(webContext, toImpl(soupRequestManagerRef), toImpl(urlRef), toImpl(initiatingPageRef), requestID)); - webkitWebContextReceivedURIRequest(webContext, request.get()); -} - -static void didFailToLoadURIRequest(WKSoupRequestManagerRef, uint64_t requestID, const void* clientInfo) -{ - webkitWebContextDidFailToLoadURIRequest(WEBKIT_WEB_CONTEXT(clientInfo), requestID); -} - -void attachRequestManagerClientToContext(WebKitWebContext* webContext) -{ - WKSoupRequestManagerClient wkRequestManagerClient = { - kWKSoupRequestManagerClientCurrentVersion, - webContext, // clientInfo - didReceiveURIRequest, - didFailToLoadURIRequest - }; - WKSoupRequestManagerSetClient(toAPI(webkitWebContextGetRequestManager(webContext)), &wkRequestManagerClient); -} - diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.h b/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.h deleted file mode 100644 index a365594f8..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitRequestManagerClient_h -#define WebKitRequestManagerClient_h - -#include "WebKitWebContext.h" - -void attachRequestManagerClientToContext(WebKitWebContext*); - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecision.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecision.cpp deleted file mode 100644 index 3a75e38c9..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecision.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitResponsePolicyDecision.h" - -#include "WebKitPolicyDecisionPrivate.h" -#include "WebKitPrivate.h" -#include "WebKitURIRequestPrivate.h" -#include "WebKitURIResponsePrivate.h" -#include "WebURLRequest.h" -#include "WebURLResponse.h" -#include <glib/gi18n-lib.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -using namespace WebKit; - -/** - * SECTION: WebKitResponsePolicyDecision - * @Short_description: A policy decision for resource responses - * @Title: WebKitResponsePolicyDecision - * @See_also: #WebKitPolicyDecision, #WebKitWebView - * - * WebKitResponsePolicyDecision represents a policy decision for a - * resource response, whether from the network or the local system. - * A very common usecase for these types of decision is deciding - * whether or not to download a particular resource or to load it - * normally. - */ - -struct _WebKitResponsePolicyDecisionPrivate { - GRefPtr<WebKitURIRequest> request; - GRefPtr<WebKitURIResponse> response; -}; - -WEBKIT_DEFINE_TYPE(WebKitResponsePolicyDecision, webkit_response_policy_decision, WEBKIT_TYPE_POLICY_DECISION) - -enum { - PROP_0, - PROP_REQUEST, - PROP_RESPONSE, -}; - -static void webkitResponsePolicyDecisionGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) -{ - WebKitResponsePolicyDecision* decision = WEBKIT_RESPONSE_POLICY_DECISION(object); - switch (propId) { - case PROP_REQUEST: - g_value_set_object(value, webkit_response_policy_decision_get_request(decision)); - break; - case PROP_RESPONSE: - g_value_set_object(value, webkit_response_policy_decision_get_response(decision)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - break; - } -} - -static void webkit_response_policy_decision_class_init(WebKitResponsePolicyDecisionClass* decisionClass) -{ - GObjectClass* objectClass = G_OBJECT_CLASS(decisionClass); - objectClass->get_property = webkitResponsePolicyDecisionGetProperty; - - /** - * WebKitResponsePolicyDecision:request: - * - * This property contains the #WebKitURIRequest associated with this - * policy decision. - */ - g_object_class_install_property(objectClass, - PROP_REQUEST, - g_param_spec_object("request", - _("Response URI request"), - _("The URI request that is associated with this policy decision"), - WEBKIT_TYPE_URI_REQUEST, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitResponsePolicyDecision:response: - * - * This property contains the #WebKitURIResponse associated with this - * policy decision. - */ - g_object_class_install_property(objectClass, - PROP_REQUEST, - g_param_spec_object("response", - _("URI response"), - _("The URI response that is associated with this policy decision"), - WEBKIT_TYPE_URI_REQUEST, - WEBKIT_PARAM_READABLE)); - -} - -/** - * webkit_response_policy_decision_get_request: - * @decision: a #WebKitResponsePolicyDecision - * - * Gets the value of the #WebKitResponsePolicyDecision:request property. - * - * Returns: (transfer none): The URI request that is associated with this policy decision. - */ -WebKitURIRequest* webkit_response_policy_decision_get_request(WebKitResponsePolicyDecision* decision) -{ - g_return_val_if_fail(WEBKIT_IS_RESPONSE_POLICY_DECISION(decision), 0); - return decision->priv->request.get(); -} - -/** - * webkit_response_policy_decision_get_response: - * @decision: a #WebKitResponsePolicyDecision - * - * Gets the value of the #WebKitResponsePolicyDecision:response property. - * - * Returns: (transfer none): The URI response that is associated with this policy decision. - */ -WebKitURIResponse* webkit_response_policy_decision_get_response(WebKitResponsePolicyDecision* decision) -{ - g_return_val_if_fail(WEBKIT_IS_RESPONSE_POLICY_DECISION(decision), 0); - return decision->priv->response.get(); -} - -WebKitResponsePolicyDecision* webkitResponsePolicyDecisionCreate(WebURLRequest* request, WebURLResponse* response, WebFramePolicyListenerProxy* listener) -{ - WebKitResponsePolicyDecision* decision = WEBKIT_RESPONSE_POLICY_DECISION(g_object_new(WEBKIT_TYPE_RESPONSE_POLICY_DECISION, NULL)); - decision->priv->request = adoptGRef(webkitURIRequestCreateForResourceRequest(request->resourceRequest())); - decision->priv->response = adoptGRef(webkitURIResponseCreateForResourceResponse(response->resourceResponse())); - webkitPolicyDecisionSetListener(WEBKIT_POLICY_DECISION(decision), listener); - return decision; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecision.h b/Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecision.h deleted file mode 100644 index 4a689fbc7..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecision.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitResponsePolicyDecision_h -#define WebKitResponsePolicyDecision_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> -#include <webkit2/WebKitPolicyDecision.h> -#include <webkit2/WebKitURIResponse.h> -#include <webkit2/WebKitURIRequest.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_RESPONSE_POLICY_DECISION (webkit_response_policy_decision_get_type()) -#define WEBKIT_RESPONSE_POLICY_DECISION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_RESPONSE_POLICY_DECISION, WebKitResponsePolicyDecision)) -#define WEBKIT_RESPONSE_POLICY_DECISION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_RESPONSE_POLICY_DECISION, WebKitResponsePolicyDecisionClass)) -#define WEBKIT_IS_RESPONSE_POLICY_DECISION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_RESPONSE_POLICY_DECISION)) -#define WEBKIT_IS_RESPONSE_POLICY_DECISION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_RESPONSE_POLICY_DECISION)) -#define WEBKIT_RESPONSE_POLICY_DECISION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_RESPONSE_POLICY_DECISION, WebKitResponsePolicyDecisionClass)) - -typedef struct _WebKitResponsePolicyDecision WebKitResponsePolicyDecision; -typedef struct _WebKitResponsePolicyDecisionClass WebKitResponsePolicyDecisionClass; -typedef struct _WebKitResponsePolicyDecisionPrivate WebKitResponsePolicyDecisionPrivate; - -struct _WebKitResponsePolicyDecision { - WebKitPolicyDecision parent; - - /*< private >*/ - WebKitResponsePolicyDecisionPrivate *priv; -}; - -struct _WebKitResponsePolicyDecisionClass { - WebKitPolicyDecisionClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_response_policy_decision_get_type (void); - -WEBKIT_API WebKitURIRequest * -webkit_response_policy_decision_get_request (WebKitResponsePolicyDecision *decision); - -WEBKIT_API WebKitURIResponse * -webkit_response_policy_decision_get_response (WebKitResponsePolicyDecision *decision); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecisionPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecisionPrivate.h deleted file mode 100644 index 3e7e59e65..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecisionPrivate.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitResponsePolicyDecisionPrivate_h -#define WebKitResponsePolicyDecisionPrivate_h - -#include "WebKitPrivate.h" -#include "WebKitResponsePolicyDecision.h" - -WebKitResponsePolicyDecision* webkitResponsePolicyDecisionCreate(WebKit::WebURLRequest*, WebKit::WebURLResponse*, WebKit::WebFramePolicyListenerProxy*); - -#endif // WebKitResponsePolicyDecisionPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitScriptDialog.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitScriptDialog.cpp deleted file mode 100644 index 863665d71..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitScriptDialog.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitScriptDialog.h" - -#include "WebKitScriptDialogPrivate.h" - -static WebKitScriptDialog* webkitScriptDialogCopy(WebKitScriptDialog* dialog) -{ - WebKitScriptDialog* copy = g_slice_new0(WebKitScriptDialog); - new (copy) WebKitScriptDialog(dialog); - return copy; -} - -static void webkitScriptDialogFree(WebKitScriptDialog* dialog) -{ - dialog->~WebKitScriptDialog(); - g_slice_free(WebKitScriptDialog, dialog); -} - -G_DEFINE_BOXED_TYPE(WebKitScriptDialog, webkit_script_dialog, webkitScriptDialogCopy, webkitScriptDialogFree) - -/** - * webkit_script_dialog_get_dialog_type: - * @dialog: a #WebKitScriptDialog - * - * Get the dialog type of a #WebKitScriptDialog. - * - * Returns: the #WebKitScriptDialogType of @dialog - */ -WebKitScriptDialogType webkit_script_dialog_get_dialog_type(WebKitScriptDialog* dialog) -{ - g_return_val_if_fail(dialog, WEBKIT_SCRIPT_DIALOG_ALERT); - - return static_cast<WebKitScriptDialogType>(dialog->type); -} - -/** - * webkit_script_dialog_get_message: - * @dialog: a #WebKitScriptDialog - * - * Get the message of a #WebKitScriptDialog. - * - * Returns: the message of @dialog. - */ -const char* webkit_script_dialog_get_message(WebKitScriptDialog* dialog) -{ - g_return_val_if_fail(dialog, 0); - - return dialog->message.data(); -} - -/** - * webkit_script_dialog_confirm_set_confirmed: - * @dialog: a #WebKitScriptDialog - * @confirmed: whether user confirmed the dialog - * - * This method is used for %WEBKIT_SCRIPT_DIALOG_CONFIRM dialogs when - * #WebKitWebView::script-dialog signal is emitted to set whether the user - * confirmed the dialog or not. The default implementation of #WebKitWebView::script-dialog - * signal sets %TRUE when the OK button is clicked and %FALSE otherwise. - * It's an error to use this method with a #WebKitScriptDialog that is not of type - * %WEBKIT_SCRIPT_DIALOG_CONFIRM. - */ -void webkit_script_dialog_confirm_set_confirmed(WebKitScriptDialog* dialog, gboolean confirmed) -{ - g_return_if_fail(dialog); - g_return_if_fail(dialog->type == WEBKIT_SCRIPT_DIALOG_CONFIRM); - - dialog->confirmed = confirmed; -} - -/** - * webkit_script_dialog_prompt_get_default_text: - * @dialog: a #WebKitScriptDialog - * - * Get the default text of a #WebKitScriptDialog of type %WEBKIT_SCRIPT_DIALOG_PROMPT. - * It's an error to use this method with a #WebKitScriptDialog that is not of type - * %WEBKIT_SCRIPT_DIALOG_PROMPT. - * - * Returns: the default text of @dialog - */ -const char* webkit_script_dialog_prompt_get_default_text(WebKitScriptDialog* dialog) -{ - g_return_val_if_fail(dialog, 0); - g_return_val_if_fail(dialog->type == WEBKIT_SCRIPT_DIALOG_PROMPT, 0); - - return dialog->defaultText.data(); -} - -/** - * webkit_script_dialog_prompt_set_text: - * @dialog: a #WebKitScriptDialog - * @text: the text to set - * - * This method is used for %WEBKIT_SCRIPT_DIALOG_PROMPT dialogs when - * #WebKitWebView::script-dialog signal is emitted to set the text - * entered by the user. The default implementation of #WebKitWebView::script-dialog - * signal sets the text of the entry form when OK button is clicked, otherwise %NULL is set. - * It's an error to use this method with a #WebKitScriptDialog that is not of type - * %WEBKIT_SCRIPT_DIALOG_PROMPT. - */ -void webkit_script_dialog_prompt_set_text(WebKitScriptDialog* dialog, const char* text) -{ - g_return_if_fail(dialog); - g_return_if_fail(dialog->type == WEBKIT_SCRIPT_DIALOG_PROMPT); - - dialog->text = text; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitScriptDialog.h b/Source/WebKit2/UIProcess/API/gtk/WebKitScriptDialog.h deleted file mode 100644 index cf88535ad..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitScriptDialog.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitScriptDialog_h -#define WebKitScriptDialog_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_SCRIPT_DIALOG (webkit_script_dialog_get_type()) - -typedef struct _WebKitScriptDialog WebKitScriptDialog; - -/** - * WebKitScriptDialogType: - * @WEBKIT_SCRIPT_DIALOG_ALERT: Alert script dialog, used to show a - * message to the user. - * @WEBKIT_SCRIPT_DIALOG_CONFIRM: Confirm script dialog, used to ask - * confirmation to the user. - * @WEBKIT_SCRIPT_DIALOG_PROMPT: Prompt script dialog, used to ask - * information to the user. - * - * Enum values used for determining the type of #WebKitScriptDialog - */ -typedef enum { - WEBKIT_SCRIPT_DIALOG_ALERT, - WEBKIT_SCRIPT_DIALOG_CONFIRM, - WEBKIT_SCRIPT_DIALOG_PROMPT -} WebKitScriptDialogType; - -WEBKIT_API GType -webkit_script_dialog_get_type (void); - -WEBKIT_API WebKitScriptDialogType -webkit_script_dialog_get_dialog_type (WebKitScriptDialog *dialog); - -WEBKIT_API const gchar * -webkit_script_dialog_get_message (WebKitScriptDialog *dialog); - -WEBKIT_API void -webkit_script_dialog_confirm_set_confirmed (WebKitScriptDialog *dialog, - gboolean confirmed); - -WEBKIT_API const gchar * -webkit_script_dialog_prompt_get_default_text (WebKitScriptDialog *dialog); - -WEBKIT_API void -webkit_script_dialog_prompt_set_text (WebKitScriptDialog *dialog, - const gchar *text); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitScriptDialogPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitScriptDialogPrivate.h deleted file mode 100644 index 5f1a43d94..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitScriptDialogPrivate.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitScriptDialogPrivate_h -#define WebKitScriptDialogPrivate_h - -#include "WebKitScriptDialog.h" -#include <wtf/text/CString.h> - -struct _WebKitScriptDialog { - _WebKitScriptDialog(unsigned type, const CString& message) - : type(type) - , message(message) - , confirmed(false) - { - } - - _WebKitScriptDialog(unsigned type, const CString& message, const CString& defaultText) - : type(type) - , message(message) - , defaultText(defaultText) - , confirmed(false) - { - ASSERT(type == WEBKIT_SCRIPT_DIALOG_PROMPT); - } - - _WebKitScriptDialog(WebKitScriptDialog* dialog) - : type(dialog->type) - , message(dialog->message) - , defaultText(dialog->defaultText) - , confirmed(dialog->confirmed) - , text(dialog->text) - { - } - - unsigned type; - CString message; - CString defaultText; - - bool confirmed; - CString text; -}; - -#endif // WebKitScriptDialogPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.cpp deleted file mode 100644 index e8c36d72c..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.cpp +++ /dev/null @@ -1,331 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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 "WebKitSecurityManager.h" - -#include "WebContext.h" -#include "WebKitSecurityManagerPrivate.h" -#include "WebKitWebContextPrivate.h" -#include <WebCore/SchemeRegistry.h> - -using namespace WebKit; - -/** - * SECTION: WebKitSecurityManager - * @Short_description: Controls security settings in a #WebKitWebContext - * @Title: WebKitSecurityManager - * - * The #WebKitSecurityManager defines security settings for URI - * schemes in a #WebKitWebContext. Get it from the context with - * webkit_web_context_get_security_manager(), and use it to register a - * URI scheme with a certain security level, or to check if it already - * has it. - * - */ - -typedef enum { - SecurityPolicyLocal, - SecurityPolicyNoAccess, - SecurityPolicyDisplayIsolated, - SecurityPolicySecure, - SecurityPolicyCORSEnabled, - SecurityPolicyEmptyDocument -} SecurityPolicy; - -struct _WebKitSecurityManagerPrivate { - WebKitWebContext* webContext; -}; - -WEBKIT_DEFINE_TYPE(WebKitSecurityManager, webkit_security_manager, G_TYPE_OBJECT) - -static void webkit_security_manager_class_init(WebKitSecurityManagerClass* klass) -{ -} - -WebKitSecurityManager* webkitSecurityManagerCreate(WebKitWebContext* webContext) -{ - WebKitSecurityManager* manager = WEBKIT_SECURITY_MANAGER(g_object_new(WEBKIT_TYPE_SECURITY_MANAGER, NULL)); - manager->priv->webContext = webContext; - return manager; -} - -static void registerSecurityPolicyForURIScheme(WebKitSecurityManager* manager, const char* scheme, SecurityPolicy policy) -{ - String urlScheme = String::fromUTF8(scheme); - WebContext* webContext = webkitWebContextGetContext(manager->priv->webContext); - - // We keep the WebCore::SchemeRegistry of the UI process in sync with the - // web process one, so that we can return the SecurityPolicy for - // a given URI scheme synchronously without blocking. - switch (policy) { - case SecurityPolicyLocal: - WebCore::SchemeRegistry::registerURLSchemeAsLocal(urlScheme); - webContext->registerURLSchemeAsLocal(urlScheme); - break; - case SecurityPolicyNoAccess: - WebCore::SchemeRegistry::registerURLSchemeAsNoAccess(urlScheme); - webContext->registerURLSchemeAsNoAccess(urlScheme); - break; - case SecurityPolicyDisplayIsolated: - WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated(urlScheme); - webContext->registerURLSchemeAsDisplayIsolated(urlScheme); - break; - case SecurityPolicySecure: - WebCore::SchemeRegistry::registerURLSchemeAsSecure(urlScheme); - webContext->registerURLSchemeAsSecure(urlScheme); - break; - case SecurityPolicyCORSEnabled: - WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled(urlScheme); - webContext->registerURLSchemeAsCORSEnabled(urlScheme); - break; - case SecurityPolicyEmptyDocument: - WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument(urlScheme); - webContext->registerURLSchemeAsEmptyDocument(urlScheme); - break; - } -} - -static bool checkSecurityPolicyForURIScheme(const char* scheme, SecurityPolicy policy) -{ - String urlScheme = String::fromUTF8(scheme); - - switch (policy) { - case SecurityPolicyLocal: - return WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal(urlScheme); - case SecurityPolicyNoAccess: - return WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess(urlScheme); - case SecurityPolicyDisplayIsolated: - return WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated(urlScheme); - case SecurityPolicySecure: - return WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure(urlScheme); - case SecurityPolicyCORSEnabled: - return WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(urlScheme); - case SecurityPolicyEmptyDocument: - return WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(urlScheme); - } - - return false; -} - -/** - * webkit_security_manager_register_uri_scheme_as_local: - * @security_manager: a #WebKitSecurityManager - * @scheme: a URI scheme - * - * Register @scheme as a local scheme. This means that other non-local pages - * cannot link to or access URIs of this scheme. - */ -void webkit_security_manager_register_uri_scheme_as_local(WebKitSecurityManager* manager, const char* scheme) -{ - g_return_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager)); - g_return_if_fail(scheme); - - registerSecurityPolicyForURIScheme(manager, scheme, SecurityPolicyLocal); -} - -/** - * webkit_security_manager_uri_scheme_is_local: - * @security_manager: a #WebKitSecurityManager - * @scheme: a URI scheme - * - * Whether @scheme is considered as a local scheme. - * See also webkit_security_manager_register_uri_scheme_as_local(). - * - * Returns: %TRUE if @scheme is a local scheme or %FALSE otherwise. - */ -gboolean webkit_security_manager_uri_scheme_is_local(WebKitSecurityManager* manager, const char* scheme) -{ - g_return_val_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager), FALSE); - g_return_val_if_fail(scheme, FALSE); - - return checkSecurityPolicyForURIScheme(scheme, SecurityPolicyLocal); -} - -/** - * webkit_security_manager_register_uri_scheme_as_no_access: - * @security_manager: a #WebKitSecurityManager - * @scheme: a URI scheme - * - * Register @scheme as a no-access scheme. This means that pages loaded - * with this URI scheme cannot access pages loaded with any other URI scheme. - */ -void webkit_security_manager_register_uri_scheme_as_no_access(WebKitSecurityManager* manager, const char* scheme) -{ - g_return_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager)); - g_return_if_fail(scheme); - - registerSecurityPolicyForURIScheme(manager, scheme, SecurityPolicyNoAccess); -} - -/** - * webkit_security_manager_uri_scheme_is_no_access: - * @security_manager: a #WebKitSecurityManager - * @scheme: a URI scheme - * - * Whether @scheme is considered as a no-access scheme. - * See also webkit_security_manager_register_uri_scheme_as_no_access(). - * - * Returns: %TRUE if @scheme is a no-access scheme or %FALSE otherwise. - */ -gboolean webkit_security_manager_uri_scheme_is_no_access(WebKitSecurityManager* manager, const char* scheme) -{ - g_return_val_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager), FALSE); - g_return_val_if_fail(scheme, FALSE); - - return checkSecurityPolicyForURIScheme(scheme, SecurityPolicyNoAccess); -} - -/** - * webkit_security_manager_register_uri_scheme_as_display_isolated: - * @security_manager: a #WebKitSecurityManager - * @scheme: a URI scheme - * - * Register @scheme as a display isolated scheme. This means that pages cannot - * display these URIs unless they are from the same scheme. - */ -void webkit_security_manager_register_uri_scheme_as_display_isolated(WebKitSecurityManager* manager, const char* scheme) -{ - g_return_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager)); - g_return_if_fail(scheme); - - registerSecurityPolicyForURIScheme(manager, scheme, SecurityPolicyDisplayIsolated); -} - -/** - * webkit_security_manager_uri_scheme_is_display_isolated: - * @security_manager: a #WebKitSecurityManager - * @scheme: a URI scheme - * - * Whether @scheme is considered as a display isolated scheme. - * See also webkit_security_manager_register_uri_scheme_as_display_isolated(). - * - * Returns: %TRUE if @scheme is a display isolated scheme or %FALSE otherwise. - */ -gboolean webkit_security_manager_uri_scheme_is_display_isolated(WebKitSecurityManager* manager, const char* scheme) -{ - g_return_val_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager), FALSE); - g_return_val_if_fail(scheme, FALSE); - - return checkSecurityPolicyForURIScheme(scheme, SecurityPolicyDisplayIsolated); -} - -/** - * webkit_security_manager_register_uri_scheme_as_secure: - * @security_manager: a #WebKitSecurityManager - * @scheme: a URI scheme - * - * Register @scheme as a secure scheme. This means that mixed - * content warnings won't be generated for this scheme when - * included by an HTTPS page. - */ -void webkit_security_manager_register_uri_scheme_as_secure(WebKitSecurityManager* manager, const char* scheme) -{ - g_return_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager)); - g_return_if_fail(scheme); - - registerSecurityPolicyForURIScheme(manager, scheme, SecurityPolicySecure); -} - -/** - * webkit_security_manager_uri_scheme_is_secure: - * @security_manager: a #WebKitSecurityManager - * @scheme: a URI scheme - * - * Whether @scheme is considered as a secure scheme. - * See also webkit_security_manager_register_uri_scheme_as_secure(). - * - * Returns: %TRUE if @scheme is a secure scheme or %FALSE otherwise. - */ -gboolean webkit_security_manager_uri_scheme_is_secure(WebKitSecurityManager* manager, const char* scheme) -{ - g_return_val_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager), FALSE); - g_return_val_if_fail(scheme, FALSE); - - return checkSecurityPolicyForURIScheme(scheme, SecurityPolicySecure); -} - -/** - * webkit_security_manager_register_uri_scheme_as_cors_enabled: - * @security_manager: a #WebKitSecurityManager - * @scheme: a URI scheme - * - * Register @scheme as a CORS (Cross-origin resource sharing) enabled scheme. - * This means that CORS requests are allowed. See W3C CORS specification - * http://www.w3.org/TR/cors/. - */ -void webkit_security_manager_register_uri_scheme_as_cors_enabled(WebKitSecurityManager* manager, const char* scheme) -{ - g_return_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager)); - g_return_if_fail(scheme); - - registerSecurityPolicyForURIScheme(manager, scheme, SecurityPolicyCORSEnabled); -} - -/** - * webkit_security_manager_uri_scheme_is_cors_enabled: - * @security_manager: a #WebKitSecurityManager - * @scheme: a URI scheme - * - * Whether @scheme is considered as a CORS enabled scheme. - * See also webkit_security_manager_register_uri_scheme_as_cors_enabled(). - * - * Returns: %TRUE if @scheme is a CORS enabled scheme or %FALSE otherwise. - */ -gboolean webkit_security_manager_uri_scheme_is_cors_enabled(WebKitSecurityManager* manager, const char* scheme) -{ - g_return_val_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager), FALSE); - g_return_val_if_fail(scheme, FALSE); - - return checkSecurityPolicyForURIScheme(scheme, SecurityPolicyCORSEnabled); -} - -/** - * webkit_security_manager_register_uri_scheme_as_empty_document: - * @security_manager: a #WebKitSecurityManager - * @scheme: a URI scheme - * - * Register @scheme as an empty document scheme. This means that - * they are allowd to commit synchronously. - */ -void webkit_security_manager_register_uri_scheme_as_empty_document(WebKitSecurityManager* manager, const char* scheme) -{ - g_return_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager)); - g_return_if_fail(scheme); - - registerSecurityPolicyForURIScheme(manager, scheme, SecurityPolicyEmptyDocument); -} - -/** - * webkit_security_manager_uri_scheme_is_empty_document: - * @security_manager: a #WebKitSecurityManager - * @scheme: a URI scheme - * - * Whether @scheme is considered as an empty document scheme. - * See also webkit_security_manager_register_uri_scheme_as_empty_document(). - * - * Returns: %TRUE if @scheme is a an empty document scheme or %FALSE otherwise. - */ -gboolean webkit_security_manager_uri_scheme_is_empty_document(WebKitSecurityManager* manager, const char* scheme) -{ - g_return_val_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager), FALSE); - g_return_val_if_fail(scheme, FALSE); - - return checkSecurityPolicyForURIScheme(scheme, SecurityPolicyEmptyDocument); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.h b/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.h deleted file mode 100644 index e8cf9e7cd..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitSecurityManager_h -#define WebKitSecurityManager_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_SECURITY_MANAGER (webkit_security_manager_get_type()) -#define WEBKIT_SECURITY_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_SECURITY_MANAGER, WebKitSecurityManager)) -#define WEBKIT_IS_SECURITY_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_SECURITY_MANAGER)) -#define WEBKIT_SECURITY_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_SECURITY_MANAGER, WebKitSecurityManagerClass)) -#define WEBKIT_IS_SECURITY_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_SECURITY_MANAGER)) -#define WEBKIT_SECURITY_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_SECURITY_MANAGER, WebKitSecurityManagerClass)) - -typedef struct _WebKitSecurityManager WebKitSecurityManager; -typedef struct _WebKitSecurityManagerClass WebKitSecurityManagerClass; -typedef struct _WebKitSecurityManagerPrivate WebKitSecurityManagerPrivate; - -struct _WebKitSecurityManager { - GObject parent; - - WebKitSecurityManagerPrivate *priv; -}; - -struct _WebKitSecurityManagerClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_security_manager_get_type (void); - -WEBKIT_API void -webkit_security_manager_register_uri_scheme_as_local (WebKitSecurityManager *security_manager, - const gchar *scheme); - -WEBKIT_API gboolean -webkit_security_manager_uri_scheme_is_local (WebKitSecurityManager *security_manager, - const gchar *scheme); - -WEBKIT_API void -webkit_security_manager_register_uri_scheme_as_no_access (WebKitSecurityManager *security_manager, - const gchar *scheme); - -WEBKIT_API gboolean -webkit_security_manager_uri_scheme_is_no_access (WebKitSecurityManager *security_manager, - const gchar *scheme); - -WEBKIT_API void -webkit_security_manager_register_uri_scheme_as_display_isolated (WebKitSecurityManager *security_manager, - const gchar *scheme); - -WEBKIT_API gboolean -webkit_security_manager_uri_scheme_is_display_isolated (WebKitSecurityManager *security_manager, - const gchar *scheme); - -WEBKIT_API void -webkit_security_manager_register_uri_scheme_as_secure (WebKitSecurityManager *security_manager, - const gchar *scheme); - -WEBKIT_API gboolean -webkit_security_manager_uri_scheme_is_secure (WebKitSecurityManager *security_manager, - const gchar *scheme); - -WEBKIT_API void -webkit_security_manager_register_uri_scheme_as_cors_enabled (WebKitSecurityManager *security_manager, - const gchar *scheme); - -WEBKIT_API gboolean -webkit_security_manager_uri_scheme_is_cors_enabled (WebKitSecurityManager *security_manager, - const gchar *scheme); - -WEBKIT_API void -webkit_security_manager_register_uri_scheme_as_empty_document (WebKitSecurityManager *security_manager, - const gchar *scheme); - -WEBKIT_API gboolean -webkit_security_manager_uri_scheme_is_empty_document (WebKitSecurityManager *security_manager, - const gchar *scheme); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManagerPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManagerPrivate.h deleted file mode 100644 index feabdced6..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManagerPrivate.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitSecurityManagerPrivate_h -#define WebKitSecurityManagerPrivate_h - -#include "WebKitSecurityManager.h" -#include "WebKitWebContext.h" - -WebKitSecurityManager* webkitSecurityManagerCreate(WebKitWebContext*); - -#endif // WebKitSecurityManagerPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp deleted file mode 100644 index 53a547a1f..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp +++ /dev/null @@ -1,2798 +0,0 @@ -/* - * Copyright (c) 2011 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: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Motorola Mobility, Inc. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT HOLDER OR - * 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 "config.h" -#include "WebKitSettings.h" - -#include "ExperimentalFeatures.h" -#include "WebKitPrivate.h" -#include "WebKitSettingsPrivate.h" -#include <WebCore/UserAgentGtk.h> -#include <glib/gi18n-lib.h> -#include <wtf/text/CString.h> - -using namespace WebKit; - -struct _WebKitSettingsPrivate { - _WebKitSettingsPrivate() - : preferences(WebPreferences::create()) - { - defaultFontFamily = preferences->standardFontFamily().utf8(); - monospaceFontFamily = preferences->fixedFontFamily().utf8(); - serifFontFamily = preferences->serifFontFamily().utf8(); - sansSerifFontFamily = preferences->sansSerifFontFamily().utf8(); - cursiveFontFamily = preferences->cursiveFontFamily().utf8(); - fantasyFontFamily = preferences->fantasyFontFamily().utf8(); - pictographFontFamily = preferences->pictographFontFamily().utf8(); - defaultCharset = preferences->defaultTextEncodingName().utf8(); - } - - RefPtr<WebPreferences> preferences; - CString defaultFontFamily; - CString monospaceFontFamily; - CString serifFontFamily; - CString sansSerifFontFamily; - CString cursiveFontFamily; - CString fantasyFontFamily; - CString pictographFontFamily; - CString defaultCharset; - CString userAgent; - bool allowModalDialogs; - bool zoomTextOnly; -}; - -/** - * SECTION:WebKitSettings - * @short_description: Control the behaviour of #WebKitWebView<!-- -->s - * @see_also: #WebKitWebViewGroup, #WebKitWebView - * - * #WebKitSettings can be applied to a #WebKitWebViewGroup to control text charset, - * color, font sizes, printing mode, script support, loading of images and various - * other things on the #WebKitWebView<!-- -->s of the group. - * After creation, a #WebKitSettings object contains default settings. - * - * <informalexample><programlisting> - * /<!-- -->* Disable JavaScript. *<!-- -->/ - * WebKitSettings *settings = webkit_web_view_group_get_settings (my_view_group); - * webkit_settings_set_enable_javascript (settings, FALSE); - * - * </programlisting></informalexample> - */ - -WEBKIT_DEFINE_TYPE(WebKitSettings, webkit_settings, G_TYPE_OBJECT) - -enum { - PROP_0, - - PROP_ENABLE_JAVASCRIPT, - PROP_AUTO_LOAD_IMAGES, - PROP_LOAD_ICONS_IGNORING_IMAGE_LOAD_SETTING, - PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE, - PROP_ENABLE_HTML5_LOCAL_STORAGE, - PROP_ENABLE_HTML5_DATABASE, - PROP_ENABLE_XSS_AUDITOR, - PROP_ENABLE_FRAME_FLATTENING, - PROP_ENABLE_PLUGINS, - PROP_ENABLE_JAVA, - PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY, - PROP_ENABLE_HYPERLINK_AUDITING, - PROP_DEFAULT_FONT_FAMILY, - PROP_MONOSPACE_FONT_FAMILY, - PROP_SERIF_FONT_FAMILY, - PROP_SANS_SERIF_FONT_FAMILY, - PROP_CURSIVE_FONT_FAMILY, - PROP_FANTASY_FONT_FAMILY, - PROP_PICTOGRAPH_FONT_FAMILY, - PROP_DEFAULT_FONT_SIZE, - PROP_DEFAULT_MONOSPACE_FONT_SIZE, - PROP_MINIMUM_FONT_SIZE, - PROP_DEFAULT_CHARSET, - PROP_ENABLE_PRIVATE_BROWSING, - PROP_ENABLE_DEVELOPER_EXTRAS, - PROP_ENABLE_RESIZABLE_TEXT_AREAS, - PROP_ENABLE_TABS_TO_LINKS, - PROP_ENABLE_DNS_PREFETCHING, - PROP_ENABLE_CARET_BROWSING, - PROP_ENABLE_FULLSCREEN, - PROP_PRINT_BACKGROUNDS, - PROP_ENABLE_WEBAUDIO, - PROP_ENABLE_WEBGL, - PROP_ALLOW_MODAL_DIALOGS, - PROP_ZOOM_TEXT_ONLY, - PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD, - PROP_MEDIA_PLAYBACK_REQUIRES_USER_GESTURE, - PROP_MEDIA_PLAYBACK_ALLOWS_INLINE, - PROP_DRAW_COMPOSITING_INDICATORS, - PROP_ENABLE_SITE_SPECIFIC_QUIRKS, - PROP_ENABLE_PAGE_CACHE, - PROP_USER_AGENT, - PROP_ENABLE_SMOOTH_SCROLLING, - PROP_ENABLE_ACCELERATED_2D_CANVAS, - PROP_ENABLE_WRITE_CONSOLE_MESSAGES_TO_STDOUT -}; - -static void webKitSettingsConstructed(GObject* object) -{ - G_OBJECT_CLASS(webkit_settings_parent_class)->constructed(object); - - WebPreferences* prefs = WEBKIT_SETTINGS(object)->priv->preferences.get(); - ExperimentalFeatures features; - bool regionBasedColumnsEnabled = features.isEnabled(ExperimentalFeatures::RegionBasedColumns); - if (prefs->regionBasedColumnsEnabled() != regionBasedColumnsEnabled) - prefs->setRegionBasedColumnsEnabled(regionBasedColumnsEnabled); -} - -static void webKitSettingsSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec) -{ - WebKitSettings* settings = WEBKIT_SETTINGS(object); - - switch (propId) { - case PROP_ENABLE_JAVASCRIPT: - webkit_settings_set_enable_javascript(settings, g_value_get_boolean(value)); - break; - case PROP_AUTO_LOAD_IMAGES: - webkit_settings_set_auto_load_images(settings, g_value_get_boolean(value)); - break; - case PROP_LOAD_ICONS_IGNORING_IMAGE_LOAD_SETTING: - webkit_settings_set_load_icons_ignoring_image_load_setting(settings, g_value_get_boolean(value)); - break; - case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE: - webkit_settings_set_enable_offline_web_application_cache(settings, g_value_get_boolean(value)); - break; - case PROP_ENABLE_HTML5_LOCAL_STORAGE: - webkit_settings_set_enable_html5_local_storage(settings, g_value_get_boolean(value)); - break; - case PROP_ENABLE_HTML5_DATABASE: - webkit_settings_set_enable_html5_database(settings, g_value_get_boolean(value)); - break; - case PROP_ENABLE_XSS_AUDITOR: - webkit_settings_set_enable_xss_auditor(settings, g_value_get_boolean(value)); - break; - case PROP_ENABLE_FRAME_FLATTENING: - webkit_settings_set_enable_frame_flattening(settings, g_value_get_boolean(value)); - break; - case PROP_ENABLE_PLUGINS: - webkit_settings_set_enable_plugins(settings, g_value_get_boolean(value)); - break; - case PROP_ENABLE_JAVA: - webkit_settings_set_enable_java(settings, g_value_get_boolean(value)); - break; - case PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY: - webkit_settings_set_javascript_can_open_windows_automatically(settings, g_value_get_boolean(value)); - break; - case PROP_ENABLE_HYPERLINK_AUDITING: - webkit_settings_set_enable_hyperlink_auditing(settings, g_value_get_boolean(value)); - break; - case PROP_DEFAULT_FONT_FAMILY: - webkit_settings_set_default_font_family(settings, g_value_get_string(value)); - break; - case PROP_MONOSPACE_FONT_FAMILY: - webkit_settings_set_monospace_font_family(settings, g_value_get_string(value)); - break; - case PROP_SERIF_FONT_FAMILY: - webkit_settings_set_serif_font_family(settings, g_value_get_string(value)); - break; - case PROP_SANS_SERIF_FONT_FAMILY: - webkit_settings_set_sans_serif_font_family(settings, g_value_get_string(value)); - break; - case PROP_CURSIVE_FONT_FAMILY: - webkit_settings_set_cursive_font_family(settings, g_value_get_string(value)); - break; - case PROP_FANTASY_FONT_FAMILY: - webkit_settings_set_fantasy_font_family(settings, g_value_get_string(value)); - break; - case PROP_PICTOGRAPH_FONT_FAMILY: - webkit_settings_set_pictograph_font_family(settings, g_value_get_string(value)); - break; - case PROP_DEFAULT_FONT_SIZE: - webkit_settings_set_default_font_size(settings, g_value_get_uint(value)); - break; - case PROP_DEFAULT_MONOSPACE_FONT_SIZE: - webkit_settings_set_default_monospace_font_size(settings, g_value_get_uint(value)); - break; - case PROP_MINIMUM_FONT_SIZE: - webkit_settings_set_minimum_font_size(settings, g_value_get_uint(value)); - break; - case PROP_DEFAULT_CHARSET: - webkit_settings_set_default_charset(settings, g_value_get_string(value)); - break; - case PROP_ENABLE_PRIVATE_BROWSING: - webkit_settings_set_enable_private_browsing(settings, g_value_get_boolean(value)); - break; - case PROP_ENABLE_DEVELOPER_EXTRAS: - webkit_settings_set_enable_developer_extras(settings, g_value_get_boolean(value)); - break; - case PROP_ENABLE_RESIZABLE_TEXT_AREAS: - webkit_settings_set_enable_resizable_text_areas(settings, g_value_get_boolean(value)); - break; - case PROP_ENABLE_TABS_TO_LINKS: - webkit_settings_set_enable_tabs_to_links(settings, g_value_get_boolean(value)); - break; - case PROP_ENABLE_DNS_PREFETCHING: - webkit_settings_set_enable_dns_prefetching(settings, g_value_get_boolean(value)); - break; - case PROP_ENABLE_CARET_BROWSING: - webkit_settings_set_enable_caret_browsing(settings, g_value_get_boolean(value)); - break; - case PROP_ENABLE_FULLSCREEN: - webkit_settings_set_enable_fullscreen(settings, g_value_get_boolean(value)); - break; - case PROP_PRINT_BACKGROUNDS: - webkit_settings_set_print_backgrounds(settings, g_value_get_boolean(value)); - break; - case PROP_ENABLE_WEBAUDIO: - webkit_settings_set_enable_webaudio(settings, g_value_get_boolean(value)); - break; - case PROP_ENABLE_WEBGL: - webkit_settings_set_enable_webgl(settings, g_value_get_boolean(value)); - break; - case PROP_ALLOW_MODAL_DIALOGS: - webkit_settings_set_allow_modal_dialogs(settings, g_value_get_boolean(value)); - break; - case PROP_ZOOM_TEXT_ONLY: - webkit_settings_set_zoom_text_only(settings, g_value_get_boolean(value)); - break; - case PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD: - webkit_settings_set_javascript_can_access_clipboard(settings, g_value_get_boolean(value)); - break; - case PROP_MEDIA_PLAYBACK_REQUIRES_USER_GESTURE: - webkit_settings_set_media_playback_requires_user_gesture(settings, g_value_get_boolean(value)); - break; - case PROP_MEDIA_PLAYBACK_ALLOWS_INLINE: - webkit_settings_set_media_playback_allows_inline(settings, g_value_get_boolean(value)); - break; - case PROP_DRAW_COMPOSITING_INDICATORS: - if (g_value_get_boolean(value)) - webkit_settings_set_draw_compositing_indicators(settings, g_value_get_boolean(value)); - else { - char* debugVisualsEnvironment = getenv("WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS"); - bool showDebugVisuals = debugVisualsEnvironment && !strcmp(debugVisualsEnvironment, "1"); - webkit_settings_set_draw_compositing_indicators(settings, showDebugVisuals); - } - break; - case PROP_ENABLE_SITE_SPECIFIC_QUIRKS: - webkit_settings_set_enable_site_specific_quirks(settings, g_value_get_boolean(value)); - break; - case PROP_ENABLE_PAGE_CACHE: - webkit_settings_set_enable_page_cache(settings, g_value_get_boolean(value)); - break; - case PROP_USER_AGENT: - webkit_settings_set_user_agent(settings, g_value_get_string(value)); - break; - case PROP_ENABLE_SMOOTH_SCROLLING: - webkit_settings_set_enable_smooth_scrolling(settings, g_value_get_boolean(value)); - break; - case PROP_ENABLE_ACCELERATED_2D_CANVAS: - webkit_settings_set_enable_accelerated_2d_canvas(settings, g_value_get_boolean(value)); - break; - case PROP_ENABLE_WRITE_CONSOLE_MESSAGES_TO_STDOUT: - webkit_settings_set_enable_write_console_messages_to_stdout(settings, g_value_get_boolean(value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - break; - } -} - -static void webKitSettingsGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) -{ - WebKitSettings* settings = WEBKIT_SETTINGS(object); - - switch (propId) { - case PROP_ENABLE_JAVASCRIPT: - g_value_set_boolean(value, webkit_settings_get_enable_javascript(settings)); - break; - case PROP_AUTO_LOAD_IMAGES: - g_value_set_boolean(value, webkit_settings_get_auto_load_images(settings)); - break; - case PROP_LOAD_ICONS_IGNORING_IMAGE_LOAD_SETTING: - g_value_set_boolean(value, webkit_settings_get_load_icons_ignoring_image_load_setting(settings)); - break; - case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE: - g_value_set_boolean(value, webkit_settings_get_enable_offline_web_application_cache(settings)); - break; - case PROP_ENABLE_HTML5_LOCAL_STORAGE: - g_value_set_boolean(value, webkit_settings_get_enable_html5_local_storage(settings)); - break; - case PROP_ENABLE_HTML5_DATABASE: - g_value_set_boolean(value, webkit_settings_get_enable_html5_database(settings)); - break; - case PROP_ENABLE_XSS_AUDITOR: - g_value_set_boolean(value, webkit_settings_get_enable_xss_auditor(settings)); - break; - case PROP_ENABLE_FRAME_FLATTENING: - g_value_set_boolean(value, webkit_settings_get_enable_frame_flattening(settings)); - break; - case PROP_ENABLE_PLUGINS: - g_value_set_boolean(value, webkit_settings_get_enable_plugins(settings)); - break; - case PROP_ENABLE_JAVA: - g_value_set_boolean(value, webkit_settings_get_enable_java(settings)); - break; - case PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY: - g_value_set_boolean(value, webkit_settings_get_javascript_can_open_windows_automatically(settings)); - break; - case PROP_ENABLE_HYPERLINK_AUDITING: - g_value_set_boolean(value, webkit_settings_get_enable_hyperlink_auditing(settings)); - break; - case PROP_DEFAULT_FONT_FAMILY: - g_value_set_string(value, webkit_settings_get_default_font_family(settings)); - break; - case PROP_MONOSPACE_FONT_FAMILY: - g_value_set_string(value, webkit_settings_get_monospace_font_family(settings)); - break; - case PROP_SERIF_FONT_FAMILY: - g_value_set_string(value, webkit_settings_get_serif_font_family(settings)); - break; - case PROP_SANS_SERIF_FONT_FAMILY: - g_value_set_string(value, webkit_settings_get_sans_serif_font_family(settings)); - break; - case PROP_CURSIVE_FONT_FAMILY: - g_value_set_string(value, webkit_settings_get_cursive_font_family(settings)); - break; - case PROP_FANTASY_FONT_FAMILY: - g_value_set_string(value, webkit_settings_get_fantasy_font_family(settings)); - break; - case PROP_PICTOGRAPH_FONT_FAMILY: - g_value_set_string(value, webkit_settings_get_pictograph_font_family(settings)); - break; - case PROP_DEFAULT_FONT_SIZE: - g_value_set_uint(value, webkit_settings_get_default_font_size(settings)); - break; - case PROP_DEFAULT_MONOSPACE_FONT_SIZE: - g_value_set_uint(value, webkit_settings_get_default_monospace_font_size(settings)); - break; - case PROP_MINIMUM_FONT_SIZE: - g_value_set_uint(value, webkit_settings_get_minimum_font_size(settings)); - break; - case PROP_DEFAULT_CHARSET: - g_value_set_string(value, webkit_settings_get_default_charset(settings)); - break; - case PROP_ENABLE_PRIVATE_BROWSING: - g_value_set_boolean(value, webkit_settings_get_enable_private_browsing(settings)); - break; - case PROP_ENABLE_DEVELOPER_EXTRAS: - g_value_set_boolean(value, webkit_settings_get_enable_developer_extras(settings)); - break; - case PROP_ENABLE_RESIZABLE_TEXT_AREAS: - g_value_set_boolean(value, webkit_settings_get_enable_resizable_text_areas(settings)); - break; - case PROP_ENABLE_TABS_TO_LINKS: - g_value_set_boolean(value, webkit_settings_get_enable_tabs_to_links(settings)); - break; - case PROP_ENABLE_DNS_PREFETCHING: - g_value_set_boolean(value, webkit_settings_get_enable_dns_prefetching(settings)); - break; - case PROP_ENABLE_CARET_BROWSING: - g_value_set_boolean(value, webkit_settings_get_enable_caret_browsing(settings)); - break; - case PROP_ENABLE_FULLSCREEN: - g_value_set_boolean(value, webkit_settings_get_enable_fullscreen(settings)); - break; - case PROP_PRINT_BACKGROUNDS: - g_value_set_boolean(value, webkit_settings_get_print_backgrounds(settings)); - break; - case PROP_ENABLE_WEBAUDIO: - g_value_set_boolean(value, webkit_settings_get_enable_webaudio(settings)); - break; - case PROP_ENABLE_WEBGL: - g_value_set_boolean(value, webkit_settings_get_enable_webgl(settings)); - break; - case PROP_ALLOW_MODAL_DIALOGS: - g_value_set_boolean(value, webkit_settings_get_allow_modal_dialogs(settings)); - break; - case PROP_ZOOM_TEXT_ONLY: - g_value_set_boolean(value, webkit_settings_get_zoom_text_only(settings)); - break; - case PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD: - g_value_set_boolean(value, webkit_settings_get_javascript_can_access_clipboard(settings)); - break; - case PROP_MEDIA_PLAYBACK_REQUIRES_USER_GESTURE: - g_value_set_boolean(value, webkit_settings_get_media_playback_requires_user_gesture(settings)); - break; - case PROP_MEDIA_PLAYBACK_ALLOWS_INLINE: - g_value_set_boolean(value, webkit_settings_get_media_playback_allows_inline(settings)); - break; - case PROP_DRAW_COMPOSITING_INDICATORS: - g_value_set_boolean(value, webkit_settings_get_draw_compositing_indicators(settings)); - break; - case PROP_ENABLE_SITE_SPECIFIC_QUIRKS: - g_value_set_boolean(value, webkit_settings_get_enable_site_specific_quirks(settings)); - break; - case PROP_ENABLE_PAGE_CACHE: - g_value_set_boolean(value, webkit_settings_get_enable_page_cache(settings)); - break; - case PROP_USER_AGENT: - g_value_set_string(value, webkit_settings_get_user_agent(settings)); - break; - case PROP_ENABLE_SMOOTH_SCROLLING: - g_value_set_boolean(value, webkit_settings_get_enable_smooth_scrolling(settings)); - break; - case PROP_ENABLE_ACCELERATED_2D_CANVAS: - g_value_set_boolean(value, webkit_settings_get_enable_accelerated_2d_canvas(settings)); - break; - case PROP_ENABLE_WRITE_CONSOLE_MESSAGES_TO_STDOUT: - g_value_set_boolean(value, webkit_settings_get_enable_write_console_messages_to_stdout(settings)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - break; - } -} - -static void webkit_settings_class_init(WebKitSettingsClass* klass) -{ - GObjectClass* gObjectClass = G_OBJECT_CLASS(klass); - gObjectClass->constructed = webKitSettingsConstructed; - gObjectClass->set_property = webKitSettingsSetProperty; - gObjectClass->get_property = webKitSettingsGetProperty; - - GParamFlags readWriteConstructParamFlags = static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT); - - /** - * WebKitSettings:enable-javascript: - * - * Determines whether or not JavaScript executes within a page. - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_JAVASCRIPT, - g_param_spec_boolean("enable-javascript", - _("Enable JavaScript"), - _("Enable JavaScript."), - TRUE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:auto-load-images: - * - * Determines whether images should be automatically loaded or not. - * On devices where network bandwidth is of concern, it might be - * useful to turn this property off. - */ - g_object_class_install_property(gObjectClass, - PROP_AUTO_LOAD_IMAGES, - g_param_spec_boolean("auto-load-images", - _("Auto load images"), - _("Load images automatically."), - TRUE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:load-icons-ignoring-image-load-setting: - * - * Determines whether a site can load favicons irrespective - * of the value of #WebKitSettings:auto-load-images. - */ - g_object_class_install_property(gObjectClass, - PROP_LOAD_ICONS_IGNORING_IMAGE_LOAD_SETTING, - g_param_spec_boolean("load-icons-ignoring-image-load-setting", - _("Load icons ignoring image load setting"), - _("Whether to load site icons ignoring image load setting."), - FALSE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-offline-web-application-cache: - * - * Whether to enable HTML5 offline web application cache support. Offline - * web application cache allows web applications to run even when - * the user is not connected to the network. - * - * HTML5 offline web application specification is available at - * http://dev.w3.org/html5/spec/offline.html. - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE, - g_param_spec_boolean("enable-offline-web-application-cache", - _("Enable offline web application cache"), - _("Whether to enable offline web application cache."), - TRUE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-html5-local-storage: - * - * Whether to enable HTML5 local storage support. Local storage provides - * simple synchronous storage access. - * - * HTML5 local storage specification is available at - * http://dev.w3.org/html5/webstorage/. - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_HTML5_LOCAL_STORAGE, - g_param_spec_boolean("enable-html5-local-storage", - _("Enable HTML5 local storage"), - _("Whether to enable HTML5 Local Storage support."), - TRUE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-html5-database: - * - * Whether to enable HTML5 client-side SQL database support. Client-side - * SQL database allows web pages to store structured data and be able to - * use SQL to manipulate that data asynchronously. - * - * HTML5 database specification is available at - * http://www.w3.org/TR/webdatabase/. - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_HTML5_DATABASE, - g_param_spec_boolean("enable-html5-database", - _("Enable HTML5 database"), - _("Whether to enable HTML5 database support."), - TRUE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-xss-auditor: - * - * Whether to enable the XSS auditor. This feature filters some kinds of - * reflective XSS attacks on vulnerable web sites. - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_XSS_AUDITOR, - g_param_spec_boolean("enable-xss-auditor", - _("Enable XSS auditor"), - _("Whether to enable the XSS auditor."), - TRUE, - readWriteConstructParamFlags)); - - - /** - * WebKitSettings:enable-frame-flattening: - * - * Whether to enable the frame flattening. With this setting each subframe is expanded - * to its contents, which will flatten all the frames to become one scrollable page. - * On touch devices scrollable subframes on a page can result in a confusing user experience. - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_FRAME_FLATTENING, - g_param_spec_boolean("enable-frame-flattening", - _("Enable frame flattening"), - _("Whether to enable frame flattening."), - FALSE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-plugins: - * - * Determines whether or not plugins on the page are enabled. - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_PLUGINS, - g_param_spec_boolean("enable-plugins", - _("Enable plugins"), - _("Enable embedded plugin objects."), - TRUE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-java: - * - * Determines whether or not Java is enabled on the page. - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_JAVA, - g_param_spec_boolean("enable-java", - _("Enable Java"), - _("Whether Java support should be enabled."), - TRUE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:javascript-can-open-windows-automatically: - * - * Whether JavaScript can open popup windows automatically without user - * intervention. - */ - g_object_class_install_property(gObjectClass, - PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY, - g_param_spec_boolean("javascript-can-open-windows-automatically", - _("JavaScript can open windows automatically"), - _("Whether JavaScript can open windows automatically."), - FALSE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-hyperlink-auditing: - * - * Determines whether or not hyperlink auditing is enabled. - * - * The hyperlink auditing specification is available at - * http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperlink-auditing. - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_HYPERLINK_AUDITING, - g_param_spec_boolean("enable-hyperlink-auditing", - _("Enable hyperlink auditing"), - _("Whether <a ping> should be able to send pings."), - FALSE, - readWriteConstructParamFlags)); - - /** - * WebKitWebSettings:default-font-family: - * - * The font family to use as the default for content that does not specify a font. - */ - g_object_class_install_property(gObjectClass, - PROP_DEFAULT_FONT_FAMILY, - g_param_spec_string("default-font-family", - _("Default font family"), - _("The font family to use as the default for content that does not specify a font."), - "sans-serif", - readWriteConstructParamFlags)); - - /** - * WebKitWebSettings:monospace-font-family: - * - * The font family used as the default for content using a monospace font. - * - */ - g_object_class_install_property(gObjectClass, - PROP_MONOSPACE_FONT_FAMILY, - g_param_spec_string("monospace-font-family", - _("Monospace font family"), - _("The font family used as the default for content using monospace font."), - "monospace", - readWriteConstructParamFlags)); - - /** - * WebKitWebSettings:serif-font-family: - * - * The font family used as the default for content using a serif font. - */ - g_object_class_install_property(gObjectClass, - PROP_SERIF_FONT_FAMILY, - g_param_spec_string("serif-font-family", - _("Serif font family"), - _("The font family used as the default for content using serif font."), - "serif", - readWriteConstructParamFlags)); - - /** - * WebKitWebSettings:sans-serif-font-family: - * - * The font family used as the default for content using a sans-serif font. - */ - g_object_class_install_property(gObjectClass, - PROP_SANS_SERIF_FONT_FAMILY, - g_param_spec_string("sans-serif-font-family", - _("Sans-serif font family"), - _("The font family used as the default for content using sans-serif font."), - "sans-serif", - readWriteConstructParamFlags)); - - /** - * WebKitWebSettings:cursive-font-family: - * - * The font family used as the default for content using a cursive font. - */ - g_object_class_install_property(gObjectClass, - PROP_CURSIVE_FONT_FAMILY, - g_param_spec_string("cursive-font-family", - _("Cursive font family"), - _("The font family used as the default for content using cursive font."), - "serif", - readWriteConstructParamFlags)); - - /** - * WebKitWebSettings:fantasy-font-family: - * - * The font family used as the default for content using a fantasy font. - */ - g_object_class_install_property(gObjectClass, - PROP_FANTASY_FONT_FAMILY, - g_param_spec_string("fantasy-font-family", - _("Fantasy font family"), - _("The font family used as the default for content using fantasy font."), - "serif", - readWriteConstructParamFlags)); - - /** - * WebKitWebSettings:pictograph-font-family: - * - * The font family used as the default for content using a pictograph font. - */ - g_object_class_install_property(gObjectClass, - PROP_PICTOGRAPH_FONT_FAMILY, - g_param_spec_string("pictograph-font-family", - _("Pictograph font family"), - _("The font family used as the default for content using pictograph font."), - "serif", - readWriteConstructParamFlags)); - - /** - * WebKitWebSettings:default-font-size: - * - * The default font size in pixels to use for content displayed if - * no font size is specified. - */ - g_object_class_install_property(gObjectClass, - PROP_DEFAULT_FONT_SIZE, - g_param_spec_uint("default-font-size", - _("Default font size"), - _("The default font size used to display text."), - 0, G_MAXUINT, 16, - readWriteConstructParamFlags)); - - /** - * WebKitWebSettings:default-monospace-font-size: - * - * The default font size in pixels to use for content displayed in - * monospace font if no font size is specified. - */ - g_object_class_install_property(gObjectClass, - PROP_DEFAULT_MONOSPACE_FONT_SIZE, - g_param_spec_uint("default-monospace-font-size", - _("Default monospace font size"), - _("The default font size used to display monospace text."), - 0, G_MAXUINT, 13, - readWriteConstructParamFlags)); - - /** - * WebKitWebSettings:minimum-font-size: - * - * The minimum font size in points used to display text. This setting - * controls the absolute smallest size. Values other than 0 can - * potentially break page layouts. - */ - g_object_class_install_property(gObjectClass, - PROP_MINIMUM_FONT_SIZE, - g_param_spec_uint("minimum-font-size", - _("Minimum font size"), - _("The minimum font size used to display text."), - 0, G_MAXUINT, 0, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:default-charset: - * - * The default text charset used when interpreting content with an unspecified charset. - */ - g_object_class_install_property(gObjectClass, - PROP_DEFAULT_CHARSET, - g_param_spec_string("default-charset", - _("Default charset"), - _("The default text charset used when interpreting content with unspecified charset."), - "iso-8859-1", - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-private-browsing: - * - * Determines whether or not private browsing is enabled. Private browsing - * will disable history, cache and form auto-fill for any pages visited. - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_PRIVATE_BROWSING, - g_param_spec_boolean("enable-private-browsing", - _("Enable private browsing"), - _("Whether to enable private browsing"), - FALSE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-developer-extras: - * - * Determines whether or not developer tools, such as the Web Inspector, are enabled. - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_DEVELOPER_EXTRAS, - g_param_spec_boolean("enable-developer-extras", - _("Enable developer extras"), - _("Whether to enable developer extras"), - FALSE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-resizable-text-areas: - * - * Determines whether or not text areas can be resized. - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_RESIZABLE_TEXT_AREAS, - g_param_spec_boolean("enable-resizable-text-areas", - _("Enable resizable text areas"), - _("Whether to enable resizable text areas"), - TRUE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-tabs-to-links: - * - * Determines whether the tab key cycles through the elements on the page. - * When this setting is enabled, users will be able to focus the next element - * in the page by pressing the tab key. If the selected element is editable, - * then pressing tab key will insert the tab character. - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_TABS_TO_LINKS, - g_param_spec_boolean("enable-tabs-to-links", - _("Enable tabs to links"), - _("Whether to enable tabs to links"), - TRUE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-dns-prefetching: - * - * Determines whether or not to prefetch domain names. DNS prefetching attempts - * to resolve domain names before a user tries to follow a link. - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_DNS_PREFETCHING, - g_param_spec_boolean("enable-dns-prefetching", - _("Enable DNS prefetching"), - _("Whether to enable DNS prefetching"), - FALSE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-caret-browsing: - * - * Whether to enable accessibility enhanced keyboard navigation. - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_CARET_BROWSING, - g_param_spec_boolean("enable-caret-browsing", - _("Enable Caret Browsing"), - _("Whether to enable accessibility enhanced keyboard navigation"), - FALSE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-fullscreen: - * - * Whether to enable the Javascript Fullscreen API. The API - * allows any HTML element to request fullscreen display. See also - * the current draft of the spec: - * http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_FULLSCREEN, - g_param_spec_boolean("enable-fullscreen", - _("Enable Fullscreen"), - _("Whether to enable the Javascriipt Fullscreen API"), - FALSE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:print-backgrounds: - * - * Whether background images should be drawn during printing. - */ - g_object_class_install_property(gObjectClass, - PROP_PRINT_BACKGROUNDS, - g_param_spec_boolean("print-backgrounds", - _("Print Backgrounds"), - _("Whether background images should be drawn during printing"), - TRUE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-webaudio: - * - * - * Enable or disable support for WebAudio on pages. WebAudio is an - * experimental proposal for allowing web pages to generate Audio - * WAVE data from JavaScript. The standard is currently a - * work-in-progress by the W3C Audio Working Group. - * - * See also https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_WEBAUDIO, - g_param_spec_boolean("enable-webaudio", - _("Enable WebAudio"), - _("Whether WebAudio content should be handled"), - FALSE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-webgl: - * - * Enable or disable support for WebGL on pages. WebGL is an experimental - * proposal for allowing web pages to use OpenGL ES-like calls directly. The - * standard is currently a work-in-progress by the Khronos Group. - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_WEBGL, - g_param_spec_boolean("enable-webgl", - _("Enable WebGL"), - _("Whether WebGL content should be rendered"), - FALSE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:allow-modal-dialogs: - * - * Determine whether it's allowed to create and run modal dialogs - * from a #WebKitWebView through JavaScript with - * <function>window.showModalDialog</function>. If it's set to - * %FALSE, the associated #WebKitWebView won't be able to create - * new modal dialogs, so not even the #WebKitWebView::create - * signal will be emitted. - */ - g_object_class_install_property(gObjectClass, - PROP_ALLOW_MODAL_DIALOGS, - g_param_spec_boolean("allow-modal-dialogs", - _("Allow modal dialogs"), - _("Whether it is possible to create modal dialogs"), - FALSE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:zoom-text-only: - * - * Whether #WebKitWebView:zoom-level affects only the - * text of the page or all the contents. Other contents containing text - * like form controls will be also affected by zoom factor when - * this property is enabled. - */ - g_object_class_install_property(gObjectClass, - PROP_ZOOM_TEXT_ONLY, - g_param_spec_boolean("zoom-text-only", - _("Zoom Text Only"), - _("Whether zoom level of web view changes only the text size"), - FALSE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:javascript-can-access-clipboard: - * - * Whether JavaScript can access the clipboard. The default value is %FALSE. If - * set to %TRUE, document.execCommand() allows cut, copy and paste commands. - * - */ - g_object_class_install_property(gObjectClass, - PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD, - g_param_spec_boolean("javascript-can-access-clipboard", - _("JavaScript can access clipboard"), - _("Whether JavaScript can access Clipboard"), - FALSE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:media-playback-requires-user-gesture: - * - * Whether a user gesture (such as clicking the play button) - * would be required to start media playback or load media. This is off - * by default, so media playback could start automatically. - * Setting it on requires a gesture by the user to start playback, or to - * load the media. - */ - g_object_class_install_property(gObjectClass, - PROP_MEDIA_PLAYBACK_REQUIRES_USER_GESTURE, - g_param_spec_boolean("media-playback-requires-user-gesture", - _("Media playback requires user gesture"), - _("Whether media playback requires user gesture"), - FALSE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:media-playback-allows-inline: - * - * Whether media playback is full-screen only or inline playback is allowed. - * This is %TRUE by default, so media playback can be inline. Setting it to - * %FALSE allows specifying that media playback should be always fullscreen. - */ - g_object_class_install_property(gObjectClass, - PROP_MEDIA_PLAYBACK_ALLOWS_INLINE, - g_param_spec_boolean("media-playback-allows-inline", - _("Media playback allows inline"), - _("Whether media playback allows inline"), - TRUE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:draw-compositing-indicators: - * - * Whether to draw compositing borders and repaint counters on layers drawn - * with accelerated compositing. This is useful for debugging issues related - * to web content that is composited with the GPU. - */ - g_object_class_install_property(gObjectClass, - PROP_DRAW_COMPOSITING_INDICATORS, - g_param_spec_boolean("draw-compositing-indicators", - _("Draw compositing indicators"), - _("Whether to draw compositing borders and repaint counters"), - FALSE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-site-specific-quirks: - * - * Whether to turn on site-specific quirks. Turning this on will - * tell WebKit to use some site-specific workarounds for - * better web compatibility. For example, older versions of - * MediaWiki will incorrectly send to WebKit a css file with KHTML - * workarounds. By turning on site-specific quirks, WebKit will - * special-case this and other cases to make some specific sites work. - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_SITE_SPECIFIC_QUIRKS, - g_param_spec_boolean("enable-site-specific-quirks", - _("Enable Site Specific Quirks"), - _("Enables the site-specific compatibility workarounds"), - FALSE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-page-cache: - * - * Enable or disable the page cache. Disabling the page cache is - * generally only useful for special circumstances like low-memory - * scenarios or special purpose applications like static HTML - * viewers. This setting only controls the Page Cache, this cache - * is different than the disk-based or memory-based traditional - * resource caches, its point is to make going back and forth - * between pages much faster. For details about the different types - * of caches and their purposes see: - * http://webkit.org/blog/427/webkit-page-cache-i-the-basics/ - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_PAGE_CACHE, - g_param_spec_boolean("enable-page-cache", - _("Enable page cache"), - _("Whether the page cache should be used"), - TRUE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:user-agent: - * - * The user-agent string used by WebKit. Unusual user-agent strings may cause web - * content to render incorrectly or fail to run, as many web pages are written to - * parse the user-agent strings of only the most popular browsers. Therefore, it's - * typically better to not completely override the standard user-agent, but to use - * webkit_settings_set_user_agent_with_application_details() instead. - * - * If this property is set to the empty string or %NULL, it will revert to the standard - * user-agent. - */ - g_object_class_install_property(gObjectClass, - PROP_USER_AGENT, - g_param_spec_string("user-agent", - _("User agent string"), - _("The user agent string"), - 0, // A null string forces the standard user agent. - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-smooth-scrolling: - * - * Enable or disable smooth scrolling. - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_SMOOTH_SCROLLING, - g_param_spec_boolean("enable-smooth-scrolling", - _("Enable smooth scrolling"), - _("Whether to enable smooth scrolling"), - FALSE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-accelerated-2d-canvas: - * - * Enable or disable accelerated 2D canvas. Accelerated 2D canvas is only available - * if WebKitGTK+ was compiled with a version of Cairo including the unstable CairoGL API. - * When accelerated 2D canvas is enabled, WebKit may render some 2D canvas content - * using hardware accelerated drawing operations. - * - * Since: 2.2 - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_ACCELERATED_2D_CANVAS, - g_param_spec_boolean("enable-accelerated-2d-canvas", - _("Enable accelerated 2D canvas"), - _("Whether to enable accelerated 2D canvas"), - FALSE, - readWriteConstructParamFlags)); - - /** - * WebKitSettings:enable-write-console-messages-to-stdout: - * - * Enable or disable writing console messages to stdout. These are messages - * sent to the console with console.log and related methods. - * - * Since: 2.2 - */ - g_object_class_install_property(gObjectClass, - PROP_ENABLE_WRITE_CONSOLE_MESSAGES_TO_STDOUT, - g_param_spec_boolean("enable-write-console-messages-to-stdout", - _("Write console messages on stdout"), - _("Whether to write console messages on stdout"), - FALSE, - readWriteConstructParamFlags)); - -} - -WebPreferences* webkitSettingsGetPreferences(WebKitSettings* settings) -{ - return settings->priv->preferences.get(); -} - -/** - * webkit_settings_new: - * - * Creates a new #WebKitSettings instance with default values. It must - * be manually attached to a #WebKitWebViewGroup. - * See also webkit_settings_new_with_settings(). - * - * Returns: a new #WebKitSettings instance. - */ -WebKitSettings* webkit_settings_new() -{ - return WEBKIT_SETTINGS(g_object_new(WEBKIT_TYPE_SETTINGS, NULL)); -} - -/** - * webkit_settings_new_with_settings: - * @first_setting_name: name of first setting to set - * @...: value of first setting, followed by more settings, - * %NULL-terminated - * - * Creates a new #WebKitSettings instance with the given settings. It must - * be manually attached to a #WebKitWebViewGroup. - * - * Returns: a new #WebKitSettings instance. - */ -WebKitSettings* webkit_settings_new_with_settings(const gchar* firstSettingName, ...) -{ - va_list args; - va_start(args, firstSettingName); - WebKitSettings* settings = WEBKIT_SETTINGS(g_object_new_valist(WEBKIT_TYPE_SETTINGS, firstSettingName, args)); - va_end(args); - return settings; -} - -/** - * webkit_settings_get_enable_javascript: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-javascript property. - * - * Returns: %TRUE If JavaScript is enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_javascript(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->javaScriptEnabled(); -} - -/** - * webkit_settings_set_enable_javascript: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-javascript property. - */ -void webkit_settings_set_enable_javascript(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->javaScriptEnabled(); - if (currentValue == enabled) - return; - - priv->preferences->setJavaScriptEnabled(enabled); - g_object_notify(G_OBJECT(settings), "enable-javascript"); -} - -/** - * webkit_settings_get_auto_load_images: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:auto-load-images property. - * - * Returns: %TRUE If auto loading of images is enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_auto_load_images(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->loadsImagesAutomatically(); -} - -/** - * webkit_settings_set_auto_load_images: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:auto-load-images property. - */ -void webkit_settings_set_auto_load_images(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->loadsImagesAutomatically(); - if (currentValue == enabled) - return; - - priv->preferences->setLoadsImagesAutomatically(enabled); - g_object_notify(G_OBJECT(settings), "auto-load-images"); -} - -/** - * webkit_settings_get_load_icons_ignoring_image_load_setting: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:load-icons-ignoring-image-load-setting property. - * - * Returns: %TRUE If site icon can be loaded irrespective of image loading preference or %FALSE otherwise. - */ -gboolean webkit_settings_get_load_icons_ignoring_image_load_setting(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->loadsSiteIconsIgnoringImageLoadingPreference(); -} - -/** - * webkit_settings_set_load_icons_ignoring_image_load_setting: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:load-icons-ignoring-image-load-setting property. - */ -void webkit_settings_set_load_icons_ignoring_image_load_setting(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->loadsSiteIconsIgnoringImageLoadingPreference(); - if (currentValue == enabled) - return; - - priv->preferences->setLoadsSiteIconsIgnoringImageLoadingPreference(enabled); - g_object_notify(G_OBJECT(settings), "load-icons-ignoring-image-load-setting"); -} - -/** - * webkit_settings_get_enable_offline_web_application_cache: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-offline-web-application-cache property. - * - * Returns: %TRUE If HTML5 offline web application cache support is enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_offline_web_application_cache(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->offlineWebApplicationCacheEnabled(); -} - -/** - * webkit_settings_set_enable_offline_web_application_cache: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-offline-web-application-cache property. - */ -void webkit_settings_set_enable_offline_web_application_cache(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->offlineWebApplicationCacheEnabled(); - if (currentValue == enabled) - return; - - priv->preferences->setOfflineWebApplicationCacheEnabled(enabled); - g_object_notify(G_OBJECT(settings), "enable-offline-web-application-cache"); -} - -/** - * webkit_settings_get_enable_html5_local_storage: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-html5-local-storage property. - * - * Returns: %TRUE If HTML5 local storage support is enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_html5_local_storage(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->localStorageEnabled(); -} - -/** - * webkit_settings_set_enable_html5_local_storage: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-html5-local-storage property. - */ -void webkit_settings_set_enable_html5_local_storage(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->localStorageEnabled(); - if (currentValue == enabled) - return; - - priv->preferences->setLocalStorageEnabled(enabled); - g_object_notify(G_OBJECT(settings), "enable-html5-local-storage"); -} - -/** - * webkit_settings_get_enable_html5_database: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-html5-database property. - * - * Returns: %TRUE If HTML5 database support is enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_html5_database(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->databasesEnabled(); -} - -/** - * webkit_settings_set_enable_html5_database: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-html5-database property. - */ -void webkit_settings_set_enable_html5_database(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->databasesEnabled(); - if (currentValue == enabled) - return; - - priv->preferences->setDatabasesEnabled(enabled); - g_object_notify(G_OBJECT(settings), "enable-html5-database"); -} - -/** - * webkit_settings_get_enable_xss_auditor: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-xss-auditor property. - * - * Returns: %TRUE If XSS auditing is enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_xss_auditor(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->xssAuditorEnabled(); -} - -/** - * webkit_settings_set_enable_xss_auditor: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-xss-auditor property. - */ -void webkit_settings_set_enable_xss_auditor(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->xssAuditorEnabled(); - if (currentValue == enabled) - return; - - priv->preferences->setXSSAuditorEnabled(enabled); - g_object_notify(G_OBJECT(settings), "enable-xss-auditor"); -} - -/** - * webkit_settings_get_enable_frame_flattening: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-frame-flattening property. - * - * Returns: %TRUE If frame flattening is enabled or %FALSE otherwise. - * - **/ -gboolean webkit_settings_get_enable_frame_flattening(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->frameFlatteningEnabled(); -} - -/** - * webkit_settings_set_enable_frame_flattening: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-frame-flattening property. - */ -void webkit_settings_set_enable_frame_flattening(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->frameFlatteningEnabled(); - if (currentValue == enabled) - return; - - priv->preferences->setFrameFlatteningEnabled(enabled); - g_object_notify(G_OBJECT(settings), "enable-frame-flattening"); -} - -/** - * webkit_settings_get_enable_plugins: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-plugins property. - * - * Returns: %TRUE If plugins are enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_plugins(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->pluginsEnabled(); -} - -/** - * webkit_settings_set_enable_plugins: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-plugins property. - */ -void webkit_settings_set_enable_plugins(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->pluginsEnabled(); - if (currentValue == enabled) - return; - - priv->preferences->setPluginsEnabled(enabled); - g_object_notify(G_OBJECT(settings), "enable-plugins"); -} - -/** - * webkit_settings_get_enable_java: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-java property. - * - * Returns: %TRUE If Java is enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_java(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->javaEnabled(); -} - -/** - * webkit_settings_set_enable_java: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-java property. - */ -void webkit_settings_set_enable_java(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->javaEnabled(); - if (currentValue == enabled) - return; - - priv->preferences->setJavaEnabled(enabled); - g_object_notify(G_OBJECT(settings), "enable-java"); -} - -/** - * webkit_settings_get_javascript_can_open_windows_automatically: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:javascript-can-open-windows-automatically property. - * - * Returns: %TRUE If JavaScript can open window automatically or %FALSE otherwise. - */ -gboolean webkit_settings_get_javascript_can_open_windows_automatically(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->javaScriptCanOpenWindowsAutomatically(); -} - -/** - * webkit_settings_set_javascript_can_open_windows_automatically: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:javascript-can-open-windows-automatically property. - */ -void webkit_settings_set_javascript_can_open_windows_automatically(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->javaScriptCanOpenWindowsAutomatically(); - if (currentValue == enabled) - return; - - priv->preferences->setJavaScriptCanOpenWindowsAutomatically(enabled); - g_object_notify(G_OBJECT(settings), "javascript-can-open-windows-automatically"); -} - -/** - * webkit_settings_get_enable_hyperlink_auditing: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-hyperlink-auditing property. - * - * Returns: %TRUE If hyper link auditing is enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_hyperlink_auditing(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->hyperlinkAuditingEnabled(); -} - -/** - * webkit_settings_set_enable_hyperlink_auditing: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-hyperlink-auditing property. - */ -void webkit_settings_set_enable_hyperlink_auditing(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->hyperlinkAuditingEnabled(); - if (currentValue == enabled) - return; - - priv->preferences->setHyperlinkAuditingEnabled(enabled); - g_object_notify(G_OBJECT(settings), "enable-hyperlink-auditing"); -} - -/** - * webkit_web_settings_get_default_font_family: - * @settings: a #WebKitSettings - * - * Gets the #WebKitSettings:default-font-family property. - * - * Returns: The default font family used to display content that does not specify a font. - */ -const gchar* webkit_settings_get_default_font_family(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0); - - return settings->priv->defaultFontFamily.data(); -} - -/** - * webkit_settings_set_default_font_family: - * @settings: a #WebKitSettings - * @default_font_family: the new default font family - * - * Set the #WebKitSettings:default-font-family property. - */ -void webkit_settings_set_default_font_family(WebKitSettings* settings, const gchar* defaultFontFamily) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - g_return_if_fail(defaultFontFamily); - - WebKitSettingsPrivate* priv = settings->priv; - if (!g_strcmp0(priv->defaultFontFamily.data(), defaultFontFamily)) - return; - - String standardFontFamily = String::fromUTF8(defaultFontFamily); - priv->preferences->setStandardFontFamily(standardFontFamily); - priv->defaultFontFamily = standardFontFamily.utf8(); - g_object_notify(G_OBJECT(settings), "default-font-family"); -} - -/** - * webkit_settings_get_monospace_font_family: - * @settings: a #WebKitSettings - * - * Gets the #WebKitSettings:monospace-font-family property. - * - * Returns: Default font family used to display content marked with monospace font. - */ -const gchar* webkit_settings_get_monospace_font_family(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0); - - return settings->priv->monospaceFontFamily.data(); -} - -/** - * webkit_settings_set_monospace_font_family: - * @settings: a #WebKitSettings - * @monospace_font_family: the new default monospace font family - * - * Set the #WebKitSettings:monospace-font-family property. - */ -void webkit_settings_set_monospace_font_family(WebKitSettings* settings, const gchar* monospaceFontFamily) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - g_return_if_fail(monospaceFontFamily); - - WebKitSettingsPrivate* priv = settings->priv; - if (!g_strcmp0(priv->monospaceFontFamily.data(), monospaceFontFamily)) - return; - - String fixedFontFamily = String::fromUTF8(monospaceFontFamily); - priv->preferences->setFixedFontFamily(fixedFontFamily); - priv->monospaceFontFamily = fixedFontFamily.utf8(); - g_object_notify(G_OBJECT(settings), "monospace-font-family"); -} - -/** - * webkit_settings_get_serif_font_family: - * @settings: a #WebKitSettings - * - * Gets the #WebKitSettings:serif-font-family property. - * - * Returns: The default font family used to display content marked with serif font. - */ -const gchar* webkit_settings_get_serif_font_family(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0); - - return settings->priv->serifFontFamily.data(); -} - -/** - * webkit_settings_set_serif_font_family: - * @settings: a #WebKitSettings - * @serif_font_family: the new default serif font family - * - * Set the #WebKitSettings:serif-font-family property. - */ -void webkit_settings_set_serif_font_family(WebKitSettings* settings, const gchar* serifFontFamily) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - g_return_if_fail(serifFontFamily); - - WebKitSettingsPrivate* priv = settings->priv; - if (!g_strcmp0(priv->serifFontFamily.data(), serifFontFamily)) - return; - - String serifFontFamilyString = String::fromUTF8(serifFontFamily); - priv->preferences->setSerifFontFamily(serifFontFamilyString); - priv->serifFontFamily = serifFontFamilyString.utf8(); - g_object_notify(G_OBJECT(settings), "serif-font-family"); -} - -/** - * webkit_settings_get_sans_serif_font_family: - * @settings: a #WebKitSettings - * - * Gets the #WebKitSettings:sans-serif-font-family property. - * - * Returns: The default font family used to display content marked with sans-serif font. - */ -const gchar* webkit_settings_get_sans_serif_font_family(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0); - - return settings->priv->sansSerifFontFamily.data(); -} - -/** - * webkit_settings_set_sans_serif_font_family: - * @settings: a #WebKitSettings - * @sans_serif_font_family: the new default sans-serif font family - * - * Set the #WebKitSettings:sans-serif-font-family property. - */ -void webkit_settings_set_sans_serif_font_family(WebKitSettings* settings, const gchar* sansSerifFontFamily) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - g_return_if_fail(sansSerifFontFamily); - - WebKitSettingsPrivate* priv = settings->priv; - if (!g_strcmp0(priv->sansSerifFontFamily.data(), sansSerifFontFamily)) - return; - - String sansSerifFontFamilyString = String::fromUTF8(sansSerifFontFamily); - priv->preferences->setSansSerifFontFamily(sansSerifFontFamilyString); - priv->sansSerifFontFamily = sansSerifFontFamilyString.utf8(); - g_object_notify(G_OBJECT(settings), "sans-serif-font-family"); -} - -/** - * webkit_settings_get_cursive_font_family: - * @settings: a #WebKitSettings - * - * Gets the #WebKitSettings:cursive-font-family property. - * - * Returns: The default font family used to display content marked with cursive font. - */ -const gchar* webkit_settings_get_cursive_font_family(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0); - - return settings->priv->cursiveFontFamily.data(); -} - -/** - * webkit_settings_set_cursive_font_family: - * @settings: a #WebKitSettings - * @cursive_font_family: the new default cursive font family - * - * Set the #WebKitSettings:cursive-font-family property. - */ -void webkit_settings_set_cursive_font_family(WebKitSettings* settings, const gchar* cursiveFontFamily) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - g_return_if_fail(cursiveFontFamily); - - WebKitSettingsPrivate* priv = settings->priv; - if (!g_strcmp0(priv->cursiveFontFamily.data(), cursiveFontFamily)) - return; - - String cursiveFontFamilyString = String::fromUTF8(cursiveFontFamily); - priv->preferences->setCursiveFontFamily(cursiveFontFamilyString); - priv->cursiveFontFamily = cursiveFontFamilyString.utf8(); - g_object_notify(G_OBJECT(settings), "cursive-font-family"); -} - -/** - * webkit_settings_get_fantasy_font_family: - * @settings: a #WebKitSettings - * - * Gets the #WebKitSettings:fantasy-font-family property. - * - * Returns: The default font family used to display content marked with fantasy font. - */ -const gchar* webkit_settings_get_fantasy_font_family(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0); - - return settings->priv->fantasyFontFamily.data(); -} - -/** - * webkit_settings_set_fantasy_font_family: - * @settings: a #WebKitSettings - * @fantasy_font_family: the new default fantasy font family - * - * Set the #WebKitSettings:fantasy-font-family property. - */ -void webkit_settings_set_fantasy_font_family(WebKitSettings* settings, const gchar* fantasyFontFamily) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - g_return_if_fail(fantasyFontFamily); - - WebKitSettingsPrivate* priv = settings->priv; - if (!g_strcmp0(priv->fantasyFontFamily.data(), fantasyFontFamily)) - return; - - String fantasyFontFamilyString = String::fromUTF8(fantasyFontFamily); - priv->preferences->setFantasyFontFamily(fantasyFontFamilyString); - priv->fantasyFontFamily = fantasyFontFamilyString.utf8(); - g_object_notify(G_OBJECT(settings), "fantasy-font-family"); -} - -/** - * webkit_settings_get_pictograph_font_family: - * @settings: a #WebKitSettings - * - * Gets the #WebKitSettings:pictograph-font-family property. - * - * Returns: The default font family used to display content marked with pictograph font. - */ -const gchar* webkit_settings_get_pictograph_font_family(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0); - - return settings->priv->pictographFontFamily.data(); -} - -/** - * webkit_settings_set_pictograph_font_family: - * @settings: a #WebKitSettings - * @pictograph_font_family: the new default pictograph font family - * - * Set the #WebKitSettings:pictograph-font-family property. - */ -void webkit_settings_set_pictograph_font_family(WebKitSettings* settings, const gchar* pictographFontFamily) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - g_return_if_fail(pictographFontFamily); - - WebKitSettingsPrivate* priv = settings->priv; - if (!g_strcmp0(priv->pictographFontFamily.data(), pictographFontFamily)) - return; - - String pictographFontFamilyString = String::fromUTF8(pictographFontFamily); - priv->preferences->setPictographFontFamily(pictographFontFamilyString); - priv->pictographFontFamily = pictographFontFamilyString.utf8(); - g_object_notify(G_OBJECT(settings), "pictograph-font-family"); -} - -/** - * webkit_settings_get_default_font_size: - * @settings: a #WebKitSettings - * - * Gets the #WebKitSettings:default-font-size property. - * - * Returns: The default font size. - */ -guint32 webkit_settings_get_default_font_size(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0); - - return settings->priv->preferences->defaultFontSize(); -} - -/** - * webkit_settings_set_default_font_size: - * @settings: a #WebKitSettings - * @font_size: default font size to be set in pixels - * - * Set the #WebKitSettings:default-font-size property. - */ -void webkit_settings_set_default_font_size(WebKitSettings* settings, guint32 fontSize) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - uint32_t currentSize = priv->preferences->defaultFontSize(); - if (currentSize == fontSize) - return; - - priv->preferences->setDefaultFontSize(fontSize); - g_object_notify(G_OBJECT(settings), "default-font-size"); -} - -/** - * webkit_settings_get_default_monospace_font_size: - * @settings: a #WebKitSettings - * - * Gets the #WebKitSettings:default-monospace-font-size property. - * - * Returns: Default monospace font size. - */ -guint32 webkit_settings_get_default_monospace_font_size(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0); - - return settings->priv->preferences->defaultFixedFontSize(); -} - -/** - * webkit_settings_set_default_monospace_font_size: - * @settings: a #WebKitSettings - * @font_size: default monospace font size to be set in pixels - * - * Set the #WebKitSettings:default-monospace-font-size property. - */ -void webkit_settings_set_default_monospace_font_size(WebKitSettings* settings, guint32 fontSize) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - uint32_t currentSize = priv->preferences->defaultFixedFontSize(); - if (currentSize == fontSize) - return; - - priv->preferences->setDefaultFixedFontSize(fontSize); - g_object_notify(G_OBJECT(settings), "default-monospace-font-size"); -} - -/** - * webkit_settings_get_minimum_font_size: - * @settings: a #WebKitSettings - * - * Gets the #WebKitSettings:minimum-font-size property. - * - * Returns: Minimum font size. - */ -guint32 webkit_settings_get_minimum_font_size(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0); - - return settings->priv->preferences->minimumFontSize(); -} - -/** - * webkit_settings_set_minimum_font_size: - * @settings: a #WebKitSettings - * @font_size: minimum font size to be set in points - * - * Set the #WebKitSettings:minimum-font-size property. - */ -void webkit_settings_set_minimum_font_size(WebKitSettings* settings, guint32 fontSize) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - uint32_t currentSize = priv->preferences->minimumFontSize(); - if (currentSize == fontSize) - return; - - priv->preferences->setMinimumFontSize(fontSize); - g_object_notify(G_OBJECT(settings), "minimum-font-size"); -} - -/** - * webkit_settings_get_default_charset: - * @settings: a #WebKitSettings - * - * Gets the #WebKitSettings:default-charset property. - * - * Returns: Default charset. - */ -const gchar* webkit_settings_get_default_charset(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0); - - return settings->priv->defaultCharset.data(); -} - -/** - * webkit_settings_set_default_charset: - * @settings: a #WebKitSettings - * @default_charset: default charset to be set - * - * Set the #WebKitSettings:default-charset property. - */ -void webkit_settings_set_default_charset(WebKitSettings* settings, const gchar* defaultCharset) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - g_return_if_fail(defaultCharset); - - WebKitSettingsPrivate* priv = settings->priv; - if (!g_strcmp0(priv->defaultCharset.data(), defaultCharset)) - return; - - String defaultCharsetString = String::fromUTF8(defaultCharset); - priv->preferences->setDefaultTextEncodingName(defaultCharsetString); - priv->defaultCharset = defaultCharsetString.utf8(); - g_object_notify(G_OBJECT(settings), "default-charset"); -} - -/** - * webkit_settings_get_enable_private_browsing: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-private-browsing property. - * - * Returns: %TRUE If private browsing is enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_private_browsing(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->privateBrowsingEnabled(); -} - -/** - * webkit_settings_set_private_caret_browsing: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-private-browsing property. - */ -void webkit_settings_set_enable_private_browsing(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->privateBrowsingEnabled(); - if (currentValue == enabled) - return; - - priv->preferences->setPrivateBrowsingEnabled(enabled); - g_object_notify(G_OBJECT(settings), "enable-private-browsing"); -} - -/** - * webkit_settings_get_enable_developer_extras: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-developer-extras property. - * - * Returns: %TRUE If developer extras is enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_developer_extras(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->developerExtrasEnabled(); -} - -/** - * webkit_settings_set_enable_developer_extras: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-developer-extras property. - */ -void webkit_settings_set_enable_developer_extras(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->developerExtrasEnabled(); - if (currentValue == enabled) - return; - - priv->preferences->setDeveloperExtrasEnabled(enabled); - g_object_notify(G_OBJECT(settings), "enable-developer-extras"); -} - -/** - * webkit_settings_get_enable_resizable_text_areas: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-resizable-text-areas property. - * - * Returns: %TRUE If text areas can be resized or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_resizable_text_areas(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->textAreasAreResizable(); -} - -/** - * webkit_settings_set_enable_resizable_text_areas: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-resizable-text-areas property. - */ -void webkit_settings_set_enable_resizable_text_areas(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->textAreasAreResizable(); - if (currentValue == enabled) - return; - - priv->preferences->setTextAreasAreResizable(enabled); - g_object_notify(G_OBJECT(settings), "enable-resizable-text-areas"); -} - -/** - * webkit_settings_get_enable_tabs_to_links: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-tabs-to-links property. - * - * Returns: %TRUE If tabs to link is enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_tabs_to_links(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->tabsToLinks(); -} - -/** - * webkit_settings_set_enable_tabs_to_links: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-tabs-to-links property. - */ -void webkit_settings_set_enable_tabs_to_links(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->tabsToLinks(); - if (currentValue == enabled) - return; - - priv->preferences->setTabsToLinks(enabled); - g_object_notify(G_OBJECT(settings), "enable-tabs-to-links"); -} - -/** - * webkit_settings_get_enable_dns_prefetching: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-dns-prefetching property. - * - * Returns: %TRUE If DNS prefetching is enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_dns_prefetching(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->dnsPrefetchingEnabled(); -} - -/** - * webkit_settings_set_enable_dns_prefetching: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-dns-prefetching property. - */ -void webkit_settings_set_enable_dns_prefetching(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->dnsPrefetchingEnabled(); - if (currentValue == enabled) - return; - - priv->preferences->setDNSPrefetchingEnabled(enabled); - g_object_notify(G_OBJECT(settings), "enable-dns-prefetching"); -} - -/** - * webkit_settings_get_enable_caret_browsing: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-caret-browsing property. - * - * Returns: %TRUE If caret browsing is enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_caret_browsing(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->caretBrowsingEnabled(); -} - -/** - * webkit_settings_set_enable_caret_browsing: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-caret-browsing property. - */ -void webkit_settings_set_enable_caret_browsing(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->caretBrowsingEnabled(); - if (currentValue == enabled) - return; - - priv->preferences->setCaretBrowsingEnabled(enabled); - g_object_notify(G_OBJECT(settings), "enable-caret-browsing"); -} - -/** - * webkit_settings_get_enable_fullscreen: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-fullscreen property. - * - * Returns: %TRUE If fullscreen support is enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_fullscreen(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->fullScreenEnabled(); -} - -/** - * webkit_settings_set_enable_fullscreen: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-fullscreen property. - */ -void webkit_settings_set_enable_fullscreen(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->fullScreenEnabled(); - if (currentValue == enabled) - return; - - priv->preferences->setFullScreenEnabled(enabled); - g_object_notify(G_OBJECT(settings), "enable-fullscreen"); -} - -/** - * webkit_settings_get_print_backgrounds: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:print-backgrounds property. - * - * Returns: %TRUE If background images should be printed or %FALSE otherwise. - */ -gboolean webkit_settings_get_print_backgrounds(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->shouldPrintBackgrounds(); -} - -/** - * webkit_settings_set_print_backgrounds: - * @settings: a #WebKitSettings - * @print_backgrounds: Value to be set - * - * Set the #WebKitSettings:print-backgrounds property. - */ -void webkit_settings_set_print_backgrounds(WebKitSettings* settings, gboolean printBackgrounds) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->shouldPrintBackgrounds(); - if (currentValue == printBackgrounds) - return; - - priv->preferences->setShouldPrintBackgrounds(printBackgrounds); - g_object_notify(G_OBJECT(settings), "print-backgrounds"); -} - -/** - * webkit_settings_get_enable_webaudio: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-webaudio property. - * - * Returns: %TRUE If webaudio support is enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_webaudio(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->webAudioEnabled(); -} - -/** - * webkit_settings_set_enable_webaudio: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-webaudio property. - */ -void webkit_settings_set_enable_webaudio(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->webAudioEnabled(); - if (currentValue == enabled) - return; - - priv->preferences->setWebAudioEnabled(enabled); - g_object_notify(G_OBJECT(settings), "enable-webaudio"); -} - -/** - * webkit_settings_get_enable_webgl: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-webgl property. - * - * Returns: %TRUE If webgl support is enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_webgl(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->webGLEnabled(); -} - -/** - * webkit_settings_set_enable_webgl: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-webgl property. - */ -void webkit_settings_set_enable_webgl(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->webGLEnabled(); - if (currentValue == enabled) - return; - - priv->preferences->setWebGLEnabled(enabled); - g_object_notify(G_OBJECT(settings), "enable-webgl"); -} - -/** - * webkit_settings_get_allow_modal_dialogs: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:allow-modal-dialogs property. - * - * Returns: %TRUE if it's allowed to create and run modal dialogs or %FALSE otherwise. - */ -gboolean webkit_settings_get_allow_modal_dialogs(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - return settings->priv->allowModalDialogs; -} - -/** - * webkit_settings_set_allow_modal_dialogs: - * @settings: a #WebKitSettings - * @allowed: Value to be set - * - * Set the #WebKitSettings:allow-modal-dialogs property. - */ -void webkit_settings_set_allow_modal_dialogs(WebKitSettings* settings, gboolean allowed) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - if (priv->allowModalDialogs == allowed) - return; - - priv->allowModalDialogs = allowed; - g_object_notify(G_OBJECT(settings), "allow-modal-dialogs"); -} - -/** - * webkit_settings_get_zoom_text_only: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:zoom-text-only property. - * - * Returns: %TRUE If zoom level of the view should only affect the text - * or %FALSE if all view contents should be scaled. - */ -gboolean webkit_settings_get_zoom_text_only(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->zoomTextOnly; -} - -/** - * webkit_settings_set_zoom_text_only: - * @settings: a #WebKitSettings - * @zoom_text_only: Value to be set - * - * Set the #WebKitSettings:zoom-text-only property. - */ -void webkit_settings_set_zoom_text_only(WebKitSettings* settings, gboolean zoomTextOnly) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - if (priv->zoomTextOnly == zoomTextOnly) - return; - - priv->zoomTextOnly = zoomTextOnly; - g_object_notify(G_OBJECT(settings), "zoom-text-only"); -} - -/** - * webkit_settings_get_javascript_can_access_clipboard: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:javascript-can-access-clipboard property. - * - * Returns: %TRUE If javascript-can-access-clipboard is enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_javascript_can_access_clipboard(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->javaScriptCanAccessClipboard() - && settings->priv->preferences->domPasteAllowed(); -} - -/** - * webkit_settings_set_javascript_can_access_clipboard: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:javascript-can-access-clipboard property. - */ -void webkit_settings_set_javascript_can_access_clipboard(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->javaScriptCanAccessClipboard() && priv->preferences->domPasteAllowed(); - if (currentValue == enabled) - return; - - priv->preferences->setJavaScriptCanAccessClipboard(enabled); - priv->preferences->setDOMPasteAllowed(enabled); - g_object_notify(G_OBJECT(settings), "javascript-can-access-clipboard"); -} - -/** - * webkit_settings_get_media_playback_requires_user_gesture: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:media-playback-requires-user-gesture property. - * - * Returns: %TRUE If an user gesture is needed to play or load media - * or %FALSE if no user gesture is needed. - */ -gboolean webkit_settings_get_media_playback_requires_user_gesture(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->mediaPlaybackRequiresUserGesture(); -} - -/** - * webkit_settings_set_media_playback_requires_user_gesture: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:media-playback-requires-user-gesture property. - */ -void webkit_settings_set_media_playback_requires_user_gesture(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->mediaPlaybackRequiresUserGesture(); - if (currentValue == enabled) - return; - - priv->preferences->setMediaPlaybackRequiresUserGesture(enabled); - g_object_notify(G_OBJECT(settings), "media-playback-requires-user-gesture"); -} - -/** - * webkit_settings_get_media_playback_allows_inline: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:media-playback-allows-inline property. - * - * Returns: %TRUE If inline playback is allowed for media - * or %FALSE if only fullscreen playback is allowed. - */ -gboolean webkit_settings_get_media_playback_allows_inline(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), TRUE); - - return settings->priv->preferences->mediaPlaybackAllowsInline(); -} - -/** - * webkit_settings_set_media_playback_allows_inline: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:media-playback-allows-inline property. - */ -void webkit_settings_set_media_playback_allows_inline(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->mediaPlaybackAllowsInline(); - if (currentValue == enabled) - return; - - priv->preferences->setMediaPlaybackAllowsInline(enabled); - g_object_notify(G_OBJECT(settings), "media-playback-allows-inline"); -} - -/** - * webkit_settings_get_draw_compositing_indicators: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:draw-compositing-indicators property. - * - * Returns: %TRUE If compositing borders are drawn or %FALSE otherwise. - */ -gboolean webkit_settings_get_draw_compositing_indicators(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - return settings->priv->preferences->compositingBordersVisible() - && settings->priv->preferences->compositingRepaintCountersVisible(); -} - -/** - * webkit_settings_set_draw_compositing_indicators: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:draw-compositing-indicators property. - */ -void webkit_settings_set_draw_compositing_indicators(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - if (priv->preferences->compositingBordersVisible() == enabled - && priv->preferences->compositingRepaintCountersVisible() == enabled) - return; - - priv->preferences->setCompositingBordersVisible(enabled); - priv->preferences->setCompositingRepaintCountersVisible(enabled); - g_object_notify(G_OBJECT(settings), "draw-compositing-indicators"); -} - -/** - * webkit_settings_get_enable_site_specific_quirks: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-site-specific-quirks property. - * - * Returns: %TRUE if site specific quirks are enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_site_specific_quirks(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->needsSiteSpecificQuirks(); -} - -/** - * webkit_settings_set_enable_site_specific_quirks: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-site-specific-quirks property. - */ -void webkit_settings_set_enable_site_specific_quirks(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->needsSiteSpecificQuirks(); - if (currentValue == enabled) - return; - - priv->preferences->setNeedsSiteSpecificQuirks(enabled); - g_object_notify(G_OBJECT(settings), "enable-site-specific-quirks"); -} - -/** - * webkit_settings_get_enable_page_cache: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-page-cache property. - * - * Returns: %TRUE if page cache enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_page_cache(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->usesPageCache(); -} - -/** - * webkit_settings_set_enable_page_cache: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-page-cache property. - */ -void webkit_settings_set_enable_page_cache(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->usesPageCache(); - if (currentValue == enabled) - return; - - priv->preferences->setUsesPageCache(enabled); - g_object_notify(G_OBJECT(settings), "enable-page-cache"); -} - -/** - * webkit_settings_get_user_agent: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:user-agent property. - * - * Returns: The current value of the user-agent property. - */ -const char* webkit_settings_get_user_agent(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0); - - WebKitSettingsPrivate* priv = settings->priv; - ASSERT(!priv->userAgent.isNull()); - return priv->userAgent.data(); -} - -/** - * webkit_settings_set_user_agent: - * @settings: a #WebKitSettings - * @user_agent: (allow-none): The new custom user agent string or %NULL to use the default user agent - * - * Set the #WebKitSettings:user-agent property. - */ -void webkit_settings_set_user_agent(WebKitSettings* settings, const char* userAgent) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - CString newUserAgent = (!userAgent || !strlen(userAgent)) ? WebCore::standardUserAgent("").utf8() : userAgent; - if (newUserAgent == priv->userAgent) - return; - - priv->userAgent = newUserAgent; - g_object_notify(G_OBJECT(settings), "user-agent"); -} - -/** - * webkit_settings_set_user_agent_with_application_details: - * @settings: a #WebKitSettings - * @application_name: (allow-none): The application name used for the user agent or %NULL to use the default user agent. - * @application_version: (allow-none): The application version for the user agent or %NULL to user the default version. - * - * Set the #WebKitSettings:user-agent property by appending the application details to the default user - * agent. If no application name or version is given, the default user agent used will be used. If only - * the version is given, the default engine version is used with the given application name. - */ -void webkit_settings_set_user_agent_with_application_details(WebKitSettings* settings, const char* applicationName, const char* applicationVersion) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - CString newUserAgent = WebCore::standardUserAgent(String::fromUTF8(applicationName), String::fromUTF8(applicationVersion)).utf8(); - webkit_settings_set_user_agent(settings, newUserAgent.data()); -} - -/** - * webkit_settings_get_enable_smooth_scrolling: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-smooth-scrolling property. - * - * Returns: %TRUE if smooth scrolling is enabled or %FALSE otherwise. - */ -gboolean webkit_settings_get_enable_smooth_scrolling(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->scrollAnimatorEnabled(); -} - -/** - * webkit_settings_set_enable_smooth_scrolling: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-smooth-scrolling property. - */ -void webkit_settings_set_enable_smooth_scrolling(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->scrollAnimatorEnabled(); - if (currentValue == enabled) - return; - - priv->preferences->setScrollAnimatorEnabled(enabled); - g_object_notify(G_OBJECT(settings), "enable-smooth-scrolling"); -} - -/** - * webkit_settings_get_enable_accelerated_2d_canvas: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-accelerated-2d-canvas property. - * - * Returns: %TRUE if accelerated 2D canvas is enabled or %FALSE otherwise. - * - * Since: 2.2 - */ -gboolean webkit_settings_get_enable_accelerated_2d_canvas(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->accelerated2dCanvasEnabled(); -} - -/** - * webkit_settings_set_enable_accelerated_2d_canvas: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-accelerated-2d-canvas property. - * - * Since: 2.2 - */ -void webkit_settings_set_enable_accelerated_2d_canvas(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - if (priv->preferences->accelerated2dCanvasEnabled() == enabled) - return; - - priv->preferences->setAccelerated2dCanvasEnabled(enabled); - g_object_notify(G_OBJECT(settings), "enable-accelerated-2d-canvas"); -} - -/** - * webkit_settings_get_enable_write_console_messages_to_stdout: - * @settings: a #WebKitSettings - * - * Get the #WebKitSettings:enable-write-console-messages-to-stdout property. - * - * Returns: %TRUE if writing console messages to stdout is enabled or %FALSE - * otherwise. - * - * Since: 2.2 - */ -gboolean webkit_settings_get_enable_write_console_messages_to_stdout(WebKitSettings* settings) -{ - g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); - - return settings->priv->preferences->logsPageMessagesToSystemConsoleEnabled(); -} - -/** - * webkit_settings_set_enable_write_console_messages_to_stdout: - * @settings: a #WebKitSettings - * @enabled: Value to be set - * - * Set the #WebKitSettings:enable-write-console-messages-to-stdout property. - * - * Since: 2.2 - */ -void webkit_settings_set_enable_write_console_messages_to_stdout(WebKitSettings* settings, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - WebKitSettingsPrivate* priv = settings->priv; - bool currentValue = priv->preferences->logsPageMessagesToSystemConsoleEnabled(); - if (currentValue == enabled) - return; - - priv->preferences->setLogsPageMessagesToSystemConsoleEnabled(enabled); - g_object_notify(G_OBJECT(settings), "enable-write-console-messages-to-stdout"); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h deleted file mode 100644 index a904d0eb6..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h +++ /dev/null @@ -1,398 +0,0 @@ -/* - * Copyright (c) 2011 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: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Motorola Mobility, Inc. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT HOLDER OR - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitSettings_h -#define WebKitSettings_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_SETTINGS (webkit_settings_get_type()) -#define WEBKIT_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_SETTINGS, WebKitSettings)) -#define WEBKIT_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_SETTINGS, WebKitSettingsClass)) -#define WEBKIT_IS_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_SETTINGS)) -#define WEBKIT_IS_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_SETTINGS)) -#define WEBKIT_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_SETTINGS, WebKitSettingsClass)) - -typedef struct _WebKitSettings WebKitSettings; -typedef struct _WebKitSettingsClass WebKitSettingsClass; -typedef struct _WebKitSettingsPrivate WebKitSettingsPrivate; - -struct _WebKitSettings { - GObject parent_instance; - - WebKitSettingsPrivate *priv; -}; - -struct _WebKitSettingsClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_settings_get_type(void); - -WEBKIT_API WebKitSettings * -webkit_settings_new (void); - -WEBKIT_API WebKitSettings * -webkit_settings_new_with_settings (const gchar *first_setting_name, - ...); - -WEBKIT_API gboolean -webkit_settings_get_enable_javascript (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_javascript (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_auto_load_images (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_auto_load_images (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_load_icons_ignoring_image_load_setting (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_load_icons_ignoring_image_load_setting (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_enable_offline_web_application_cache (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_offline_web_application_cache (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_enable_html5_local_storage (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_html5_local_storage (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_enable_html5_database (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_html5_database (WebKitSettings *settings, - gboolean enabled); -WEBKIT_API gboolean -webkit_settings_get_enable_xss_auditor (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_xss_auditor (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_enable_frame_flattening (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_frame_flattening (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_enable_plugins (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_plugins (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_enable_java (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_java (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_javascript_can_open_windows_automatically (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_javascript_can_open_windows_automatically (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_enable_hyperlink_auditing (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_hyperlink_auditing (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API const gchar * -webkit_settings_get_default_font_family (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_default_font_family (WebKitSettings *settings, - const gchar *default_font_family); - -WEBKIT_API const gchar * -webkit_settings_get_monospace_font_family (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_monospace_font_family (WebKitSettings *settings, - const gchar *monospace_font_family); - -WEBKIT_API const gchar * -webkit_settings_get_serif_font_family (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_serif_font_family (WebKitSettings *settings, - const gchar *serif_font_family); - -WEBKIT_API const gchar * -webkit_settings_get_sans_serif_font_family (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_sans_serif_font_family (WebKitSettings *settings, - const gchar *sans_serif_font_family); - -WEBKIT_API const gchar * -webkit_settings_get_cursive_font_family (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_cursive_font_family (WebKitSettings *settings, - const gchar *cursive_font_family); - -WEBKIT_API const gchar * -webkit_settings_get_fantasy_font_family (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_fantasy_font_family (WebKitSettings *settings, - const gchar *fantasy_font_family); - -WEBKIT_API const gchar * -webkit_settings_get_pictograph_font_family (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_pictograph_font_family (WebKitSettings *settings, - const gchar *pictograph_font_family); - -WEBKIT_API guint32 -webkit_settings_get_default_font_size (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_default_font_size (WebKitSettings *settings, - guint32 font_size); - -WEBKIT_API guint32 -webkit_settings_get_default_monospace_font_size (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_default_monospace_font_size (WebKitSettings *settings, - guint32 font_size); - -WEBKIT_API guint32 -webkit_settings_get_minimum_font_size (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_minimum_font_size (WebKitSettings *settings, - guint32 font_size); - -WEBKIT_API const gchar * -webkit_settings_get_default_charset (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_default_charset (WebKitSettings *settings, - const gchar *default_charset); - -WEBKIT_API gboolean -webkit_settings_get_enable_private_browsing (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_private_browsing (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_enable_developer_extras (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_developer_extras (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_enable_resizable_text_areas (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_resizable_text_areas (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_enable_tabs_to_links (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_tabs_to_links (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_enable_dns_prefetching (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_dns_prefetching (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_enable_caret_browsing (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_caret_browsing (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_enable_fullscreen (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_fullscreen (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_print_backgrounds (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_print_backgrounds (WebKitSettings *settings, - gboolean print_backgrounds); - -WEBKIT_API gboolean -webkit_settings_get_enable_webaudio (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_webaudio (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_enable_webgl (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_webgl (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API void -webkit_settings_set_allow_modal_dialogs (WebKitSettings *settings, - gboolean allowed); - -WEBKIT_API gboolean -webkit_settings_get_allow_modal_dialogs (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_zoom_text_only (WebKitSettings *settings, - gboolean zoom_text_only); - -WEBKIT_API gboolean -webkit_settings_get_zoom_text_only (WebKitSettings *settings); - -WEBKIT_API gboolean -webkit_settings_get_javascript_can_access_clipboard (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_javascript_can_access_clipboard (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_media_playback_requires_user_gesture (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_media_playback_requires_user_gesture (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_media_playback_allows_inline (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_media_playback_allows_inline (WebKitSettings *settings, - gboolean enabled); -WEBKIT_API gboolean -webkit_settings_get_draw_compositing_indicators (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_draw_compositing_indicators (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_enable_site_specific_quirks (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_site_specific_quirks (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_enable_page_cache (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_page_cache (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API const gchar * -webkit_settings_get_user_agent (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_user_agent (WebKitSettings *settings, - const gchar *user_agent); -WEBKIT_API void -webkit_settings_set_user_agent_with_application_details (WebKitSettings *settings, - const gchar *application_name, - const gchar *application_version); - -WEBKIT_API gboolean -webkit_settings_get_enable_smooth_scrolling (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_smooth_scrolling (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_enable_accelerated_2d_canvas (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_accelerated_2d_canvas (WebKitSettings *settings, - gboolean enabled); - -WEBKIT_API gboolean -webkit_settings_get_enable_write_console_messages_to_stdout (WebKitSettings *settings); - -WEBKIT_API void -webkit_settings_set_enable_write_console_messages_to_stdout (WebKitSettings *settings, - gboolean enabled); - -G_END_DECLS - -#endif /* WebKitSettings_h */ diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSettingsPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitSettingsPrivate.h deleted file mode 100644 index c23a8cd1f..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitSettingsPrivate.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 WebKitSettingsPrivate_h -#define WebKitSettingsPrivate_h - -#include "WebKitSettings.h" -#include "WebPreferences.h" - -WebKit::WebPreferences* webkitSettingsGetPreferences(WebKitSettings*); - -#endif // WebKitSettingsPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp deleted file mode 100644 index 89e746d47..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "config.h" -#include "WebKitTextChecker.h" - -#if ENABLE(SPELLCHECK) - -#include "WebKitPrivate.h" - -using namespace WebKit; - -static inline WebKitTextChecker* toTextChecker(const void* clientInfo) -{ - return static_cast<WebKitTextChecker*>(const_cast<void*>(clientInfo)); -} - -static bool continuousSpellCheckingEnabledCallback(const void* clientInfo) -{ - return toTextChecker(clientInfo)->isSpellCheckingEnabled(); -} - -static void setContinuousSpellCheckingEnabledCallback(bool enabled, const void* clientInfo) -{ - toTextChecker(clientInfo)->setSpellCheckingEnabled(enabled); -} - -static void checkSpellingOfStringCallback(uint64_t tag, WKStringRef text, int32_t* misspellingLocation, int32_t* misspellingLength, const void* clientInfo) -{ - toTextChecker(clientInfo)->checkSpellingOfString(toImpl(text)->string(), *misspellingLocation, *misspellingLength); -} - -static WKArrayRef guessesForWordCallback(uint64_t tag, WKStringRef word, const void* clientInfo) -{ - Vector<String> guesses = toTextChecker(clientInfo)->getGuessesForWord(toImpl(word)->string()); - if (guesses.isEmpty()) - return 0; - - WKMutableArrayRef wkSuggestions = WKMutableArrayCreate(); - for (Vector<String>::const_iterator iter = guesses.begin(); iter != guesses.end(); ++iter) { - WKRetainPtr<WKStringRef> wkSuggestion(AdoptWK, WKStringCreateWithUTF8CString(iter->utf8().data())); - WKArrayAppendItem(wkSuggestions, wkSuggestion.get()); - } - - return wkSuggestions; -} - -static void learnWordCallback(uint64_t tag, WKStringRef word, const void* clientInfo) -{ - toTextChecker(clientInfo)->learnWord(toImpl(word)->string()); -} - -static void ignoreWordCallback(uint64_t tag, WKStringRef word, const void* clientInfo) -{ - toTextChecker(clientInfo)->ignoreWord(toImpl(word)->string()); -} - -WebKitTextChecker::~WebKitTextChecker() -{ -} - -WebKitTextChecker::WebKitTextChecker() - : m_textChecker(WebCore::TextCheckerEnchant::create()) - , m_spellCheckingEnabled(false) -{ - WKTextCheckerClient wkTextCheckerClient = { - kWKTextCheckerClientCurrentVersion, - this, // clientInfo - 0, // continuousSpellCheckingAllowed - continuousSpellCheckingEnabledCallback, - setContinuousSpellCheckingEnabledCallback, - 0, // grammarCheckingEnabled - 0, // setGrammarCheckingEnabled - 0, // uniqueSpellDocumentTag - 0, // closeSpellDocumentWithTag - checkSpellingOfStringCallback, - 0, // checkGrammarOfString - 0, // spellingUIIsShowing - 0, // toggleSpellingUIIsShowing - 0, // updateSpellingUIWithMisspelledWord - 0, // updateSpellingUIWithGrammarString - guessesForWordCallback, - learnWordCallback, - ignoreWordCallback, - }; - WKTextCheckerSetClient(&wkTextCheckerClient); -} - -void WebKitTextChecker::checkSpellingOfString(const String& string, int& misspellingLocation, int& misspellingLength) -{ - m_textChecker->checkSpellingOfString(string, misspellingLocation, misspellingLength); -} - -Vector<String> WebKitTextChecker::getGuessesForWord(const String& word) -{ - return m_textChecker->getGuessesForWord(word); -} - -void WebKitTextChecker::learnWord(const String& word) -{ - m_textChecker->learnWord(word); -} - -void WebKitTextChecker::ignoreWord(const String& word) -{ - m_textChecker->ignoreWord(word); -} - -void WebKitTextChecker::setSpellCheckingEnabled(bool enabled) -{ - if (m_spellCheckingEnabled == enabled) - return; - m_spellCheckingEnabled = enabled; - - // We need to notify the Web process that this has changed. - WKTextCheckerContinuousSpellCheckingEnabledStateChanged(enabled); -} - -const char* const* WebKitTextChecker::getSpellCheckingLanguages() -{ - Vector<String> spellCheckingLanguages = m_textChecker->loadedSpellCheckingLanguages(); - if (spellCheckingLanguages.isEmpty()) - return 0; - - m_spellCheckingLanguages = adoptGRef(g_ptr_array_new_with_free_func(g_free)); - for (size_t i = 0; i < spellCheckingLanguages.size(); ++i) - g_ptr_array_add(m_spellCheckingLanguages.get(), g_strdup(spellCheckingLanguages[i].utf8().data())); - g_ptr_array_add(m_spellCheckingLanguages.get(), 0); - - return reinterpret_cast<char**>(m_spellCheckingLanguages->pdata); -} - -void WebKitTextChecker::setSpellCheckingLanguages(const char* const* languages) -{ - Vector<String> spellCheckingLanguages; - for (size_t i = 0; languages[i]; ++i) - spellCheckingLanguages.append(String::fromUTF8(languages[i])); - m_textChecker->updateSpellCheckingLanguages(spellCheckingLanguages); -} -#endif // ENABLE(SPELLCHECK) diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h b/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h deleted file mode 100644 index 15f764f61..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitTextChecker_h -#define WebKitTextChecker_h - -#if ENABLE(SPELLCHECK) - -#include <WebCore/TextCheckerEnchant.h> -#include <wtf/FastAllocBase.h> -#include <wtf/PassOwnPtr.h> -#include <wtf/Vector.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -class WebKitTextChecker { - WTF_MAKE_FAST_ALLOCATED; - -public: - static PassOwnPtr<WebKitTextChecker> create() { return adoptPtr(new WebKitTextChecker()); } - virtual ~WebKitTextChecker(); - - // For implementing TextCheckerClient. - bool isSpellCheckingEnabled() { return m_spellCheckingEnabled; } - void setSpellCheckingEnabled(bool enabled); - void checkSpellingOfString(const String& string, int& misspellingLocation, int& misspellingLength); - Vector<String> getGuessesForWord(const String& word); - void learnWord(const String& word); - void ignoreWord(const String& word); - - // To be called from WebKitWebContext only. - const char* const* getSpellCheckingLanguages(); - void setSpellCheckingLanguages(const char* const* spellCheckingLanguages); - -private: - WebKitTextChecker(); - - OwnPtr<WebCore::TextCheckerEnchant> m_textChecker; - GRefPtr<GPtrArray> m_spellCheckingLanguages; - bool m_spellCheckingEnabled; -}; - -#endif // ENABLE(SPELLCHECK) - -#endif // WebKitTextChecker_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp deleted file mode 100644 index 0899b8563..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (C) 2011, 2012 Igalia S.L. - * - * 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 "WebKitUIClient.h" - -#include "WebKitFileChooserRequestPrivate.h" -#include "WebKitGeolocationPermissionRequestPrivate.h" -#include "WebKitPrivate.h" -#include "WebKitWebViewBasePrivate.h" -#include "WebKitWebViewPrivate.h" -#include "WebKitWindowPropertiesPrivate.h" -#include "WebPageProxy.h" -#include <WebCore/GtkUtilities.h> -#include <wtf/gobject/GRefPtr.h> - -using namespace WebKit; - -static WKPageRef createNewPage(WKPageRef page, WKURLRequestRef, WKDictionaryRef wkWindowFeatures, WKEventModifiers, WKEventMouseButton, const void* clientInfo) -{ - return static_cast<WKPageRef>(toAPI(webkitWebViewCreateNewPage(WEBKIT_WEB_VIEW(clientInfo), toImpl(wkWindowFeatures)))); -} - -static void showPage(WKPageRef page, const void* clientInfo) -{ - webkitWebViewReadyToShowPage(WEBKIT_WEB_VIEW(clientInfo)); -} - -static void closePage(WKPageRef page, const void* clientInfo) -{ - webkitWebViewClosePage(WEBKIT_WEB_VIEW(clientInfo)); -} - -static void runJavaScriptAlert(WKPageRef page, WKStringRef message, WKFrameRef, const void* clientInfo) -{ - webkitWebViewRunJavaScriptAlert(WEBKIT_WEB_VIEW(clientInfo), toImpl(message)->string().utf8()); -} - -static bool runJavaScriptConfirm(WKPageRef page, WKStringRef message, WKFrameRef, const void* clientInfo) -{ - return webkitWebViewRunJavaScriptConfirm(WEBKIT_WEB_VIEW(clientInfo), toImpl(message)->string().utf8()); -} - -static WKStringRef runJavaScriptPrompt(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef, const void* clientInfo) -{ - CString result = webkitWebViewRunJavaScriptPrompt(WEBKIT_WEB_VIEW(clientInfo), toImpl(message)->string().utf8(), - toImpl(defaultValue)->string().utf8()); - return WKStringCreateWithUTF8CString(result.data()); -} - -static bool toolbarsAreVisible(WKPageRef page, const void* clientInfo) -{ - WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(clientInfo)); - return webkit_window_properties_get_toolbar_visible(windowProperties); -} - -static void setToolbarsAreVisible(WKPageRef page, bool toolbarsVisible, const void* clientInfo) -{ - WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(clientInfo)); - webkitWindowPropertiesSetToolbarVisible(windowProperties, toolbarsVisible); -} - -static bool menuBarIsVisible(WKPageRef page, const void* clientInfo) -{ - WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(clientInfo)); - return webkit_window_properties_get_menubar_visible(windowProperties); -} - -static void setMenuBarIsVisible(WKPageRef page, bool menuBarVisible, const void* clientInfo) -{ - WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(clientInfo)); - webkitWindowPropertiesSetMenubarVisible(windowProperties, menuBarVisible); -} - -static bool statusBarIsVisible(WKPageRef page, const void* clientInfo) -{ - WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(clientInfo)); - return webkit_window_properties_get_statusbar_visible(windowProperties); -} - -static void setStatusBarIsVisible(WKPageRef page, bool statusBarVisible, const void* clientInfo) -{ - WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(clientInfo)); - webkitWindowPropertiesSetStatusbarVisible(windowProperties, statusBarVisible); -} - -static bool isResizable(WKPageRef page, const void* clientInfo) -{ - WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(clientInfo)); - return webkit_window_properties_get_resizable(windowProperties); -} - -static void setIsResizable(WKPageRef page, bool resizable, const void* clientInfo) -{ - WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(clientInfo)); - webkitWindowPropertiesSetResizable(windowProperties, resizable); -} - -static WKRect getWindowFrame(WKPageRef page, const void* clientInfo) -{ - GdkRectangle geometry = { 0, 0, 0, 0 }; - GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(clientInfo)); - if (WebCore::widgetIsOnscreenToplevelWindow(window) && gtk_widget_get_visible(window)) { - gtk_window_get_position(GTK_WINDOW(window), &geometry.x, &geometry.y); - gtk_window_get_size(GTK_WINDOW(window), &geometry.width, &geometry.height); - } - return WKRectMake(geometry.x, geometry.y, geometry.width, geometry.height); -} - -static void setWindowFrame(WKPageRef page, WKRect frame, const void* clientInfo) -{ - WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(clientInfo)); - GdkRectangle geometry = { static_cast<int>(frame.origin.x), static_cast<int>(frame.origin.y), - static_cast<int>(frame.size.width), static_cast<int>(frame.size.height) }; - webkitWindowPropertiesSetGeometry(windowProperties, &geometry); -} - -static void mouseDidMoveOverElement(WKPageRef page, WKHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef userData, const void* clientInfo) -{ - webkitWebViewMouseTargetChanged(WEBKIT_WEB_VIEW(clientInfo), toImpl(hitTestResult), wkEventModifiersToGdkModifiers(modifiers)); -} - -static void printFrame(WKPageRef page, WKFrameRef frame, const void*) -{ - webkitWebViewPrintFrame(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()), toImpl(frame)); -} - -static void runOpenPanel(WKPageRef page, WKFrameRef frame, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void *clientInfo) -{ - GRefPtr<WebKitFileChooserRequest> request = adoptGRef(webkitFileChooserRequestCreate(toImpl(parameters), toImpl(listener))); - webkitWebViewRunFileChooserRequest(WEBKIT_WEB_VIEW(clientInfo), request.get()); -} - -static void decidePolicyForGeolocationPermissionRequest(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKGeolocationPermissionRequestRef request, const void* clientInfo) -{ - GRefPtr<WebKitGeolocationPermissionRequest> geolocationPermissionRequest = adoptGRef(webkitGeolocationPermissionRequestCreate(toImpl(request))); - webkitWebViewMakePermissionRequest(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_PERMISSION_REQUEST(geolocationPermissionRequest.get())); -} - -static void runModal(WKPageRef page, const void* clientInfo) -{ - webkitWebViewRunAsModal(WEBKIT_WEB_VIEW(clientInfo)); -} - -void attachUIClientToView(WebKitWebView* webView) -{ - WKPageUIClient wkUIClient = { - kWKPageUIClientCurrentVersion, - webView, // clientInfo - 0, // createNewPage_deprecatedForUseWithV0 - showPage, - closePage, - 0, // takeFocus - 0, // focus - 0, // unfocus - runJavaScriptAlert, - runJavaScriptConfirm, - runJavaScriptPrompt, - 0, // setStatusText - 0, // mouseDidMoveOverElement_deprecatedForUseWithV0 - 0, // missingPluginButtonClicked - 0, // didNotHandleKeyEvent - 0, // didNotHandleWheelEvent - toolbarsAreVisible, - setToolbarsAreVisible, - menuBarIsVisible, - setMenuBarIsVisible, - statusBarIsVisible, - setStatusBarIsVisible, - isResizable, - setIsResizable, - getWindowFrame, - setWindowFrame, - 0, // runBeforeUnloadConfirmPanel - 0, // didDraw - 0, // pageDidScroll - 0, // exceededDatabaseQuota - runOpenPanel, - decidePolicyForGeolocationPermissionRequest, - 0, // headerHeight - 0, // footerHeight - 0, // drawHeader - 0, // drawFooter - printFrame, - runModal, - 0, // didCompleteRubberBandForMainFrame - 0, // saveDataToFileInDownloadsFolder - 0, // shouldInterruptJavaScript - createNewPage, - mouseDidMoveOverElement, - 0, // decidePolicyForNotificationPermissionRequest - 0, // unavailablePluginButtonClicked - 0, // showColorPicker - 0, // hideColorPicker - 0, // pluginLoadPolicy - }; - WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))); - WKPageSetPageUIClient(wkPage, &wkUIClient); -} - diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.h b/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.h deleted file mode 100644 index e5a1a3e0f..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 WebKitUIClient_h -#define WebKitUIClient_h - -#include "WebKitWebView.h" - -void attachUIClientToView(WebKitWebView*); - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURIRequest.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitURIRequest.cpp deleted file mode 100644 index 50c6eea5d..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitURIRequest.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 "WebKitURIRequest.h" - -#include "WebKitPrivate.h" -#include "WebKitURIRequestPrivate.h" -#include <WebCore/GOwnPtrSoup.h> -#include <glib/gi18n-lib.h> -#include <wtf/text/CString.h> - -enum { - PROP_0, - - PROP_URI -}; - -using namespace WebCore; - -/** - * SECTION: WebKitURIRequest - * @Short_description: Represents a URI request - * @Title: WebKitURIRequest - * - * A #WebKitURIRequest can be created with a URI using the - * webkit_uri_request_new() method, and you can get the URI of an - * existing request with the webkit_uri_request_get_uri() one. - * - */ - -struct _WebKitURIRequestPrivate { - WebCore::ResourceRequest resourceRequest; - CString uri; - GOwnPtr<SoupMessageHeaders> httpHeaders; -}; - -WEBKIT_DEFINE_TYPE(WebKitURIRequest, webkit_uri_request, G_TYPE_OBJECT) - -static void webkitURIRequestGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) -{ - WebKitURIRequest* request = WEBKIT_URI_REQUEST(object); - - switch (propId) { - case PROP_URI: - g_value_set_string(value, webkit_uri_request_get_uri(request)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static void webkitURIRequestSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec) -{ - WebKitURIRequest* request = WEBKIT_URI_REQUEST(object); - - switch (propId) { - case PROP_URI: - webkit_uri_request_set_uri(request, g_value_get_string(value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static void webkit_uri_request_class_init(WebKitURIRequestClass* requestClass) -{ - GObjectClass* objectClass = G_OBJECT_CLASS(requestClass); - objectClass->get_property = webkitURIRequestGetProperty; - objectClass->set_property = webkitURIRequestSetProperty; - - /** - * WebKitURIRequest:uri: - * - * The URI to which the request will be made. - */ - g_object_class_install_property(objectClass, PROP_URI, - g_param_spec_string("uri", - _("URI"), - _("The URI to which the request will be made."), - "about:blank", - static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT))); -} - -/** - * webkit_uri_request_new: - * @uri: an URI - * - * Creates a new #WebKitURIRequest for the given URI. - * - * Returns: a new #WebKitURIRequest - */ -WebKitURIRequest* webkit_uri_request_new(const gchar* uri) -{ - g_return_val_if_fail(uri, 0); - - return WEBKIT_URI_REQUEST(g_object_new(WEBKIT_TYPE_URI_REQUEST, "uri", uri, NULL)); -} - -/** - * webkit_uri_request_get_uri: - * @request: a #WebKitURIRequest - * - * Returns: the uri of the #WebKitURIRequest - */ -const gchar* webkit_uri_request_get_uri(WebKitURIRequest* request) -{ - g_return_val_if_fail(WEBKIT_IS_URI_REQUEST(request), 0); - - request->priv->uri = request->priv->resourceRequest.url().string().utf8(); - return request->priv->uri.data(); -} - -/** - * webkit_uri_request_set_uri: - * @request: a #WebKitURIRequest - * @uri: an URI - * - * Set the URI of @request - */ -void webkit_uri_request_set_uri(WebKitURIRequest* request, const char* uri) -{ - g_return_if_fail(WEBKIT_IS_URI_REQUEST(request)); - g_return_if_fail(uri); - - KURL url(KURL(), uri); - if (url == request->priv->resourceRequest.url()) - return; - - request->priv->resourceRequest.setURL(url); - g_object_notify(G_OBJECT(request), "uri"); -} - -/** - * webkit_uri_request_get_http_headers: - * @request: a #WebKitURIRequest - * - * Get the HTTP headers of a #WebKitURIRequest as a #SoupMessageHeaders. - * - * Returns: (transfer none): a #SoupMessageHeaders with the HTTP headers of @request - * or %NULL if @request is not an HTTP request. - */ -SoupMessageHeaders* webkit_uri_request_get_http_headers(WebKitURIRequest* request) -{ - g_return_val_if_fail(WEBKIT_IS_URI_REQUEST(request), 0); - - if (request->priv->httpHeaders) - return request->priv->httpHeaders.get(); - - if (!request->priv->resourceRequest.url().protocolIsInHTTPFamily()) - return 0; - - request->priv->httpHeaders.set(soup_message_headers_new(SOUP_MESSAGE_HEADERS_REQUEST)); - request->priv->resourceRequest.updateSoupMessageHeaders(request->priv->httpHeaders.get()); - return request->priv->httpHeaders.get(); -} - -WebKitURIRequest* webkitURIRequestCreateForResourceRequest(const ResourceRequest& resourceRequest) -{ - WebKitURIRequest* uriRequest = WEBKIT_URI_REQUEST(g_object_new(WEBKIT_TYPE_URI_REQUEST, NULL)); - uriRequest->priv->resourceRequest = resourceRequest; - return uriRequest; -} - -void webkitURIRequestGetResourceRequest(WebKitURIRequest* request, ResourceRequest& resourceRequest) -{ - resourceRequest = request->priv->resourceRequest; - if (request->priv->httpHeaders) - resourceRequest.updateFromSoupMessageHeaders(request->priv->httpHeaders.get()); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURIRequest.h b/Source/WebKit2/UIProcess/API/gtk/WebKitURIRequest.h deleted file mode 100644 index cac3b332b..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitURIRequest.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) && !defined(__WEBKIT_WEB_EXTENSION_H_INSIDE__) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitURIRequest_h -#define WebKitURIRequest_h - -#include <glib-object.h> -#include <libsoup/soup.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_URI_REQUEST (webkit_uri_request_get_type()) -#define WEBKIT_URI_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_URI_REQUEST, WebKitURIRequest)) -#define WEBKIT_IS_URI_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_URI_REQUEST)) -#define WEBKIT_URI_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_URI_REQUEST, WebKitURIRequestClass)) -#define WEBKIT_IS_URI_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_URI_REQUEST)) -#define WEBKIT_URI_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_URI_REQUEST, WebKitURIRequestClass)) - -typedef struct _WebKitURIRequest WebKitURIRequest; -typedef struct _WebKitURIRequestClass WebKitURIRequestClass; -typedef struct _WebKitURIRequestPrivate WebKitURIRequestPrivate; - -struct _WebKitURIRequest { - GObject parent; - - /*< private >*/ - WebKitURIRequestPrivate *priv; -}; - -struct _WebKitURIRequestClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_uri_request_get_type (void); - -WEBKIT_API WebKitURIRequest * -webkit_uri_request_new (const gchar *uri); - -WEBKIT_API const gchar * -webkit_uri_request_get_uri (WebKitURIRequest *request); - -WEBKIT_API void -webkit_uri_request_set_uri (WebKitURIRequest *request, - const gchar *uri); - -WEBKIT_API SoupMessageHeaders * -webkit_uri_request_get_http_headers (WebKitURIRequest *request); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURIRequestPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitURIRequestPrivate.h deleted file mode 100644 index 12586153b..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitURIRequestPrivate.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 WebKitURIRequestPrivate_h -#define WebKitURIRequestPrivate_h - -#include "WebKitURIRequest.h" -#include <WebCore/ResourceRequest.h> - -WebKitURIRequest* webkitURIRequestCreateForResourceRequest(const WebCore::ResourceRequest&); -void webkitURIRequestGetResourceRequest(WebKitURIRequest*, WebCore::ResourceRequest&); - -#endif // WebKitURIRequestPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp deleted file mode 100644 index 20ab248a5..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 "WebKitURIResponse.h" - -#include "WebKitPrivate.h" -#include "WebKitURIResponsePrivate.h" -#include <glib/gi18n-lib.h> -#include <wtf/text/CString.h> - -using namespace WebKit; -using namespace WebCore; - -/** - * SECTION: WebKitURIResponse - * @Short_description: Represents a URI response - * @Title: WebKitURIResponse - * - * A #WebKitURIResponse contains information such as the URI, the - * status code, the content length, the mime type, the HTTP status or - * the suggested filename. - * - */ - -enum { - PROP_0, - - PROP_URI, - PROP_STATUS_CODE, - PROP_CONTENT_LENGTH, - PROP_MIME_TYPE, - PROP_SUGGESTED_FILENAME -}; - -struct _WebKitURIResponsePrivate { - ResourceResponse resourceResponse; - CString uri; - CString mimeType; - CString suggestedFilename; -}; - -WEBKIT_DEFINE_TYPE(WebKitURIResponse, webkit_uri_response, G_TYPE_OBJECT) - -static void webkitURIResponseGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) -{ - WebKitURIResponse* response = WEBKIT_URI_RESPONSE(object); - - switch (propId) { - case PROP_URI: - g_value_set_string(value, webkit_uri_response_get_uri(response)); - break; - case PROP_STATUS_CODE: - g_value_set_uint(value, webkit_uri_response_get_status_code(response)); - break; - case PROP_CONTENT_LENGTH: - g_value_set_uint64(value, webkit_uri_response_get_content_length(response)); - break; - case PROP_MIME_TYPE: - g_value_set_string(value, webkit_uri_response_get_mime_type(response)); - break; - case PROP_SUGGESTED_FILENAME: - g_value_set_string(value, webkit_uri_response_get_suggested_filename(response)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static void webkit_uri_response_class_init(WebKitURIResponseClass* responseClass) -{ - GObjectClass* objectClass = G_OBJECT_CLASS(responseClass); - objectClass->get_property = webkitURIResponseGetProperty; - - /** - * WebKitURIResponse:uri: - * - * The URI for which the response was made. - */ - g_object_class_install_property(objectClass, - PROP_URI, - g_param_spec_string("uri", - _("URI"), - _("The URI for which the response was made."), - 0, - WEBKIT_PARAM_READABLE)); - /** - * WebKitURIResponse:status-code: - * - * The status code of the response as returned by the server. - */ - g_object_class_install_property(objectClass, - PROP_STATUS_CODE, - g_param_spec_uint("status-code", - _("Status Code"), - _("The status code of the response as returned by the server."), - 0, G_MAXUINT, SOUP_STATUS_NONE, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitURIResponse:content-length: - * - * The expected content length of the response. - */ - g_object_class_install_property(objectClass, - PROP_CONTENT_LENGTH, - g_param_spec_uint64("content-length", - _("Content Length"), - _("The expected content length of the response."), - 0, G_MAXUINT64, 0, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitURIResponse:mime-type: - * - * The MIME type of the response. - */ - g_object_class_install_property(objectClass, - PROP_MIME_TYPE, - g_param_spec_string("mime-type", - _("MIME Type"), - _("The MIME type of the response"), - 0, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitURIResponse:suggested-filename: - * - * The suggested filename for the URI response. - */ - g_object_class_install_property(objectClass, - PROP_SUGGESTED_FILENAME, - g_param_spec_string("suggested-filename", - _("Suggested Filename"), - _("The suggested filename for the URI response"), - 0, - WEBKIT_PARAM_READABLE)); -} - -/** - * webkit_uri_response_get_uri: - * @response: a #WebKitURIResponse - * - * Returns: the uri of the #WebKitURIResponse - */ -const gchar* webkit_uri_response_get_uri(WebKitURIResponse* response) -{ - g_return_val_if_fail(WEBKIT_IS_URI_RESPONSE(response), 0); - - response->priv->uri = response->priv->resourceResponse.url().string().utf8(); - return response->priv->uri.data(); -} - -/** - * webkit_uri_response_get_status_code: - * @response: a #WebKitURIResponse - * - * Get the status code of the #WebKitURIResponse as returned by - * the server. It will normally be a #SoupKnownStatusCode, for - * example %SOUP_STATUS_OK, though the server can respond with any - * unsigned integer. - * - * Returns: the status code of @response - */ -guint webkit_uri_response_get_status_code(WebKitURIResponse* response) -{ - g_return_val_if_fail(WEBKIT_IS_URI_RESPONSE(response), SOUP_STATUS_NONE); - - return response->priv->resourceResponse.httpStatusCode(); -} - -/** - * webkit_uri_response_get_content_length: - * @response: a #WebKitURIResponse - * - * Get the expected content length of the #WebKitURIResponse. It can - * be 0 if the server provided an incorrect or missing Content-Length. - * - * Returns: the expected content length of @response. - */ -guint64 webkit_uri_response_get_content_length(WebKitURIResponse* response) -{ - g_return_val_if_fail(WEBKIT_IS_URI_RESPONSE(response), 0); - - return response->priv->resourceResponse.expectedContentLength(); -} - -/** - * webkit_uri_response_get_mime_type: - * @response: a #WebKitURIResponse - * - * Returns: the MIME type of the #WebKitURIResponse - */ -const gchar* webkit_uri_response_get_mime_type(WebKitURIResponse* response) -{ - g_return_val_if_fail(WEBKIT_IS_URI_RESPONSE(response), 0); - - response->priv->mimeType = response->priv->resourceResponse.mimeType().utf8(); - return response->priv->mimeType.data(); -} - -/** - * webkit_uri_response_get_suggested_filename: - * @response: a #WebKitURIResponse - * - * Get the suggested filename for @response, as specified by - * the 'Content-Disposition' HTTP header, or %NULL if it's not - * present. - * - * Returns: (transfer none): the suggested filename or %NULL if - * the 'Content-Disposition' HTTP header is not present. - */ -const gchar* webkit_uri_response_get_suggested_filename(WebKitURIResponse* response) -{ - g_return_val_if_fail(WEBKIT_IS_URI_RESPONSE(response), 0); - - if (response->priv->resourceResponse.suggestedFilename().isEmpty()) - return 0; - - response->priv->suggestedFilename = response->priv->resourceResponse.suggestedFilename().utf8(); - return response->priv->suggestedFilename.data(); -} - -WebKitURIResponse* webkitURIResponseCreateForResourceResponse(const WebCore::ResourceResponse& resourceResponse) -{ - WebKitURIResponse* uriResponse = WEBKIT_URI_RESPONSE(g_object_new(WEBKIT_TYPE_URI_RESPONSE, NULL)); - uriResponse->priv->resourceResponse = resourceResponse; - return uriResponse; -} - -const WebCore::ResourceResponse& webkitURIResponseGetResourceResponse(WebKitURIResponse* uriResponse) -{ - return uriResponse->priv->resourceResponse; -} - diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.h b/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.h deleted file mode 100644 index d43eca13f..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) && !defined(__WEBKIT_WEB_EXTENSION_H_INSIDE__) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitURIResponse_h -#define WebKitURIResponse_h - -#include <gio/gio.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_URI_RESPONSE (webkit_uri_response_get_type()) -#define WEBKIT_URI_RESPONSE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_URI_RESPONSE, WebKitURIResponse)) -#define WEBKIT_IS_URI_RESPONSE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_URI_RESPONSE)) -#define WEBKIT_URI_RESPONSE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_URI_RESPONSE, WebKitURIResponseClass)) -#define WEBKIT_IS_URI_RESPONSE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_URI_RESPONSE)) -#define WEBKIT_URI_RESPONSE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_URI_RESPONSE, WebKitURIResponseClass)) - -typedef struct _WebKitURIResponse WebKitURIResponse; -typedef struct _WebKitURIResponseClass WebKitURIResponseClass; -typedef struct _WebKitURIResponsePrivate WebKitURIResponsePrivate; - -struct _WebKitURIResponse { - GObject parent; - - /*< private >*/ - WebKitURIResponsePrivate *priv; -}; - -struct _WebKitURIResponseClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_uri_response_get_type (void); - -WEBKIT_API const gchar * -webkit_uri_response_get_uri (WebKitURIResponse *response); - -WEBKIT_API guint -webkit_uri_response_get_status_code (WebKitURIResponse *response); - -WEBKIT_API guint64 -webkit_uri_response_get_content_length (WebKitURIResponse *response); - -WEBKIT_API const gchar * -webkit_uri_response_get_mime_type (WebKitURIResponse *response); - -WEBKIT_API const gchar * -webkit_uri_response_get_suggested_filename (WebKitURIResponse *response); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponsePrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponsePrivate.h deleted file mode 100644 index c2dc49c17..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponsePrivate.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 WebKitURIResponsePrivate_h -#define WebKitURIResponsePrivate_h - -#include "WebKitURIResponse.h" -#include <WebCore/ResourceResponse.h> - -WebKitURIResponse* webkitURIResponseCreateForResourceResponse(const WebCore::ResourceResponse&); -const WebCore::ResourceResponse& webkitURIResponseGetResourceResponse(WebKitURIResponse*); - -#endif // WebKitURIResponsePrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp deleted file mode 100644 index 0e5218129..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitURISchemeRequest.h" - -#include "WebData.h" -#include "WebKitURISchemeRequestPrivate.h" -#include "WebKitWebContextPrivate.h" -#include "WebKitWebView.h" -#include "WebPageProxy.h" -#include "WebSoupRequestManagerProxy.h" -#include <WebCore/GOwnPtrSoup.h> -#include <WebCore/ResourceError.h> -#include <libsoup/soup.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -using namespace WebKit; - -/** - * SECTION: WebKitURISchemeRequest - * @Short_description: Represents a URI scheme request - * @Title: WebKitURISchemeRequest - * - * If you register a particular URI scheme in a #WebKitWebContext, - * using webkit_web_context_register_uri_scheme(), you have to provide - * a #WebKitURISchemeRequestCallback. After that, when a URI request - * is made with that particular scheme, your callback will be - * called. There you will be able to access properties such as the - * scheme, the URI and path, and the #WebKitWebView that initiated the - * request, and also finish the request with - * webkit_uri_scheme_request_finish(). - * - */ - -static const unsigned int gReadBufferSize = 8192; - -struct _WebKitURISchemeRequestPrivate { - WebKitWebContext* webContext; - RefPtr<WebSoupRequestManagerProxy> webRequestManager; - RefPtr<WebPageProxy> initiatingPage; - uint64_t requestID; - CString uri; - GOwnPtr<SoupURI> soupURI; - - GRefPtr<GInputStream> stream; - uint64_t streamLength; - GRefPtr<GCancellable> cancellable; - char readBuffer[gReadBufferSize]; - uint64_t bytesRead; - CString mimeType; -}; - -WEBKIT_DEFINE_TYPE(WebKitURISchemeRequest, webkit_uri_scheme_request, G_TYPE_OBJECT) - -static void webkit_uri_scheme_request_class_init(WebKitURISchemeRequestClass* requestClass) -{ -} - -WebKitURISchemeRequest* webkitURISchemeRequestCreate(WebKitWebContext* webContext, WebSoupRequestManagerProxy* webRequestManager, WebURL* webURL, WebPageProxy* initiatingPage, uint64_t requestID) -{ - WebKitURISchemeRequest* request = WEBKIT_URI_SCHEME_REQUEST(g_object_new(WEBKIT_TYPE_URI_SCHEME_REQUEST, NULL)); - request->priv->webContext = webContext; - request->priv->webRequestManager = webRequestManager; - request->priv->uri = webURL->string().utf8(); - request->priv->initiatingPage = initiatingPage; - request->priv->requestID = requestID; - return request; -} - -uint64_t webkitURISchemeRequestGetID(WebKitURISchemeRequest* request) -{ - return request->priv->requestID; -} - -void webkitURISchemeRequestCancel(WebKitURISchemeRequest* request) -{ - if (request->priv->cancellable.get()) - g_cancellable_cancel(request->priv->cancellable.get()); -} - -/** - * webkit_uri_scheme_request_get_scheme: - * @request: a #WebKitURISchemeRequest - * - * Get the URI scheme of @request - * - * Returns: the URI scheme of @request - */ -const char* webkit_uri_scheme_request_get_scheme(WebKitURISchemeRequest* request) -{ - g_return_val_if_fail(WEBKIT_IS_URI_SCHEME_REQUEST(request), 0); - - if (!request->priv->soupURI) - request->priv->soupURI.set(soup_uri_new(request->priv->uri.data())); - return request->priv->soupURI->scheme; -} - -/** - * webkit_uri_scheme_request_get_uri: - * @request: a #WebKitURISchemeRequest - * - * Get the URI of @request - * - * Returns: the full URI of @request - */ -const char* webkit_uri_scheme_request_get_uri(WebKitURISchemeRequest* request) -{ - g_return_val_if_fail(WEBKIT_IS_URI_SCHEME_REQUEST(request), 0); - - return request->priv->uri.data(); -} - -/** - * webkit_uri_scheme_request_get_path: - * @request: a #WebKitURISchemeRequest - * - * Get the URI path of @request - * - * Returns: the URI path of @request - */ -const char* webkit_uri_scheme_request_get_path(WebKitURISchemeRequest* request) -{ - g_return_val_if_fail(WEBKIT_IS_URI_SCHEME_REQUEST(request), 0); - - if (!request->priv->soupURI) - request->priv->soupURI.set(soup_uri_new(request->priv->uri.data())); - return request->priv->soupURI->path; -} - -/** - * webkit_uri_scheme_request_get_web_view: - * @request: a #WebKitURISchemeRequest - * - * Get the #WebKitWebView that initiated the request. - * - * Returns: (transfer none): the #WebKitWebView that initiated @request. - */ -WebKitWebView* webkit_uri_scheme_request_get_web_view(WebKitURISchemeRequest* request) -{ - g_return_val_if_fail(WEBKIT_IS_URI_SCHEME_REQUEST(request), 0); - - return WEBKIT_WEB_VIEW(request->priv->initiatingPage->viewWidget()); -} - -static void webkitURISchemeRequestReadCallback(GInputStream* inputStream, GAsyncResult* result, WebKitURISchemeRequest* schemeRequest) -{ - GRefPtr<WebKitURISchemeRequest> request = adoptGRef(schemeRequest); - GOwnPtr<GError> error; - gssize bytesRead = g_input_stream_read_finish(inputStream, result, &error.outPtr()); - if (bytesRead == -1) { - webkit_uri_scheme_request_finish_error(request.get(), error.get()); - return; - } - - WebKitURISchemeRequestPrivate* priv = request->priv; - RefPtr<WebData> webData = WebData::create(reinterpret_cast<const unsigned char*>(priv->readBuffer), bytesRead); - if (!priv->bytesRead) { - // First chunk read. In case of empty reply an empty WebData is sent to the WebProcess. - priv->webRequestManager->didHandleURIRequest(webData.get(), priv->streamLength, String::fromUTF8(priv->mimeType.data()), priv->requestID); - } else if (bytesRead || (!bytesRead && !priv->streamLength)) { - // Subsequent chunk read. We only send an empty WebData to the WebProcess when stream length is unknown. - priv->webRequestManager->didReceiveURIRequestData(webData.get(), priv->requestID); - } - - if (!bytesRead) { - webkitWebContextDidFinishURIRequest(request->priv->webContext, request->priv->requestID); - return; - } - - priv->bytesRead += bytesRead; - g_input_stream_read_async(inputStream, priv->readBuffer, gReadBufferSize, G_PRIORITY_DEFAULT, priv->cancellable.get(), - reinterpret_cast<GAsyncReadyCallback>(webkitURISchemeRequestReadCallback), g_object_ref(request.get())); -} - -/** - * webkit_uri_scheme_request_finish: - * @request: a #WebKitURISchemeRequest - * @stream: a #GInputStream to read the contents of the request - * @stream_length: the length of the stream or -1 if not known - * @mime_type: (allow-none): the content type of the stream or %NULL if not known - * - * Finish a #WebKitURISchemeRequest by setting the contents of the request and its mime type. - */ -void webkit_uri_scheme_request_finish(WebKitURISchemeRequest* request, GInputStream* inputStream, gint64 streamLength, const gchar* mimeType) -{ - g_return_if_fail(WEBKIT_IS_URI_SCHEME_REQUEST(request)); - g_return_if_fail(G_IS_INPUT_STREAM(inputStream)); - g_return_if_fail(streamLength == -1 || streamLength >= 0); - - request->priv->stream = inputStream; - // We use -1 in the API for consistency with soup when the content length is not known, but 0 internally. - request->priv->streamLength = streamLength == -1 ? 0 : streamLength; - request->priv->cancellable = adoptGRef(g_cancellable_new()); - request->priv->bytesRead = 0; - request->priv->mimeType = mimeType; - g_input_stream_read_async(inputStream, request->priv->readBuffer, gReadBufferSize, G_PRIORITY_DEFAULT, request->priv->cancellable.get(), - reinterpret_cast<GAsyncReadyCallback>(webkitURISchemeRequestReadCallback), g_object_ref(request)); -} - -/** - * webkit_uri_scheme_request_finish_error: - * @request: a #WebKitURISchemeRequest - * @error: a #GError that will be passed to the #WebKitWebView - * - * Finish a #WebKitURISchemeRequest with a #GError. - * - * Since: 2.2 - */ -void webkit_uri_scheme_request_finish_error(WebKitURISchemeRequest* request, GError* error) -{ - g_return_if_fail(WEBKIT_IS_URI_SCHEME_REQUEST(request)); - g_return_if_fail(error); - - WebKitURISchemeRequestPrivate* priv = request->priv; - - WebCore::ResourceError resourceError(g_quark_to_string(error->domain), error->code, priv->uri.data(), String::fromUTF8(error->message)); - priv->webRequestManager->didFailURIRequest(resourceError, priv->requestID); - - webkitWebContextDidFinishURIRequest(priv->webContext, priv->requestID); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.h b/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.h deleted file mode 100644 index 71895da51..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitURISchemeRequest_h -#define WebKitURISchemeRequest_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> -#include <webkit2/WebKitForwardDeclarations.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_URI_SCHEME_REQUEST (webkit_uri_scheme_request_get_type()) -#define WEBKIT_URI_SCHEME_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_URI_SCHEME_REQUEST, WebKitURISchemeRequest)) -#define WEBKIT_IS_URI_SCHEME_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_URI_SCHEME_REQUEST)) -#define WEBKIT_URI_SCHEME_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_URI_SCHEME_REQUEST, WebKitURISchemeRequestClass)) -#define WEBKIT_IS_URI_SCHEME_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_URI_SCHEME_REQUEST)) -#define WEBKIT_URI_SCHEME_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_URI_SCHEME_REQUEST, WebKitURISchemeRequestClass)) - -typedef struct _WebKitURISchemeRequest WebKitURISchemeRequest; -typedef struct _WebKitURISchemeRequestClass WebKitURISchemeRequestClass; -typedef struct _WebKitURISchemeRequestPrivate WebKitURISchemeRequestPrivate; - -struct _WebKitURISchemeRequest { - GObject parent; - - WebKitURISchemeRequestPrivate *priv; -}; - -struct _WebKitURISchemeRequestClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_uri_scheme_request_get_type (void); - -WEBKIT_API const gchar * -webkit_uri_scheme_request_get_scheme (WebKitURISchemeRequest *request); - -WEBKIT_API const gchar * -webkit_uri_scheme_request_get_uri (WebKitURISchemeRequest *request); - -WEBKIT_API const gchar * -webkit_uri_scheme_request_get_path (WebKitURISchemeRequest *request); - -WEBKIT_API WebKitWebView * -webkit_uri_scheme_request_get_web_view (WebKitURISchemeRequest *request); - -WEBKIT_API void -webkit_uri_scheme_request_finish (WebKitURISchemeRequest *request, - GInputStream *stream, - gint64 stream_length, - const gchar *mime_type); - -WEBKIT_API void -webkit_uri_scheme_request_finish_error (WebKitURISchemeRequest *request, - GError *error); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequestPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequestPrivate.h deleted file mode 100644 index 3baebd1fe..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequestPrivate.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitURISchemeRequestPrivate_h -#define WebKitURISchemeRequestPrivate_h - -#include "WebKitPrivate.h" -#include "WebKitURISchemeRequest.h" -#include "WebKitWebContext.h" - -WebKitURISchemeRequest* webkitURISchemeRequestCreate(WebKitWebContext*, WebKit::WebSoupRequestManagerProxy*, WebKit::WebURL*, WebKit::WebPageProxy*, uint64_t requestID); -uint64_t webkitURISchemeRequestGetID(WebKitURISchemeRequest*); -void webkitURISchemeRequestCancel(WebKitURISchemeRequest*); - -#endif // WebKitURISchemeRequestPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitVersion.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitVersion.cpp deleted file mode 100644 index 54dacc4f7..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitVersion.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitVersion.h" - -/** - * SECTION: WebKitVersion - * @Short_description: Provides the WebKit version - * @Title: WebKitVersion - * - * Provides convenience functions returning WebKit's major, minor and - * micro versions of the WebKit library your code is running - * against. This is not necessarily the same as the - * #WEBKIT_MAJOR_VERSION, #WEBKIT_MINOR_VERSION or - * #WEBKIT_MICRO_VERSION, which represent the version of the WebKit - * headers included when compiling the code. - * - */ - -/** - * webkit_get_major_version: - * - * Returns the major version number of the WebKit library. - * (e.g. in WebKit version 1.8.3 this is 1.) - * - * This function is in the library, so it represents the WebKit library - * your code is running against. Contrast with the #WEBKIT_MAJOR_VERSION - * macro, which represents the major version of the WebKit headers you - * have included when compiling your code. - * - * Returns: the major version number of the WebKit library - */ -guint webkit_get_major_version(void) -{ - return WEBKIT_MAJOR_VERSION; -} - -/** - * webkit_get_minor_version: - * - * Returns the minor version number of the WebKit library. - * (e.g. in WebKit version 1.8.3 this is 8.) - * - * This function is in the library, so it represents the WebKit library - * your code is running against. Contrast with the #WEBKIT_MINOR_VERSION - * macro, which represents the minor version of the WebKit headers you - * have included when compiling your code. - * - * Returns: the minor version number of the WebKit library - */ -guint webkit_get_minor_version(void) -{ - return WEBKIT_MINOR_VERSION; -} - -/** - * webkit_get_micro_version: - * - * Returns the micro version number of the WebKit library. - * (e.g. in WebKit version 1.8.3 this is 3.) - * - * This function is in the library, so it represents the WebKit library - * your code is running against. Contrast with the #WEBKIT_MICRO_VERSION - * macro, which represents the micro version of the WebKit headers you - * have included when compiling your code. - * - * Returns: the micro version number of the WebKit library - */ -guint webkit_get_micro_version(void) -{ - return WEBKIT_MICRO_VERSION; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitVersion.h.in b/Source/WebKit2/UIProcess/API/gtk/WebKitVersion.h.in deleted file mode 100644 index 81ef5179a..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitVersion.h.in +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitVersion_h -#define WebKitVersion_h - -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -/** - * WEBKIT_MAJOR_VERSION: - * - * Like webkit_get_major_version(), but from the headers used at - * application compile time, rather than from the library linked - * against at application run time. - */ -#define WEBKIT_MAJOR_VERSION (@WEBKIT_MAJOR_VERSION@) - -/** - * WEBKIT_MINOR_VERSION: - * - * Like webkit_get_minor_version(), but from the headers used at - * application compile time, rather than from the library linked - * against at application run time. - */ -#define WEBKIT_MINOR_VERSION (@WEBKIT_MINOR_VERSION@) - -/** - * WEBKIT_MICRO_VERSION: - * - * Like webkit_get_micro_version(), but from the headers used at - * application compile time, rather than from the library linked - * against at application run time. - */ -#define WEBKIT_MICRO_VERSION (@WEBKIT_MICRO_VERSION@) - -/** - * WEBKIT_CHECK_VERSION: - * @major: major version (e.g. 1 for version 1.2.5) - * @minor: minor version (e.g. 2 for version 1.2.5) - * @micro: micro version (e.g. 5 for version 1.2.5) - * - * Returns: %TRUE if the version of the WebKit header files - * is the same as or newer than the passed-in version. - */ -#define WEBKIT_CHECK_VERSION(major, minor, micro) \ - (WEBKIT_MAJOR_VERSION > (major) || \ - (WEBKIT_MAJOR_VERSION == (major) && WEBKIT_MINOR_VERSION > (minor)) || \ - (WEBKIT_MAJOR_VERSION == (major) && WEBKIT_MINOR_VERSION == (minor) && \ - WEBKIT_MICRO_VERSION >= (micro))) - -WEBKIT_API guint -webkit_get_major_version (void); - -WEBKIT_API guint -webkit_get_minor_version (void); - -WEBKIT_API guint -webkit_get_micro_version (void); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp deleted file mode 100644 index d2c8bbdf9..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp +++ /dev/null @@ -1,904 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 "WebKitWebContext.h" - -#include "WebCookieManagerProxy.h" -#include "WebGeolocationManagerProxy.h" -#include "WebKitCookieManagerPrivate.h" -#include "WebKitDownloadClient.h" -#include "WebKitDownloadPrivate.h" -#include "WebKitFaviconDatabasePrivate.h" -#include "WebKitGeolocationProvider.h" -#include "WebKitInjectedBundleClient.h" -#include "WebKitPluginPrivate.h" -#include "WebKitPrivate.h" -#include "WebKitRequestManagerClient.h" -#include "WebKitSecurityManagerPrivate.h" -#include "WebKitTextChecker.h" -#include "WebKitURISchemeRequestPrivate.h" -#include "WebKitWebContextPrivate.h" -#include "WebKitWebViewBasePrivate.h" -#include "WebKitWebViewGroupPrivate.h" -#include "WebResourceCacheManagerProxy.h" -#include <WebCore/FileSystem.h> -#include <WebCore/IconDatabase.h> -#include <WebCore/Language.h> -#include <wtf/HashMap.h> -#include <wtf/OwnPtr.h> -#include <wtf/PassRefPtr.h> -#include <wtf/RefCounted.h> -#include <wtf/gobject/GOwnPtr.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -using namespace WebKit; - -/** - * SECTION: WebKitWebContext - * @Short_description: Manages aspects common to all #WebKitWebView<!-- -->s - * @Title: WebKitWebContext - * - * The #WebKitWebContext manages all aspects common to all - * #WebKitWebView<!-- -->s. - * - * You can define the #WebKitCacheModel with - * webkit_web_context_set_cache_model(), depending on the needs of - * your application. You can access the #WebKitCookieManager or the - * #WebKitSecurityManager to specify the behaviour of your application - * regarding cookies and security, using - * webkit_web_context_get_cookie_manager() and - * webkit_web_context_get_security_manager() for that. - * - * It is also possible to change your preferred language or enable - * spell checking, using webkit_web_context_set_preferred_languages(), - * webkit_web_context_set_spell_checking_languages() and - * webkit_web_context_set_spell_checking_enabled(). - * - * You can use webkit_web_context_register_uri_scheme() to register - * custom URI schemes, and manage several other settings. - * - */ - -enum { - DOWNLOAD_STARTED, - - LAST_SIGNAL -}; - -class WebKitURISchemeHandler: public RefCounted<WebKitURISchemeHandler> { -public: - WebKitURISchemeHandler() - : m_callback(0) - , m_userData(0) - , m_destroyNotify(0) - { - } - WebKitURISchemeHandler(WebKitURISchemeRequestCallback callback, void* userData, GDestroyNotify destroyNotify) - : m_callback(callback) - , m_userData(userData) - , m_destroyNotify(destroyNotify) - { - } - - ~WebKitURISchemeHandler() - { - if (m_destroyNotify) - m_destroyNotify(m_userData); - } - - bool hasCallback() - { - return m_callback; - } - - void performCallback(WebKitURISchemeRequest* request) - { - ASSERT(m_callback); - - m_callback(request, m_userData); - } - -private: - WebKitURISchemeRequestCallback m_callback; - void* m_userData; - GDestroyNotify m_destroyNotify; -}; - -typedef HashMap<String, RefPtr<WebKitURISchemeHandler> > URISchemeHandlerMap; -typedef HashMap<uint64_t, GRefPtr<WebKitURISchemeRequest> > URISchemeRequestMap; - -struct _WebKitWebContextPrivate { - RefPtr<WebContext> context; - - GRefPtr<WebKitCookieManager> cookieManager; - GRefPtr<WebKitFaviconDatabase> faviconDatabase; - GRefPtr<WebKitSecurityManager> securityManager; - RefPtr<WebSoupRequestManagerProxy> requestManager; - URISchemeHandlerMap uriSchemeHandlers; - URISchemeRequestMap uriSchemeRequests; -#if ENABLE(GEOLOCATION) - RefPtr<WebKitGeolocationProvider> geolocationProvider; -#endif -#if ENABLE(SPELLCHECK) - OwnPtr<WebKitTextChecker> textChecker; -#endif - CString faviconDatabaseDirectory; - WebKitTLSErrorsPolicy tlsErrorsPolicy; - - HashMap<uint64_t, WebKitWebView*> webViews; - GRefPtr<WebKitWebViewGroup> defaultWebViewGroup; -}; - -static guint signals[LAST_SIGNAL] = { 0, }; - -WEBKIT_DEFINE_TYPE(WebKitWebContext, webkit_web_context, G_TYPE_OBJECT) - -static void webkit_web_context_class_init(WebKitWebContextClass* webContextClass) -{ - GObjectClass* gObjectClass = G_OBJECT_CLASS(webContextClass); - - /** - * WebKitWebContext::download-started: - * @context: the #WebKitWebContext - * @download: the #WebKitDownload associated with this event - * - * This signal is emitted when a new download request is made. - */ - signals[DOWNLOAD_STARTED] = - g_signal_new("download-started", - G_TYPE_FROM_CLASS(gObjectClass), - G_SIGNAL_RUN_LAST, - 0, 0, 0, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - WEBKIT_TYPE_DOWNLOAD); -} - -static CString injectedBundleDirectory() -{ - const char* bundleDirectory = g_getenv("WEBKIT_INJECTED_BUNDLE_PATH"); - if (bundleDirectory && g_file_test(bundleDirectory, G_FILE_TEST_IS_DIR)) - return bundleDirectory; - - static const char* injectedBundlePath = LIBDIR G_DIR_SEPARATOR_S "webkit2gtk-" WEBKITGTK_API_VERSION_STRING - G_DIR_SEPARATOR_S "injected-bundle" G_DIR_SEPARATOR_S; - return injectedBundlePath; -} - -static CString injectedBundleFilename() -{ - GOwnPtr<char> bundleFilename(g_build_filename(injectedBundleDirectory().data(), "libwebkit2gtkinjectedbundle.so", NULL)); - return bundleFilename.get(); -} - -static gpointer createDefaultWebContext(gpointer) -{ - static GRefPtr<WebKitWebContext> webContext = adoptGRef(WEBKIT_WEB_CONTEXT(g_object_new(WEBKIT_TYPE_WEB_CONTEXT, NULL))); - WebKitWebContextPrivate* priv = webContext->priv; - - priv->context = WebContext::create(WebCore::filenameToString(injectedBundleFilename().data())); - priv->requestManager = webContext->priv->context->supplement<WebSoupRequestManagerProxy>(); - priv->context->setCacheModel(CacheModelPrimaryWebBrowser); - priv->tlsErrorsPolicy = WEBKIT_TLS_ERRORS_POLICY_IGNORE; - - attachInjectedBundleClientToContext(webContext.get()); - attachDownloadClientToContext(webContext.get()); - attachRequestManagerClientToContext(webContext.get()); - -#if ENABLE(GEOLOCATION) - priv->geolocationProvider = WebKitGeolocationProvider::create(priv->context->supplement<WebGeolocationManagerProxy>()); -#endif -#if ENABLE(SPELLCHECK) - priv->textChecker = WebKitTextChecker::create(); -#endif - return webContext.get(); -} - -/** - * webkit_web_context_get_default: - * - * Gets the default web context - * - * Returns: (transfer none): a #WebKitWebContext - */ -WebKitWebContext* webkit_web_context_get_default(void) -{ - static GOnce onceInit = G_ONCE_INIT; - return WEBKIT_WEB_CONTEXT(g_once(&onceInit, createDefaultWebContext, 0)); -} - -/** - * webkit_web_context_set_cache_model: - * @context: the #WebKitWebContext - * @cache_model: a #WebKitCacheModel - * - * Specifies a usage model for WebViews, which WebKit will use to - * determine its caching behavior. All web views follow the cache - * model. This cache model determines the RAM and disk space to use - * for caching previously viewed content . - * - * Research indicates that users tend to browse within clusters of - * documents that hold resources in common, and to revisit previously - * visited documents. WebKit and the frameworks below it include - * built-in caches that take advantage of these patterns, - * substantially improving document load speed in browsing - * situations. The WebKit cache model controls the behaviors of all of - * these caches, including various WebCore caches. - * - * Browsers can improve document load speed substantially by - * specifying %WEBKIT_CACHE_MODEL_WEB_BROWSER. Applications without a - * browsing interface can reduce memory usage substantially by - * specifying %WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER. The default value is - * %WEBKIT_CACHE_MODEL_WEB_BROWSER. - */ -void webkit_web_context_set_cache_model(WebKitWebContext* context, WebKitCacheModel model) -{ - CacheModel cacheModel; - - g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); - - switch (model) { - case WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER: - cacheModel = CacheModelDocumentViewer; - break; - case WEBKIT_CACHE_MODEL_WEB_BROWSER: - cacheModel = CacheModelPrimaryWebBrowser; - break; - case WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER: - cacheModel = CacheModelDocumentBrowser; - break; - default: - g_assert_not_reached(); - } - - if (cacheModel != context->priv->context->cacheModel()) - context->priv->context->setCacheModel(cacheModel); -} - -/** - * webkit_web_context_get_cache_model: - * @context: the #WebKitWebContext - * - * Returns the current cache model. For more information about this - * value check the documentation of the function - * webkit_web_context_set_cache_model(). - * - * Returns: the current #WebKitCacheModel - */ -WebKitCacheModel webkit_web_context_get_cache_model(WebKitWebContext* context) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), WEBKIT_CACHE_MODEL_WEB_BROWSER); - - switch (context->priv->context->cacheModel()) { - case CacheModelDocumentViewer: - return WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER; - case CacheModelPrimaryWebBrowser: - return WEBKIT_CACHE_MODEL_WEB_BROWSER; - case CacheModelDocumentBrowser: - return WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER; - default: - g_assert_not_reached(); - } - - return WEBKIT_CACHE_MODEL_WEB_BROWSER; -} - -/** - * webkit_web_context_clear_cache: - * @context: a #WebKitWebContext - * - * Clears all resources currently cached. - * See also webkit_web_context_set_cache_model(). - */ -void webkit_web_context_clear_cache(WebKitWebContext* context) -{ - g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); - - context->priv->context->supplement<WebResourceCacheManagerProxy>()->clearCacheForAllOrigins(AllResourceCaches); -} - -typedef HashMap<DownloadProxy*, GRefPtr<WebKitDownload> > DownloadsMap; - -static DownloadsMap& downloadsMap() -{ - DEFINE_STATIC_LOCAL(DownloadsMap, downloads, ()); - return downloads; -} - -/** - * webkit_web_context_download_uri: - * @context: a #WebKitWebContext - * @uri: the URI to download - * - * Requests downloading of the specified URI string. The download operation - * will not be associated to any #WebKitWebView, if you are interested in - * starting a download from a particular #WebKitWebView use - * webkit_web_view_download_uri() instead. - * - * Returns: (transfer full): a new #WebKitDownload representing the - * the download operation. - */ -WebKitDownload* webkit_web_context_download_uri(WebKitWebContext* context, const gchar* uri) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0); - g_return_val_if_fail(uri, 0); - - return webkitWebContextStartDownload(context, uri, 0); -} - -/** - * webkit_web_context_get_cookie_manager: - * @context: a #WebKitWebContext - * - * Get the #WebKitCookieManager of @context. - * - * Returns: (transfer none): the #WebKitCookieManager of @context. - */ -WebKitCookieManager* webkit_web_context_get_cookie_manager(WebKitWebContext* context) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0); - - WebKitWebContextPrivate* priv = context->priv; - if (!priv->cookieManager) - priv->cookieManager = adoptGRef(webkitCookieManagerCreate(priv->context->supplement<WebCookieManagerProxy>())); - - return priv->cookieManager.get(); -} - -static void ensureFaviconDatabase(WebKitWebContext* context) -{ - WebKitWebContextPrivate* priv = context->priv; - if (priv->faviconDatabase) - return; - - priv->faviconDatabase = adoptGRef(webkitFaviconDatabaseCreate(priv->context->iconDatabase())); -} - -/** - * webkit_web_context_set_favicon_database_directory: - * @context: a #WebKitWebContext - * @path: (allow-none): an absolute path to the icon database - * directory or %NULL to use the defaults - * - * Set the directory path to be used to store the favicons database - * for @context on disk. Passing %NULL as @path means using the - * default directory for the platform (see g_get_user_data_dir()). - * - * Calling this method also means enabling the favicons database for - * its use from the applications, so that's why it's expected to be - * called only once. Further calls for the same instance of - * #WebKitWebContext won't cause any effect. - */ -void webkit_web_context_set_favicon_database_directory(WebKitWebContext* context, const gchar* path) -{ - g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); - - WebKitWebContextPrivate* priv = context->priv; - WebIconDatabase* iconDatabase = priv->context->iconDatabase(); - if (iconDatabase->isOpen()) - return; - - ensureFaviconDatabase(context); - - // Use default if 0 is passed as parameter. - String directoryPath = WebCore::filenameToString(path); - priv->faviconDatabaseDirectory = directoryPath.isEmpty() - ? priv->context->iconDatabasePath().utf8() - : directoryPath.utf8(); - - // Build the full path to the icon database file on disk. - GOwnPtr<gchar> faviconDatabasePath(g_build_filename(priv->faviconDatabaseDirectory.data(), - WebCore::IconDatabase::defaultDatabaseFilename().utf8().data(), - NULL)); - - // Setting the path will cause the icon database to be opened. - priv->context->setIconDatabasePath(WebCore::filenameToString(faviconDatabasePath.get())); -} - -/** - * webkit_web_context_get_favicon_database_directory: - * @context: a #WebKitWebContext - * - * Get the directory path being used to store the favicons database - * for @context, or %NULL if - * webkit_web_context_set_favicon_database_directory() hasn't been - * called yet. - * - * This function will always return the same path after having called - * webkit_web_context_set_favicon_database_directory() for the first - * time. - * - * Returns: (transfer none): the path of the directory of the favicons - * database associated with @context, or %NULL. - */ -const gchar* webkit_web_context_get_favicon_database_directory(WebKitWebContext *context) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0); - - WebKitWebContextPrivate* priv = context->priv; - if (priv->faviconDatabaseDirectory.isNull()) - return 0; - - return priv->faviconDatabaseDirectory.data(); -} - -/** - * webkit_web_context_get_favicon_database: - * @context: a #WebKitWebContext - * - * Get the #WebKitFaviconDatabase associated with @context. - * - * To initialize the database you need to call - * webkit_web_context_set_favicon_database_directory(). - * - * Returns: (transfer none): the #WebKitFaviconDatabase of @context. - */ -WebKitFaviconDatabase* webkit_web_context_get_favicon_database(WebKitWebContext* context) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0); - - ensureFaviconDatabase(context); - return context->priv->faviconDatabase.get(); -} - -/** - * webkit_web_context_get_security_manager: - * @context: a #WebKitWebContext - * - * Get the #WebKitSecurityManager of @context. - * - * Returns: (transfer none): the #WebKitSecurityManager of @context. - */ -WebKitSecurityManager* webkit_web_context_get_security_manager(WebKitWebContext* context) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0); - - WebKitWebContextPrivate* priv = context->priv; - if (!priv->securityManager) - priv->securityManager = adoptGRef(webkitSecurityManagerCreate(context)); - - return priv->securityManager.get(); -} - -/** - * webkit_web_context_set_additional_plugins_directory: - * @context: a #WebKitWebContext - * @directory: the directory to add - * - * Set an additional directory where WebKit will look for plugins. - */ -void webkit_web_context_set_additional_plugins_directory(WebKitWebContext* context, const char* directory) -{ - g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); - g_return_if_fail(directory); - - context->priv->context->setAdditionalPluginsDirectory(WebCore::filenameToString(directory)); -} - -static void destroyPluginList(GList* plugins) -{ - g_list_free_full(plugins, g_object_unref); -} - -static void webkitWebContextGetPluginThread(GTask* task, gpointer object, gpointer taskData, GCancellable*) -{ - Vector<PluginModuleInfo> plugins = WEBKIT_WEB_CONTEXT(object)->priv->context->pluginInfoStore().plugins(); - GList* returnValue = 0; - for (size_t i = 0; i < plugins.size(); ++i) - returnValue = g_list_prepend(returnValue, webkitPluginCreate(plugins[i])); - g_task_return_pointer(task, returnValue, reinterpret_cast<GDestroyNotify>(destroyPluginList)); -} - -/** - * webkit_web_context_get_plugins: - * @context: a #WebKitWebContext - * @cancellable: (allow-none): a #GCancellable or %NULL to ignore - * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied - * @user_data: (closure): the data to pass to callback function - * - * Asynchronously get the list of installed plugins. - * - * When the operation is finished, @callback will be called. You can then call - * webkit_web_context_get_plugins_finish() to get the result of the operation. - */ -void webkit_web_context_get_plugins(WebKitWebContext* context, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData) -{ - g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); - - GRefPtr<GTask> task = adoptGRef(g_task_new(context, cancellable, callback, userData)); - g_task_run_in_thread(task.get(), webkitWebContextGetPluginThread); -} - -/** - * webkit_web_context_get_plugins_finish: - * @context: a #WebKitWebContext - * @result: a #GAsyncResult - * @error: return location for error or %NULL to ignore - * - * Finish an asynchronous operation started with webkit_web_context_get_plugins. - * - * Returns: (element-type WebKitPlugin) (transfer full): a #GList of #WebKitPlugin. You must free the #GList with - * g_list_free() and unref the #WebKitPlugin<!-- -->s with g_object_unref() when you're done with them. - */ -GList* webkit_web_context_get_plugins_finish(WebKitWebContext* context, GAsyncResult* result, GError** error) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0); - g_return_val_if_fail(g_task_is_valid(result, context), 0); - - return static_cast<GList*>(g_task_propagate_pointer(G_TASK(result), error)); -} - -/** - * webkit_web_context_register_uri_scheme: - * @context: a #WebKitWebContext - * @scheme: the network scheme to register - * @callback: (scope async): a #WebKitURISchemeRequestCallback - * @user_data: data to pass to callback function - * @user_data_destroy_func: destroy notify for @user_data - * - * Register @scheme in @context, so that when an URI request with @scheme is made in the - * #WebKitWebContext, the #WebKitURISchemeRequestCallback registered will be called with a - * #WebKitURISchemeRequest. - * It is possible to handle URI scheme requests asynchronously, by calling g_object_ref() on the - * #WebKitURISchemeRequest and calling webkit_uri_scheme_request_finish() later - * when the data of the request is available or - * webkit_uri_scheme_request_finish_error() in case of error. - * - * <informalexample><programlisting> - * static void - * about_uri_scheme_request_cb (WebKitURISchemeRequest *request, - * gpointer user_data) - * { - * GInputStream *stream; - * gsize stream_length; - * const gchar *path; - * - * path = webkit_uri_scheme_request_get_path (request); - * if (!g_strcmp0 (path, "plugins")) { - * /<!-- -->* Create a GInputStream with the contents of plugins about page, and set its length to stream_length *<!-- -->/ - * } else if (!g_strcmp0 (path, "memory")) { - * /<!-- -->* Create a GInputStream with the contents of memory about page, and set its length to stream_length *<!-- -->/ - * } else if (!g_strcmp0 (path, "applications")) { - * /<!-- -->* Create a GInputStream with the contents of applications about page, and set its length to stream_length *<!-- -->/ - * } else if (!g_strcmp0 (path, "example")) { - * gchar *contents; - * - * contents = g_strdup_printf ("<html><body><p>Example about page</p></body></html>"); - * stream_length = strlen (contents); - * stream = g_memory_input_stream_new_from_data (contents, stream_length, g_free); - * } else { - * GError *error; - * - * error = g_error_new (ABOUT_HANDLER_ERROR, ABOUT_HANDLER_ERROR_INVALID, "Invalid about:%s page.", path); - * webkit_uri_scheme_request_finish_error (request, error); - * g_error_free (error); - * return; - * } - * webkit_uri_scheme_request_finish (request, stream, stream_length, "text/html"); - * g_object_unref (stream); - * } - * </programlisting></informalexample> - */ -void webkit_web_context_register_uri_scheme(WebKitWebContext* context, const char* scheme, WebKitURISchemeRequestCallback callback, gpointer userData, GDestroyNotify destroyNotify) -{ - g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); - g_return_if_fail(scheme); - g_return_if_fail(callback); - - RefPtr<WebKitURISchemeHandler> handler = adoptRef(new WebKitURISchemeHandler(callback, userData, destroyNotify)); - context->priv->uriSchemeHandlers.set(String::fromUTF8(scheme), handler.get()); - context->priv->requestManager->registerURIScheme(String::fromUTF8(scheme)); -} - -/** - * webkit_web_context_get_spell_checking_enabled: - * @context: a #WebKitWebContext - * - * Get whether spell checking feature is currently enabled. - * - * Returns: %TRUE If spell checking is enabled, or %FALSE otherwise. - */ -gboolean webkit_web_context_get_spell_checking_enabled(WebKitWebContext* context) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), FALSE); - -#if ENABLE(SPELLCHECK) - return context->priv->textChecker->isSpellCheckingEnabled(); -#else - return false; -#endif -} - -/** - * webkit_web_context_set_spell_checking_enabled: - * @context: a #WebKitWebContext - * @enabled: Value to be set - * - * Enable or disable the spell checking feature. - */ -void webkit_web_context_set_spell_checking_enabled(WebKitWebContext* context, gboolean enabled) -{ - g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); - -#if ENABLE(SPELLCHECK) - context->priv->textChecker->setSpellCheckingEnabled(enabled); -#endif -} - -/** - * webkit_web_context_get_spell_checking_languages: - * @context: a #WebKitWebContext - * - * Get the the list of spell checking languages associated with - * @context, or %NULL if no languages have been previously set. - * - * See webkit_web_context_set_spell_checking_languages() for more - * details on the format of the languages in the list. - * - * Returns: (array zero-terminated=1) (element-type utf8) (transfer none): A %NULL-terminated - * array of languages if available, or %NULL otherwise. - */ -const gchar* const* webkit_web_context_get_spell_checking_languages(WebKitWebContext* context) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0); - -#if ENABLE(SPELLCHECK) - return context->priv->textChecker->getSpellCheckingLanguages(); -#else - return 0; -#endif -} - -/** - * webkit_web_context_set_spell_checking_languages: - * @context: a #WebKitWebContext - * @languages: (array zero-terminated=1) (transfer none): a %NULL-terminated list of spell checking languages - * - * Set the list of spell checking languages to be used for spell - * checking. - * - * The locale string typically is in the form lang_COUNTRY, where lang - * is an ISO-639 language code, and COUNTRY is an ISO-3166 country code. - * For instance, sv_FI for Swedish as written in Finland or pt_BR - * for Portuguese as written in Brazil. - * - * You need to call this function with a valid list of languages at - * least once in order to properly enable the spell checking feature - * in WebKit. - */ -void webkit_web_context_set_spell_checking_languages(WebKitWebContext* context, const gchar* const* languages) -{ - g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); - g_return_if_fail(languages); - -#if ENABLE(SPELLCHECK) - context->priv->textChecker->setSpellCheckingLanguages(languages); -#endif -} - -/** - * webkit_web_context_set_preferred_languages: - * @context: a #WebKitWebContext - * @languages: (allow-none) (array zero-terminated=1) (element-type utf8) (transfer none): a %NULL-terminated list of language identifiers - * - * Set the list of preferred languages, sorted from most desirable - * to least desirable. The list will be used to build the "Accept-Language" - * header that will be included in the network requests started by - * the #WebKitWebContext. - */ -void webkit_web_context_set_preferred_languages(WebKitWebContext* context, const gchar* const* languageList) -{ - g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); - - if (!languageList || !g_strv_length(const_cast<char**>(languageList))) - return; - - Vector<String> languages; - for (size_t i = 0; languageList[i]; ++i) - languages.append(String::fromUTF8(languageList[i]).lower().replace("_", "-")); - - WebCore::overrideUserPreferredLanguages(languages); - WebCore::languageDidChange(); -} - -/** - * webkit_web_context_set_tls_errors_policy: - * @context: a #WebKitWebContext - * @policy: a #WebKitTLSErrorsPolicy - * - * Set the TLS errors policy of @context as @policy - */ -void webkit_web_context_set_tls_errors_policy(WebKitWebContext* context, WebKitTLSErrorsPolicy policy) -{ - g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); - - if (context->priv->tlsErrorsPolicy == policy) - return; - - context->priv->tlsErrorsPolicy = policy; - bool ignoreTLSErrors = policy == WEBKIT_TLS_ERRORS_POLICY_IGNORE; - if (context->priv->context->ignoreTLSErrors() != ignoreTLSErrors) - context->priv->context->setIgnoreTLSErrors(ignoreTLSErrors); -} - -/** - * webkit_web_context_get_tls_errors_policy: - * @context: a #WebKitWebContext - * - * Get the TLS errors policy of @context - * - * Returns: a #WebKitTLSErrorsPolicy - */ -WebKitTLSErrorsPolicy webkit_web_context_get_tls_errors_policy(WebKitWebContext* context) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), WEBKIT_TLS_ERRORS_POLICY_IGNORE); - - return context->priv->tlsErrorsPolicy; -} - -/** - * webkit_web_context_set_web_extensions_directory: - * @context: a #WebKitWebContext - * @directory: the directory to add - * - * Set the directory where WebKit will look for Web Extensions. - * This method must be called before loading anything in this context, otherwise - * it will not have any effect. - */ -void webkit_web_context_set_web_extensions_directory(WebKitWebContext* context, const char* directory) -{ - g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); - g_return_if_fail(directory); - - // We pass the additional web extensions directory to the injected bundle as initialization user data. - context->priv->context->setInjectedBundleInitializationUserData(WebString::create(WebCore::filenameToString(directory))); -} - -/** - * webkit_web_context_set_disk_cache_directory: - * @context: a #WebKitWebContext - * @directory: the directory to set - * - * Set the directory where disk cache files will be stored - * This method must be called before loading anything in this context, otherwise - * it will not have any effect. - */ -void webkit_web_context_set_disk_cache_directory(WebKitWebContext* context, const char* directory) -{ - g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); - g_return_if_fail(directory); - - context->priv->context->setDiskCacheDirectory(WebCore::filenameToString(directory)); -} - -/** - * webkit_web_context_prefetch_dns: - * @context: a #WebKitWebContext - * @hostname: a hostname to be resolved - * - * Resolve the domain name of the given @hostname in advance, so that if a URI - * of @hostname is requested the load will be performed more quickly. - */ -void webkit_web_context_prefetch_dns(WebKitWebContext* context, const char* hostname) -{ - g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); - g_return_if_fail(hostname); - - ImmutableDictionary::MapType message; - message.set(String::fromUTF8("Hostname"), WebString::create(String::fromUTF8(hostname))); - context->priv->context->postMessageToInjectedBundle(String::fromUTF8("PrefetchDNS"), ImmutableDictionary::adopt(message).get()); -} - -WebKitDownload* webkitWebContextGetOrCreateDownload(DownloadProxy* downloadProxy) -{ - GRefPtr<WebKitDownload> download = downloadsMap().get(downloadProxy); - if (download) - return download.get(); - - download = adoptGRef(webkitDownloadCreate(downloadProxy)); - downloadsMap().set(downloadProxy, download.get()); - return download.get(); -} - -WebKitDownload* webkitWebContextStartDownload(WebKitWebContext* context, const char* uri, WebPageProxy* initiatingPage) -{ - WebCore::ResourceRequest request(String::fromUTF8(uri)); - DownloadProxy* downloadProxy = context->priv->context->download(initiatingPage, request); - WebKitDownload* download = webkitDownloadCreateForRequest(downloadProxy, request); - downloadsMap().set(downloadProxy, download); - return download; -} - -void webkitWebContextRemoveDownload(DownloadProxy* downloadProxy) -{ - downloadsMap().remove(downloadProxy); -} - -void webkitWebContextDownloadStarted(WebKitWebContext* context, WebKitDownload* download) -{ - g_signal_emit(context, signals[DOWNLOAD_STARTED], 0, download); -} - -WebContext* webkitWebContextGetContext(WebKitWebContext* context) -{ - g_assert(WEBKIT_IS_WEB_CONTEXT(context)); - - return context->priv->context.get(); -} - -WebSoupRequestManagerProxy* webkitWebContextGetRequestManager(WebKitWebContext* context) -{ - return context->priv->requestManager.get(); -} - -void webkitWebContextReceivedURIRequest(WebKitWebContext* context, WebKitURISchemeRequest* request) -{ - String scheme(String::fromUTF8(webkit_uri_scheme_request_get_scheme(request))); - RefPtr<WebKitURISchemeHandler> handler = context->priv->uriSchemeHandlers.get(scheme); - ASSERT(handler.get()); - if (!handler->hasCallback()) - return; - - context->priv->uriSchemeRequests.set(webkitURISchemeRequestGetID(request), request); - handler->performCallback(request); -} - -void webkitWebContextDidFailToLoadURIRequest(WebKitWebContext* context, uint64_t requestID) -{ - GRefPtr<WebKitURISchemeRequest> request = context->priv->uriSchemeRequests.get(requestID); - if (!request.get()) - return; - webkitURISchemeRequestCancel(request.get()); -} - -void webkitWebContextDidFinishURIRequest(WebKitWebContext* context, uint64_t requestID) -{ - context->priv->uriSchemeRequests.remove(requestID); -} - -void webkitWebContextCreatePageForWebView(WebKitWebContext* context, WebKitWebView* webView, WebKitWebViewGroup* webViewGroup) -{ - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(webView); - WebPageGroup* pageGroup = webViewGroup ? webkitWebViewGroupGetPageGroup(webViewGroup) : 0; - webkitWebViewBaseCreateWebPage(webViewBase, context->priv->context.get(), pageGroup); - - WebPageProxy* page = webkitWebViewBaseGetPage(webViewBase); - context->priv->webViews.set(page->pageID(), webView); - - if (!pageGroup && !context->priv->defaultWebViewGroup) - context->priv->defaultWebViewGroup = adoptGRef(webkitWebViewGroupCreate(page->pageGroup())); -} - -void webkitWebContextWebViewDestroyed(WebKitWebContext* context, WebKitWebView* webView) -{ - WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)); - context->priv->webViews.remove(page->pageID()); -} - -WebKitWebView* webkitWebContextGetWebViewForPage(WebKitWebContext* context, WebPageProxy* page) -{ - return page ? context->priv->webViews.get(page->pageID()) : 0; -} - -WebKitWebViewGroup* webkitWebContextGetDefaultWebViewGroup(WebKitWebContext* context) -{ - return context->priv->defaultWebViewGroup.get(); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h deleted file mode 100644 index dd38c1d37..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitWebContext_h -#define WebKitWebContext_h - -#include <glib-object.h> -#include <webkit2/WebKitCookieManager.h> -#include <webkit2/WebKitDefines.h> -#include <webkit2/WebKitDownload.h> -#include <webkit2/WebKitFaviconDatabase.h> -#include <webkit2/WebKitSecurityManager.h> -#include <webkit2/WebKitURISchemeRequest.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_WEB_CONTEXT (webkit_web_context_get_type()) -#define WEBKIT_WEB_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_CONTEXT, WebKitWebContext)) -#define WEBKIT_WEB_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_CONTEXT, WebKitWebContextClass)) -#define WEBKIT_IS_WEB_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_CONTEXT)) -#define WEBKIT_IS_WEB_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_CONTEXT)) -#define WEBKIT_WEB_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_CONTEXT, WebKitWebContextClass)) - -/** - * WebKitCacheModel: - * @WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER: Disable the cache completely, which - * substantially reduces memory usage. Useful for applications that only - * access a single local file, with no navigation to other pages. No remote - * resources will be cached. - * @WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER: A cache model optimized for viewing - * a series of local files -- for example, a documentation viewer or a website - * designer. WebKit will cache a moderate number of resources. - * @WEBKIT_CACHE_MODEL_WEB_BROWSER: Improve document load speed substantially - * by caching a very large number of resources and previously viewed content. - * - * Enum values used for determining the #WebKitWebContext cache model. - */ -typedef enum { - WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER, - WEBKIT_CACHE_MODEL_WEB_BROWSER, - WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER -} WebKitCacheModel; - -/** - * WebKitTLSErrorsPolicy: - * @WEBKIT_TLS_ERRORS_POLICY_IGNORE: Ignore TLS errors. - * @WEBKIT_TLS_ERRORS_POLICY_FAIL: TLS errors make the load to finish with an error. - * - * Enum values used to denote the TLS errors policy. - */ -typedef enum { - WEBKIT_TLS_ERRORS_POLICY_IGNORE, - WEBKIT_TLS_ERRORS_POLICY_FAIL -} WebKitTLSErrorsPolicy; - -/** - * WebKitURISchemeRequestCallback: - * @request: the #WebKitURISchemeRequest - * @user_data: user data passed to the callback - * - * Type definition for a function that will be called back when an URI request is - * made for a user registered URI scheme. - */ -typedef void (* WebKitURISchemeRequestCallback) (WebKitURISchemeRequest *request, - gpointer user_data); - -typedef struct _WebKitWebContext WebKitWebContext; -typedef struct _WebKitWebContextClass WebKitWebContextClass; -typedef struct _WebKitWebContextPrivate WebKitWebContextPrivate; - -struct _WebKitWebContext { - GObject parent; - - /*< private >*/ - WebKitWebContextPrivate *priv; -}; - -struct _WebKitWebContextClass { - GObjectClass parent; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); - void (*_webkit_reserved4) (void); - void (*_webkit_reserved5) (void); - void (*_webkit_reserved6) (void); - void (*_webkit_reserved7) (void); -}; - -WEBKIT_API GType -webkit_web_context_get_type (void); - -WEBKIT_API WebKitWebContext * -webkit_web_context_get_default (void); - -WEBKIT_API void -webkit_web_context_set_cache_model (WebKitWebContext *context, - WebKitCacheModel cache_model); -WEBKIT_API WebKitCacheModel -webkit_web_context_get_cache_model (WebKitWebContext *context); - -WEBKIT_API void -webkit_web_context_clear_cache (WebKitWebContext *context); - -WEBKIT_API WebKitDownload * -webkit_web_context_download_uri (WebKitWebContext *context, - const gchar *uri); - -WEBKIT_API WebKitCookieManager * -webkit_web_context_get_cookie_manager (WebKitWebContext *context); - -WEBKIT_API WebKitFaviconDatabase * -webkit_web_context_get_favicon_database (WebKitWebContext *context); - -WEBKIT_API void -webkit_web_context_set_favicon_database_directory (WebKitWebContext *context, - const gchar *path); -WEBKIT_API const gchar * -webkit_web_context_get_favicon_database_directory (WebKitWebContext *context); - -WEBKIT_API WebKitSecurityManager * -webkit_web_context_get_security_manager (WebKitWebContext *context); - -WEBKIT_API void -webkit_web_context_set_additional_plugins_directory (WebKitWebContext *context, - const gchar *directory); - -WEBKIT_API void -webkit_web_context_get_plugins (WebKitWebContext *context, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -WEBKIT_API GList * -webkit_web_context_get_plugins_finish (WebKitWebContext *context, - GAsyncResult *result, - GError **error); -WEBKIT_API void -webkit_web_context_register_uri_scheme (WebKitWebContext *context, - const gchar *scheme, - WebKitURISchemeRequestCallback callback, - gpointer user_data, - GDestroyNotify user_data_destroy_func); - -WEBKIT_API gboolean -webkit_web_context_get_spell_checking_enabled (WebKitWebContext *context); - -WEBKIT_API void -webkit_web_context_set_spell_checking_enabled (WebKitWebContext *context, - gboolean enabled); -WEBKIT_API const gchar * const * -webkit_web_context_get_spell_checking_languages (WebKitWebContext *context); - -WEBKIT_API void -webkit_web_context_set_spell_checking_languages (WebKitWebContext *context, - const gchar * const *languages); - -WEBKIT_API void -webkit_web_context_set_preferred_languages (WebKitWebContext *context, - const gchar * const *languages); - -WEBKIT_API void -webkit_web_context_set_tls_errors_policy (WebKitWebContext *context, - WebKitTLSErrorsPolicy policy); - -WEBKIT_API WebKitTLSErrorsPolicy -webkit_web_context_get_tls_errors_policy (WebKitWebContext *context); - -WEBKIT_API void -webkit_web_context_set_web_extensions_directory (WebKitWebContext *context, - const gchar *directory); - -WEBKIT_API void -webkit_web_context_prefetch_dns (WebKitWebContext *context, - const gchar *hostname); - -WEBKIT_API void -webkit_web_context_set_disk_cache_directory (WebKitWebContext *context, - const gchar *directory); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h deleted file mode 100644 index 81c473c56..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 WebKitWebContextPrivate_h -#define WebKitWebContextPrivate_h - -#include "DownloadProxy.h" -#include "WebContext.h" -#include "WebKitPrivate.h" -#include "WebKitURISchemeRequest.h" -#include "WebKitWebContext.h" -#include "WebKitWebViewGroup.h" -#include "WebSoupRequestManagerProxy.h" - -WebKit::WebContext* webkitWebContextGetContext(WebKitWebContext*); -WebKitDownload* webkitWebContextGetOrCreateDownload(WebKit::DownloadProxy*); -WebKitDownload* webkitWebContextStartDownload(WebKitWebContext*, const char* uri, WebKit::WebPageProxy*); -void webkitWebContextRemoveDownload(WebKit::DownloadProxy*); -void webkitWebContextDownloadStarted(WebKitWebContext*, WebKitDownload*); -WebKit::WebSoupRequestManagerProxy* webkitWebContextGetRequestManager(WebKitWebContext*); -void webkitWebContextReceivedURIRequest(WebKitWebContext*, WebKitURISchemeRequest*); -void webkitWebContextDidFailToLoadURIRequest(WebKitWebContext*, uint64_t requestID); -void webkitWebContextDidFinishURIRequest(WebKitWebContext*, uint64_t requestID); -void webkitWebContextCreatePageForWebView(WebKitWebContext*, WebKitWebView*, WebKitWebViewGroup*); -void webkitWebContextWebViewDestroyed(WebKitWebContext*, WebKitWebView*); -WebKitWebView* webkitWebContextGetWebViewForPage(WebKitWebContext*, WebKit::WebPageProxy*); -WebKitWebViewGroup* webkitWebContextGetDefaultWebViewGroup(WebKitWebContext*); - -#endif // WebKitWebContextPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebInspector.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebInspector.cpp deleted file mode 100644 index 3839ad3e2..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebInspector.cpp +++ /dev/null @@ -1,461 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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 "WebKitWebInspector.h" - -#include "WebInspectorProxy.h" -#include "WebKitMarshal.h" -#include "WebKitWebInspectorPrivate.h" -#include <glib/gi18n-lib.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -using namespace WebKit; - -/** - * SECTION: WebKitWebInspector - * @Short_description: Access to the WebKit inspector - * @Title: WebKitWebInspector - * - * The WebKit Inspector is a graphical tool to inspect and change the - * content of a #WebKitWebView. It also includes an interactive - * JavaScript debugger. Using this class one can get a #GtkWidget - * which can be embedded into an application to show the inspector. - * - * The inspector is available when the #WebKitSettings of the - * #WebKitWebView has set the #WebKitSettings:enable-developer-extras - * to true, otherwise no inspector is available. - * - * <informalexample><programlisting> - * /<!-- -->* Enable the developer extras *<!-- -->/ - * WebKitSettings *setting = webkit_web_view_get_settings (WEBKIT_WEB_VIEW(my_webview)); - * g_object_set (G_OBJECT(settings), "enable-developer-extras", TRUE, NULL); - * - * /<!-- -->* Load some data or reload to be able to inspect the page*<!-- -->/ - * webkit_web_load_uri (WEBKIT_WEB_VIEW(my_webview), "http://www.gnome.org"); - * - * /<!-- -->* Show the inspector *<!-- -->/ - * WebKitWebInspector *inspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW(my_webview)); - * webkit_web_inspector_show (WEBKIT_WEB_INSPECTOR(inspector)); - * </programlisting></informalexample> - * - */ - -enum { - OPEN_WINDOW, - BRING_TO_FRONT, - CLOSED, - ATTACH, - DETACH, - - LAST_SIGNAL -}; - -enum { - PROP_0, - - PROP_INSPECTED_URI, - PROP_ATTACHED_HEIGHT -}; - -struct _WebKitWebInspectorPrivate { - ~_WebKitWebInspectorPrivate() - { - WKInspectorSetInspectorClientGtk(toAPI(webInspector.get()), 0); - } - - RefPtr<WebInspectorProxy> webInspector; - CString inspectedURI; - unsigned attachedHeight; -}; - -WEBKIT_DEFINE_TYPE(WebKitWebInspector, webkit_web_inspector, G_TYPE_OBJECT) - -static guint signals[LAST_SIGNAL] = { 0, }; - -static void webkitWebInspectorGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) -{ - WebKitWebInspector* inspector = WEBKIT_WEB_INSPECTOR(object); - - switch (propId) { - case PROP_INSPECTED_URI: - g_value_set_string(value, webkit_web_inspector_get_inspected_uri(inspector)); - break; - case PROP_ATTACHED_HEIGHT: - g_value_set_uint(value, webkit_web_inspector_get_attached_height(inspector)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static void webkit_web_inspector_class_init(WebKitWebInspectorClass* findClass) -{ - GObjectClass* gObjectClass = G_OBJECT_CLASS(findClass); - gObjectClass->get_property = webkitWebInspectorGetProperty; - - /** - * WebKitWebInspector:inspected-uri: - * - * The URI that is currently being inspected. - */ - g_object_class_install_property(gObjectClass, - PROP_INSPECTED_URI, - g_param_spec_string("inspected-uri", - _("Inspected URI"), - _("The URI that is currently being inspected"), - 0, - WEBKIT_PARAM_READABLE)); - /** - * WebKitWebInspector:attached-height: - * - * The height that the inspector view should have when it is attached. - */ - g_object_class_install_property(gObjectClass, - PROP_ATTACHED_HEIGHT, - g_param_spec_uint("attached-height", - _("Attached Height"), - _("The height that the inspector view should have when it is attached"), - 0, G_MAXUINT, 0, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitWebInspector::open-window: - * @inspector: the #WebKitWebInspector on which the signal is emitted - * - * Emitted when the inspector is requested to open in a separate window. - * If this signal is not handled, a #GtkWindow with the inspector will be - * created and shown, so you only need to handle this signal if you want - * to use your own window. - * This signal is emitted after #WebKitWebInspector::detach to show - * the inspector in a separate window after being detached. - * - * To prevent the inspector from being shown you can connect to this - * signal and simply return %TRUE - * - * Returns: %TRUE to stop other handlers from being invoked for the event. - * %FALSE to propagate the event further. - */ - signals[OPEN_WINDOW] = - g_signal_new("open-window", - G_TYPE_FROM_CLASS(gObjectClass), - G_SIGNAL_RUN_LAST, - 0, - g_signal_accumulator_true_handled, 0, - webkit_marshal_BOOLEAN__VOID, - G_TYPE_BOOLEAN, 0); - - /** - * WebKitWebInspector::bring-to-front: - * @inspector: the #WebKitWebInspector on which the signal is emitted - * - * Emitted when the inspector should be shown. - * - * If the inspector is not attached the inspector window should be shown - * on top of any other windows. - * If the inspector is attached the inspector view should be made visible. - * For example, if the inspector view is attached using a tab in a browser - * window, the browser window should be raised and the tab containing the - * inspector view should be the active one. - * In both cases, if this signal is not handled, the default implementation - * calls gtk_window_present() on the current toplevel #GtkWindow of the - * inspector view. - * - * Returns: %TRUE to stop other handlers from being invoked for the event. - * %FALSE to propagate the event further. - */ - signals[BRING_TO_FRONT] = - g_signal_new("bring-to-front", - G_TYPE_FROM_CLASS(gObjectClass), - G_SIGNAL_RUN_LAST, - 0, - g_signal_accumulator_true_handled, 0, - webkit_marshal_BOOLEAN__VOID, - G_TYPE_BOOLEAN, 0); - - /** - * WebKitWebInspector::closed: - * @inspector: the #WebKitWebInspector on which the signal is emitted - * - * Emitted when the inspector page is closed. If you are using your own - * inspector window, you should connect to this signal and destroy your - * window. - */ - signals[CLOSED] = - g_signal_new("closed", - G_TYPE_FROM_CLASS(gObjectClass), - G_SIGNAL_RUN_LAST, - 0, 0, 0, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /** - * WebKitWebInspector::attach: - * @inspector: the #WebKitWebInspector on which the signal is emitted - * - * Emitted when the inspector is requested to be attached to the window - * where the inspected web view is. - * If this signal is not handled the inspector view will be automatically - * attached to the inspected view, so you only need to handle this signal - * if you want to attach the inspector view yourself (for example, to add - * the inspector view to a browser tab). - * - * To prevent the inspector vew from being attached you can connect to this - * signal and simply return %TRUE. - * - * Returns: %TRUE to stop other handlers from being invoked for the event. - * %FALSE to propagate the event further. - */ - signals[ATTACH] = - g_signal_new("attach", - G_TYPE_FROM_CLASS(gObjectClass), - G_SIGNAL_RUN_LAST, - 0, - g_signal_accumulator_true_handled, 0, - webkit_marshal_BOOLEAN__VOID, - G_TYPE_BOOLEAN, 0); - - /** - * WebKitWebInspector::detach: - * @inspector: the #WebKitWebInspector on which the signal is emitted - * - * Emitted when the inspector is requested to be detached from the window - * it is currently attached to. The inspector is detached when the inspector page - * is about to be closed, and this signal is emitted right before - * #WebKitWebInspector::closed, or when the user clicks on the detach button - * in the inspector view to show the inspector in a separate window. In this case - * the signal #WebKitWebInspector::open-window is emitted after this one. - * - * To prevent the inspector vew from being detached you can connect to this - * signal and simply return %TRUE. - * - * Returns: %TRUE to stop other handlers from being invoked for the event. - * %FALSE to propagate the event further. - */ - signals[DETACH] = - g_signal_new("detach", - G_TYPE_FROM_CLASS(gObjectClass), - G_SIGNAL_RUN_LAST, - 0, - g_signal_accumulator_true_handled, 0, - webkit_marshal_BOOLEAN__VOID, - G_TYPE_BOOLEAN, 0); -} - -static bool openWindow(WKInspectorRef, const void* clientInfo) -{ - gboolean returnValue; - g_signal_emit(WEBKIT_WEB_INSPECTOR(clientInfo), signals[OPEN_WINDOW], 0, &returnValue); - return returnValue; -} - -static void didClose(WKInspectorRef, const void* clientInfo) -{ - g_signal_emit(WEBKIT_WEB_INSPECTOR(clientInfo), signals[CLOSED], 0); -} - -static bool bringToFront(WKInspectorRef, const void* clientInfo) -{ - gboolean returnValue; - g_signal_emit(WEBKIT_WEB_INSPECTOR(clientInfo), signals[BRING_TO_FRONT], 0, &returnValue); - return returnValue; -} - -static void inspectedURLChanged(WKInspectorRef, WKStringRef url, const void* clientInfo) -{ - WebKitWebInspector* inspector = WEBKIT_WEB_INSPECTOR(clientInfo); - CString uri = toImpl(url)->string().utf8(); - if (uri == inspector->priv->inspectedURI) - return; - inspector->priv->inspectedURI = uri; - g_object_notify(G_OBJECT(inspector), "inspected-uri"); -} - -static bool attach(WKInspectorRef, const void* clientInfo) -{ - gboolean returnValue; - g_signal_emit(WEBKIT_WEB_INSPECTOR(clientInfo), signals[ATTACH], 0, &returnValue); - return returnValue; -} - -static bool detach(WKInspectorRef inspector, const void* clientInfo) -{ - gboolean returnValue; - g_signal_emit(WEBKIT_WEB_INSPECTOR(clientInfo), signals[DETACH], 0, &returnValue); - return returnValue; -} - -static void didChangeAttachedHeight(WKInspectorRef, unsigned height, const void* clientInfo) -{ - WebKitWebInspector* inspector = WEBKIT_WEB_INSPECTOR(clientInfo); - if (inspector->priv->attachedHeight == height) - return; - inspector->priv->attachedHeight = height; - g_object_notify(G_OBJECT(inspector), "attached-height"); -} - -WebKitWebInspector* webkitWebInspectorCreate(WebInspectorProxy* webInspector) -{ - WebKitWebInspector* inspector = WEBKIT_WEB_INSPECTOR(g_object_new(WEBKIT_TYPE_WEB_INSPECTOR, NULL)); - inspector->priv->webInspector = webInspector; - - WKInspectorClientGtk wkInspectorClientGtk = { - kWKInspectorClientGtkCurrentVersion, - inspector, // clientInfo - openWindow, - didClose, - bringToFront, - inspectedURLChanged, - attach, - detach, - didChangeAttachedHeight - }; - WKInspectorSetInspectorClientGtk(toAPI(webInspector), &wkInspectorClientGtk); - - return inspector; -} - -/** - * webkit_web_inspector_get_web_view: - * @inspector: a #WebKitWebInspector - * - * Get the #WebKitWebViewBase used to display the inspector. - * This might be %NULL if the inspector hasn't been loaded yet, - * or it has been closed. - * - * Returns: (transfer none): the #WebKitWebViewBase used to display the inspector or %NULL - */ -WebKitWebViewBase* webkit_web_inspector_get_web_view(WebKitWebInspector* inspector) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_INSPECTOR(inspector), 0); - - return WEBKIT_WEB_VIEW_BASE(inspector->priv->webInspector->inspectorView()); -} - -/** - * webkit_web_inspector_get_inspected_uri: - * @inspector: a #WebKitWebInspector - * - * Get the URI that is currently being inspected. This can be %NULL if - * nothing has been loaded yet in the inspected view, if the inspector - * has been closed or when inspected view was loaded from a HTML string - * instead of a URI. - * - * Returns: the URI that is currently being inspected or %NULL - */ -const char* webkit_web_inspector_get_inspected_uri(WebKitWebInspector* inspector) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_INSPECTOR(inspector), 0); - - return inspector->priv->inspectedURI.data(); -} - -/** - * webkit_web_inspector_is_attached: - * @inspector: a #WebKitWebInspector - * - * Whether the @inspector view is currently attached to the same window that contains - * the inspected view. - * - * Returns: %TRUE if @inspector is currently attached or %FALSE otherwise - */ -gboolean webkit_web_inspector_is_attached(WebKitWebInspector* inspector) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_INSPECTOR(inspector), FALSE); - - return inspector->priv->webInspector->isAttached(); -} - -/** - * webkit_web_inspector_attach: - * @inspector: a #WebKitWebInspector - * - * Request @inspector to be attached. The signal #WebKitWebInspector::attach - * will be emitted. If the inspector is already attached it does nothing. - */ -void webkit_web_inspector_attach(WebKitWebInspector* inspector) -{ - g_return_if_fail(WEBKIT_IS_WEB_INSPECTOR(inspector)); - - if (inspector->priv->webInspector->isAttached()) - return; - inspector->priv->webInspector->attach(); -} - -/** - * webkit_web_inspector_detach: - * @inspector: a #WebKitWebInspector - * - * Request @inspector to be detached. The signal #WebKitWebInspector::detach - * will be emitted. If the inspector is already detached it does nothing. - */ -void webkit_web_inspector_detach(WebKitWebInspector* inspector) -{ - g_return_if_fail(WEBKIT_IS_WEB_INSPECTOR(inspector)); - - if (!inspector->priv->webInspector->isAttached()) - return; - inspector->priv->webInspector->detach(); -} - -/** - * webkit_web_inspector_show: - * @inspector: a #WebKitWebInspector - * - * Request @inspector to be shown. - */ -void webkit_web_inspector_show(WebKitWebInspector* inspector) -{ - g_return_if_fail(WEBKIT_IS_WEB_INSPECTOR(inspector)); - - inspector->priv->webInspector->show(); -} - -/** - * webkit_web_inspector_close: - * @inspector: a #WebKitWebInspector - * - * Request @inspector to be closed. - */ -void webkit_web_inspector_close(WebKitWebInspector* inspector) -{ - g_return_if_fail(WEBKIT_IS_WEB_INSPECTOR(inspector)); - - inspector->priv->webInspector->close(); -} - -/** - * webkit_web_inspector_get_attached_height: - * @inspector: a #WebKitWebInspector - * - * Get the height that the inspector view should have when - * it's attached. If the inspector view is not attached this - * returns 0. - * - * Returns: the height of the inspector view when attached - */ -guint webkit_web_inspector_get_attached_height(WebKitWebInspector* inspector) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_INSPECTOR(inspector), 0); - - if (!inspector->priv->webInspector->isAttached()) - return 0; - return inspector->priv->attachedHeight; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebInspector.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebInspector.h deleted file mode 100644 index 67f0f4957..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebInspector.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitWebInspector_h -#define WebKitWebInspector_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> -#include <webkit2/WebKitWebViewBase.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_WEB_INSPECTOR (webkit_web_inspector_get_type()) -#define WEBKIT_WEB_INSPECTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_INSPECTOR, WebKitWebInspector)) -#define WEBKIT_IS_WEB_INSPECTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_INSPECTOR)) -#define WEBKIT_WEB_INSPECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_INSPECTOR, WebKitWebInspectorClass)) -#define WEBKIT_IS_WEB_INSPECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_INSPECTOR)) -#define WEBKIT_WEB_INSPECTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_INSPECTOR, WebKitWebInspectorClass)) - -typedef struct _WebKitWebInspector WebKitWebInspector; -typedef struct _WebKitWebInspectorClass WebKitWebInspectorClass; -typedef struct _WebKitWebInspectorPrivate WebKitWebInspectorPrivate; - -struct _WebKitWebInspector { - GObject parent; - - WebKitWebInspectorPrivate *priv; -}; - -struct _WebKitWebInspectorClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_web_inspector_get_type (void); - -WEBKIT_API WebKitWebViewBase * -webkit_web_inspector_get_web_view (WebKitWebInspector *inspector); - -WEBKIT_API const char * -webkit_web_inspector_get_inspected_uri (WebKitWebInspector *inspector); - -WEBKIT_API gboolean -webkit_web_inspector_is_attached (WebKitWebInspector *inspector); - -WEBKIT_API void -webkit_web_inspector_attach (WebKitWebInspector *inspector); - -WEBKIT_API void -webkit_web_inspector_detach (WebKitWebInspector *inspector); - -WEBKIT_API void -webkit_web_inspector_show (WebKitWebInspector *inspector); - -WEBKIT_API void -webkit_web_inspector_close (WebKitWebInspector *inspector); - -WEBKIT_API guint -webkit_web_inspector_get_attached_height (WebKitWebInspector *inspector); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebInspectorPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebInspectorPrivate.h deleted file mode 100644 index 2f5e99f8e..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebInspectorPrivate.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitWebInspectorPrivate_h -#define WebKitWebInspectorPrivate_h - -#include "WebKitPrivate.h" -#include "WebKitWebInspector.h" - -WebKitWebInspector* webkitWebInspectorCreate(WebKit::WebInspectorProxy*); - -#endif // WebKitWebInspectorPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebResource.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebResource.cpp deleted file mode 100644 index f81cd2b17..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebResource.cpp +++ /dev/null @@ -1,376 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitWebResource.h" - -#include "WebData.h" -#include "WebFrameProxy.h" -#include "WebKitMarshal.h" -#include "WebKitURIRequest.h" -#include "WebKitWebResourcePrivate.h" -#include <glib/gi18n-lib.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -using namespace WebKit; - -/** - * SECTION: WebKitWebResource - * @Short_description: Represents a resource at the end of a URI - * @Title: WebKitWebResource - * - * A #WebKitWebResource encapsulates content for each resource at the - * end of a particular URI. For example, one #WebKitWebResource will - * be created for each separate image and stylesheet when a page is - * loaded. - * - * You can access the response and the URI for a given - * #WebKitWebResource, using webkit_web_resource_get_uri() and - * webkit_web_resource_get_response(), as well as the raw data, using - * webkit_web_resource_get_data(). - * - */ - -enum { - SENT_REQUEST, - RECEIVED_DATA, - FINISHED, - FAILED, - - LAST_SIGNAL -}; - -enum { - PROP_0, - - PROP_URI, - PROP_RESPONSE -}; - - -struct _WebKitWebResourcePrivate { - RefPtr<WebFrameProxy> frame; - CString uri; - GRefPtr<WebKitURIResponse> response; - bool isMainResource; -}; - -WEBKIT_DEFINE_TYPE(WebKitWebResource, webkit_web_resource, G_TYPE_OBJECT) - -static guint signals[LAST_SIGNAL] = { 0, }; - -static void webkitWebResourceGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) -{ - WebKitWebResource* resource = WEBKIT_WEB_RESOURCE(object); - - switch (propId) { - case PROP_URI: - g_value_set_string(value, webkit_web_resource_get_uri(resource)); - break; - case PROP_RESPONSE: - g_value_set_object(value, webkit_web_resource_get_response(resource)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static void webkit_web_resource_class_init(WebKitWebResourceClass* resourceClass) -{ - GObjectClass* objectClass = G_OBJECT_CLASS(resourceClass); - objectClass->get_property = webkitWebResourceGetProperty; - - /** - * WebKitWebResource:uri: - * - * The current active URI of the #WebKitWebResource. - * See webkit_web_resource_get_uri() for more details. - */ - g_object_class_install_property(objectClass, - PROP_URI, - g_param_spec_string("uri", - _("URI"), - _("The current active URI of the resource"), - 0, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitWebResource:response: - * - * The #WebKitURIResponse associated with this resource. - */ - g_object_class_install_property(objectClass, - PROP_RESPONSE, - g_param_spec_object("response", - _("Response"), - _("The response of the resource"), - WEBKIT_TYPE_URI_RESPONSE, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitWebResource::sent-request: - * @resource: the #WebKitWebResource - * @request: a #WebKitURIRequest - * @redirected_response: a #WebKitURIResponse, or %NULL - * - * This signal is emitted when @request has been sent to the - * server. In case of a server redirection this signal is - * emitted again with the @request argument containing the new - * request sent to the server due to the redirection and the - * @redirected_response parameter containing the response - * received by the server for the initial request. - */ - signals[SENT_REQUEST] = - g_signal_new("sent-request", - G_TYPE_FROM_CLASS(objectClass), - G_SIGNAL_RUN_LAST, - 0, 0, 0, - webkit_marshal_VOID__OBJECT_OBJECT, - G_TYPE_NONE, 2, - WEBKIT_TYPE_URI_REQUEST, - WEBKIT_TYPE_URI_RESPONSE); - - /** - * WebKitWebResource::received-data: - * @resource: the #WebKitWebResource - * @data_length: the length of data received in bytes - * - * This signal is emitted after response is received, - * every time new data has been received. It's - * useful to know the progress of the resource load operation. - */ - signals[RECEIVED_DATA] = - g_signal_new("received-data", - G_TYPE_FROM_CLASS(objectClass), - G_SIGNAL_RUN_LAST, - 0, 0, 0, - webkit_marshal_VOID__UINT64, - G_TYPE_NONE, 1, - G_TYPE_UINT64); - - /** - * WebKitWebResource::finished: - * @resource: the #WebKitWebResource - * - * This signal is emitted when the resource load finishes successfully - * or due to an error. In case of errors #WebKitWebResource::failed signal - * is emitted before this one. - */ - signals[FINISHED] = - g_signal_new("finished", - G_TYPE_FROM_CLASS(objectClass), - G_SIGNAL_RUN_LAST, - 0, 0, 0, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /** - * WebKitWebResource::failed: - * @resource: the #WebKitWebResource - * @error: the #GError that was triggered - * - * This signal is emitted when an error occurs during the resource - * load operation. - */ - signals[FAILED] = - g_signal_new("failed", - G_TYPE_FROM_CLASS(objectClass), - G_SIGNAL_RUN_LAST, - 0, 0, 0, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); -} - -static void webkitWebResourceUpdateURI(WebKitWebResource* resource, const CString& requestURI) -{ - if (resource->priv->uri == requestURI) - return; - - resource->priv->uri = requestURI; - g_object_notify(G_OBJECT(resource), "uri"); -} - -WebKitWebResource* webkitWebResourceCreate(WebFrameProxy* frame, WebKitURIRequest* request, bool isMainResource) -{ - ASSERT(frame); - WebKitWebResource* resource = WEBKIT_WEB_RESOURCE(g_object_new(WEBKIT_TYPE_WEB_RESOURCE, NULL)); - resource->priv->frame = frame; - resource->priv->uri = webkit_uri_request_get_uri(request); - resource->priv->isMainResource = isMainResource; - return resource; -} - -void webkitWebResourceSentRequest(WebKitWebResource* resource, WebKitURIRequest* request, WebKitURIResponse* redirectResponse) -{ - webkitWebResourceUpdateURI(resource, webkit_uri_request_get_uri(request)); - g_signal_emit(resource, signals[SENT_REQUEST], 0, request, redirectResponse); -} - -void webkitWebResourceSetResponse(WebKitWebResource* resource, WebKitURIResponse* response) -{ - resource->priv->response = response; - g_object_notify(G_OBJECT(resource), "response"); -} - -void webkitWebResourceNotifyProgress(WebKitWebResource* resource, guint64 bytesReceived) -{ - g_signal_emit(resource, signals[RECEIVED_DATA], 0, bytesReceived); -} - -void webkitWebResourceFinished(WebKitWebResource* resource) -{ - g_signal_emit(resource, signals[FINISHED], 0, NULL); -} - -void webkitWebResourceFailed(WebKitWebResource* resource, GError* error) -{ - g_signal_emit(resource, signals[FAILED], 0, error); - g_signal_emit(resource, signals[FINISHED], 0, NULL); -} - -WebFrameProxy* webkitWebResourceGetFrame(WebKitWebResource* resource) -{ - return resource->priv->frame.get(); -} - -/** - * webkit_web_resource_get_uri: - * @resource: a #WebKitWebResource - * - * Returns the current active URI of @resource. The active URI might change during - * a load operation: - * - * <orderedlist> - * <listitem><para> - * When the resource load starts, the active URI is the requested URI - * </para></listitem> - * <listitem><para> - * When the initial request is sent to the server, #WebKitWebResource::sent-request - * signal is emitted without a redirected response, the active URI is the URI of - * the request sent to the server. - * </para></listitem> - * <listitem><para> - * In case of a server redirection, #WebKitWebResource::sent-request signal - * is emitted again with a redirected response, the active URI is the URI the request - * was redirected to. - * </para></listitem> - * <listitem><para> - * When the response is received from the server, the active URI is the final - * one and it will not change again. - * </para></listitem> - * </orderedlist> - * - * You can monitor the active URI by connecting to the notify::uri - * signal of @resource. - * - * Returns: the current active URI of @resource - */ -const char* webkit_web_resource_get_uri(WebKitWebResource* resource) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(resource), 0); - - return resource->priv->uri.data(); -} - -/** - * webkit_web_resource_get_response: - * @resource: a #WebKitWebResource - * - * Retrieves the #WebKitURIResponse of the resource load operation. - * This method returns %NULL if called before the response - * is received from the server. You can connect to notify::response - * signal to be notified when the response is received. - * - * Returns: (transfer none): the #WebKitURIResponse, or %NULL if - * the response hasn't been received yet. - */ -WebKitURIResponse* webkit_web_resource_get_response(WebKitWebResource* resource) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(resource), 0); - - return resource->priv->response.get(); -} - -struct ResourceGetDataAsyncData { - RefPtr<WebData> webData; -}; -WEBKIT_DEFINE_ASYNC_DATA_STRUCT(ResourceGetDataAsyncData) - -static void resourceDataCallback(WKDataRef wkData, WKErrorRef, void* context) -{ - GRefPtr<GTask> task = adoptGRef(G_TASK(context)); - ResourceGetDataAsyncData* data = static_cast<ResourceGetDataAsyncData*>(g_task_get_task_data(task.get())); - data->webData = toImpl(wkData); - g_task_return_boolean(task.get(), TRUE); -} - -/** - * webkit_web_resource_get_data: - * @resource: a #WebKitWebResource - * @cancellable: (allow-none): a #GCancellable or %NULL to ignore - * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied - * @user_data: (closure): the data to pass to callback function - * - * Asynchronously get the raw data for @resource. - * - * When the operation is finished, @callback will be called. You can then call - * webkit_web_resource_get_data_finish() to get the result of the operation. - */ -void webkit_web_resource_get_data(WebKitWebResource* resource, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData) -{ - g_return_if_fail(WEBKIT_IS_WEB_RESOURCE(resource)); - - GTask* task = g_task_new(resource, cancellable, callback, userData); - g_task_set_task_data(task, createResourceGetDataAsyncData(), reinterpret_cast<GDestroyNotify>(destroyResourceGetDataAsyncData)); - if (resource->priv->isMainResource) - resource->priv->frame->getMainResourceData(DataCallback::create(task, resourceDataCallback)); - else { - String url = String::fromUTF8(resource->priv->uri.data()); - resource->priv->frame->getResourceData(WebURL::create(url).get(), DataCallback::create(task, resourceDataCallback)); - } -} - -/** - * webkit_web_resource_get_data_finish: - * @resource: a #WebKitWebResource - * @result: a #GAsyncResult - * @length: (out): return location for the length of the resource data - * @error: return location for error or %NULL to ignore - * - * Finish an asynchronous operation started with webkit_web_resource_get_data(). - * - * Returns: (transfer full): a string with the data of @resource, or %NULL in case - * of error. if @length is not %NULL, the size of the data will be assigned to it. - */ -guchar* webkit_web_resource_get_data_finish(WebKitWebResource* resource, GAsyncResult* result, gsize* length, GError** error) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(resource), 0); - g_return_val_if_fail(g_task_is_valid(result, resource), 0); - - GTask* task = G_TASK(result); - if (!g_task_propagate_boolean(task, error)) - return 0; - - ResourceGetDataAsyncData* data = static_cast<ResourceGetDataAsyncData*>(g_task_get_task_data(task)); - if (length) - *length = data->webData->size(); - return static_cast<guchar*>(g_memdup(data->webData->bytes(), data->webData->size())); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebResource.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebResource.h deleted file mode 100644 index 7463686ab..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebResource.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitWebResource_h -#define WebKitWebResource_h - -#include <glib-object.h> -#include <gio/gio.h> -#include <webkit2/WebKitDefines.h> -#include <webkit2/WebKitURIResponse.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_WEB_RESOURCE (webkit_web_resource_get_type()) -#define WEBKIT_WEB_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_RESOURCE, WebKitWebResource)) -#define WEBKIT_IS_WEB_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_RESOURCE)) -#define WEBKIT_WEB_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_RESOURCE, WebKitWebResourceClass)) -#define WEBKIT_IS_WEB_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_RESOURCE)) -#define WEBKIT_WEB_RESOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_RESOURCE, WebKitWebResourceClass)) - -typedef struct _WebKitWebResource WebKitWebResource; -typedef struct _WebKitWebResourceClass WebKitWebResourceClass; -typedef struct _WebKitWebResourcePrivate WebKitWebResourcePrivate; - -struct _WebKitWebResource { - GObject parent; - - WebKitWebResourcePrivate *priv; -}; - -struct _WebKitWebResourceClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_web_resource_get_type (void); - -WEBKIT_API const gchar * -webkit_web_resource_get_uri (WebKitWebResource *resource); - -WEBKIT_API WebKitURIResponse * -webkit_web_resource_get_response (WebKitWebResource *resource); - -WEBKIT_API void -webkit_web_resource_get_data (WebKitWebResource *resource, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -WEBKIT_API guchar * -webkit_web_resource_get_data_finish (WebKitWebResource *resource, - GAsyncResult *result, - gsize *length, - GError **error); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebResourcePrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebResourcePrivate.h deleted file mode 100644 index 82e2d8f5a..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebResourcePrivate.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitWebResourcePrivate_h -#define WebKitWebResourcePrivate_h - -#include "WebKitPrivate.h" -#include "WebKitWebResource.h" - -WebKitWebResource* webkitWebResourceCreate(WebKit::WebFrameProxy*, WebKitURIRequest*, bool isMainResource); -void webkitWebResourceSentRequest(WebKitWebResource*, WebKitURIRequest*, WebKitURIResponse*); -void webkitWebResourceSetResponse(WebKitWebResource*, WebKitURIResponse*); -void webkitWebResourceNotifyProgress(WebKitWebResource*, guint64 bytesReceived); -void webkitWebResourceFinished(WebKitWebResource*); -void webkitWebResourceFailed(WebKitWebResource*, GError*); -WebKit::WebFrameProxy* webkitWebResourceGetFrame(WebKitWebResource*); - - -#endif // WebKitWebResourcePrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp deleted file mode 100644 index 29497090d..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp +++ /dev/null @@ -1,3032 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * Portions Copyright (c) 2011 Motorola Mobility, 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 "config.h" -#include "WebKitWebView.h" - -#include "ImageOptions.h" -#include "PlatformCertificateInfo.h" -#include "WebCertificateInfo.h" -#include "WebContextMenuItem.h" -#include "WebContextMenuItemData.h" -#include "WebData.h" -#include "WebKitAuthenticationDialog.h" -#include "WebKitBackForwardListPrivate.h" -#include "WebKitContextMenuClient.h" -#include "WebKitContextMenuItemPrivate.h" -#include "WebKitContextMenuPrivate.h" -#include "WebKitDownloadPrivate.h" -#include "WebKitEnumTypes.h" -#include "WebKitError.h" -#include "WebKitFaviconDatabasePrivate.h" -#include "WebKitFormClient.h" -#include "WebKitFullscreenClient.h" -#include "WebKitHitTestResultPrivate.h" -#include "WebKitJavascriptResultPrivate.h" -#include "WebKitLoaderClient.h" -#include "WebKitMarshal.h" -#include "WebKitPolicyClient.h" -#include "WebKitPrintOperationPrivate.h" -#include "WebKitPrivate.h" -#include "WebKitResponsePolicyDecision.h" -#include "WebKitScriptDialogPrivate.h" -#include "WebKitUIClient.h" -#include "WebKitURIRequestPrivate.h" -#include "WebKitURIResponsePrivate.h" -#include "WebKitWebContextPrivate.h" -#include "WebKitWebInspectorPrivate.h" -#include "WebKitWebResourcePrivate.h" -#include "WebKitWebViewBasePrivate.h" -#include "WebKitWebViewGroupPrivate.h" -#include "WebKitWebViewPrivate.h" -#include "WebKitWindowPropertiesPrivate.h" -#include <JavaScriptCore/APICast.h> -#include <WebCore/DragIcon.h> -#include <WebCore/GOwnPtrGtk.h> -#include <WebCore/GtkUtilities.h> -#include <WebCore/RefPtrCairo.h> -#include <glib/gi18n-lib.h> -#include <wtf/gobject/GOwnPtr.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -using namespace WebKit; -using namespace WebCore; - -/** - * SECTION: WebKitWebView - * @Short_description: The central class of the WebKit2GTK+ API - * @Title: WebKitWebView - * - * #WebKitWebView is the central class of the WebKit2GTK+ API. It is - * responsible for managing the drawing of the content and forwarding - * of events. You can load any URI into the #WebKitWebView or a data - * string. With #WebKitSettings you can control various aspects of the - * rendering and loading of the content. - * - * Note that #WebKitWebView is scrollable by itself, so you don't need - * to embed it in a #GtkScrolledWindow. - */ - -enum { - LOAD_CHANGED, - LOAD_FAILED, - - CREATE, - READY_TO_SHOW, - RUN_AS_MODAL, - CLOSE, - - SCRIPT_DIALOG, - - DECIDE_POLICY, - PERMISSION_REQUEST, - - MOUSE_TARGET_CHANGED, - - PRINT, - - RESOURCE_LOAD_STARTED, - - ENTER_FULLSCREEN, - LEAVE_FULLSCREEN, - - RUN_FILE_CHOOSER, - - CONTEXT_MENU, - CONTEXT_MENU_DISMISSED, - - SUBMIT_FORM, - - INSECURE_CONTENT_DETECTED, - - WEB_PROCESS_CRASHED, - - LAST_SIGNAL -}; - -enum { - PROP_0, - - PROP_WEB_CONTEXT, - PROP_GROUP, - PROP_TITLE, - PROP_ESTIMATED_LOAD_PROGRESS, - PROP_FAVICON, - PROP_URI, - PROP_ZOOM_LEVEL, - PROP_IS_LOADING, - PROP_VIEW_MODE -}; - -typedef HashMap<uint64_t, GRefPtr<WebKitWebResource> > LoadingResourcesMap; -typedef HashMap<uint64_t, GRefPtr<GTask> > SnapshotResultsMap; - -struct _WebKitWebViewPrivate { - ~_WebKitWebViewPrivate() - { - if (javascriptGlobalContext) - JSGlobalContextRelease(javascriptGlobalContext); - - // For modal dialogs, make sure the main loop is stopped when finalizing the webView. - if (modalLoop && g_main_loop_is_running(modalLoop.get())) - g_main_loop_quit(modalLoop.get()); - } - - WebKitWebContext* context; - CString title; - CString customTextEncoding; - double estimatedLoadProgress; - CString activeURI; - bool isLoading; - WebKitViewMode viewMode; - - bool waitingForMainResource; - unsigned long mainResourceResponseHandlerID; - WebKitLoadEvent lastDelayedEvent; - - GRefPtr<WebKitBackForwardList> backForwardList; - GRefPtr<WebKitSettings> settings; - unsigned long settingsChangedHandlerID; - GRefPtr<WebKitWebViewGroup> group; - GRefPtr<WebKitWindowProperties> windowProperties; - - GRefPtr<GMainLoop> modalLoop; - - GRefPtr<WebKitHitTestResult> mouseTargetHitTestResult; - unsigned mouseTargetModifiers; - - GRefPtr<WebKitFindController> findController; - JSGlobalContextRef javascriptGlobalContext; - - GRefPtr<WebKitWebResource> mainResource; - LoadingResourcesMap loadingResourcesMap; - - GRefPtr<WebKitWebInspector> inspector; - - RefPtr<cairo_surface_t> favicon; - GRefPtr<GCancellable> faviconCancellable; - CString faviconURI; - unsigned long faviconChangedHandlerID; - - SnapshotResultsMap snapshotResultsMap; -}; - -static guint signals[LAST_SIGNAL] = { 0, }; - -WEBKIT_DEFINE_TYPE(WebKitWebView, webkit_web_view, WEBKIT_TYPE_WEB_VIEW_BASE) - -static inline WebPageProxy* getPage(WebKitWebView* webView) -{ - return webkitWebViewBaseGetPage(reinterpret_cast<WebKitWebViewBase*>(webView)); -} - -static gboolean webkitWebViewLoadFail(WebKitWebView* webView, WebKitLoadEvent, const char* failingURI, GError* error) -{ - if (g_error_matches(error, WEBKIT_NETWORK_ERROR, WEBKIT_NETWORK_ERROR_CANCELLED) - || g_error_matches(error, WEBKIT_POLICY_ERROR, WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE) - || g_error_matches(error, WEBKIT_PLUGIN_ERROR, WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD)) - return FALSE; - - GOwnPtr<char> htmlString(g_strdup_printf("<html><body>%s</body></html>", error->message)); - webkit_web_view_load_alternate_html(webView, htmlString.get(), failingURI, 0); - - return TRUE; -} - -static GtkWidget* webkitWebViewCreate(WebKitWebView*) -{ - return 0; -} - -static GtkWidget* webkitWebViewCreateJavaScriptDialog(WebKitWebView* webView, GtkMessageType type, GtkButtonsType buttons, int defaultResponse, const char* message) -{ - GtkWidget* parent = gtk_widget_get_toplevel(GTK_WIDGET(webView)); - GtkWidget* dialog = gtk_message_dialog_new(widgetIsOnscreenToplevelWindow(parent) ? GTK_WINDOW(parent) : 0, - GTK_DIALOG_DESTROY_WITH_PARENT, type, buttons, "%s", message); - GOwnPtr<char> title(g_strdup_printf("JavaScript - %s", webkit_web_view_get_uri(webView))); - gtk_window_set_title(GTK_WINDOW(dialog), title.get()); - gtk_dialog_set_default_response(GTK_DIALOG(dialog), defaultResponse); - - return dialog; -} - -static gboolean webkitWebViewScriptDialog(WebKitWebView* webView, WebKitScriptDialog* scriptDialog) -{ - GtkWidget* dialog = 0; - - switch (scriptDialog->type) { - case WEBKIT_SCRIPT_DIALOG_ALERT: - dialog = webkitWebViewCreateJavaScriptDialog(webView, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, GTK_RESPONSE_CLOSE, scriptDialog->message.data()); - gtk_dialog_run(GTK_DIALOG(dialog)); - break; - case WEBKIT_SCRIPT_DIALOG_CONFIRM: - dialog = webkitWebViewCreateJavaScriptDialog(webView, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, GTK_RESPONSE_OK, scriptDialog->message.data()); - scriptDialog->confirmed = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK; - break; - case WEBKIT_SCRIPT_DIALOG_PROMPT: - dialog = webkitWebViewCreateJavaScriptDialog(webView, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, GTK_RESPONSE_OK, scriptDialog->message.data()); - GtkWidget* entry = gtk_entry_new(); - gtk_entry_set_text(GTK_ENTRY(entry), scriptDialog->defaultText.data()); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), entry); - gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); - gtk_widget_show(entry); - if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) - scriptDialog->text = gtk_entry_get_text(GTK_ENTRY(entry)); - break; - } - - gtk_widget_destroy(dialog); - - return TRUE; -} - -static gboolean webkitWebViewDecidePolicy(WebKitWebView* webView, WebKitPolicyDecision* decision, WebKitPolicyDecisionType decisionType) -{ - if (decisionType != WEBKIT_POLICY_DECISION_TYPE_RESPONSE) { - webkit_policy_decision_use(decision); - return TRUE; - } - - WebKitURIResponse* response = webkit_response_policy_decision_get_response(WEBKIT_RESPONSE_POLICY_DECISION(decision)); - const ResourceResponse resourceResponse = webkitURIResponseGetResourceResponse(response); - if (resourceResponse.isAttachment()) { - webkit_policy_decision_download(decision); - return TRUE; - } - - if (webkit_web_view_can_show_mime_type(webView, webkit_uri_response_get_mime_type(response))) - webkit_policy_decision_use(decision); - else - webkit_policy_decision_ignore(decision); - - return TRUE; -} - -static gboolean webkitWebViewPermissionRequest(WebKitWebView*, WebKitPermissionRequest* request) -{ - webkit_permission_request_deny(request); - return TRUE; -} - -static void allowModalDialogsChanged(WebKitSettings* settings, GParamSpec*, WebKitWebView* webView) -{ - WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)); - if (!page) - return; - getPage(webView)->setCanRunModal(webkit_settings_get_allow_modal_dialogs(settings)); -} - -static void zoomTextOnlyChanged(WebKitSettings* settings, GParamSpec*, WebKitWebView* webView) -{ - WebPageProxy* page = getPage(webView); - gboolean zoomTextOnly = webkit_settings_get_zoom_text_only(settings); - gdouble pageZoomLevel = zoomTextOnly ? 1 : page->textZoomFactor(); - gdouble textZoomLevel = zoomTextOnly ? page->pageZoomFactor() : 1; - page->setPageAndTextZoomFactors(pageZoomLevel, textZoomLevel); -} - -static void userAgentChanged(WebKitSettings* settings, GParamSpec*, WebKitWebView* webView) -{ - getPage(webView)->setCustomUserAgent(String::fromUTF8(webkit_settings_get_user_agent(settings))); -} - -static void webkitWebViewUpdateFavicon(WebKitWebView* webView, cairo_surface_t* favicon) -{ - WebKitWebViewPrivate* priv = webView->priv; - if (priv->favicon.get() == favicon) - return; - - priv->favicon = favicon; - g_object_notify(G_OBJECT(webView), "favicon"); -} - -static void webkitWebViewCancelFaviconRequest(WebKitWebView* webView) -{ - if (!webView->priv->faviconCancellable) - return; - - g_cancellable_cancel(webView->priv->faviconCancellable.get()); - webView->priv->faviconCancellable = 0; -} - -static void gotFaviconCallback(GObject* object, GAsyncResult* result, gpointer userData) -{ - GOwnPtr<GError> error; - RefPtr<cairo_surface_t> favicon = adoptRef(webkit_favicon_database_get_favicon_finish(WEBKIT_FAVICON_DATABASE(object), result, &error.outPtr())); - if (g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - - WebKitWebView* webView = WEBKIT_WEB_VIEW(userData); - webkitWebViewUpdateFavicon(webView, favicon.get()); - webView->priv->faviconCancellable = 0; -} - -static void webkitWebViewRequestFavicon(WebKitWebView* webView) -{ - webkitWebViewCancelFaviconRequest(webView); - - WebKitWebViewPrivate* priv = webView->priv; - priv->faviconCancellable = adoptGRef(g_cancellable_new()); - WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(priv->context); - webkit_favicon_database_get_favicon(database, priv->activeURI.data(), priv->faviconCancellable.get(), gotFaviconCallback, webView); -} - -static void webkitWebViewUpdateFaviconURI(WebKitWebView* webView, const char* faviconURI) -{ - if (webView->priv->faviconURI == faviconURI) - return; - - webView->priv->faviconURI = faviconURI; - webkitWebViewRequestFavicon(webView); -} - -static void faviconChangedCallback(WebKitFaviconDatabase* database, const char* pageURI, const char* faviconURI, WebKitWebView* webView) -{ - if (webView->priv->activeURI != pageURI) - return; - - webkitWebViewUpdateFaviconURI(webView, faviconURI); -} - -static void webkitWebViewUpdateSettings(WebKitWebView* webView) -{ - // We keep a ref of the current settings to disconnect the signals when settings change in the group. - webView->priv->settings = webkit_web_view_get_settings(webView); - - WebKitSettings* settings = webView->priv->settings.get(); - WebPageProxy* page = getPage(webView); - page->setCanRunModal(webkit_settings_get_allow_modal_dialogs(settings)); - page->setCustomUserAgent(String::fromUTF8(webkit_settings_get_user_agent(settings))); - - g_signal_connect(settings, "notify::allow-modal-dialogs", G_CALLBACK(allowModalDialogsChanged), webView); - g_signal_connect(settings, "notify::zoom-text-only", G_CALLBACK(zoomTextOnlyChanged), webView); - g_signal_connect(settings, "notify::user-agent", G_CALLBACK(userAgentChanged), webView); -} - -static void webkitWebViewDisconnectSettingsSignalHandlers(WebKitWebView* webView) -{ - WebKitSettings* settings = webView->priv->settings.get(); - g_signal_handlers_disconnect_by_func(settings, reinterpret_cast<gpointer>(allowModalDialogsChanged), webView); - g_signal_handlers_disconnect_by_func(settings, reinterpret_cast<gpointer>(zoomTextOnlyChanged), webView); - g_signal_handlers_disconnect_by_func(settings, reinterpret_cast<gpointer>(userAgentChanged), webView); -} - -static void webkitWebViewSettingsChanged(WebKitWebViewGroup* group, GParamSpec*, WebKitWebView* webView) -{ - webkitWebViewDisconnectSettingsSignalHandlers(webView); - webkitWebViewUpdateSettings(webView); -} - -static void webkitWebViewDisconnectSettingsChangedSignalHandler(WebKitWebView* webView) -{ - WebKitWebViewPrivate* priv = webView->priv; - if (priv->settingsChangedHandlerID) - g_signal_handler_disconnect(webkit_web_view_get_group(webView), priv->settingsChangedHandlerID); - priv->settingsChangedHandlerID = 0; -} - -static void webkitWebViewDisconnectMainResourceResponseChangedSignalHandler(WebKitWebView* webView) -{ - WebKitWebViewPrivate* priv = webView->priv; - if (priv->mainResourceResponseHandlerID) - g_signal_handler_disconnect(priv->mainResource.get(), priv->mainResourceResponseHandlerID); - priv->mainResourceResponseHandlerID = 0; -} - -static void webkitWebViewWatchForChangesInFavicon(WebKitWebView* webView) -{ - WebKitWebViewPrivate* priv = webView->priv; - if (priv->faviconChangedHandlerID) - return; - - WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(priv->context); - priv->faviconChangedHandlerID = g_signal_connect(database, "favicon-changed", G_CALLBACK(faviconChangedCallback), webView); -} - -static void webkitWebViewDisconnectFaviconDatabaseSignalHandlers(WebKitWebView* webView) -{ - WebKitWebViewPrivate* priv = webView->priv; - if (priv->faviconChangedHandlerID) - g_signal_handler_disconnect(webkit_web_context_get_favicon_database(priv->context), priv->faviconChangedHandlerID); - priv->faviconChangedHandlerID = 0; -} - -static void fileChooserDialogResponseCallback(GtkDialog* dialog, gint responseID, WebKitFileChooserRequest* request) -{ - GRefPtr<WebKitFileChooserRequest> adoptedRequest = adoptGRef(request); - if (responseID == GTK_RESPONSE_ACCEPT) { - GOwnPtr<GSList> filesList(gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog))); - GRefPtr<GPtrArray> filesArray = adoptGRef(g_ptr_array_new()); - for (GSList* file = filesList.get(); file; file = g_slist_next(file)) - g_ptr_array_add(filesArray.get(), file->data); - g_ptr_array_add(filesArray.get(), 0); - webkit_file_chooser_request_select_files(adoptedRequest.get(), reinterpret_cast<const gchar* const*>(filesArray->pdata)); - } else - webkit_file_chooser_request_cancel(adoptedRequest.get()); - - gtk_widget_destroy(GTK_WIDGET(dialog)); -} - -static gboolean webkitWebViewRunFileChooser(WebKitWebView* webView, WebKitFileChooserRequest* request) -{ - GtkWidget* toplevel = gtk_widget_get_toplevel(GTK_WIDGET(webView)); - if (!widgetIsOnscreenToplevelWindow(toplevel)) - toplevel = 0; - - gboolean allowsMultipleSelection = webkit_file_chooser_request_get_select_multiple(request); - GtkWidget* dialog = gtk_file_chooser_dialog_new(allowsMultipleSelection ? _("Select Files") : _("Select File"), - toplevel ? GTK_WINDOW(toplevel) : 0, - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, - NULL); - - if (GtkFileFilter* filter = webkit_file_chooser_request_get_mime_types_filter(request)) - gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter); - gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), allowsMultipleSelection); - - if (const gchar* const* selectedFiles = webkit_file_chooser_request_get_selected_files(request)) - gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(dialog), selectedFiles[0]); - - g_signal_connect(dialog, "response", G_CALLBACK(fileChooserDialogResponseCallback), g_object_ref(request)); - gtk_widget_show(dialog); - - return TRUE; -} - -static void webkitWebViewHandleDownloadRequest(WebKitWebViewBase* webViewBase, DownloadProxy* downloadProxy) -{ - GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy); - webkitDownloadSetWebView(download.get(), WEBKIT_WEB_VIEW(webViewBase)); -} - -static void webkitWebViewConstructed(GObject* object) -{ - if (G_OBJECT_CLASS(webkit_web_view_parent_class)->constructed) - G_OBJECT_CLASS(webkit_web_view_parent_class)->constructed(object); - - WebKitWebView* webView = WEBKIT_WEB_VIEW(object); - WebKitWebViewPrivate* priv = webView->priv; - webkitWebContextCreatePageForWebView(priv->context, webView, priv->group.get()); - - webkitWebViewBaseSetDownloadRequestHandler(WEBKIT_WEB_VIEW_BASE(webView), webkitWebViewHandleDownloadRequest); - - attachLoaderClientToView(webView); - attachUIClientToView(webView); - attachPolicyClientToView(webView); - attachFullScreenClientToView(webView); - attachContextMenuClientToView(webView); - attachFormClientToView(webView); - - priv->backForwardList = adoptGRef(webkitBackForwardListCreate(getPage(webView)->backForwardList())); - priv->windowProperties = adoptGRef(webkitWindowPropertiesCreate()); - - webkitWebViewUpdateSettings(webView); - priv->settingsChangedHandlerID = - g_signal_connect(webkit_web_view_get_group(webView), "notify::settings", G_CALLBACK(webkitWebViewSettingsChanged), webView); -} - -static void webkitWebViewSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec) -{ - WebKitWebView* webView = WEBKIT_WEB_VIEW(object); - - switch (propId) { - case PROP_WEB_CONTEXT: { - gpointer webContext = g_value_get_object(value); - webView->priv->context = webContext ? WEBKIT_WEB_CONTEXT(webContext) : webkit_web_context_get_default(); - break; - } - case PROP_GROUP: { - gpointer group = g_value_get_object(value); - webView->priv->group = group ? WEBKIT_WEB_VIEW_GROUP(group) : 0; - break; - } - case PROP_ZOOM_LEVEL: - webkit_web_view_set_zoom_level(webView, g_value_get_double(value)); - break; - case PROP_VIEW_MODE: - webkit_web_view_set_view_mode(webView, static_cast<WebKitViewMode>(g_value_get_enum(value))); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static void webkitWebViewGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) -{ - WebKitWebView* webView = WEBKIT_WEB_VIEW(object); - - switch (propId) { - case PROP_WEB_CONTEXT: - g_value_take_object(value, webView->priv->context); - break; - case PROP_GROUP: - g_value_set_object(value, webkit_web_view_get_group(webView)); - break; - case PROP_TITLE: - g_value_set_string(value, webView->priv->title.data()); - break; - case PROP_ESTIMATED_LOAD_PROGRESS: - g_value_set_double(value, webkit_web_view_get_estimated_load_progress(webView)); - break; - case PROP_FAVICON: - g_value_set_pointer(value, webkit_web_view_get_favicon(webView)); - break; - case PROP_URI: - g_value_set_string(value, webkit_web_view_get_uri(webView)); - break; - case PROP_ZOOM_LEVEL: - g_value_set_double(value, webkit_web_view_get_zoom_level(webView)); - break; - case PROP_IS_LOADING: - g_value_set_boolean(value, webkit_web_view_is_loading(webView)); - break; - case PROP_VIEW_MODE: - g_value_set_enum(value, webkit_web_view_get_view_mode(webView)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static void webkitWebViewDispose(GObject* object) -{ - WebKitWebView* webView = WEBKIT_WEB_VIEW(object); - webkitWebViewCancelFaviconRequest(webView); - webkitWebViewDisconnectMainResourceResponseChangedSignalHandler(webView); - webkitWebViewDisconnectSettingsChangedSignalHandler(webView); - webkitWebViewDisconnectSettingsSignalHandlers(webView); - webkitWebViewDisconnectFaviconDatabaseSignalHandlers(webView); - - webkitWebContextWebViewDestroyed(webView->priv->context, webView); - - G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object); -} - -static gboolean webkitWebViewAccumulatorObjectHandled(GSignalInvocationHint*, GValue* returnValue, const GValue* handlerReturn, gpointer) -{ - void* object = g_value_get_object(handlerReturn); - if (object) - g_value_set_object(returnValue, object); - - return !object; -} - -static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) -{ - GObjectClass* gObjectClass = G_OBJECT_CLASS(webViewClass); - - gObjectClass->constructed = webkitWebViewConstructed; - gObjectClass->set_property = webkitWebViewSetProperty; - gObjectClass->get_property = webkitWebViewGetProperty; - gObjectClass->dispose = webkitWebViewDispose; - - webViewClass->load_failed = webkitWebViewLoadFail; - webViewClass->create = webkitWebViewCreate; - webViewClass->script_dialog = webkitWebViewScriptDialog; - webViewClass->decide_policy = webkitWebViewDecidePolicy; - webViewClass->permission_request = webkitWebViewPermissionRequest; - webViewClass->run_file_chooser = webkitWebViewRunFileChooser; - - /** - * WebKitWebView:web-context: - * - * The #WebKitWebContext of the view. - */ - g_object_class_install_property(gObjectClass, - PROP_WEB_CONTEXT, - g_param_spec_object("web-context", - _("Web Context"), - _("The web context for the view"), - WEBKIT_TYPE_WEB_CONTEXT, - static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY))); - /** - * WebKitWebView:group: - * - * The #WebKitWebViewGroup of the view. - */ - g_object_class_install_property( - gObjectClass, - PROP_GROUP, - g_param_spec_object( - "group", - _("WebView Group"), - _("The WebKitWebViewGroup of the view"), - WEBKIT_TYPE_WEB_VIEW_GROUP, - static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY))); - - /** - * WebKitWebView:title: - * - * The main frame document title of this #WebKitWebView. If - * the title has not been received yet, it will be %NULL. - */ - g_object_class_install_property(gObjectClass, - PROP_TITLE, - g_param_spec_string("title", - _("Title"), - _("Main frame document title"), - 0, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitWebView:estimated-load-progress: - * - * An estimate of the percent completion for the current loading operation. - * This value will range from 0.0 to 1.0 and, once a load completes, - * will remain at 1.0 until a new load starts, at which point it - * will be reset to 0.0. - * The value is an estimate based on the total number of bytes expected - * to be received for a document, including all its possible subresources - * and child documents. - */ - g_object_class_install_property(gObjectClass, - PROP_ESTIMATED_LOAD_PROGRESS, - g_param_spec_double("estimated-load-progress", - _("Estimated Load Progress"), - _("An estimate of the percent completion for a document load"), - 0.0, 1.0, 0.0, - WEBKIT_PARAM_READABLE)); - /** - * WebKitWebView:favicon: - * - * The favicon currently associated to the #WebKitWebView. - * See webkit_web_view_get_favicon() for more details. - */ - g_object_class_install_property(gObjectClass, - PROP_FAVICON, - g_param_spec_pointer("favicon", - _("Favicon"), - _("The favicon associated to the view, if any"), - WEBKIT_PARAM_READABLE)); - /** - * WebKitWebView:uri: - * - * The current active URI of the #WebKitWebView. - * See webkit_web_view_get_uri() for more details. - */ - g_object_class_install_property(gObjectClass, - PROP_URI, - g_param_spec_string("uri", - _("URI"), - _("The current active URI of the view"), - 0, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitWebView:zoom-level: - * - * The zoom level of the #WebKitWebView content. - * See webkit_web_view_set_zoom_level() for more details. - */ - g_object_class_install_property(gObjectClass, - PROP_ZOOM_LEVEL, - g_param_spec_double("zoom-level", - "Zoom level", - _("The zoom level of the view content"), - 0, G_MAXDOUBLE, 1, - WEBKIT_PARAM_READWRITE)); - - /** - * WebKitWebView:is-loading: - * - * Whether the #WebKitWebView is currently loading a page. This property becomes - * %TRUE as soon as a new load operation is requested and before the - * #WebKitWebView::load-changed signal is emitted with %WEBKIT_LOAD_STARTED and - * at that point the active URI is the requested one. - * When the load operation finishes the property is set to %FALSE before - * #WebKitWebView::load-changed is emitted with %WEBKIT_LOAD_FINISHED. - */ - g_object_class_install_property(gObjectClass, - PROP_IS_LOADING, - g_param_spec_boolean("is-loading", - "Is Loading", - _("Whether the view is loading a page"), - FALSE, - WEBKIT_PARAM_READABLE)); - - /** - * WebKitWebView:view-mode: - * - * The #WebKitViewMode that is used to display the contents of a #WebKitWebView. - * See also webkit_web_view_set_view_mode(). - */ - g_object_class_install_property(gObjectClass, - PROP_VIEW_MODE, - g_param_spec_enum("view-mode", - "View Mode", - _("The view mode to display the web view contents"), - WEBKIT_TYPE_VIEW_MODE, - WEBKIT_VIEW_MODE_WEB, - WEBKIT_PARAM_READWRITE)); - - /** - * WebKitWebView::load-changed: - * @web_view: the #WebKitWebView on which the signal is emitted - * @load_event: the #WebKitLoadEvent - * - * Emitted when the a load operation in @web_view changes. - * The signal is always emitted with %WEBKIT_LOAD_STARTED when a - * new load request is made and %WEBKIT_LOAD_FINISHED when the load - * finishes successfully or due to an error. When the ongoing load - * operation fails #WebKitWebView::load-failed signal is emitted - * before #WebKitWebView::load-changed is emitted with - * %WEBKIT_LOAD_FINISHED. - * If a redirection is received from the server, this signal is emitted - * with %WEBKIT_LOAD_REDIRECTED after the initial emission with - * %WEBKIT_LOAD_STARTED and before %WEBKIT_LOAD_COMMITTED. - * When the page content starts arriving the signal is emitted with - * %WEBKIT_LOAD_COMMITTED event. - * - * You can handle this signal and use a switch to track any ongoing - * load operation. - * - * <informalexample><programlisting> - * static void web_view_load_changed (WebKitWebView *web_view, - * WebKitLoadEvent load_event, - * gpointer user_data) - * { - * switch (load_event) { - * case WEBKIT_LOAD_STARTED: - * /<!-- -->* New load, we have now a provisional URI *<!-- -->/ - * provisional_uri = webkit_web_view_get_uri (web_view); - * /<!-- -->* Here we could start a spinner or update the - * <!-- -->* location bar with the provisional URI *<!-- -->/ - * break; - * case WEBKIT_LOAD_REDIRECTED: - * redirected_uri = webkit_web_view_get_uri (web_view); - * break; - * case WEBKIT_LOAD_COMMITTED: - * /<!-- -->* The load is being performed. Current URI is - * <!-- -->* the final one and it won't change unless a new - * <!-- -->* load is requested or a navigation within the - * <!-- -->* same page is performed *<!-- -->/ - * uri = webkit_web_view_get_uri (web_view); - * break; - * case WEBKIT_LOAD_FINISHED: - * /<!-- -->* Load finished, we can now stop the spinner *<!-- -->/ - * break; - * } - * } - * </programlisting></informalexample> - */ - signals[LOAD_CHANGED] = - g_signal_new("load-changed", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, load_changed), - 0, 0, - g_cclosure_marshal_VOID__ENUM, - G_TYPE_NONE, 1, - WEBKIT_TYPE_LOAD_EVENT); - - /** - * WebKitWebView::load-failed: - * @web_view: the #WebKitWebView on which the signal is emitted - * @load_event: the #WebKitLoadEvent of the load operation - * @failing_uri: the URI that failed to load - * @error: the #GError that was triggered - * - * Emitted when an error occurs during a load operation. - * If the error happened when starting to load data for a page - * @load_event will be %WEBKIT_LOAD_STARTED. If it happened while - * loading a committed data source @load_event will be %WEBKIT_LOAD_COMMITTED. - * Since a load error causes the load operation to finish, the signal - * WebKitWebView::load-changed will always be emitted with - * %WEBKIT_LOAD_FINISHED event right after this one. - * - * By default, if the signal is not handled, a stock error page will be displayed. - * You need to handle the signal if you want to provide your own error page. - * - * Returns: %TRUE to stop other handlers from being invoked for the event. - * %FALSE to propagate the event further. - */ - signals[LOAD_FAILED] = - g_signal_new("load-failed", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, load_failed), - g_signal_accumulator_true_handled, 0, - webkit_marshal_BOOLEAN__ENUM_STRING_POINTER, - G_TYPE_BOOLEAN, 3, - WEBKIT_TYPE_LOAD_EVENT, - G_TYPE_STRING, - G_TYPE_POINTER); - - /** - * WebKitWebView::create: - * @web_view: the #WebKitWebView on which the signal is emitted - * - * Emitted when the creation of a new #WebKitWebView is requested. - * If this signal is handled the signal handler should return the - * newly created #WebKitWebView. - * - * The new #WebKitWebView should not be displayed to the user - * until the #WebKitWebView::ready-to-show signal is emitted. - * - * Returns: (transfer full): a newly allocated #WebKitWebView widget - * or %NULL to propagate the event further. - */ - signals[CREATE] = - g_signal_new("create", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, create), - webkitWebViewAccumulatorObjectHandled, 0, - webkit_marshal_OBJECT__VOID, - GTK_TYPE_WIDGET, 0); - - /** - * WebKitWebView::ready-to-show: - * @web_view: the #WebKitWebView on which the signal is emitted - * - * Emitted after #WebKitWebView::create on the newly created #WebKitWebView - * when it should be displayed to the user. When this signal is emitted - * all the information about how the window should look, including - * size, position, whether the location, status and scrollbars - * should be displayed, is already set on the #WebKitWindowProperties - * of @web_view. See also webkit_web_view_get_window_properties(). - */ - signals[READY_TO_SHOW] = - g_signal_new("ready-to-show", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, ready_to_show), - 0, 0, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /** - * WebKitWebView::run-as-modal: - * @web_view: the #WebKitWebView on which the signal is emitted - * - * Emitted after #WebKitWebView::ready-to-show on the newly - * created #WebKitWebView when JavaScript code calls - * <function>window.showModalDialog</function>. The purpose of - * this signal is to allow the client application to prepare the - * new view to behave as modal. Once the signal is emitted a new - * mainloop will be run to block user interaction in the parent - * #WebKitWebView until the new dialog is closed. - */ - signals[RUN_AS_MODAL] = - g_signal_new("run-as-modal", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, run_as_modal), - 0, 0, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /** - * WebKitWebView::close: - * @webView: the #WebKitWebView on which the signal is emitted - * - * Emitted when closing a #WebKitWebView is requested. This occurs when a - * call is made from JavaScript's <function>window.close</function> function. - * It is the owner's responsibility to handle this signal to hide or - * destroy the #WebKitWebView, if necessary. - */ - signals[CLOSE] = - g_signal_new("close", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, close), - 0, 0, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /** - * WebKitWebView::script-dialog: - * @web_view: the #WebKitWebView on which the signal is emitted - * @dialog: the #WebKitScriptDialog to show - * - * Emitted when JavaScript code calls <function>window.alert</function>, - * <function>window.confirm</function> or <function>window.prompt</function>. - * The @dialog parameter should be used to build the dialog. - * If the signal is not handled a different dialog will be built and shown depending - * on the dialog type: - * <itemizedlist> - * <listitem><para> - * %WEBKIT_SCRIPT_DIALOG_ALERT: message dialog with a single Close button. - * </para></listitem> - * <listitem><para> - * %WEBKIT_SCRIPT_DIALOG_CONFIRM: message dialog with OK and Cancel buttons. - * </para></listitem> - * <listitem><para> - * %WEBKIT_SCRIPT_DIALOG_PROMPT: message dialog with OK and Cancel buttons and - * a text entry with the default text. - * </para></listitem> - * </itemizedlist> - * - * Returns: %TRUE to stop other handlers from being invoked for the event. - * %FALSE to propagate the event further. - */ - signals[SCRIPT_DIALOG] = - g_signal_new("script-dialog", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, script_dialog), - g_signal_accumulator_true_handled, 0, - webkit_marshal_BOOLEAN__BOXED, - G_TYPE_BOOLEAN, 1, - WEBKIT_TYPE_SCRIPT_DIALOG | G_SIGNAL_TYPE_STATIC_SCOPE); - - /** - * WebKitWebView::decide-policy: - * @web_view: the #WebKitWebView on which the signal is emitted - * @decision: the #WebKitPolicyDecision - * @decision_type: a #WebKitPolicyDecisionType denoting the type of @decision - * - * This signal is emitted when WebKit is requesting the client to decide a policy - * decision, such as whether to navigate to a page, open a new window or whether or - * not to download a resource. The #WebKitNavigationPolicyDecision passed in the - * @decision argument is a generic type, but should be casted to a more - * specific type when making the decision. For example: - * - * <informalexample><programlisting> - * static gboolean - * decide_policy_cb (WebKitWebView *web_view, - * WebKitPolicyDecision *decision, - * WebKitPolicyDecisionType type) - * { - * switch (type) { - * case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: - * WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision); - * /<!-- -->* Make a policy decision here. *<!-- -->/ - * break; - * case WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION: - * WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision); - * /<!-- -->* Make a policy decision here. *<!-- -->/ - * break; - * case WEBKIT_POLICY_DECISION_TYPE_RESPONSE: - * WebKitResponsePolicyDecision *response = WEBKIT_RESPONSE_POLICY_DECISION (decision); - * /<!-- -->* Make a policy decision here. *<!-- -->/ - * break; - * default: - * /<!-- -->* Making no decision results in webkit_policy_decision_use(). *<!-- -->/ - * return FALSE; - * } - * return TRUE; - * } - * </programlisting></informalexample> - * - * It is possible to make policy decision asynchronously, by simply calling g_object_ref() - * on the @decision argument and returning %TRUE to block the default signal handler. - * If the last reference is removed on a #WebKitPolicyDecision and no decision has been - * made explicitly, webkit_policy_decision_use() will be the default policy decision. The - * default signal handler will simply call webkit_policy_decision_use(). Only the first - * policy decision chosen for a given #WebKitPolicyDecision will have any affect. - * - * Returns: %TRUE to stop other handlers from being invoked for the event. - * %FALSE to propagate the event further. - * - */ - signals[DECIDE_POLICY] = - g_signal_new("decide-policy", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, decide_policy), - g_signal_accumulator_true_handled, 0 /* accumulator data */, - webkit_marshal_BOOLEAN__OBJECT_ENUM, - G_TYPE_BOOLEAN, 2, /* number of parameters */ - WEBKIT_TYPE_POLICY_DECISION, - WEBKIT_TYPE_POLICY_DECISION_TYPE); - - /** - * WebKitWebView::permission-request: - * @web_view: the #WebKitWebView on which the signal is emitted - * @request: the #WebKitPermissionRequest - * - * This signal is emitted when WebKit is requesting the client to - * decide about a permission request, such as allowing the browser - * to switch to fullscreen mode, sharing its location or similar - * operations. - * - * A possible way to use this signal could be through a dialog - * allowing the user decide what to do with the request: - * - * <informalexample><programlisting> - * static gboolean permission_request_cb (WebKitWebView *web_view, - * WebKitPermissionRequest *request, - * GtkWindow *parent_window) - * { - * GtkWidget *dialog = gtk_message_dialog_new (parent_window, - * GTK_DIALOG_MODAL, - * GTK_MESSAGE_QUESTION, - * GTK_BUTTONS_YES_NO, - * "Allow Permission Request?"); - * gtk_widget_show (dialog); - * gint result = gtk_dialog_run (GTK_DIALOG (dialog)); - * - * switch (result) { - * case GTK_RESPONSE_YES: - * webkit_permission_request_allow (request); - * break; - * default: - * webkit_permission_request_deny (request); - * break; - * } - * gtk_widget_destroy (dialog); - * - * return TRUE; - * } - * </programlisting></informalexample> - * - * It is possible to handle permission requests asynchronously, by - * simply calling g_object_ref() on the @request argument and - * returning %TRUE to block the default signal handler. If the - * last reference is removed on a #WebKitPermissionRequest and the - * request has not been handled, webkit_permission_request_deny() - * will be the default action. - * - * By default, if the signal is not handled, - * webkit_permission_request_deny() will be called over the - * #WebKitPermissionRequest. - * - * Returns: %TRUE to stop other handlers from being invoked for the event. - * %FALSE to propagate the event further. - * - */ - signals[PERMISSION_REQUEST] = - g_signal_new("permission-request", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, permission_request), - g_signal_accumulator_true_handled, 0 /* accumulator data */, - webkit_marshal_BOOLEAN__OBJECT, - G_TYPE_BOOLEAN, 1, /* number of parameters */ - WEBKIT_TYPE_PERMISSION_REQUEST); - /** - * WebKitWebView::mouse-target-changed: - * @web_view: the #WebKitWebView on which the signal is emitted - * @hit_test_result: a #WebKitHitTestResult - * @modifiers: a bitmask of #GdkModifierType - * - * This signal is emitted when the mouse cursor moves over an - * element such as a link, image or a media element. To determine - * what type of element the mouse cursor is over, a Hit Test is performed - * on the current mouse coordinates and the result is passed in the - * @hit_test_result argument. The @modifiers argument is a bitmask of - * #GdkModifierType flags indicating the state of modifier keys. - * The signal is emitted again when the mouse is moved out of the - * current element with a new @hit_test_result. - */ - signals[MOUSE_TARGET_CHANGED] = - g_signal_new("mouse-target-changed", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, mouse_target_changed), - 0, 0, - webkit_marshal_VOID__OBJECT_UINT, - G_TYPE_NONE, 2, - WEBKIT_TYPE_HIT_TEST_RESULT, - G_TYPE_UINT); - /** - * WebKitWebView::print: - * @web_view: the #WebKitWebView on which the signal is emitted - * @print_operation: the #WebKitPrintOperation that will handle the print request - * - * Emitted when printing is requested on @web_view, usually by a javascript call, - * before the print dialog is shown. This signal can be used to set the initial - * print settings and page setup of @print_operation to be used as default values in - * the print dialog. You can call webkit_print_operation_set_print_settings() and - * webkit_print_operation_set_page_setup() and then return %FALSE to propagate the - * event so that the print dialog is shown. - * - * You can connect to this signal and return %TRUE to cancel the print operation - * or implement your own print dialog. - * - * Returns: %TRUE to stop other handlers from being invoked for the event. - * %FALSE to propagate the event further. - */ - signals[PRINT] = - g_signal_new("print", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, print), - g_signal_accumulator_true_handled, 0, - webkit_marshal_BOOLEAN__OBJECT, - G_TYPE_BOOLEAN, 1, - WEBKIT_TYPE_PRINT_OPERATION); - - /** - * WebKitWebView::resource-load-started: - * @web_view: the #WebKitWebView on which the signal is emitted - * @resource: a #WebKitWebResource - * @request: a #WebKitURIRequest - * - * Emitted when a new resource is going to be loaded. The @request parameter - * contains the #WebKitURIRequest that will be sent to the server. - * You can monitor the load operation by connecting to the different signals - * of @resource. - */ - signals[RESOURCE_LOAD_STARTED] = - g_signal_new("resource-load-started", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, resource_load_started), - 0, 0, - webkit_marshal_VOID__OBJECT_OBJECT, - G_TYPE_NONE, 2, - WEBKIT_TYPE_WEB_RESOURCE, - WEBKIT_TYPE_URI_REQUEST); - - /** - * WebKitWebView::enter-fullscreen: - * @web_view: the #WebKitWebView on which the signal is emitted. - * - * Emitted when JavaScript code calls - * <function>element.webkitRequestFullScreen</function>. If the - * signal is not handled the #WebKitWebView will proceed to full screen - * its top level window. This signal can be used by client code to - * request permission to the user prior doing the full screen - * transition and eventually prepare the top-level window - * (e.g. hide some widgets that would otherwise be part of the - * full screen window). - * - * Returns: %TRUE to stop other handlers from being invoked for the event. - * %FALSE to continue emission of the event. - */ - signals[ENTER_FULLSCREEN] = - g_signal_new("enter-fullscreen", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, enter_fullscreen), - g_signal_accumulator_true_handled, 0, - webkit_marshal_BOOLEAN__VOID, - G_TYPE_BOOLEAN, 0); - - /** - * WebKitWebView::leave-fullscreen: - * @web_view: the #WebKitWebView on which the signal is emitted. - * - * Emitted when the #WebKitWebView is about to restore its top level - * window out of its full screen state. This signal can be used by - * client code to restore widgets hidden during the - * #WebKitWebView::enter-fullscreen stage for instance. - * - * Returns: %TRUE to stop other handlers from being invoked for the event. - * %FALSE to continue emission of the event. - */ - signals[LEAVE_FULLSCREEN] = - g_signal_new("leave-fullscreen", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, leave_fullscreen), - g_signal_accumulator_true_handled, 0, - webkit_marshal_BOOLEAN__VOID, - G_TYPE_BOOLEAN, 0); - /** - * WebKitWebView::run-file-chooser: - * @web_view: the #WebKitWebView on which the signal is emitted - * @request: a #WebKitFileChooserRequest - * - * This signal is emitted when the user interacts with a <input - * type='file' /> HTML element, requesting from WebKit to show - * a dialog to select one or more files to be uploaded. To let the - * application know the details of the file chooser, as well as to - * allow the client application to either cancel the request or - * perform an actual selection of files, the signal will pass an - * instance of the #WebKitFileChooserRequest in the @request - * argument. - * - * The default signal handler will asynchronously run a regular - * #GtkFileChooserDialog for the user to interact with. - * - * Returns: %TRUE to stop other handlers from being invoked for the event. - * %FALSE to propagate the event further. - * - */ - signals[RUN_FILE_CHOOSER] = - g_signal_new("run-file-chooser", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, run_file_chooser), - g_signal_accumulator_true_handled, 0 /* accumulator data */, - webkit_marshal_BOOLEAN__OBJECT, - G_TYPE_BOOLEAN, 1, /* number of parameters */ - WEBKIT_TYPE_FILE_CHOOSER_REQUEST); - - /** - * WebKitWebView::context-menu: - * @web_view: the #WebKitWebView on which the signal is emitted - * @context_menu: the proposed #WebKitContextMenu - * @event: the #GdkEvent that triggered the context menu - * @hit_test_result: a #WebKitHitTestResult - * - * Emmited when a context menu is about to be displayed to give the application - * a chance to customize the proposed menu, prevent the menu from being displayed - * or build its own context menu. - * <itemizedlist> - * <listitem><para> - * To customize the proposed menu you can use webkit_context_menu_prepend(), - * webkit_context_menu_append() or webkit_context_menu_insert() to add new - * #WebKitContextMenuItem<!-- -->s to @context_menu, webkit_context_menu_move_item() - * to reorder existing items, or webkit_context_menu_remove() to remove an - * existing item. The signal handler should return %FALSE, and the menu represented - * by @context_menu will be shown. - * </para></listitem> - * <listitem><para> - * To prevent the menu from being displayed you can just connect to this signal - * and return %TRUE so that the proposed menu will not be shown. - * </para></listitem> - * <listitem><para> - * To build your own menu, you can remove all items from the proposed menu with - * webkit_context_menu_remove_all(), add your own items and return %FALSE so - * that the menu will be shown. You can also ignore the proposed #WebKitContextMenu, - * build your own #GtkMenu and return %TRUE to prevent the proposed menu from being shown. - * </para></listitem> - * <listitem><para> - * If you just want the default menu to be shown always, simply don't connect to this - * signal because showing the proposed context menu is the default behaviour. - * </para></listitem> - * </itemizedlist> - * - * If the signal handler returns %FALSE the context menu represented by @context_menu - * will be shown, if it return %TRUE the context menu will not be shown. - * - * The proposed #WebKitContextMenu passed in @context_menu argument is only valid - * during the signal emission. - * - * Returns: %TRUE to stop other handlers from being invoked for the event. - * %FALSE to propagate the event further. - */ - signals[CONTEXT_MENU] = - g_signal_new("context-menu", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, context_menu), - g_signal_accumulator_true_handled, 0, - webkit_marshal_BOOLEAN__OBJECT_BOXED_OBJECT, - G_TYPE_BOOLEAN, 3, - WEBKIT_TYPE_CONTEXT_MENU, - GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE, - WEBKIT_TYPE_HIT_TEST_RESULT); - - /** - * WebKitWebView::context-menu-dismissed: - * @web_view: the #WebKitWebView on which the signal is emitted - * - * Emitted after #WebKitWebView::context-menu signal, if the context menu is shown, - * to notify that the context menu is dismissed. - */ - signals[CONTEXT_MENU_DISMISSED] = - g_signal_new("context-menu-dismissed", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, context_menu_dismissed), - 0, 0, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /** - * WebKitWebView::submit-form: - * @web_view: the #WebKitWebView on which the signal is emitted - * @request: a #WebKitFormSubmissionRequest - * - * This signal is emitted when a form is about to be submitted. The @request - * argument passed contains information about the text fields of the form. This - * is typically used to store login information that can be used later to - * pre-fill the form. - * The form will not be submitted until webkit_form_submission_request_submit() is called. - * - * It is possible to handle the form submission request asynchronously, by - * simply calling g_object_ref() on the @request argument and calling - * webkit_form_submission_request_submit() when done to continue with the form submission. - * If the last reference is removed on a #WebKitFormSubmissionRequest and the - * form has not been submitted, webkit_form_submission_request_submit() will be called. - */ - signals[SUBMIT_FORM] = - g_signal_new("submit-form", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, submit_form), - 0, 0, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - WEBKIT_TYPE_FORM_SUBMISSION_REQUEST); - - /** - * WebKitWebView::insecure-content-detected: - * @web_view: the #WebKitWebView on which the signal is emitted - * @event: the #WebKitInsecureContentEvent - * - * This signal is emitted when insecure content has been detected - * in a page loaded through a secure connection. This typically - * means that a external resource from an unstrusted source has - * been run or displayed, resulting in a mix of HTTPS and - * non-HTTPS content. - * - * You can check the @event parameter to know exactly which kind - * of event has been detected (see #WebKitInsecureContentEvent). - */ - signals[INSECURE_CONTENT_DETECTED] = - g_signal_new("insecure-content-detected", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, insecure_content_detected), - 0, 0, - g_cclosure_marshal_VOID__ENUM, - G_TYPE_NONE, 1, - WEBKIT_TYPE_INSECURE_CONTENT_EVENT); - - /** - * WebKitWebView::web-process-crashed: - * @web_view: the #WebKitWebView - * - * This signal is emitted when the web process crashes. - * - * Returns: %TRUE to stop other handlers from being invoked for the event. - * %FALSE to propagate the event further. - */ - signals[WEB_PROCESS_CRASHED] = g_signal_new( - "web-process-crashed", - G_TYPE_FROM_CLASS(webViewClass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(WebKitWebViewClass, web_process_crashed), - g_signal_accumulator_true_handled, - 0, - webkit_marshal_BOOLEAN__VOID, - G_TYPE_BOOLEAN, 0); -} - -static void webkitWebViewSetIsLoading(WebKitWebView* webView, bool isLoading) -{ - if (webView->priv->isLoading == isLoading) - return; - - webView->priv->isLoading = isLoading; - g_object_freeze_notify(G_OBJECT(webView)); - g_object_notify(G_OBJECT(webView), "is-loading"); - - // Update the URI if a new load has started. - if (webView->priv->isLoading) - webkitWebViewUpdateURI(webView); - g_object_thaw_notify(G_OBJECT(webView)); -} - -static void webkitWebViewEmitLoadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent) -{ - if (loadEvent == WEBKIT_LOAD_STARTED) { - webkitWebViewSetIsLoading(webView, true); - webkitWebViewWatchForChangesInFavicon(webView); - webkitWebViewBaseCancelAuthenticationDialog(WEBKIT_WEB_VIEW_BASE(webView)); - } else if (loadEvent == WEBKIT_LOAD_FINISHED) { - webkitWebViewSetIsLoading(webView, false); - webView->priv->waitingForMainResource = false; - webkitWebViewDisconnectMainResourceResponseChangedSignalHandler(webView); - } else - webkitWebViewUpdateURI(webView); - g_signal_emit(webView, signals[LOAD_CHANGED], 0, loadEvent); -} - -static void webkitWebViewEmitDelayedLoadEvents(WebKitWebView* webView) -{ - WebKitWebViewPrivate* priv = webView->priv; - if (!priv->waitingForMainResource) - return; - ASSERT(priv->lastDelayedEvent == WEBKIT_LOAD_COMMITTED || priv->lastDelayedEvent == WEBKIT_LOAD_FINISHED); - - if (priv->lastDelayedEvent == WEBKIT_LOAD_FINISHED) - webkitWebViewEmitLoadChanged(webView, WEBKIT_LOAD_COMMITTED); - webkitWebViewEmitLoadChanged(webView, priv->lastDelayedEvent); - priv->waitingForMainResource = false; -} - -void webkitWebViewLoadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent) -{ - WebKitWebViewPrivate* priv = webView->priv; - if (loadEvent == WEBKIT_LOAD_STARTED) { - // Finish a possible previous load waiting for main resource. - webkitWebViewEmitDelayedLoadEvents(webView); - - webkitWebViewCancelFaviconRequest(webView); - priv->loadingResourcesMap.clear(); - priv->mainResource = 0; - priv->waitingForMainResource = false; - } else if (loadEvent == WEBKIT_LOAD_COMMITTED) { - WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(priv->context); - GOwnPtr<char> faviconURI(webkit_favicon_database_get_favicon_uri(database, priv->activeURI.data())); - webkitWebViewUpdateFaviconURI(webView, faviconURI.get()); - - if (!priv->mainResource) { - // When a page is loaded from the history cache, the main resource load callbacks - // are called when the main frame load is finished. We want to make sure there's a - // main resource available when load has been committed, so we delay the emission of - // load-changed signal until main resource object has been created. - priv->waitingForMainResource = true; - } - } - - if (priv->waitingForMainResource) - priv->lastDelayedEvent = loadEvent; - else - webkitWebViewEmitLoadChanged(webView, loadEvent); -} - -void webkitWebViewLoadFailed(WebKitWebView* webView, WebKitLoadEvent loadEvent, const char* failingURI, GError *error) -{ - webkitWebViewSetIsLoading(webView, false); - gboolean returnValue; - g_signal_emit(webView, signals[LOAD_FAILED], 0, loadEvent, failingURI, error, &returnValue); - g_signal_emit(webView, signals[LOAD_CHANGED], 0, WEBKIT_LOAD_FINISHED); -} - -void webkitWebViewLoadFailedWithTLSErrors(WebKitWebView* webView, const char* failingURI, GError *error, GTlsCertificateFlags tlsErrors, GTlsCertificate* certificate) -{ - webkitWebViewSetIsLoading(webView, false); - - WebKitTLSErrorsPolicy tlsErrorsPolicy = webkit_web_context_get_tls_errors_policy(webView->priv->context); - if (tlsErrorsPolicy == WEBKIT_TLS_ERRORS_POLICY_FAIL) { - webkitWebViewLoadFailed(webView, WEBKIT_LOAD_STARTED, failingURI, error); - return; - } - - g_signal_emit(webView, signals[LOAD_CHANGED], 0, WEBKIT_LOAD_FINISHED); -} - -void webkitWebViewSetTitle(WebKitWebView* webView, const CString& title) -{ - WebKitWebViewPrivate* priv = webView->priv; - if (priv->title == title) - return; - - priv->title = title; - g_object_notify(G_OBJECT(webView), "title"); -} - -void webkitWebViewSetEstimatedLoadProgress(WebKitWebView* webView, double estimatedLoadProgress) -{ - if (webView->priv->estimatedLoadProgress == estimatedLoadProgress) - return; - - webView->priv->estimatedLoadProgress = estimatedLoadProgress; - g_object_notify(G_OBJECT(webView), "estimated-load-progress"); -} - -void webkitWebViewUpdateURI(WebKitWebView* webView) -{ - CString activeURI = getPage(webView)->activeURL().utf8(); - if (webView->priv->activeURI == activeURI) - return; - - webView->priv->activeURI = activeURI; - g_object_notify(G_OBJECT(webView), "uri"); -} - -WebPageProxy* webkitWebViewCreateNewPage(WebKitWebView* webView, ImmutableDictionary* windowFeatures) -{ - WebKitWebView* newWebView; - g_signal_emit(webView, signals[CREATE], 0, &newWebView); - if (!newWebView) - return 0; - - webkitWindowPropertiesUpdateFromWebWindowFeatures(newWebView->priv->windowProperties.get(), windowFeatures); - - RefPtr<WebPageProxy> newPage = getPage(newWebView); - return newPage.release().leakRef(); -} - -void webkitWebViewReadyToShowPage(WebKitWebView* webView) -{ - g_signal_emit(webView, signals[READY_TO_SHOW], 0, NULL); -} - -void webkitWebViewRunAsModal(WebKitWebView* webView) -{ - g_signal_emit(webView, signals[RUN_AS_MODAL], 0, NULL); - - webView->priv->modalLoop = adoptGRef(g_main_loop_new(0, FALSE)); - gdk_threads_leave(); - g_main_loop_run(webView->priv->modalLoop.get()); - gdk_threads_enter(); -} - -void webkitWebViewClosePage(WebKitWebView* webView) -{ - g_signal_emit(webView, signals[CLOSE], 0, NULL); -} - -void webkitWebViewRunJavaScriptAlert(WebKitWebView* webView, const CString& message) -{ - WebKitScriptDialog dialog(WEBKIT_SCRIPT_DIALOG_ALERT, message); - gboolean returnValue; - g_signal_emit(webView, signals[SCRIPT_DIALOG], 0, &dialog, &returnValue); -} - -bool webkitWebViewRunJavaScriptConfirm(WebKitWebView* webView, const CString& message) -{ - WebKitScriptDialog dialog(WEBKIT_SCRIPT_DIALOG_CONFIRM, message); - gboolean returnValue; - g_signal_emit(webView, signals[SCRIPT_DIALOG], 0, &dialog, &returnValue); - return dialog.confirmed; -} - -CString webkitWebViewRunJavaScriptPrompt(WebKitWebView* webView, const CString& message, const CString& defaultText) -{ - WebKitScriptDialog dialog(WEBKIT_SCRIPT_DIALOG_PROMPT, message, defaultText); - gboolean returnValue; - g_signal_emit(webView, signals[SCRIPT_DIALOG], 0, &dialog, &returnValue); - return dialog.text; -} - -void webkitWebViewMakePolicyDecision(WebKitWebView* webView, WebKitPolicyDecisionType type, WebKitPolicyDecision* decision) -{ - gboolean returnValue; - g_signal_emit(webView, signals[DECIDE_POLICY], 0, decision, type, &returnValue); -} - -void webkitWebViewMakePermissionRequest(WebKitWebView* webView, WebKitPermissionRequest* request) -{ - gboolean returnValue; - g_signal_emit(webView, signals[PERMISSION_REQUEST], 0, request, &returnValue); -} - -void webkitWebViewMouseTargetChanged(WebKitWebView* webView, WebHitTestResult* hitTestResult, unsigned modifiers) -{ - webkitWebViewBaseSetTooltipArea(WEBKIT_WEB_VIEW_BASE(webView), hitTestResult->elementBoundingBox()); - - WebKitWebViewPrivate* priv = webView->priv; - if (priv->mouseTargetHitTestResult - && priv->mouseTargetModifiers == modifiers - && webkitHitTestResultCompare(priv->mouseTargetHitTestResult.get(), hitTestResult)) - return; - - priv->mouseTargetModifiers = modifiers; - priv->mouseTargetHitTestResult = adoptGRef(webkitHitTestResultCreate(hitTestResult)); - g_signal_emit(webView, signals[MOUSE_TARGET_CHANGED], 0, priv->mouseTargetHitTestResult.get(), modifiers); -} - -void webkitWebViewPrintFrame(WebKitWebView* webView, WebFrameProxy* frame) -{ - GRefPtr<WebKitPrintOperation> printOperation = adoptGRef(webkit_print_operation_new(webView)); - gboolean returnValue; - g_signal_emit(webView, signals[PRINT], 0, printOperation.get(), &returnValue); - if (returnValue) - return; - - WebKitPrintOperationResponse response = webkitPrintOperationRunDialogForFrame(printOperation.get(), 0, frame); - if (response == WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL) - return; - g_signal_connect(printOperation.leakRef(), "finished", G_CALLBACK(g_object_unref), 0); -} - -static void mainResourceResponseChangedCallback(WebKitWebResource*, GParamSpec*, WebKitWebView* webView) -{ - webkitWebViewDisconnectMainResourceResponseChangedSignalHandler(webView); - webkitWebViewEmitDelayedLoadEvents(webView); -} - -static void waitForMainResourceResponseIfWaitingForResource(WebKitWebView* webView) -{ - WebKitWebViewPrivate* priv = webView->priv; - if (!priv->waitingForMainResource) - return; - - webkitWebViewDisconnectMainResourceResponseChangedSignalHandler(webView); - priv->mainResourceResponseHandlerID = - g_signal_connect(priv->mainResource.get(), "notify::response", G_CALLBACK(mainResourceResponseChangedCallback), webView); -} - -void webkitWebViewResourceLoadStarted(WebKitWebView* webView, WebFrameProxy* frame, uint64_t resourceIdentifier, WebKitURIRequest* request) -{ - WebKitWebViewPrivate* priv = webView->priv; - bool isMainResource = frame->isMainFrame() && !priv->mainResource; - WebKitWebResource* resource = webkitWebResourceCreate(frame, request, isMainResource); - if (isMainResource) { - priv->mainResource = resource; - waitForMainResourceResponseIfWaitingForResource(webView); - } - priv->loadingResourcesMap.set(resourceIdentifier, adoptGRef(resource)); - g_signal_emit(webView, signals[RESOURCE_LOAD_STARTED], 0, resource, request); -} - -WebKitWebResource* webkitWebViewGetLoadingWebResource(WebKitWebView* webView, uint64_t resourceIdentifier) -{ - GRefPtr<WebKitWebResource> resource = webView->priv->loadingResourcesMap.get(resourceIdentifier); - return resource.get(); -} - -void webkitWebViewRemoveLoadingWebResource(WebKitWebView* webView, uint64_t resourceIdentifier) -{ - WebKitWebViewPrivate* priv = webView->priv; - ASSERT(priv->loadingResourcesMap.contains(resourceIdentifier)); - priv->loadingResourcesMap.remove(resourceIdentifier); -} - -bool webkitWebViewEnterFullScreen(WebKitWebView* webView) -{ - gboolean returnValue; - g_signal_emit(webView, signals[ENTER_FULLSCREEN], 0, &returnValue); - return !returnValue; -} - -bool webkitWebViewLeaveFullScreen(WebKitWebView* webView) -{ - gboolean returnValue; - g_signal_emit(webView, signals[LEAVE_FULLSCREEN], 0, &returnValue); - return !returnValue; -} - -void webkitWebViewRunFileChooserRequest(WebKitWebView* webView, WebKitFileChooserRequest* request) -{ - gboolean returnValue; - g_signal_emit(webView, signals[RUN_FILE_CHOOSER], 0, request, &returnValue); -} - -static bool webkitWebViewShouldShowInputMethodsMenu(WebKitWebView* webView) -{ - GtkSettings* settings = gtk_widget_get_settings(GTK_WIDGET(webView)); - if (!settings) - return true; - - gboolean showInputMethodMenu; - g_object_get(settings, "gtk-show-input-method-menu", &showInputMethodMenu, NULL); - return showInputMethodMenu; -} - -static int getUnicodeMenuItemPosition(WebKitContextMenu* contextMenu) -{ - GList* items = webkit_context_menu_get_items(contextMenu); - GList* iter; - int i = 0; - for (iter = items, i = 0; iter; iter = g_list_next(iter), ++i) { - WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(iter->data); - - if (webkit_context_menu_item_is_separator(item)) - continue; - if (webkit_context_menu_item_get_stock_action(item) == WEBKIT_CONTEXT_MENU_ACTION_UNICODE) - return i; - } - return -1; -} - -static void webkitWebViewCreateAndAppendInputMethodsMenuItem(WebKitWebView* webView, WebKitContextMenu* contextMenu) -{ - if (!webkitWebViewShouldShowInputMethodsMenu(webView)) - return; - - // Place the im context menu item right before the unicode menu item - // if it's present. - int unicodeMenuItemPosition = getUnicodeMenuItemPosition(contextMenu); - if (unicodeMenuItemPosition == -1) - webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator()); - - GtkIMContext* imContext = webkitWebViewBaseGetIMContext(WEBKIT_WEB_VIEW_BASE(webView)); - GtkMenu* imContextMenu = GTK_MENU(gtk_menu_new()); - gtk_im_multicontext_append_menuitems(GTK_IM_MULTICONTEXT(imContext), GTK_MENU_SHELL(imContextMenu)); - WebKitContextMenuItem* menuItem = webkit_context_menu_item_new_from_stock_action(WEBKIT_CONTEXT_MENU_ACTION_INPUT_METHODS); - webkitContextMenuItemSetSubMenuFromGtkMenu(menuItem, imContextMenu); - webkit_context_menu_insert(contextMenu, menuItem, unicodeMenuItemPosition); -} - -static void contextMenuDismissed(GtkMenuShell*, WebKitWebView* webView) -{ - g_signal_emit(webView, signals[CONTEXT_MENU_DISMISSED], 0, NULL); -} - -void webkitWebViewPopulateContextMenu(WebKitWebView* webView, ImmutableArray* proposedMenu, WebHitTestResult* webHitTestResult) -{ - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(webView); - WebContextMenuProxyGtk* contextMenuProxy = webkitWebViewBaseGetActiveContextMenuProxy(webViewBase); - ASSERT(contextMenuProxy); - - GRefPtr<WebKitContextMenu> contextMenu = adoptGRef(webkitContextMenuCreate(proposedMenu)); - if (webHitTestResult->isContentEditable()) - webkitWebViewCreateAndAppendInputMethodsMenuItem(webView, contextMenu.get()); - - GRefPtr<WebKitHitTestResult> hitTestResult = adoptGRef(webkitHitTestResultCreate(webHitTestResult)); - GOwnPtr<GdkEvent> contextMenuEvent(webkitWebViewBaseTakeContextMenuEvent(webViewBase)); - - gboolean returnValue; - g_signal_emit(webView, signals[CONTEXT_MENU], 0, contextMenu.get(), contextMenuEvent.get(), hitTestResult.get(), &returnValue); - if (returnValue) - return; - - Vector<ContextMenuItem> contextMenuItems; - webkitContextMenuPopulate(contextMenu.get(), contextMenuItems); - contextMenuProxy->populate(contextMenuItems); - - g_signal_connect(contextMenuProxy->gtkMenu(), "deactivate", G_CALLBACK(contextMenuDismissed), webView); - - // Clear the menu to make sure it's useless after signal emission. - webkit_context_menu_remove_all(contextMenu.get()); -} - -void webkitWebViewSubmitFormRequest(WebKitWebView* webView, WebKitFormSubmissionRequest* request) -{ - g_signal_emit(webView, signals[SUBMIT_FORM], 0, request); -} - -void webkitWebViewHandleAuthenticationChallenge(WebKitWebView* webView, AuthenticationChallengeProxy* authenticationChallenge) -{ - CredentialStorageMode credentialStorageMode; - if (webkit_settings_get_enable_private_browsing(webkit_web_view_get_settings(webView))) - credentialStorageMode = DisallowPersistentStorage; - else - credentialStorageMode = AllowPersistentStorage; - - webkitWebViewBaseAddAuthenticationDialog(WEBKIT_WEB_VIEW_BASE(webView), webkitAuthenticationDialogNew(authenticationChallenge, credentialStorageMode)); -} - -void webkitWebViewInsecureContentDetected(WebKitWebView* webView, WebKitInsecureContentEvent type) -{ - g_signal_emit(webView, signals[INSECURE_CONTENT_DETECTED], 0, type); -} - -/** - * webkit_web_view_new: - * - * Creates a new #WebKitWebView with the default #WebKitWebContext and the - * default #WebKitWebViewGroup. - * See also webkit_web_view_new_with_context() and webkit_web_view_new_with_group(). - * - * Returns: The newly created #WebKitWebView widget - */ -GtkWidget* webkit_web_view_new() -{ - return webkit_web_view_new_with_context(webkit_web_context_get_default()); -} - -/** - * webkit_web_view_new_with_context: - * @context: the #WebKitWebContext to be used by the #WebKitWebView - * - * Creates a new #WebKitWebView with the given #WebKitWebContext and the - * default #WebKitWebViewGroup. - * See also webkit_web_view_new_with_group(). - * - * Returns: The newly created #WebKitWebView widget - */ -GtkWidget* webkit_web_view_new_with_context(WebKitWebContext* context) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0); - - return GTK_WIDGET(g_object_new(WEBKIT_TYPE_WEB_VIEW, "web-context", context, NULL)); -} - -/** - * webkit_web_view_new_with_group: - * @group: a #WebKitWebViewGroup - * - * Creates a new #WebKitWebView with the given #WebKitWebViewGroup. - * The view will be part of @group and it will be affected by the - * group properties like the settings. - * - * Returns: The newly created #WebKitWebView widget - */ -GtkWidget* webkit_web_view_new_with_group(WebKitWebViewGroup* group) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW_GROUP(group), 0); - - return GTK_WIDGET(g_object_new(WEBKIT_TYPE_WEB_VIEW, "group", group, NULL)); -} - -/** - * webkit_web_view_get_context: - * @web_view: a #WebKitWebView - * - * Gets the web context of @web_view. - * - * Returns: (transfer none): the #WebKitWebContext of the view - */ -WebKitWebContext* webkit_web_view_get_context(WebKitWebView *webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - - return webView->priv->context; -} - -/** - * webkit_web_view_get_group: - * @web_view: a #WebKitWebView - * - * Gets the group @web_view belongs to. - * - * Returns: (transfer none): the #WebKitWebViewGroup to which the view belongs - */ -WebKitWebViewGroup* webkit_web_view_get_group(WebKitWebView* webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - - if (webView->priv->group) - return webView->priv->group.get(); - - return webkitWebContextGetDefaultWebViewGroup(webView->priv->context); -} - -/** - * webkit_web_view_load_uri: - * @web_view: a #WebKitWebView - * @uri: an URI string - * - * Requests loading of the specified URI string. - * You can monitor the load operation by connecting to - * #WebKitWebView::load-changed signal. - */ -void webkit_web_view_load_uri(WebKitWebView* webView, const gchar* uri) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - g_return_if_fail(uri); - - getPage(webView)->loadURL(String::fromUTF8(uri)); -} - -/** - * webkit_web_view_load_html: - * @web_view: a #WebKitWebView - * @content: The HTML string to load - * @base_uri: (allow-none): The base URI for relative locations or %NULL - * - * Load the given @content string with the specified @base_uri. - * If @base_uri is not %NULL, relative URLs in the @content will be - * resolved against @base_uri and absolute local paths must be children of the @base_uri. - * For security reasons absolute local paths that are not children of @base_uri - * will cause the web process to terminate. - * If you need to include URLs in @content that are local paths in a different - * directory than @base_uri you can build a data URI for them. When @base_uri is %NULL, - * it defaults to "about:blank". The mime type of the document will be "text/html". - * You can monitor the load operation by connecting to #WebKitWebView::load-changed signal. - */ -void webkit_web_view_load_html(WebKitWebView* webView, const gchar* content, const gchar* baseURI) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - g_return_if_fail(content); - - getPage(webView)->loadHTMLString(String::fromUTF8(content), String::fromUTF8(baseURI)); -} - -/** - * webkit_web_view_load_alternate_html: - * @web_view: a #WebKitWebView - * @content: the new content to display as the main page of the @web_view - * @content_uri: the URI for the alternate page content - * @base_uri: (allow-none): the base URI for relative locations or %NULL - * - * Load the given @content string for the URI @content_uri. - * This allows clients to display page-loading errors in the #WebKitWebView itself. - * When this method is called from #WebKitWebView::load-failed signal to show an - * error page, the the back-forward list is maintained appropriately. - * For everything else this method works the same way as webkit_web_view_load_html(). - */ -void webkit_web_view_load_alternate_html(WebKitWebView* webView, const gchar* content, const gchar* contentURI, const gchar* baseURI) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - g_return_if_fail(content); - g_return_if_fail(contentURI); - - getPage(webView)->loadAlternateHTMLString(String::fromUTF8(content), String::fromUTF8(baseURI), String::fromUTF8(contentURI)); -} - -/** - * webkit_web_view_load_plain_text: - * @web_view: a #WebKitWebView - * @plain_text: The plain text to load - * - * Load the specified @plain_text string into @web_view. The mime type of - * document will be "text/plain". You can monitor the load - * operation by connecting to #WebKitWebView::load-changed signal. - */ -void webkit_web_view_load_plain_text(WebKitWebView* webView, const gchar* plainText) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - g_return_if_fail(plainText); - - getPage(webView)->loadPlainTextString(String::fromUTF8(plainText)); -} - -/** - * webkit_web_view_load_request: - * @web_view: a #WebKitWebView - * @request: a #WebKitURIRequest to load - * - * Requests loading of the specified #WebKitURIRequest. - * You can monitor the load operation by connecting to - * #WebKitWebView::load-changed signal. - */ -void webkit_web_view_load_request(WebKitWebView* webView, WebKitURIRequest* request) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - g_return_if_fail(WEBKIT_IS_URI_REQUEST(request)); - - ResourceRequest resourceRequest; - webkitURIRequestGetResourceRequest(request, resourceRequest); - RefPtr<WebURLRequest> urlRequest = WebURLRequest::create(resourceRequest); - getPage(webView)->loadURLRequest(urlRequest.get()); -} - -/** - * webkit_web_view_get_page_id: - * @web_view: a #WebKitWebView - * - * Get the identifier of the #WebKitWebPage corresponding to - * the #WebKitWebView - * - * Returns: the page ID of @web_view. - */ -guint64 webkit_web_view_get_page_id(WebKitWebView* webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - - return getPage(webView)->pageID(); -} - -/** - * webkit_web_view_get_title: - * @web_view: a #WebKitWebView - * - * Gets the value of the #WebKitWebView:title property. - * You can connect to notify::title signal of @web_view to - * be notified when the title has been received. - * - * Returns: The main frame document title of @web_view. - */ -const gchar* webkit_web_view_get_title(WebKitWebView* webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - - return webView->priv->title.data(); -} - -/** - * webkit_web_view_reload: - * @web_view: a #WebKitWebView - * - * Reloads the current contents of @web_view. - * See also webkit_web_view_reload_bypass_cache(). - */ -void webkit_web_view_reload(WebKitWebView* webView) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - - getPage(webView)->reload(false); -} - -/** - * webkit_web_view_reload_bypass_cache: - * @web_view: a #WebKitWebView - * - * Reloads the current contents of @web_view without - * using any cached data. - */ -void webkit_web_view_reload_bypass_cache(WebKitWebView* webView) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - - getPage(webView)->reload(true); -} - -/** - * webkit_web_view_stop_loading: - * @web_view: a #WebKitWebView - * - * Stops any ongoing loading operation in @web_view. - * This method does nothing if no content is being loaded. - * If there is a loading operation in progress, it will be cancelled and - * #WebKitWebView::load-failed signal will be emitted with - * %WEBKIT_NETWORK_ERROR_CANCELLED error. - */ -void webkit_web_view_stop_loading(WebKitWebView* webView) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - - getPage(webView)->stopLoading(); -} - -/** - * webkit_web_view_is_loading: - * @web_view: a #WebKitWebView - * - * Gets the value of the #WebKitWebView:is-loading property. - * You can monitor when a #WebKitWebView is loading a page by connecting to - * notify::is-loading signal of @web_view. This is useful when you are - * interesting in knowing when the view is loding something but not in the - * details about the status of the load operation, for example to start a spinner - * when the view is loading a page and stop it when it finishes. - * - * Returns: %TRUE if @web_view is loading a page or %FALSE otherwise. - */ -gboolean webkit_web_view_is_loading(WebKitWebView* webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); - - return webView->priv->isLoading; -} - -/** - * webkit_web_view_go_back: - * @web_view: a #WebKitWebView - * - * Loads the previous history item. - * You can monitor the load operation by connecting to - * #WebKitWebView::load-changed signal. - */ -void webkit_web_view_go_back(WebKitWebView* webView) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - - getPage(webView)->goBack(); -} - -/** - * webkit_web_view_can_go_back: - * @web_view: a #WebKitWebView - * - * Determines whether @web_view has a previous history item. - * - * Returns: %TRUE if able to move back or %FALSE otherwise. - */ -gboolean webkit_web_view_can_go_back(WebKitWebView* webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); - - return getPage(webView)->canGoBack(); -} - -/** - * webkit_web_view_go_forward: - * @web_view: a #WebKitWebView - * - * Loads the next history item. - * You can monitor the load operation by connecting to - * #WebKitWebView::load-changed signal. - */ -void webkit_web_view_go_forward(WebKitWebView* webView) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - - getPage(webView)->goForward(); -} - -/** - * webkit_web_view_can_go_forward: - * @web_view: a #WebKitWebView - * - * Determines whether @web_view has a next history item. - * - * Returns: %TRUE if able to move forward or %FALSE otherwise. - */ -gboolean webkit_web_view_can_go_forward(WebKitWebView* webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); - - return getPage(webView)->canGoForward(); -} - -/** - * webkit_web_view_get_uri: - * @web_view: a #WebKitWebView - * - * Returns the current active URI of @web_view. The active URI might change during - * a load operation: - * - * <orderedlist> - * <listitem><para> - * When nothing has been loaded yet on @web_view the active URI is %NULL. - * </para></listitem> - * <listitem><para> - * When a new load operation starts the active URI is the requested URI: - * <itemizedlist> - * <listitem><para> - * If the load operation was started by webkit_web_view_load_uri(), - * the requested URI is the given one. - * </para></listitem> - * <listitem><para> - * If the load operation was started by webkit_web_view_load_html(), - * the requested URI is "about:blank". - * </para></listitem> - * <listitem><para> - * If the load operation was started by webkit_web_view_load_alternate_html(), - * the requested URI is content URI provided. - * </para></listitem> - * <listitem><para> - * If the load operation was started by webkit_web_view_go_back() or - * webkit_web_view_go_forward(), the requested URI is the original URI - * of the previous/next item in the #WebKitBackForwardList of @web_view. - * </para></listitem> - * <listitem><para> - * If the load operation was started by - * webkit_web_view_go_to_back_forward_list_item(), the requested URI - * is the opriginal URI of the given #WebKitBackForwardListItem. - * </para></listitem> - * </itemizedlist> - * </para></listitem> - * <listitem><para> - * If there is a server redirection during the load operation, - * the active URI is the redirected URI. When the signal - * #WebKitWebView::load-changed is emitted with %WEBKIT_LOAD_REDIRECTED - * event, the active URI is already updated to the redirected URI. - * </para></listitem> - * <listitem><para> - * When the signal #WebKitWebView::load-changed is emitted - * with %WEBKIT_LOAD_COMMITTED event, the active URI is the final - * one and it will not change unless a new load operation is started - * or a navigation action within the same page is performed. - * </para></listitem> - * </orderedlist> - * - * You can monitor the active URI by connecting to the notify::uri - * signal of @web_view. - * - * Returns: the current active URI of @web_view or %NULL - * if nothing has been loaded yet. - */ -const gchar* webkit_web_view_get_uri(WebKitWebView* webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - - return webView->priv->activeURI.data(); -} - -/** - * webkit_web_view_get_favicon: - * @web_view: a #WebKitWebView - * - * Returns favicon currently associated to @web_view, if any. You can - * connect to notify::favicon signal of @web_view to be notified when - * the favicon is available. - * - * Returns: (transfer none): a pointer to a #cairo_surface_t with the - * favicon or %NULL if there's no icon associated with @web_view. - */ -cairo_surface_t* webkit_web_view_get_favicon(WebKitWebView* webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - if (webView->priv->activeURI.isNull()) - return 0; - - return webView->priv->favicon.get(); -} - -/** - * webkit_web_view_get_custom_charset: - * @web_view: a #WebKitWebView - * - * Returns the current custom character encoding name of @web_view. - * - * Returns: the current custom character encoding name or %NULL if no - * custom character encoding has been set. - */ -const gchar* webkit_web_view_get_custom_charset(WebKitWebView* webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - - String customTextEncoding = getPage(webView)->customTextEncodingName(); - if (customTextEncoding.isEmpty()) - return 0; - - webView->priv->customTextEncoding = customTextEncoding.utf8(); - return webView->priv->customTextEncoding.data(); -} - -/** - * webkit_web_view_set_custom_charset: - * @web_view: a #WebKitWebView - * @charset: (allow-none): a character encoding name or %NULL - * - * Sets the current custom character encoding override of @web_view. The custom - * character encoding will override any text encoding detected via HTTP headers or - * META tags. Calling this method will stop any current load operation and reload the - * current page. Setting the custom character encoding to %NULL removes the character - * encoding override. - */ -void webkit_web_view_set_custom_charset(WebKitWebView* webView, const gchar* charset) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - - getPage(webView)->setCustomTextEncodingName(String::fromUTF8(charset)); -} - -/** - * webkit_web_view_get_estimated_load_progress: - * @web_view: a #WebKitWebView - * - * Gets the value of the #WebKitWebView:estimated-load-progress property. - * You can monitor the estimated progress of a load operation by - * connecting to the notify::estimated-load-progress signal of @web_view. - * - * Returns: an estimate of the of the percent complete for a document - * load as a range from 0.0 to 1.0. - */ -gdouble webkit_web_view_get_estimated_load_progress(WebKitWebView* webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - return webView->priv->estimatedLoadProgress; -} - -/** - * webkit_web_view_get_back_forward_list: - * @web_view: a #WebKitWebView - * - * Obtains the #WebKitBackForwardList associated with the given #WebKitWebView. The - * #WebKitBackForwardList is owned by the #WebKitWebView. - * - * Returns: (transfer none): the #WebKitBackForwardList - */ -WebKitBackForwardList* webkit_web_view_get_back_forward_list(WebKitWebView* webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - - return webView->priv->backForwardList.get(); -} - -/** - * webkit_web_view_go_to_back_forward_list_item: - * @web_view: a #WebKitWebView - * @list_item: a #WebKitBackForwardListItem - * - * Loads the specific history item @list_item. - * You can monitor the load operation by connecting to - * #WebKitWebView::load-changed signal. - */ -void webkit_web_view_go_to_back_forward_list_item(WebKitWebView* webView, WebKitBackForwardListItem* listItem) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - g_return_if_fail(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(listItem)); - - getPage(webView)->goToBackForwardItem(webkitBackForwardListItemGetItem(listItem)); -} - -/** - * webkit_web_view_set_settings: - * @web_view: a #WebKitWebView - * @settings: a #WebKitSettings - * - * Sets the #WebKitSettings to be applied to @web_view. - * This is a convenient method to set new settings to the - * #WebKitWebViewGroup @web_view belongs to. - * New settings are applied immediately on all #WebKitWebView<!-- -->s - * in the @web_view group. - * See also webkit_web_view_group_set_settings(). - */ -void webkit_web_view_set_settings(WebKitWebView* webView, WebKitSettings* settings) -{ - webkit_web_view_group_set_settings(webkit_web_view_get_group(webView), settings); -} - -/** - * webkit_web_view_get_settings: - * @web_view: a #WebKitWebView - * - * Gets the #WebKitSettings currently applied to @web_view. - * This is a convenient method to get the settings of the - * #WebKitWebViewGroup @web_view belongs to. - * #WebKitSettings objects are shared by all the #WebKitWebView<!-- -->s - * in the same #WebKitWebViewGroup, so modifying - * the settings of a #WebKitWebView would affect other - * #WebKitWebView<!-- -->s of the same group. - * See also webkit_web_view_group_get_settings(). - * - * Returns: (transfer none): the #WebKitSettings attached to @web_view - */ -WebKitSettings* webkit_web_view_get_settings(WebKitWebView* webView) -{ - return webkit_web_view_group_get_settings(webkit_web_view_get_group(webView)); -} - -/** - * webkit_web_view_get_window_properties: - * @web_view: a #WebKitWebView - * - * Get the #WebKitWindowProperties object containing the properties - * that the window containing @web_view should have. - * - * Returns: (transfer none): the #WebKitWindowProperties of @web_view - */ -WebKitWindowProperties* webkit_web_view_get_window_properties(WebKitWebView* webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - - return webView->priv->windowProperties.get(); -} - -/** - * webkit_web_view_set_zoom_level: - * @web_view: a #WebKitWebView - * @zoom_level: the zoom level - * - * Set the zoom level of @web_view, i.e. the factor by which the - * view contents are scaled with respect to their original size. - */ -void webkit_web_view_set_zoom_level(WebKitWebView* webView, gdouble zoomLevel) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - - if (webkit_web_view_get_zoom_level(webView) == zoomLevel) - return; - - WebPageProxy* page = getPage(webView); - if (webkit_settings_get_zoom_text_only(webkit_web_view_get_settings(webView))) - page->setTextZoomFactor(zoomLevel); - else - page->setPageZoomFactor(zoomLevel); - g_object_notify(G_OBJECT(webView), "zoom-level"); -} - -/** - * webkit_web_view_get_zoom_level: - * @web_view: a #WebKitWebView - * - * Get the zoom level of @web_view, i.e. the factor by which the - * view contents are scaled with respect to their original size. - * - * Returns: the current zoom level of @web_view - */ -gdouble webkit_web_view_get_zoom_level(WebKitWebView* webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 1); - - WebPageProxy* page = getPage(webView); - gboolean zoomTextOnly = webkit_settings_get_zoom_text_only(webkit_web_view_get_settings(webView)); - return zoomTextOnly ? page->textZoomFactor() : page->pageZoomFactor(); -} - -static void didValidateCommand(WKStringRef command, bool isEnabled, int32_t state, WKErrorRef, void* context) -{ - GRefPtr<GTask> task = adoptGRef(G_TASK(context)); - g_task_return_boolean(task.get(), isEnabled); -} - -/** - * webkit_web_view_can_execute_editing_command: - * @web_view: a #WebKitWebView - * @command: the command to check - * @cancellable: (allow-none): a #GCancellable or %NULL to ignore - * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied - * @user_data: (closure): the data to pass to callback function - * - * Asynchronously execute the given editing command. - * - * When the operation is finished, @callback will be called. You can then call - * webkit_web_view_can_execute_editing_command_finish() to get the result of the operation. - */ -void webkit_web_view_can_execute_editing_command(WebKitWebView* webView, const char* command, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - g_return_if_fail(command); - - GTask* task = g_task_new(webView, cancellable, callback, userData); - getPage(webView)->validateCommand(String::fromUTF8(command), ValidateCommandCallback::create(task, didValidateCommand)); -} - -/** - * webkit_web_view_can_execute_editing_command_finish: - * @web_view: a #WebKitWebView - * @result: a #GAsyncResult - * @error: return location for error or %NULL to ignore - * - * Finish an asynchronous operation started with webkit_web_view_can_execute_editing_command(). - * - * Returns: %TRUE if the editing command can be executed or %FALSE otherwise - */ -gboolean webkit_web_view_can_execute_editing_command_finish(WebKitWebView* webView, GAsyncResult* result, GError** error) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); - g_return_val_if_fail(g_task_is_valid(result, webView), FALSE); - - return g_task_propagate_boolean(G_TASK(result), error); -} - -/** - * webkit_web_view_execute_editing_command: - * @web_view: a #WebKitWebView - * @command: the command to execute - * - * Request to execute the given @command for @web_view. You can use - * webkit_web_view_can_execute_editing_command() to check whether - * it's possible to execute the command. - */ -void webkit_web_view_execute_editing_command(WebKitWebView* webView, const char* command) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - g_return_if_fail(command); - - getPage(webView)->executeEditCommand(String::fromUTF8(command)); -} - -/** - * webkit_web_view_get_find_controller: - * @web_view: the #WebKitWebView - * - * Gets the #WebKitFindController that will allow the caller to query - * the #WebKitWebView for the text to look for. - * - * Returns: (transfer none): the #WebKitFindController associated to - * this particular #WebKitWebView. - */ -WebKitFindController* webkit_web_view_get_find_controller(WebKitWebView* webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - - if (!webView->priv->findController) - webView->priv->findController = adoptGRef(WEBKIT_FIND_CONTROLLER(g_object_new(WEBKIT_TYPE_FIND_CONTROLLER, "web-view", webView, NULL))); - - return webView->priv->findController.get(); -} - -/** - * webkit_web_view_get_javascript_global_context: - * @web_view: a #WebKitWebView - * - * Get the global JavaScript context used by @web_view to deserialize the - * result values of scripts executed with webkit_web_view_run_javascript(). - * - * Returns: the <function>JSGlobalContextRef</function> used by @web_view to deserialize - * the result values of scripts. - */ -JSGlobalContextRef webkit_web_view_get_javascript_global_context(WebKitWebView* webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - - if (!webView->priv->javascriptGlobalContext) - webView->priv->javascriptGlobalContext = JSGlobalContextCreate(0); - return webView->priv->javascriptGlobalContext; -} - -static void webkitWebViewRunJavaScriptCallback(WKSerializedScriptValueRef wkSerializedScriptValue, WKErrorRef, void* context) -{ - GRefPtr<GTask> task = adoptGRef(G_TASK(context)); - if (g_task_return_error_if_cancelled(task.get())) - return; - - if (!wkSerializedScriptValue) { - g_task_return_new_error(task.get(), WEBKIT_JAVASCRIPT_ERROR, WEBKIT_JAVASCRIPT_ERROR_SCRIPT_FAILED, - _("An exception was raised in JavaScript")); - return; - } - - WebKitWebView* webView = WEBKIT_WEB_VIEW(g_task_get_source_object(task.get())); - g_task_return_pointer(task.get(), webkitJavascriptResultCreate(webView, toImpl(wkSerializedScriptValue)), - reinterpret_cast<GDestroyNotify>(webkit_javascript_result_unref)); -} - -/** - * webkit_web_view_run_javascript: - * @web_view: a #WebKitWebView - * @script: the script to run - * @cancellable: (allow-none): a #GCancellable or %NULL to ignore - * @callback: (scope async): a #GAsyncReadyCallback to call when the script finished - * @user_data: (closure): the data to pass to callback function - * - * Asynchronously run @script in the context of the current page in @web_view. If - * WebKitWebSettings:enable-javascript is FALSE, this method will do nothing. - * - * When the operation is finished, @callback will be called. You can then call - * webkit_web_view_run_javascript_finish() to get the result of the operation. - */ -void webkit_web_view_run_javascript(WebKitWebView* webView, const gchar* script, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - g_return_if_fail(script); - - GTask* task = g_task_new(webView, cancellable, callback, userData); - getPage(webView)->runJavaScriptInMainFrame(String::fromUTF8(script), ScriptValueCallback::create(task, webkitWebViewRunJavaScriptCallback)); -} - -/** - * webkit_web_view_run_javascript_finish: - * @web_view: a #WebKitWebView - * @result: a #GAsyncResult - * @error: return location for error or %NULL to ignore - * - * Finish an asynchronous operation started with webkit_web_view_run_javascript(). - * - * This is an example of using webkit_web_view_run_javascript() with a script returning - * a string: - * - * <informalexample><programlisting> - * static void - * web_view_javascript_finished (GObject *object, - * GAsyncResult *result, - * gpointer user_data) - * { - * WebKitJavascriptResult *js_result; - * JSValueRef value; - * JSGlobalContextRef context; - * GError *error = NULL; - * - * js_result = webkit_web_view_run_javascript_finish (WEBKIT_WEB_VIEW (object), result, &error); - * if (!js_result) { - * g_warning ("Error running javascript: %s", error->message); - * g_error_free (error); - * return; - * } - * - * context = webkit_javascript_result_get_global_context (js_result); - * value = webkit_javascript_result_get_value (js_result); - * if (JSValueIsString (context, value)) { - * JSStringRef js_str_value; - * gchar *str_value; - * gsize str_length; - * - * js_str_value = JSValueToStringCopy (context, value, NULL); - * str_length = JSStringGetMaximumUTF8CStringSize (js_str_value); - * str_value = (gchar *)g_malloc (str_length); - * JSStringGetUTF8CString (js_str_value, str_value, str_length); - * JSStringRelease (js_str_value); - * g_print ("Script result: %s\n", str_value); - * g_free (str_value); - * } else { - * g_warning ("Error running javascript: unexpected return value"); - * } - * webkit_javascript_result_unref (js_result); - * } - * - * static void - * web_view_get_link_url (WebKitWebView *web_view, - * const gchar *link_id) - * { - * gchar *script; - * - * script = g_strdup_printf ("window.document.getElementById('%s').href;", link_id); - * webkit_web_view_run_javascript (web_view, script, NULL, web_view_javascript_finished, NULL); - * g_free (script); - * } - * </programlisting></informalexample> - * - * Returns: (transfer full): a #WebKitJavascriptResult with the result of the last executed statement in @script - * or %NULL in case of error - */ -WebKitJavascriptResult* webkit_web_view_run_javascript_finish(WebKitWebView* webView, GAsyncResult* result, GError** error) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - g_return_val_if_fail(g_task_is_valid(result, webView), 0); - - return static_cast<WebKitJavascriptResult*>(g_task_propagate_pointer(G_TASK(result), error)); -} - -static void resourcesStreamReadCallback(GObject* object, GAsyncResult* result, gpointer userData) -{ - GRefPtr<GTask> task = adoptGRef(G_TASK(userData)); - - GError* error = 0; - g_output_stream_splice_finish(G_OUTPUT_STREAM(object), result, &error); - if (error) { - g_task_return_error(task.get(), error); - return; - } - - WebKitWebView* webView = WEBKIT_WEB_VIEW(g_task_get_source_object(task.get())); - gpointer outputStreamData = g_memory_output_stream_get_data(G_MEMORY_OUTPUT_STREAM(object)); - getPage(webView)->runJavaScriptInMainFrame(String::fromUTF8(reinterpret_cast<const gchar*>(outputStreamData)), - ScriptValueCallback::create(task.leakRef(), webkitWebViewRunJavaScriptCallback)); -} - -/** - * webkit_web_view_run_javascript_from_gresource: - * @web_view: a #WebKitWebView - * @resource: the location of the resource to load - * @cancellable: (allow-none): a #GCancellable or %NULL to ignore - * @callback: (scope async): a #GAsyncReadyCallback to call when the script finished - * @user_data: (closure): the data to pass to callback function - * - * Asynchronously run the script from @resource in the context of the - * current page in @web_view. - * - * When the operation is finished, @callback will be called. You can - * then call webkit_web_view_run_javascript_from_gresource_finish() to get the result - * of the operation. - */ -void webkit_web_view_run_javascript_from_gresource(WebKitWebView* webView, const gchar* resource, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - g_return_if_fail(resource); - - GError* error = 0; - GRefPtr<GInputStream> inputStream = adoptGRef(g_resources_open_stream(resource, G_RESOURCE_LOOKUP_FLAGS_NONE, &error)); - if (error) { - g_task_report_error(webView, callback, userData, 0, error); - return; - } - - GTask* task = g_task_new(webView, cancellable, callback, userData); - GRefPtr<GOutputStream> outputStream = adoptGRef(g_memory_output_stream_new(0, 0, fastRealloc, fastFree)); - g_output_stream_splice_async(outputStream.get(), inputStream.get(), - static_cast<GOutputStreamSpliceFlags>(G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET), - G_PRIORITY_DEFAULT, cancellable, resourcesStreamReadCallback, task); -} - -/** - * webkit_web_view_run_javascript_from_gresource_finish: - * @web_view: a #WebKitWebView - * @result: a #GAsyncResult - * @error: return location for error or %NULL to ignore - * - * Finish an asynchronous operation started with webkit_web_view_run_javascript_from_gresource(). - * - * Check webkit_web_view_run_javascript_finish() for a usage example. - * - * Returns: (transfer full): a #WebKitJavascriptResult with the result of the last executed statement in @script - * or %NULL in case of error - */ -WebKitJavascriptResult* webkit_web_view_run_javascript_from_gresource_finish(WebKitWebView* webView, GAsyncResult* result, GError** error) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - g_return_val_if_fail(g_task_is_valid(result, webView), 0); - - return static_cast<WebKitJavascriptResult*>(g_task_propagate_pointer(G_TASK(result), error)); -} - -/** - * webkit_web_view_get_main_resource: - * @web_view: a #WebKitWebView - * - * Return the main resource of @web_view. - * - * Returns: (transfer none): the main #WebKitWebResource of the view - * or %NULL if nothing has been loaded. - */ -WebKitWebResource* webkit_web_view_get_main_resource(WebKitWebView* webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - - return webView->priv->mainResource.get(); -} - -/** - * webkit_web_view_get_inspector: - * @web_view: a #WebKitWebView - * - * Get the #WebKitWebInspector associated to @web_view - * - * Returns: (transfer none): the #WebKitWebInspector of @web_view - */ -WebKitWebInspector* webkit_web_view_get_inspector(WebKitWebView* webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - - if (!webView->priv->inspector) - webView->priv->inspector = adoptGRef(webkitWebInspectorCreate(getPage(webView)->inspector())); - - return webView->priv->inspector.get(); -} - -/** - * webkit_web_view_can_show_mime_type: - * @web_view: a #WebKitWebView - * @mime_type: a MIME type - * - * Whether or not a MIME type can be displayed in @web_view. - * - * Returns: %TRUE if the MIME type @mime_type can be displayed or %FALSE otherwise - */ -gboolean webkit_web_view_can_show_mime_type(WebKitWebView* webView, const char* mimeType) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); - g_return_val_if_fail(mimeType, FALSE); - - return getPage(webView)->canShowMIMEType(String::fromUTF8(mimeType)); -} - -struct ViewSaveAsyncData { - RefPtr<WebData> webData; - GRefPtr<GFile> file; -}; -WEBKIT_DEFINE_ASYNC_DATA_STRUCT(ViewSaveAsyncData) - -static void fileReplaceContentsCallback(GObject* object, GAsyncResult* result, gpointer data) -{ - GRefPtr<GTask> task = adoptGRef(G_TASK(data)); - GError* error = 0; - if (!g_file_replace_contents_finish(G_FILE(object), result, 0, &error)) { - g_task_return_error(task.get(), error); - return; - } - - g_task_return_boolean(task.get(), TRUE); -} - -static void getContentsAsMHTMLDataCallback(WKDataRef wkData, WKErrorRef, void* context) -{ - GRefPtr<GTask> task = adoptGRef(G_TASK(context)); - if (g_task_return_error_if_cancelled(task.get())) - return; - - ViewSaveAsyncData* data = static_cast<ViewSaveAsyncData*>(g_task_get_task_data(task.get())); - // We need to retain the data until the asyncronous process - // initiated by the user has finished completely. - data->webData = toImpl(wkData); - - // If we are saving to a file we need to write the data on disk before finishing. - if (g_task_get_source_tag(task.get()) == webkit_web_view_save_to_file) { - ASSERT(G_IS_FILE(data->file.get())); - GCancellable* cancellable = g_task_get_cancellable(task.get()); - g_file_replace_contents_async(data->file.get(), reinterpret_cast<const gchar*>(data->webData->bytes()), data->webData->size(), - 0, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, cancellable, fileReplaceContentsCallback, task.leakRef()); - return; - } - - g_task_return_boolean(task.get(), TRUE); -} - -/** - * webkit_web_view_save: - * @web_view: a #WebKitWebView - * @save_mode: the #WebKitSaveMode specifying how the web page should be saved. - * @cancellable: (allow-none): a #GCancellable or %NULL to ignore - * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied - * @user_data: (closure): the data to pass to callback function - * - * Asynchronously save the current web page associated to the - * #WebKitWebView into a self-contained format using the mode - * specified in @save_mode. - * - * When the operation is finished, @callback will be called. You can - * then call webkit_web_view_save_finish() to get the result of the - * operation. - */ -void webkit_web_view_save(WebKitWebView* webView, WebKitSaveMode saveMode, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - - // We only support MHTML at the moment. - g_return_if_fail(saveMode == WEBKIT_SAVE_MODE_MHTML); - - GTask* task = g_task_new(webView, cancellable, callback, userData); - g_task_set_source_tag(task, reinterpret_cast<gpointer>(webkit_web_view_save)); - g_task_set_task_data(task, createViewSaveAsyncData(), reinterpret_cast<GDestroyNotify>(destroyViewSaveAsyncData)); - getPage(webView)->getContentsAsMHTMLData(DataCallback::create(task, getContentsAsMHTMLDataCallback), false); -} - -/** - * webkit_web_view_save_finish: - * @web_view: a #WebKitWebView - * @result: a #GAsyncResult - * @error: return location for error or %NULL to ignore - * - * Finish an asynchronous operation started with webkit_web_view_save(). - * - * Returns: (transfer full): a #GInputStream with the result of saving - * the current web page or %NULL in case of error. - */ -GInputStream* webkit_web_view_save_finish(WebKitWebView* webView, GAsyncResult* result, GError** error) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - g_return_val_if_fail(g_task_is_valid(result, webView), 0); - - GTask* task = G_TASK(result); - if (!g_task_propagate_boolean(task, error)) - return 0; - - GInputStream* dataStream = g_memory_input_stream_new(); - ViewSaveAsyncData* data = static_cast<ViewSaveAsyncData*>(g_task_get_task_data(task)); - gsize length = data->webData->size(); - if (length) - g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(dataStream), g_memdup(data->webData->bytes(), length), length, g_free); - - return dataStream; -} - -/** - * webkit_web_view_save_to_file: - * @web_view: a #WebKitWebView - * @file: the #GFile where the current web page should be saved to. - * @save_mode: the #WebKitSaveMode specifying how the web page should be saved. - * @cancellable: (allow-none): a #GCancellable or %NULL to ignore - * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied - * @user_data: (closure): the data to pass to callback function - * - * Asynchronously save the current web page associated to the - * #WebKitWebView into a self-contained format using the mode - * specified in @save_mode and writing it to @file. - * - * When the operation is finished, @callback will be called. You can - * then call webkit_web_view_save_to_file_finish() to get the result of the - * operation. - */ -void webkit_web_view_save_to_file(WebKitWebView* webView, GFile* file, WebKitSaveMode saveMode, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - g_return_if_fail(G_IS_FILE(file)); - - // We only support MHTML at the moment. - g_return_if_fail(saveMode == WEBKIT_SAVE_MODE_MHTML); - - GTask* task = g_task_new(webView, cancellable, callback, userData); - g_task_set_source_tag(task, reinterpret_cast<gpointer>(webkit_web_view_save_to_file)); - ViewSaveAsyncData* data = createViewSaveAsyncData(); - data->file = file; - g_task_set_task_data(task, data, reinterpret_cast<GDestroyNotify>(destroyViewSaveAsyncData)); - - getPage(webView)->getContentsAsMHTMLData(DataCallback::create(task, getContentsAsMHTMLDataCallback), false); -} - -/** - * webkit_web_view_save_to_file_finish: - * @web_view: a #WebKitWebView - * @result: a #GAsyncResult - * @error: return location for error or %NULL to ignore - * - * Finish an asynchronous operation started with webkit_web_view_save_to_file(). - * - * Returns: %TRUE if the web page was successfully saved to a file or %FALSE otherwise. - */ -gboolean webkit_web_view_save_to_file_finish(WebKitWebView* webView, GAsyncResult* result, GError** error) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); - g_return_val_if_fail(g_task_is_valid(result, webView), FALSE); - - return g_task_propagate_boolean(G_TASK(result), error); -} - -/** - * webkit_web_view_download_uri: - * @web_view: a #WebKitWebView - * @uri: the URI to download - * - * Requests downloading of the specified URI string for @web_view. - * - * Returns: (transfer full): a new #WebKitDownload representing the - * the download operation. - */ -WebKitDownload* webkit_web_view_download_uri(WebKitWebView* webView, const char* uri) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - g_return_val_if_fail(uri, 0); - - WebKitDownload* download = webkitWebContextStartDownload(webView->priv->context, uri, getPage(webView)); - webkitDownloadSetWebView(download, webView); - - return download; -} - -/** - * webkit_web_view_set_view_mode: - * @web_view: a #WebKitWebView - * @view_mode: a #WebKitViewMode - * - * Set the view mode of @web_view to @view_mode. This method should be called - * before loading new contents on @web_view so that the new #WebKitViewMode will - * be applied to the new contents. - */ -void webkit_web_view_set_view_mode(WebKitWebView* webView, WebKitViewMode viewMode) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - - if (webView->priv->viewMode == viewMode) - return; - - getPage(webView)->setMainFrameInViewSourceMode(viewMode == WEBKIT_VIEW_MODE_SOURCE); - - webView->priv->viewMode = viewMode; - g_object_notify(G_OBJECT(webView), "view-mode"); -} - -/** - * webkit_web_view_get_view_mode: - * @web_view: a #WebKitWebView - * - * Get the view mode of @web_view. - * - * Returns: the #WebKitViewMode of @web_view. - */ -WebKitViewMode webkit_web_view_get_view_mode(WebKitWebView* webView) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), WEBKIT_VIEW_MODE_WEB); - - return webView->priv->viewMode; -} - -/** - * webkit_web_view_get_tls_info: - * @web_view: a #WebKitWebView - * @certificate: (out) (transfer none): return location for a #GTlsCertificate - * @errors: (out): return location for a #GTlsCertificateFlags the verification status of @certificate - * - * Retrieves the #GTlsCertificate associated with the @web_view connection, - * and the #GTlsCertificateFlags showing what problems, if any, have been found - * with that certificate. - * If the connection is not HTTPS, this function returns %FALSE. - * This function should be called after a response has been received from the - * server, so you can connect to #WebKitWebView::load-changed and call this function - * when it's emitted with %WEBKIT_LOAD_COMMITTED event. - * - * Returns: %TRUE if the @web_view connection uses HTTPS and a response has been received - * from the server, or %FALSE otherwise. - */ -gboolean webkit_web_view_get_tls_info(WebKitWebView* webView, GTlsCertificate** certificate, GTlsCertificateFlags* errors) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); - - WebFrameProxy* mainFrame = getPage(webView)->mainFrame(); - if (!mainFrame) - return FALSE; - - const PlatformCertificateInfo& certificateInfo = mainFrame->certificateInfo()->platformCertificateInfo(); - if (certificate) - *certificate = certificateInfo.certificate(); - if (errors) - *errors = certificateInfo.tlsErrors(); - - return !!certificateInfo.certificate(); -} - -void webKitWebViewDidReceiveSnapshot(WebKitWebView* webView, uint64_t callbackID, WebImage* webImage) -{ - GRefPtr<GTask> task = webView->priv->snapshotResultsMap.take(callbackID); - if (g_task_return_error_if_cancelled(task.get())) - return; - - if (!webImage) { - g_task_return_new_error(task.get(), WEBKIT_SNAPSHOT_ERROR, WEBKIT_SNAPSHOT_ERROR_FAILED_TO_CREATE, - _("There was an error creating the snapshot")); - return; - } - - if (RefPtr<ShareableBitmap> image = webImage->bitmap()) - g_task_return_pointer(task.get(), image->createCairoSurface().leakRef(), reinterpret_cast<GDestroyNotify>(cairo_surface_destroy)); - else - g_task_return_pointer(task.get(), 0, 0); -} - -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_SNAPSHOT_REGION_VISIBLE, SnapshotRegionVisible); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT, SnapshotRegionFullDocument); - -static inline unsigned webKitSnapshotOptionsToSnapshotOptions(WebKitSnapshotOptions options) -{ - SnapshotOptions snapshotOptions = 0; - - if (!(options & WEBKIT_SNAPSHOT_OPTIONS_INCLUDE_SELECTION_HIGHLIGHTING)) - snapshotOptions |= SnapshotOptionsExcludeSelectionHighlighting; - - return snapshotOptions; -} - -static inline uint64_t generateSnapshotCallbackID() -{ - static uint64_t uniqueCallbackID = 1; - return uniqueCallbackID++; -} - -/** - * webkit_web_view_get_snapshot: - * @web_view: a #WebKitWebView - * @options: #WebKitSnapshotOptions for the snapshot - * @region: the #WebKitSnapshotRegion for this snapshot - * @cancellable: (allow-none): a #GCancellable - * @callback: (scope async): a #GAsyncReadyCallback - * @user_data: (closure): user data - * - * Asynchronously retrieves a snapshot of @web_view for @region. - * @options specifies how the snapshot should be rendered. - * - * When the operation is finished, @callback will be called. You must - * call webkit_web_view_get_snapshot_finish() to get the result of the - * operation. - */ -void webkit_web_view_get_snapshot(WebKitWebView* webView, WebKitSnapshotRegion region, WebKitSnapshotOptions options, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - - ImmutableDictionary::MapType message; - uint64_t callbackID = generateSnapshotCallbackID(); - message.set(String::fromUTF8("SnapshotOptions"), WebUInt64::create(static_cast<uint64_t>(webKitSnapshotOptionsToSnapshotOptions(options)))); - message.set(String::fromUTF8("SnapshotRegion"), WebUInt64::create(static_cast<uint64_t>(region))); - message.set(String::fromUTF8("CallbackID"), WebUInt64::create(callbackID)); - - webView->priv->snapshotResultsMap.set(callbackID, adoptGRef(g_task_new(webView, cancellable, callback, userData))); - getPage(webView)->postMessageToInjectedBundle(String::fromUTF8("GetSnapshot"), ImmutableDictionary::adopt(message).get()); -} - -/** - * webkit_web_view_get_snapshot_finish: - * @web_view: a #WebKitWebView - * @result: a #GAsyncResult - * @error: return location for error or %NULL to ignore - * - * Finishes an asynchronous operation started with webkit_web_view_get_snapshot(). - * - * Returns: (transfer full): a #cairo_surface_t with the retrieved snapshot or %NULL in error. - */ -cairo_surface_t* webkit_web_view_get_snapshot_finish(WebKitWebView* webView, GAsyncResult* result, GError** error) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - g_return_val_if_fail(g_task_is_valid(result, webView), 0); - - return static_cast<cairo_surface_t*>(g_task_propagate_pointer(G_TASK(result), error)); -} - -void webkitWebViewWebProcessCrashed(WebKitWebView* webView) -{ - gboolean returnValue; - g_signal_emit(webView, signals[WEB_PROCESS_CRASHED], 0, &returnValue); -} - diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h deleted file mode 100644 index b23d7ffb1..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h +++ /dev/null @@ -1,471 +0,0 @@ -/* - * Copyright (C) 2007 Holger Hans Peter Freyther - * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com> - * Copyright (C) 2008 Collabora Ltd. - * Copyright (C) 2011 Igalia S.L. - * Portions Copyright (c) 2011 Motorola Mobility, 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitWebView_h -#define WebKitWebView_h - -#include <JavaScriptCore/JSBase.h> -#include <webkit2/WebKitBackForwardList.h> -#include <webkit2/WebKitDefines.h> -#include <webkit2/WebKitFileChooserRequest.h> -#include <webkit2/WebKitFindController.h> -#include <webkit2/WebKitFormSubmissionRequest.h> -#include <webkit2/WebKitForwardDeclarations.h> -#include <webkit2/WebKitHitTestResult.h> -#include <webkit2/WebKitJavascriptResult.h> -#include <webkit2/WebKitPermissionRequest.h> -#include <webkit2/WebKitPolicyDecision.h> -#include <webkit2/WebKitScriptDialog.h> -#include <webkit2/WebKitSettings.h> -#include <webkit2/WebKitURIRequest.h> -#include <webkit2/WebKitWebContext.h> -#include <webkit2/WebKitWebInspector.h> -#include <webkit2/WebKitWebResource.h> -#include <webkit2/WebKitWebViewBase.h> -#include <webkit2/WebKitWebViewGroup.h> -#include <webkit2/WebKitWindowProperties.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_WEB_VIEW (webkit_web_view_get_type()) -#define WEBKIT_WEB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebView)) -#define WEBKIT_IS_WEB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_VIEW)) -#define WEBKIT_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass)) -#define WEBKIT_IS_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_VIEW)) -#define WEBKIT_WEB_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass)) - -typedef struct _WebKitWebViewClass WebKitWebViewClass; -typedef struct _WebKitWebViewPrivate WebKitWebViewPrivate; - -/** - * WebKitPolicyDecisionType: - * @WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: This type of policy decision - * is requested when WebKit is about to navigate to a new page in either the - * main frame or a subframe. Acceptable policy decisions are either - * webkit_policy_decision_use() or webkit_policy_decision_ignore(). This - * type of policy decision is always a #WebKitNavigationPolicyDecision. - * @WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION: This type of policy decision - * is requested when WebKit is about to create a new window. Acceptable policy - * decisions are either webkit_policy_decision_use() or - * webkit_policy_decision_ignore(). This type of policy decision is always - * a #WebKitNavigationPolicyDecision. These decisions are useful for implementing - * special actions for new windows, such as forcing the new window to open - * in a tab when a keyboard modifier is active or handling a special - * target attribute on <a> elements. - * @WEBKIT_POLICY_DECISION_TYPE_RESPONSE: This type of decision is used when WebKit has - * received a response for a network resource and is about to start the load. - * Note that these resources include all subresources of a page such as images - * and stylesheets as well as main documents. Appropriate policy responses to - * this decision are webkit_policy_decision_use(), webkit_policy_decision_ignore(), - * or webkit_policy_decision_download(). This type of policy decision is always - * a #WebKitResponsePolicyDecision. This decision is useful for forcing - * some types of resources to be downloaded rather than rendered in the WebView - * or to block the transfer of resources entirely. - * - * Enum values used for determining the type of a policy decision during - * #WebKitWebView::decide-policy. - */ -typedef enum { - WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION, - WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION, - WEBKIT_POLICY_DECISION_TYPE_RESPONSE, -} WebKitPolicyDecisionType; - -/** - * WebKitLoadEvent: - * @WEBKIT_LOAD_STARTED: A new load request has been made. - * No data has been received yet, empty structures have - * been allocated to perform the load; the load may still - * fail due to transport issues such as not being able to - * resolve a name, or connect to a port. - * @WEBKIT_LOAD_REDIRECTED: A provisional data source received - * a server redirect. - * @WEBKIT_LOAD_COMMITTED: The content started arriving for a page load. - * The necessary transport requirements are stabilished, and the - * load is being performed. - * @WEBKIT_LOAD_FINISHED: Load completed. All resources are done loading - * or there was an error during the load operation. - * - * Enum values used to denote the different events that happen during a - * #WebKitWebView load operation. - */ -typedef enum { - WEBKIT_LOAD_STARTED, - WEBKIT_LOAD_REDIRECTED, - WEBKIT_LOAD_COMMITTED, - WEBKIT_LOAD_FINISHED -} WebKitLoadEvent; - -/** - * WebKitSaveMode: - * @WEBKIT_SAVE_MODE_MHTML: Save the current page using the MHTML format. - * - * Enum values to specify the different ways in which a #WebKitWebView - * can save its current web page into a self-contained file. - */ -typedef enum { - WEBKIT_SAVE_MODE_MHTML -} WebKitSaveMode; - -/** - * WebKitInsecureContentEvent: - * @WEBKIT_INSECURE_CONTENT_RUN: Insecure content has been detected by - * trying to execute any kind of logic (e.g. a script) from an - * untrusted source. - * @WEBKIT_INSECURE_CONTENT_DISPLAYED: Insecure content has been - * detected by trying to display any kind of resource (e.g. an image) - * from an untrusted source. - * - * Enum values used to denote the different events which can trigger - * the detection of insecure content. - */ -typedef enum { - WEBKIT_INSECURE_CONTENT_RUN, - WEBKIT_INSECURE_CONTENT_DISPLAYED -} WebKitInsecureContentEvent; - -/** - * WebKitViewMode: - * @WEBKIT_VIEW_MODE_WEB: The normal view mode to display web contents. - * @WEBKIT_VIEW_MODE_SOURCE: The source mode to display web source code. - * - * Enum values to specify the different ways in which a #WebKitWebView - * can display a web page. - */ -typedef enum { - WEBKIT_VIEW_MODE_WEB, - WEBKIT_VIEW_MODE_SOURCE -} WebKitViewMode; - -/** - * WebKitSnapshotOptions: - * @WEBKIT_SNAPSHOT_OPTIONS_NONE: Do not include any special options. - * @WEBKIT_SNAPSHOT_OPTIONS_INCLUDE_SELECTION_HIGHLIGHTING: Whether to include in the - * snapshot the highlight of the selected content. - * - * Enum values used to specify options when taking a snapshot - * from a #WebKitWebView. - */ -typedef enum { - WEBKIT_SNAPSHOT_OPTIONS_NONE = 0, - WEBKIT_SNAPSHOT_OPTIONS_INCLUDE_SELECTION_HIGHLIGHTING = 1 << 0, -} WebKitSnapshotOptions; - -/** - * WebKitSnapshotRegion: - * @WEBKIT_SNAPSHOT_REGION_VISIBLE: Specifies a snapshot only for the area that is - * visible in the webview - * @WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT: A snapshot of the entire document. - * - * Enum values used to specify the region from which to get a #WebKitWebView - * snapshot - */ -typedef enum { - WEBKIT_SNAPSHOT_REGION_VISIBLE = 0, - WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT, -} WebKitSnapshotRegion; - -struct _WebKitWebView { - WebKitWebViewBase parent; - - /*< private >*/ - WebKitWebViewPrivate *priv; -}; - -struct _WebKitWebViewClass { - WebKitWebViewBaseClass parent; - - void (* load_changed) (WebKitWebView *web_view, - WebKitLoadEvent load_event); - gboolean (* load_failed) (WebKitWebView *web_view, - WebKitLoadEvent load_event, - const gchar *failing_uri, - GError *error); - - GtkWidget *(* create) (WebKitWebView *web_view); - void (* ready_to_show) (WebKitWebView *web_view); - void (* run_as_modal) (WebKitWebView *web_view); - void (* close) (WebKitWebView *web_view); - - gboolean (* script_dialog) (WebKitWebView *web_view, - WebKitScriptDialog *dialog) ; - - gboolean (* decide_policy) (WebKitWebView *web_view, - WebKitPolicyDecision *decision, - WebKitPolicyDecisionType type); - gboolean (* permission_request) (WebKitWebView *web_view, - WebKitPermissionRequest *permission_request); - void (* mouse_target_changed) (WebKitWebView *web_view, - WebKitHitTestResult *hit_test_result, - guint modifiers); - gboolean (* print) (WebKitWebView *web_view, - WebKitPrintOperation *print_operation); - void (* resource_load_started) (WebKitWebView *web_view, - WebKitWebResource *resource, - WebKitURIRequest *request); - gboolean (* enter_fullscreen) (WebKitWebView *web_view); - gboolean (* leave_fullscreen) (WebKitWebView *web_view); - gboolean (* run_file_chooser) (WebKitWebView *web_view, - WebKitFileChooserRequest *request); - gboolean (* context_menu) (WebKitWebView *web_view, - WebKitContextMenu *context_menu, - GdkEvent *event, - WebKitHitTestResult *hit_test_result); - void (* context_menu_dismissed) (WebKitWebView *web_view); - void (* submit_form) (WebKitWebView *web_view, - WebKitFormSubmissionRequest *request); - void (* insecure_content_detected) (WebKitWebView *web_view, - WebKitInsecureContentEvent event); - gboolean (* web_process_crashed) (WebKitWebView *web_view); - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); - void (*_webkit_reserved4) (void); - void (*_webkit_reserved5) (void); - void (*_webkit_reserved6) (void); - void (*_webkit_reserved7) (void); -}; - -WEBKIT_API GType -webkit_web_view_get_type (void); - -WEBKIT_API GtkWidget * -webkit_web_view_new (void); - -WEBKIT_API GtkWidget * -webkit_web_view_new_with_context (WebKitWebContext *context); - -WEBKIT_API GtkWidget * -webkit_web_view_new_with_group (WebKitWebViewGroup *group); - -WEBKIT_API WebKitWebContext * -webkit_web_view_get_context (WebKitWebView *web_view); - -WEBKIT_API WebKitWebViewGroup * -webkit_web_view_get_group (WebKitWebView *web_view); - -WEBKIT_API void -webkit_web_view_load_uri (WebKitWebView *web_view, - const gchar *uri); - -WEBKIT_API void -webkit_web_view_load_html (WebKitWebView *web_view, - const gchar *content, - const gchar *base_uri); -WEBKIT_API void -webkit_web_view_load_alternate_html (WebKitWebView *web_view, - const gchar *content, - const gchar *content_uri, - const gchar *base_uri); -WEBKIT_API void -webkit_web_view_load_plain_text (WebKitWebView *web_view, - const gchar *plain_text); - -WEBKIT_API void -webkit_web_view_load_request (WebKitWebView *web_view, - WebKitURIRequest *request); - -WEBKIT_API void -webkit_web_view_stop_loading (WebKitWebView *web_view); - -WEBKIT_API gboolean -webkit_web_view_is_loading (WebKitWebView *web_view); - -WEBKIT_API guint64 -webkit_web_view_get_page_id (WebKitWebView *web_view); - -WEBKIT_API const gchar * -webkit_web_view_get_title (WebKitWebView *web_view); - -WEBKIT_API void -webkit_web_view_reload (WebKitWebView *web_view); - -WEBKIT_API void -webkit_web_view_reload_bypass_cache (WebKitWebView *web_view); - -WEBKIT_API gdouble -webkit_web_view_get_estimated_load_progress (WebKitWebView *web_view); - -WEBKIT_API void -webkit_web_view_go_back (WebKitWebView *web_view); - -WEBKIT_API gboolean -webkit_web_view_can_go_back (WebKitWebView *web_view); - -WEBKIT_API void -webkit_web_view_go_forward (WebKitWebView *web_view); - -WEBKIT_API gboolean -webkit_web_view_can_go_forward (WebKitWebView *web_view); - -WEBKIT_API WebKitBackForwardList * -webkit_web_view_get_back_forward_list (WebKitWebView *web_view); - -WEBKIT_API void -webkit_web_view_go_to_back_forward_list_item (WebKitWebView *web_view, - WebKitBackForwardListItem *list_item); -WEBKIT_API const gchar * -webkit_web_view_get_uri (WebKitWebView *web_view); - -WEBKIT_API cairo_surface_t * -webkit_web_view_get_favicon (WebKitWebView *web_view); - -WEBKIT_API const gchar * -webkit_web_view_get_custom_charset (WebKitWebView *web_view); - -WEBKIT_API void -webkit_web_view_set_custom_charset (WebKitWebView *web_view, - const gchar *charset); - -WEBKIT_API void -webkit_web_view_set_settings (WebKitWebView *web_view, - WebKitSettings *settings); - -WEBKIT_API WebKitSettings * -webkit_web_view_get_settings (WebKitWebView *web_view); - -WEBKIT_API WebKitWindowProperties * -webkit_web_view_get_window_properties (WebKitWebView *web_view); - -WEBKIT_API void -webkit_web_view_set_zoom_level (WebKitWebView *web_view, - gdouble zoom_level); -WEBKIT_API gdouble -webkit_web_view_get_zoom_level (WebKitWebView *web_view); - -WEBKIT_API void -webkit_web_view_can_execute_editing_command (WebKitWebView *web_view, - const gchar *command, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -WEBKIT_API gboolean -webkit_web_view_can_execute_editing_command_finish (WebKitWebView *web_view, - GAsyncResult *result, - GError **error); - -WEBKIT_API void -webkit_web_view_execute_editing_command (WebKitWebView *web_view, - const gchar *command); - -WEBKIT_API WebKitFindController * -webkit_web_view_get_find_controller (WebKitWebView *web_view); - -WEBKIT_API JSGlobalContextRef -webkit_web_view_get_javascript_global_context (WebKitWebView *web_view); - -WEBKIT_API void -webkit_web_view_run_javascript (WebKitWebView *web_view, - const gchar *script, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -WEBKIT_API WebKitJavascriptResult * -webkit_web_view_run_javascript_finish (WebKitWebView *web_view, - GAsyncResult *result, - GError **error); - -WEBKIT_API void -webkit_web_view_run_javascript_from_gresource (WebKitWebView *web_view, - const gchar *resource, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -WEBKIT_API WebKitJavascriptResult * -webkit_web_view_run_javascript_from_gresource_finish (WebKitWebView *web_view, - GAsyncResult *result, - GError **error); - -WEBKIT_API WebKitWebResource * -webkit_web_view_get_main_resource (WebKitWebView *web_view); - -WEBKIT_API WebKitWebInspector * -webkit_web_view_get_inspector (WebKitWebView *web_view); - -WEBKIT_API gboolean -webkit_web_view_can_show_mime_type (WebKitWebView *web_view, - const gchar *mime_type); - -WEBKIT_API void -webkit_web_view_save (WebKitWebView *web_view, - WebKitSaveMode save_mode, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -WEBKIT_API GInputStream * -webkit_web_view_save_finish (WebKitWebView *web_view, - GAsyncResult *result, - GError **error); - -WEBKIT_API void -webkit_web_view_save_to_file (WebKitWebView *web_view, - GFile *file, - WebKitSaveMode save_mode, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -WEBKIT_API gboolean -webkit_web_view_save_to_file_finish (WebKitWebView *web_view, - GAsyncResult *result, - GError **error); - -WEBKIT_API WebKitDownload * -webkit_web_view_download_uri (WebKitWebView *web_view, - const char *uri); - -WEBKIT_API void -webkit_web_view_set_view_mode (WebKitWebView *web_view, - WebKitViewMode view_mode); - -WEBKIT_API WebKitViewMode -webkit_web_view_get_view_mode (WebKitWebView *web_view); - -WEBKIT_API gboolean -webkit_web_view_get_tls_info (WebKitWebView *web_view, - GTlsCertificate **certificate, - GTlsCertificateFlags *errors); -WEBKIT_API void -webkit_web_view_get_snapshot (WebKitWebView *web_view, - WebKitSnapshotRegion region, - WebKitSnapshotOptions options, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -WEBKIT_API cairo_surface_t * -webkit_web_view_get_snapshot_finish (WebKitWebView *web_view, - GAsyncResult *result, - GError **error); -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp deleted file mode 100644 index a414920b1..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp +++ /dev/null @@ -1,1105 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. - * Copyright (C) 2011 Igalia S.L. - * - * 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 "config.h" -#include "WebKitWebViewBase.h" - -#include "DrawingAreaProxyImpl.h" -#include "NativeWebMouseEvent.h" -#include "NativeWebWheelEvent.h" -#include "PageClientImpl.h" -#include "WebContext.h" -#include "WebEventFactory.h" -#include "WebFullScreenClientGtk.h" -#include "WebInspectorProxy.h" -#include "WebKitAuthenticationDialog.h" -#include "WebKitPrivate.h" -#include "WebKitWebViewBaseAccessible.h" -#include "WebKitWebViewBasePrivate.h" -#include "WebPageProxy.h" -#include "WebViewBaseInputMethodFilter.h" -#include <WebCore/ClipboardUtilitiesGtk.h> -#include <WebCore/DataObjectGtk.h> -#include <WebCore/DragData.h> -#include <WebCore/DragIcon.h> -#include <WebCore/GOwnPtrGtk.h> -#include <WebCore/GtkClickCounter.h> -#include <WebCore/GtkDragAndDropHelper.h> -#include <WebCore/GtkUtilities.h> -#include <WebCore/GtkVersioning.h> -#include <WebCore/NotImplemented.h> -#include <WebCore/PasteboardHelper.h> -#include <WebCore/RefPtrCairo.h> -#include <WebCore/Region.h> -#include <gdk/gdk.h> -#include <gdk/gdkkeysyms.h> -#include <wtf/HashMap.h> -#include <wtf/gobject/GOwnPtr.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -#if ENABLE(FULLSCREEN_API) -#include "WebFullScreenManagerProxy.h" -#endif - -#if USE(TEXTURE_MAPPER_GL) && defined(GDK_WINDOWING_X11) -#include <WebCore/RedirectedXCompositeWindow.h> -#endif - -using namespace WebKit; -using namespace WebCore; - -typedef HashMap<GtkWidget*, IntRect> WebKitWebViewChildrenMap; - -#if USE(TEXTURE_MAPPER_GL) -void redirectedWindowDamagedCallback(void* data); -#endif - -struct _WebKitWebViewBasePrivate { - _WebKitWebViewBasePrivate() -#if USE(TEXTURE_MAPPER_GL) - : redirectedWindow(RedirectedXCompositeWindow::create(IntSize(1, 1), RedirectedXCompositeWindow::DoNotCreateGLContext)) -#endif - { - } - - ~_WebKitWebViewBasePrivate() - { - pageProxy->close(); - } - - WebKitWebViewChildrenMap children; - OwnPtr<PageClientImpl> pageClient; - RefPtr<WebPageProxy> pageProxy; - bool shouldForwardNextKeyEvent; - GtkClickCounter clickCounter; - CString tooltipText; - IntRect tooltipArea; - GtkDragAndDropHelper dragAndDropHelper; - DragIcon dragIcon; - IntSize resizerSize; - GRefPtr<AtkObject> accessible; - bool needsResizeOnMap; - GtkWidget* authenticationDialog; - GtkWidget* inspectorView; - unsigned inspectorViewHeight; - GOwnPtr<GdkEvent> contextMenuEvent; - WebContextMenuProxyGtk* activeContextMenuProxy; - WebViewBaseInputMethodFilter inputMethodFilter; - - GtkWindow* toplevelOnScreenWindow; - unsigned long toplevelResizeGripVisibilityID; - unsigned long toplevelFocusInEventID; - unsigned long toplevelFocusOutEventID; - - // View State. - bool isInWindowActive : 1; - bool isFocused : 1; - bool isVisible : 1; - - WebKitWebViewBaseDownloadRequestHandler downloadHandler; - -#if ENABLE(FULLSCREEN_API) - bool fullScreenModeActive; - WebFullScreenClientGtk fullScreenClient; -#endif - -#if USE(TEXTURE_MAPPER_GL) - OwnPtr<RedirectedXCompositeWindow> redirectedWindow; -#endif -}; - -WEBKIT_DEFINE_TYPE(WebKitWebViewBase, webkit_web_view_base, GTK_TYPE_CONTAINER) - -static void webkitWebViewBaseNotifyResizerSize(WebKitWebViewBase* webViewBase) -{ - WebKitWebViewBasePrivate* priv = webViewBase->priv; - if (!priv->toplevelOnScreenWindow) - return; - - gboolean resizerVisible; - g_object_get(G_OBJECT(priv->toplevelOnScreenWindow), "resize-grip-visible", &resizerVisible, NULL); - - IntSize resizerSize; - if (resizerVisible) { - GdkRectangle resizerRect; - gtk_window_get_resize_grip_area(priv->toplevelOnScreenWindow, &resizerRect); - GdkRectangle allocation; - gtk_widget_get_allocation(GTK_WIDGET(webViewBase), &allocation); - if (gdk_rectangle_intersect(&resizerRect, &allocation, 0)) - resizerSize = IntSize(resizerRect.width, resizerRect.height); - } - - if (resizerSize != priv->resizerSize) { - priv->resizerSize = resizerSize; - priv->pageProxy->setWindowResizerSize(resizerSize); - } -} - -static void toplevelWindowResizeGripVisibilityChanged(GObject*, GParamSpec*, WebKitWebViewBase* webViewBase) -{ - webkitWebViewBaseNotifyResizerSize(webViewBase); -} - -static gboolean toplevelWindowFocusInEvent(GtkWidget* widget, GdkEventFocus*, WebKitWebViewBase* webViewBase) -{ - WebKitWebViewBasePrivate* priv = webViewBase->priv; - if (!priv->isInWindowActive) { - priv->isInWindowActive = true; - priv->pageProxy->viewStateDidChange(WebPageProxy::ViewWindowIsActive); - } - - return FALSE; -} - -static gboolean toplevelWindowFocusOutEvent(GtkWidget* widget, GdkEventFocus*, WebKitWebViewBase* webViewBase) -{ - WebKitWebViewBasePrivate* priv = webViewBase->priv; - if (priv->isInWindowActive) { - priv->isInWindowActive = false; - priv->pageProxy->viewStateDidChange(WebPageProxy::ViewWindowIsActive); - } - - return FALSE; -} - -static void webkitWebViewBaseSetToplevelOnScreenWindow(WebKitWebViewBase* webViewBase, GtkWindow* window) -{ - WebKitWebViewBasePrivate* priv = webViewBase->priv; - if (priv->toplevelOnScreenWindow == window) - return; - - if (priv->toplevelResizeGripVisibilityID) { - g_signal_handler_disconnect(priv->toplevelOnScreenWindow, priv->toplevelResizeGripVisibilityID); - priv->toplevelResizeGripVisibilityID = 0; - } - if (priv->toplevelFocusInEventID) { - g_signal_handler_disconnect(priv->toplevelOnScreenWindow, priv->toplevelFocusInEventID); - priv->toplevelFocusInEventID = 0; - } - if (priv->toplevelFocusOutEventID) { - g_signal_handler_disconnect(priv->toplevelOnScreenWindow, priv->toplevelFocusOutEventID); - priv->toplevelFocusOutEventID = 0; - } - - priv->toplevelOnScreenWindow = window; - priv->pageProxy->viewStateDidChange(WebPageProxy::ViewIsInWindow); - if (!priv->toplevelOnScreenWindow) - return; - - webkitWebViewBaseNotifyResizerSize(webViewBase); - - priv->toplevelResizeGripVisibilityID = - g_signal_connect(priv->toplevelOnScreenWindow, "notify::resize-grip-visible", - G_CALLBACK(toplevelWindowResizeGripVisibilityChanged), webViewBase); - priv->toplevelFocusInEventID = - g_signal_connect(priv->toplevelOnScreenWindow, "focus-in-event", - G_CALLBACK(toplevelWindowFocusInEvent), webViewBase); - priv->toplevelFocusOutEventID = - g_signal_connect(priv->toplevelOnScreenWindow, "focus-out-event", - G_CALLBACK(toplevelWindowFocusOutEvent), webViewBase); -} - -static void webkitWebViewBaseRealize(GtkWidget* widget) -{ - gtk_widget_set_realized(widget, TRUE); - - GtkAllocation allocation; - gtk_widget_get_allocation(widget, &allocation); - - GdkWindowAttr attributes; - attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = allocation.x; - attributes.y = allocation.y; - attributes.width = allocation.width; - attributes.height = allocation.height; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual(widget); - attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK - | GDK_EXPOSURE_MASK - | GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK - | GDK_SCROLL_MASK - | GDK_SMOOTH_SCROLL_MASK - | GDK_POINTER_MOTION_MASK - | GDK_KEY_PRESS_MASK - | GDK_KEY_RELEASE_MASK - | GDK_BUTTON_MOTION_MASK - | GDK_BUTTON1_MOTION_MASK - | GDK_BUTTON2_MOTION_MASK - | GDK_BUTTON3_MOTION_MASK; - - gint attributesMask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; - - GdkWindow* window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributesMask); - gtk_widget_set_window(widget, window); - gdk_window_set_user_data(window, widget); - - gtk_style_context_set_background(gtk_widget_get_style_context(widget), window); - - WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(widget); - GtkWidget* toplevel = gtk_widget_get_toplevel(widget); - if (widgetIsOnscreenToplevelWindow(toplevel)) - webkitWebViewBaseSetToplevelOnScreenWindow(webView, GTK_WINDOW(toplevel)); -} - -static bool webkitWebViewChildIsInternalWidget(WebKitWebViewBase* webViewBase, GtkWidget* widget) -{ - WebKitWebViewBasePrivate* priv = webViewBase->priv; - return widget == priv->inspectorView || widget == priv->authenticationDialog; -} - -static void webkitWebViewBaseContainerAdd(GtkContainer* container, GtkWidget* widget) -{ - WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(container); - WebKitWebViewBasePrivate* priv = webView->priv; - - // Internal widgets like the web inspector and authentication dialog have custom - // allocations so we don't need to add them to our list of children. - if (!webkitWebViewChildIsInternalWidget(webView, widget)) { - GtkAllocation childAllocation; - gtk_widget_get_allocation(widget, &childAllocation); - priv->children.set(widget, childAllocation); - } - - gtk_widget_set_parent(widget, GTK_WIDGET(container)); -} - -void webkitWebViewBaseAddAuthenticationDialog(WebKitWebViewBase* webViewBase, GtkWidget* dialog) -{ - WebKitWebViewBasePrivate* priv = webViewBase->priv; - priv->authenticationDialog = dialog; - gtk_container_add(GTK_CONTAINER(webViewBase), dialog); - gtk_widget_show(dialog); - - // We need to draw the shadow over the widget. - gtk_widget_queue_draw(GTK_WIDGET(webViewBase)); -} - -void webkitWebViewBaseCancelAuthenticationDialog(WebKitWebViewBase* webViewBase) -{ - WebKitWebViewBasePrivate* priv = webViewBase->priv; - if (priv->authenticationDialog) - gtk_widget_destroy(priv->authenticationDialog); -} - -void webkitWebViewBaseAddWebInspector(WebKitWebViewBase* webViewBase, GtkWidget* inspector) -{ - webViewBase->priv->inspectorView = inspector; - gtk_container_add(GTK_CONTAINER(webViewBase), inspector); -} - -static void webkitWebViewBaseContainerRemove(GtkContainer* container, GtkWidget* widget) -{ - WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(container); - WebKitWebViewBasePrivate* priv = webView->priv; - GtkWidget* widgetContainer = GTK_WIDGET(container); - - gboolean wasVisible = gtk_widget_get_visible(widget); - gtk_widget_unparent(widget); - - if (priv->inspectorView == widget) { - priv->inspectorView = 0; - priv->inspectorViewHeight = 0; - } else if (priv->authenticationDialog == widget) { - priv->authenticationDialog = 0; - } else { - ASSERT(priv->children.contains(widget)); - priv->children.remove(widget); - } - if (wasVisible && gtk_widget_get_visible(widgetContainer)) - gtk_widget_queue_resize(widgetContainer); -} - -static void webkitWebViewBaseContainerForall(GtkContainer* container, gboolean includeInternals, GtkCallback callback, gpointer callbackData) -{ - WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(container); - WebKitWebViewBasePrivate* priv = webView->priv; - - WebKitWebViewChildrenMap children = priv->children; - WebKitWebViewChildrenMap::const_iterator end = children.end(); - for (WebKitWebViewChildrenMap::const_iterator current = children.begin(); current != end; ++current) - (*callback)(current->key, callbackData); - - if (includeInternals && priv->inspectorView) - (*callback)(priv->inspectorView, callbackData); - - if (includeInternals && priv->authenticationDialog) - (*callback)(priv->authenticationDialog, callbackData); -} - -void webkitWebViewBaseChildMoveResize(WebKitWebViewBase* webView, GtkWidget* child, const IntRect& childRect) -{ - const IntRect& geometry = webView->priv->children.get(child); - if (geometry == childRect) - return; - - webView->priv->children.set(child, childRect); - gtk_widget_queue_resize_no_redraw(GTK_WIDGET(webView)); -} - -static void webkitWebViewBaseDispose(GObject* gobject) -{ - webkitWebViewBaseSetToplevelOnScreenWindow(WEBKIT_WEB_VIEW_BASE(gobject), 0); - G_OBJECT_CLASS(webkit_web_view_base_parent_class)->dispose(gobject); -} - -static void webkitWebViewBaseConstructed(GObject* object) -{ - G_OBJECT_CLASS(webkit_web_view_base_parent_class)->constructed(object); - - GtkWidget* viewWidget = GTK_WIDGET(object); - gtk_widget_set_can_focus(viewWidget, TRUE); - gtk_drag_dest_set(viewWidget, static_cast<GtkDestDefaults>(0), 0, 0, - static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_PRIVATE)); - gtk_drag_dest_set_target_list(viewWidget, PasteboardHelper::defaultPasteboardHelper()->targetList()); - - WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(object)->priv; - priv->pageClient = PageClientImpl::create(viewWidget); - priv->dragAndDropHelper.setWidget(viewWidget); - -#if USE(TEXTURE_MAPPER_GL) - if (priv->redirectedWindow) - priv->redirectedWindow->setDamageNotifyCallback(redirectedWindowDamagedCallback, object); -#endif - - priv->authenticationDialog = 0; -} - -#if USE(TEXTURE_MAPPER_GL) -static bool webkitWebViewRenderAcceleratedCompositingResults(WebKitWebViewBase* webViewBase, DrawingAreaProxyImpl* drawingArea, cairo_t* cr, GdkRectangle* clipRect) -{ - if (!drawingArea->isInAcceleratedCompositingMode()) - return false; - - // To avoid flashes when initializing accelerated compositing for the first - // time, we wait until we know there's a frame ready before rendering. - WebKitWebViewBasePrivate* priv = webViewBase->priv; - if (!priv->redirectedWindow) - return false; - - cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height); - cairo_surface_t* surface = priv->redirectedWindow->cairoSurfaceForWidget(GTK_WIDGET(webViewBase)); - cairo_set_source_surface(cr, surface, 0, 0); - cairo_fill(cr); - return true; -} -#endif - -static gboolean webkitWebViewBaseDraw(GtkWidget* widget, cairo_t* cr) -{ - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); - DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(webViewBase->priv->pageProxy->drawingArea()); - if (!drawingArea) - return FALSE; - - GdkRectangle clipRect; - if (!gdk_cairo_get_clip_rectangle(cr, &clipRect)) - return FALSE; - -#if USE(TEXTURE_MAPPER_GL) - if (webkitWebViewRenderAcceleratedCompositingResults(webViewBase, drawingArea, cr, &clipRect)) - return FALSE; -#endif - - WebCore::Region unpaintedRegion; // This is simply unused. - drawingArea->paint(cr, clipRect, unpaintedRegion); - - if (webViewBase->priv->authenticationDialog) { - cairo_set_operator(cr, CAIRO_OPERATOR_OVER); - cairo_set_source_rgba(cr, 0, 0, 0, 0.5); - cairo_paint(cr); - } - - GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->draw(widget, cr); - - return FALSE; -} - -static void webkitWebViewBaseChildAllocate(GtkWidget* child, gpointer userData) -{ - if (!gtk_widget_get_visible(child)) - return; - - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(userData); - WebKitWebViewBasePrivate* priv = webViewBase->priv; - const IntRect& geometry = priv->children.get(child); - if (geometry.isEmpty()) - return; - - GtkAllocation childAllocation = geometry; - gtk_widget_size_allocate(child, &childAllocation); - priv->children.set(child, IntRect()); -} - -static void resizeWebKitWebViewBaseFromAllocation(WebKitWebViewBase* webViewBase, GtkAllocation* allocation, bool sizeChanged) -{ - gtk_container_foreach(GTK_CONTAINER(webViewBase), webkitWebViewBaseChildAllocate, webViewBase); - - IntRect viewRect(allocation->x, allocation->y, allocation->width, allocation->height); - WebKitWebViewBasePrivate* priv = webViewBase->priv; - if (priv->inspectorView) { - int inspectorViewHeight = std::min(static_cast<int>(priv->inspectorViewHeight), allocation->height); - GtkAllocation childAllocation = viewRect; - childAllocation.y = allocation->height - inspectorViewHeight; - childAllocation.height = inspectorViewHeight; - gtk_widget_size_allocate(priv->inspectorView, &childAllocation); - - viewRect.setHeight(std::max(allocation->height - inspectorViewHeight, 1)); - } - - // The authentication dialog is centered in the view rect, which means that it - // never overlaps the web inspector. Thus, we need to calculate the allocation here - // after calculating the inspector allocation. - if (priv->authenticationDialog) { - GtkRequisition naturalSize; - gtk_widget_get_preferred_size(priv->authenticationDialog, 0, &naturalSize); - - GtkAllocation childAllocation = { - (viewRect.width() - naturalSize.width) / 2, - (viewRect.height() - naturalSize.height) / 2, - naturalSize.width, - naturalSize.height - }; - gtk_widget_size_allocate(priv->authenticationDialog, &childAllocation); - } - -#if USE(TEXTURE_MAPPER_GL) - if (sizeChanged && webViewBase->priv->redirectedWindow) - webViewBase->priv->redirectedWindow->resize(viewRect.size()); -#endif - - if (priv->pageProxy->drawingArea()) - priv->pageProxy->drawingArea()->setSize(viewRect.size(), IntSize(), IntSize()); - - webkitWebViewBaseNotifyResizerSize(webViewBase); -} - -static void webkitWebViewBaseSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) -{ - bool sizeChanged = gtk_widget_get_allocated_width(widget) != allocation->width - || gtk_widget_get_allocated_height(widget) != allocation->height; - - GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->size_allocate(widget, allocation); - - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); - if (sizeChanged && !gtk_widget_get_mapped(widget)) { - webViewBase->priv->needsResizeOnMap = true; - return; - } - - resizeWebKitWebViewBaseFromAllocation(webViewBase, allocation, sizeChanged); -} - -static void webkitWebViewBaseMap(GtkWidget* widget) -{ - GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->map(widget); - - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); - WebKitWebViewBasePrivate* priv = webViewBase->priv; - if (!priv->isVisible) { - priv->isVisible = true; - priv->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible); - } - - if (!priv->needsResizeOnMap) - return; - - GtkAllocation allocation; - gtk_widget_get_allocation(widget, &allocation); - resizeWebKitWebViewBaseFromAllocation(webViewBase, &allocation, true /* sizeChanged */); - priv->needsResizeOnMap = false; -} - -static void webkitWebViewBaseUnmap(GtkWidget* widget) -{ - GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->unmap(widget); - - WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv; - if (priv->isVisible) { - priv->isVisible = false; - priv->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible); - } -} - -static gboolean webkitWebViewBaseFocusInEvent(GtkWidget* widget, GdkEventFocus* event) -{ - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); - webkitWebViewBaseSetFocus(webViewBase, true); - webViewBase->priv->inputMethodFilter.notifyFocusedIn(); - - return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->focus_in_event(widget, event); -} - -static gboolean webkitWebViewBaseFocusOutEvent(GtkWidget* widget, GdkEventFocus* event) -{ - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); - webkitWebViewBaseSetFocus(webViewBase, false); - webViewBase->priv->inputMethodFilter.notifyFocusedOut(); - - return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->focus_out_event(widget, event); -} - -static gboolean webkitWebViewBaseKeyPressEvent(GtkWidget* widget, GdkEventKey* event) -{ - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); - WebKitWebViewBasePrivate* priv = webViewBase->priv; - - if (priv->authenticationDialog) - return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->key_press_event(widget, event); - -#if ENABLE(FULLSCREEN_API) - if (priv->fullScreenModeActive) { - switch (event->keyval) { - case GDK_KEY_Escape: - case GDK_KEY_f: - case GDK_KEY_F: - webkitWebViewBaseExitFullScreen(webViewBase); - return TRUE; - default: - break; - } - } -#endif - - // Since WebProcess key event handling is not synchronous, handle the event in two passes. - // When WebProcess processes the input event, it will call PageClientImpl::doneWithKeyEvent - // with event handled status which determines whether to pass the input event to parent or not - // using gtk_main_do_event(). - if (priv->shouldForwardNextKeyEvent) { - priv->shouldForwardNextKeyEvent = FALSE; - return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->key_press_event(widget, event); - } - priv->inputMethodFilter.filterKeyEvent(event); - return TRUE; -} - -static gboolean webkitWebViewBaseKeyReleaseEvent(GtkWidget* widget, GdkEventKey* event) -{ - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); - WebKitWebViewBasePrivate* priv = webViewBase->priv; - - if (priv->shouldForwardNextKeyEvent) { - priv->shouldForwardNextKeyEvent = FALSE; - return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->key_release_event(widget, event); - } - priv->inputMethodFilter.filterKeyEvent(event); - return TRUE; -} - -static gboolean webkitWebViewBaseButtonPressEvent(GtkWidget* widget, GdkEventButton* buttonEvent) -{ - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); - WebKitWebViewBasePrivate* priv = webViewBase->priv; - - if (priv->authenticationDialog) - return TRUE; - - gtk_widget_grab_focus(widget); - - priv->inputMethodFilter.notifyMouseButtonPress(); - - if (!priv->clickCounter.shouldProcessButtonEvent(buttonEvent)) - return TRUE; - - // If it's a right click event save it as a possible context menu event. - if (buttonEvent->button == 3) - priv->contextMenuEvent.set(gdk_event_copy(reinterpret_cast<GdkEvent*>(buttonEvent))); - priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(reinterpret_cast<GdkEvent*>(buttonEvent), - priv->clickCounter.clickCountForGdkButtonEvent(widget, buttonEvent))); - return TRUE; -} - -static gboolean webkitWebViewBaseButtonReleaseEvent(GtkWidget* widget, GdkEventButton* event) -{ - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); - WebKitWebViewBasePrivate* priv = webViewBase->priv; - - if (priv->authenticationDialog) - return TRUE; - - gtk_widget_grab_focus(widget); - priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(reinterpret_cast<GdkEvent*>(event), 0 /* currentClickCount */)); - - return TRUE; -} - -static gboolean webkitWebViewBaseScrollEvent(GtkWidget* widget, GdkEventScroll* event) -{ - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); - WebKitWebViewBasePrivate* priv = webViewBase->priv; - - if (priv->authenticationDialog) - return TRUE; - - priv->pageProxy->handleWheelEvent(NativeWebWheelEvent(reinterpret_cast<GdkEvent*>(event))); - - return TRUE; -} - -static gboolean webkitWebViewBaseMotionNotifyEvent(GtkWidget* widget, GdkEventMotion* event) -{ - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); - WebKitWebViewBasePrivate* priv = webViewBase->priv; - - if (priv->authenticationDialog) - return TRUE; - - priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(reinterpret_cast<GdkEvent*>(event), 0 /* currentClickCount */)); - - return TRUE; -} - -static gboolean webkitWebViewBaseQueryTooltip(GtkWidget* widget, gint x, gint y, gboolean keyboardMode, GtkTooltip* tooltip) -{ - WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv; - - if (keyboardMode) { - // TODO: https://bugs.webkit.org/show_bug.cgi?id=61732. - notImplemented(); - return FALSE; - } - - if (priv->tooltipText.length() <= 0) - return FALSE; - - if (!priv->tooltipArea.isEmpty()) { - GdkRectangle area = priv->tooltipArea; - gtk_tooltip_set_tip_area(tooltip, &area); - } else - gtk_tooltip_set_tip_area(tooltip, 0); - gtk_tooltip_set_text(tooltip, priv->tooltipText.data()); - - return TRUE; -} - -static void webkitWebViewBaseDragDataGet(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selectionData, guint info, guint time) -{ - WEBKIT_WEB_VIEW_BASE(widget)->priv->dragAndDropHelper.handleGetDragData(context, selectionData, info); -} - -static void webkitWebViewBaseDragEnd(GtkWidget* widget, GdkDragContext* context) -{ - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); - if (!webViewBase->priv->dragAndDropHelper.handleDragEnd(context)) - return; - - GdkDevice* device = gdk_drag_context_get_device(context); - int x = 0, y = 0; - gdk_device_get_window_at_position(device, &x, &y); - int xRoot = 0, yRoot = 0; - gdk_device_get_position(device, 0, &xRoot, &yRoot); - webViewBase->priv->pageProxy->dragEnded(IntPoint(x, y), IntPoint(xRoot, yRoot), - gdkDragActionToDragOperation(gdk_drag_context_get_selected_action(context))); -} - -static void webkitWebViewBaseDragDataReceived(GtkWidget* widget, GdkDragContext* context, gint x, gint y, GtkSelectionData* selectionData, guint info, guint time) -{ - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); - IntPoint position; - DataObjectGtk* dataObject = webViewBase->priv->dragAndDropHelper.handleDragDataReceived(context, selectionData, info, position); - if (!dataObject) - return; - - DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context))); - webViewBase->priv->pageProxy->resetDragOperation(); - webViewBase->priv->pageProxy->dragEntered(&dragData); - DragOperation operation = webViewBase->priv->pageProxy->dragSession().operation; - gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time); -} - -static AtkObject* webkitWebViewBaseGetAccessible(GtkWidget* widget) -{ - // If the socket has already been created and embedded a plug ID, return it. - WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv; - if (priv->accessible && atk_socket_is_occupied(ATK_SOCKET(priv->accessible.get()))) - return priv->accessible.get(); - - // Create the accessible object and associate it to the widget. - if (!priv->accessible) { - priv->accessible = adoptGRef(ATK_OBJECT(webkitWebViewBaseAccessibleNew(widget))); - - // Set the parent not to break bottom-up navigation. - GtkWidget* parentWidget = gtk_widget_get_parent(widget); - AtkObject* axParent = parentWidget ? gtk_widget_get_accessible(parentWidget) : 0; - if (axParent) - atk_object_set_parent(priv->accessible.get(), axParent); - } - - // Try to embed the plug in the socket, if posssible. - String plugID = priv->pageProxy->accessibilityPlugID(); - if (plugID.isNull()) - return priv->accessible.get(); - - atk_socket_embed(ATK_SOCKET(priv->accessible.get()), const_cast<gchar*>(plugID.utf8().data())); - - return priv->accessible.get(); -} - -static gboolean webkitWebViewBaseDragMotion(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time) -{ - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); - IntPoint position(x, y); - DataObjectGtk* dataObject = webViewBase->priv->dragAndDropHelper.handleDragMotion(context, position, time); - if (!dataObject) - return TRUE; - - DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context))); - webViewBase->priv->pageProxy->dragUpdated(&dragData); - DragOperation operation = webViewBase->priv->pageProxy->dragSession().operation; - gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time); - return TRUE; -} - -static void dragExitedCallback(GtkWidget* widget, DragData* dragData, bool dropHappened) -{ - // Don't call dragExited if we have just received a drag-drop signal. This - // happens in the case of a successful drop onto the view. - if (dropHappened) - return; - - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); - webViewBase->priv->pageProxy->dragExited(dragData); - webViewBase->priv->pageProxy->resetDragOperation(); -} - -static void webkitWebViewBaseDragLeave(GtkWidget* widget, GdkDragContext* context, guint time) -{ - WEBKIT_WEB_VIEW_BASE(widget)->priv->dragAndDropHelper.handleDragLeave(context, dragExitedCallback); -} - -static gboolean webkitWebViewBaseDragDrop(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time) -{ - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); - DataObjectGtk* dataObject = webViewBase->priv->dragAndDropHelper.handleDragDrop(context); - if (!dataObject) - return FALSE; - - IntPoint position(x, y); - DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context))); - SandboxExtension::Handle handle; - SandboxExtension::HandleArray sandboxExtensionForUpload; - webViewBase->priv->pageProxy->performDrag(&dragData, String(), handle, sandboxExtensionForUpload); - gtk_drag_finish(context, TRUE, FALSE, time); - return TRUE; -} - -static void webkitWebViewBaseParentSet(GtkWidget* widget, GtkWidget* oldParent) -{ - if (!gtk_widget_get_parent(widget)) - webkitWebViewBaseSetToplevelOnScreenWindow(WEBKIT_WEB_VIEW_BASE(widget), 0); -} - -static gboolean webkitWebViewBaseFocus(GtkWidget* widget, GtkDirectionType direction) -{ - // If the authentication dialog is active, we need to forward focus events there. This - // ensures that you can tab between elements in the box. - WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv; - if (priv->authenticationDialog) { - gboolean returnValue; - g_signal_emit_by_name(priv->authenticationDialog, "focus", direction, &returnValue); - return returnValue; - } - - return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->focus(widget, direction); -} - -static void webkitWebViewBaseDestroy(GtkWidget* widget) -{ - WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv; - if (priv->authenticationDialog) - gtk_widget_destroy(priv->authenticationDialog); - - GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->destroy(widget); -} - -static void webkit_web_view_base_class_init(WebKitWebViewBaseClass* webkitWebViewBaseClass) -{ - GtkWidgetClass* widgetClass = GTK_WIDGET_CLASS(webkitWebViewBaseClass); - widgetClass->realize = webkitWebViewBaseRealize; - widgetClass->draw = webkitWebViewBaseDraw; - widgetClass->size_allocate = webkitWebViewBaseSizeAllocate; - widgetClass->map = webkitWebViewBaseMap; - widgetClass->unmap = webkitWebViewBaseUnmap; - widgetClass->focus = webkitWebViewBaseFocus; - widgetClass->focus_in_event = webkitWebViewBaseFocusInEvent; - widgetClass->focus_out_event = webkitWebViewBaseFocusOutEvent; - widgetClass->key_press_event = webkitWebViewBaseKeyPressEvent; - widgetClass->key_release_event = webkitWebViewBaseKeyReleaseEvent; - widgetClass->button_press_event = webkitWebViewBaseButtonPressEvent; - widgetClass->button_release_event = webkitWebViewBaseButtonReleaseEvent; - widgetClass->scroll_event = webkitWebViewBaseScrollEvent; - widgetClass->motion_notify_event = webkitWebViewBaseMotionNotifyEvent; - widgetClass->query_tooltip = webkitWebViewBaseQueryTooltip; - widgetClass->drag_end = webkitWebViewBaseDragEnd; - widgetClass->drag_data_get = webkitWebViewBaseDragDataGet; - widgetClass->drag_motion = webkitWebViewBaseDragMotion; - widgetClass->drag_leave = webkitWebViewBaseDragLeave; - widgetClass->drag_drop = webkitWebViewBaseDragDrop; - widgetClass->drag_data_received = webkitWebViewBaseDragDataReceived; - widgetClass->get_accessible = webkitWebViewBaseGetAccessible; - widgetClass->parent_set = webkitWebViewBaseParentSet; - widgetClass->destroy = webkitWebViewBaseDestroy; - - GObjectClass* gobjectClass = G_OBJECT_CLASS(webkitWebViewBaseClass); - gobjectClass->constructed = webkitWebViewBaseConstructed; - gobjectClass->dispose = webkitWebViewBaseDispose; - - GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(webkitWebViewBaseClass); - containerClass->add = webkitWebViewBaseContainerAdd; - containerClass->remove = webkitWebViewBaseContainerRemove; - containerClass->forall = webkitWebViewBaseContainerForall; -} - -WebKitWebViewBase* webkitWebViewBaseCreate(WebContext* context, WebPageGroup* pageGroup) -{ - WebKitWebViewBase* webkitWebViewBase = WEBKIT_WEB_VIEW_BASE(g_object_new(WEBKIT_TYPE_WEB_VIEW_BASE, NULL)); - webkitWebViewBaseCreateWebPage(webkitWebViewBase, context, pageGroup); - return webkitWebViewBase; -} - -GtkIMContext* webkitWebViewBaseGetIMContext(WebKitWebViewBase* webkitWebViewBase) -{ - return webkitWebViewBase->priv->inputMethodFilter.context(); -} - -WebPageProxy* webkitWebViewBaseGetPage(WebKitWebViewBase* webkitWebViewBase) -{ - return webkitWebViewBase->priv->pageProxy.get(); -} - -void webkitWebViewBaseCreateWebPage(WebKitWebViewBase* webkitWebViewBase, WebContext* context, WebPageGroup* pageGroup) -{ - WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv; - - priv->pageProxy = context->createWebPage(priv->pageClient.get(), pageGroup); - priv->pageProxy->initializeWebPage(); - -#if ENABLE(FULLSCREEN_API) - priv->pageProxy->fullScreenManager()->setWebView(webkitWebViewBase); -#endif - -#if USE(TEXTURE_MAPPER_GL) - if (priv->redirectedWindow) - priv->pageProxy->setAcceleratedCompositingWindowId(priv->redirectedWindow->windowId()); -#endif - - // This must happen here instead of the instance initializer, because the input method - // filter must have access to the page. - priv->inputMethodFilter.setWebView(webkitWebViewBase); -} - -void webkitWebViewBaseSetTooltipText(WebKitWebViewBase* webViewBase, const char* tooltip) -{ - WebKitWebViewBasePrivate* priv = webViewBase->priv; - if (tooltip && tooltip[0] != '\0') { - priv->tooltipText = tooltip; - gtk_widget_set_has_tooltip(GTK_WIDGET(webViewBase), TRUE); - } else { - priv->tooltipText = ""; - gtk_widget_set_has_tooltip(GTK_WIDGET(webViewBase), FALSE); - } - - gtk_widget_trigger_tooltip_query(GTK_WIDGET(webViewBase)); -} - -void webkitWebViewBaseSetTooltipArea(WebKitWebViewBase* webViewBase, const IntRect& tooltipArea) -{ - webViewBase->priv->tooltipArea = tooltipArea; -} - -void webkitWebViewBaseStartDrag(WebKitWebViewBase* webViewBase, const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage) -{ - WebKitWebViewBasePrivate* priv = webViewBase->priv; - - RefPtr<DataObjectGtk> dataObject = adoptRef(dragData.platformData()); - GRefPtr<GtkTargetList> targetList = adoptGRef(PasteboardHelper::defaultPasteboardHelper()->targetListForDataObject(dataObject.get())); - GOwnPtr<GdkEvent> currentEvent(gtk_get_current_event()); - GdkDragContext* context = gtk_drag_begin(GTK_WIDGET(webViewBase), - targetList.get(), - dragOperationToGdkDragActions(dragData.draggingSourceOperationMask()), - 1, /* button */ - currentEvent.get()); - priv->dragAndDropHelper.startedDrag(context, dataObject.get()); - - - // A drag starting should prevent a double-click from happening. This might - // happen if a drag is followed very quickly by another click (like in the DRT). - priv->clickCounter.reset(); - - if (dragImage) { - RefPtr<cairo_surface_t> image(dragImage->createCairoSurface()); - priv->dragIcon.setImage(image.get()); - priv->dragIcon.useForDrag(context); - } else - gtk_drag_set_icon_default(context); -} - -void webkitWebViewBaseForwardNextKeyEvent(WebKitWebViewBase* webkitWebViewBase) -{ - webkitWebViewBase->priv->shouldForwardNextKeyEvent = TRUE; -} - -void webkitWebViewBaseEnterFullScreen(WebKitWebViewBase* webkitWebViewBase) -{ -#if ENABLE(FULLSCREEN_API) - WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv; - if (priv->fullScreenModeActive) - return; - - if (!priv->fullScreenClient.willEnterFullScreen()) - return; - - WebFullScreenManagerProxy* fullScreenManagerProxy = priv->pageProxy->fullScreenManager(); - fullScreenManagerProxy->willEnterFullScreen(); - - GtkWidget* topLevelWindow = gtk_widget_get_toplevel(GTK_WIDGET(webkitWebViewBase)); - if (gtk_widget_is_toplevel(topLevelWindow)) - gtk_window_fullscreen(GTK_WINDOW(topLevelWindow)); - fullScreenManagerProxy->didEnterFullScreen(); - priv->fullScreenModeActive = true; -#endif -} - -void webkitWebViewBaseExitFullScreen(WebKitWebViewBase* webkitWebViewBase) -{ -#if ENABLE(FULLSCREEN_API) - WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv; - if (!priv->fullScreenModeActive) - return; - - if (!priv->fullScreenClient.willExitFullScreen()) - return; - - WebFullScreenManagerProxy* fullScreenManagerProxy = priv->pageProxy->fullScreenManager(); - fullScreenManagerProxy->willExitFullScreen(); - - GtkWidget* topLevelWindow = gtk_widget_get_toplevel(GTK_WIDGET(webkitWebViewBase)); - if (gtk_widget_is_toplevel(topLevelWindow)) - gtk_window_unfullscreen(GTK_WINDOW(topLevelWindow)); - fullScreenManagerProxy->didExitFullScreen(); - priv->fullScreenModeActive = false; -#endif -} - -void webkitWebViewBaseInitializeFullScreenClient(WebKitWebViewBase* webkitWebViewBase, const WKFullScreenClientGtk* wkClient) -{ - webkitWebViewBase->priv->fullScreenClient.initialize(wkClient); -} - -void webkitWebViewBaseSetInspectorViewHeight(WebKitWebViewBase* webkitWebViewBase, unsigned height) -{ - if (webkitWebViewBase->priv->inspectorViewHeight == height) - return; - webkitWebViewBase->priv->inspectorViewHeight = height; - if (webkitWebViewBase->priv->inspectorView) - gtk_widget_queue_resize_no_redraw(GTK_WIDGET(webkitWebViewBase)); -} - -void webkitWebViewBaseSetActiveContextMenuProxy(WebKitWebViewBase* webkitWebViewBase, WebContextMenuProxyGtk* contextMenuProxy) -{ - webkitWebViewBase->priv->activeContextMenuProxy = contextMenuProxy; -} - -WebContextMenuProxyGtk* webkitWebViewBaseGetActiveContextMenuProxy(WebKitWebViewBase* webkitWebViewBase) -{ - return webkitWebViewBase->priv->activeContextMenuProxy; -} - -GdkEvent* webkitWebViewBaseTakeContextMenuEvent(WebKitWebViewBase* webkitWebViewBase) -{ - return webkitWebViewBase->priv->contextMenuEvent.release(); -} - -#if USE(TEXTURE_MAPPER_GL) -void redirectedWindowDamagedCallback(void* data) -{ - gtk_widget_queue_draw(GTK_WIDGET(data)); -} -#endif - -void webkitWebViewBaseSetFocus(WebKitWebViewBase* webViewBase, bool focused) -{ - WebKitWebViewBasePrivate* priv = webViewBase->priv; - if (priv->isFocused == focused) - return; - - unsigned viewStateFlags = WebPageProxy::ViewIsFocused; - priv->isFocused = focused; - - // If the view has received the focus and the window is not active - // mark the current window as active now. This can happen if the - // toplevel window is a GTK_WINDOW_POPUP and the focus has been - // set programatically like WebKitTestRunner does, because POPUP - // can't be focused. - if (priv->isFocused && !priv->isInWindowActive) { - priv->isInWindowActive = true; - viewStateFlags |= WebPageProxy::ViewWindowIsActive; - } - priv->pageProxy->viewStateDidChange(viewStateFlags); -} - -bool webkitWebViewBaseIsInWindowActive(WebKitWebViewBase* webViewBase) -{ - return webViewBase->priv->isInWindowActive; -} - -bool webkitWebViewBaseIsFocused(WebKitWebViewBase* webViewBase) -{ - return webViewBase->priv->isFocused; -} - -bool webkitWebViewBaseIsVisible(WebKitWebViewBase* webViewBase) -{ - return webViewBase->priv->isVisible; -} - -bool webkitWebViewBaseIsInWindow(WebKitWebViewBase* webViewBase) -{ - return webViewBase->priv->toplevelOnScreenWindow; -} - -void webkitWebViewBaseSetDownloadRequestHandler(WebKitWebViewBase* webViewBase, WebKitWebViewBaseDownloadRequestHandler downloadHandler) -{ - webViewBase->priv->downloadHandler = downloadHandler; -} - -void webkitWebViewBaseHandleDownloadRequest(WebKitWebViewBase* webViewBase, DownloadProxy* download) -{ - if (webViewBase->priv->downloadHandler) - webViewBase->priv->downloadHandler(webViewBase, download); -} - -void webkitWebViewBaseSetInputMethodState(WebKitWebViewBase* webkitWebViewBase, bool enabled) -{ - webkitWebViewBase->priv->inputMethodFilter.setEnabled(enabled); -} - -void webkitWebViewBaseUpdateTextInputState(WebKitWebViewBase* webkitWebViewBase) -{ - webkitWebViewBase->priv->inputMethodFilter.setCursorRect(webkitWebViewBase->priv->pageProxy->editorState().cursorRect); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.h deleted file mode 100644 index f24457f57..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. - * Copyright (C) 2011 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitWebViewBase_h -#define WebKitWebViewBase_h - -#include <gtk/gtk.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_WEB_VIEW_BASE (webkit_web_view_base_get_type()) -#define WEBKIT_WEB_VIEW_BASE(object) (G_TYPE_CHECK_INSTANCE_CAST((object), WEBKIT_TYPE_WEB_VIEW_BASE, WebKitWebViewBase)) -#define WEBKIT_WEB_VIEW_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_VIEW_BASE, WebKitWebViewBaseClass)) -#define WEBKIT_IS_WEB_VIEW_BASE(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), WEBKIT_TYPE_WEB_VIEW_BASE)) -#define WEBKIT_IS_WEB_VIEW_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_VIEW_BASE)) -#define WEBKIT_WEB_VIEW_BASE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), WEBKIT_TYPE_WEB_VIEW_BASE, WebKitWebViewBaseClass)) - -typedef struct _WebKitWebViewBase WebKitWebViewBase; -typedef struct _WebKitWebViewBaseClass WebKitWebViewBaseClass; -typedef struct _WebKitWebViewBasePrivate WebKitWebViewBasePrivate; - -struct _WebKitWebViewBase { - GtkContainer parentInstance; - /*< private >*/ - WebKitWebViewBasePrivate* priv; -}; - -struct _WebKitWebViewBaseClass { - GtkContainerClass parentClass; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_web_view_base_get_type (void); - -G_END_DECLS - -#endif // WebKitWebViewBase_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBaseAccessible.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBaseAccessible.cpp deleted file mode 100644 index 7b069dd94..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBaseAccessible.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitWebViewBaseAccessible.h" - -#include "WebKitPrivate.h" -#include <gtk/gtk.h> - -struct _WebKitWebViewBaseAccessiblePrivate { - GtkWidget* widget; -}; - -WEBKIT_DEFINE_TYPE(WebKitWebViewBaseAccessible, webkit_web_view_base_accessible, ATK_TYPE_SOCKET) - -static void webkitWebViewBaseAccessibleWidgetDestroyed(GtkWidget* widget, WebKitWebViewBaseAccessible* accessible) -{ - accessible->priv->widget = 0; - atk_object_notify_state_change(ATK_OBJECT(accessible), ATK_STATE_DEFUNCT, TRUE); -} - -static void webkitWebViewBaseAccessibleInitialize(AtkObject* atkObject, gpointer data) -{ - if (ATK_OBJECT_CLASS(webkit_web_view_base_accessible_parent_class)->initialize) - ATK_OBJECT_CLASS(webkit_web_view_base_accessible_parent_class)->initialize(atkObject, data); - - if (data && GTK_IS_WIDGET(data)) { - WebKitWebViewBaseAccessible* accessible = WEBKIT_WEB_VIEW_BASE_ACCESSIBLE(atkObject); - accessible->priv->widget = GTK_WIDGET(data); - - g_signal_connect_after(accessible->priv->widget, "destroy", - G_CALLBACK(webkitWebViewBaseAccessibleWidgetDestroyed), atkObject); - } - - atk_object_set_role(atkObject, ATK_ROLE_FILLER); -} - -static AtkStateSet* webkitWebViewBaseAccessibleRefStateSet(AtkObject* atkObject) -{ - WebKitWebViewBaseAccessible* accessible = WEBKIT_WEB_VIEW_BASE_ACCESSIBLE(atkObject); - - AtkStateSet* stateSet; - if (accessible->priv->widget) { - // Use the implementation of AtkSocket if the widget is still alive. - stateSet = ATK_OBJECT_CLASS(webkit_web_view_base_accessible_parent_class)->ref_state_set(atkObject); - } else { - // If the widget is no longer alive, save some remote calls - // (because of AtkSocket's implementation of ref_state_set()) - // and just return that this AtkObject is defunct. - stateSet = atk_state_set_new(); - atk_state_set_add_state(stateSet, ATK_STATE_DEFUNCT); - } - - return stateSet; -} - -static gint webkitWebViewBaseAccessibleGetIndexInParent(AtkObject* atkObject) -{ - AtkObject* atkParent = atk_object_get_parent(atkObject); - if (!atkParent) - return -1; - - guint count = atk_object_get_n_accessible_children(atkParent); - for (guint i = 0; i < count; ++i) { - AtkObject* child = atk_object_ref_accessible_child(atkParent, i); - bool childIsObject = child == atkObject; - g_object_unref(child); - if (childIsObject) - return i; - } - - return -1; -} - -static void webkit_web_view_base_accessible_class_init(WebKitWebViewBaseAccessibleClass* klass) -{ - // No need to implement get_n_children() and ref_child() here - // since this is a subclass of AtkSocket and all the logic related - // to those functions will be implemented by the ATK bridge. - AtkObjectClass* atkObjectClass = ATK_OBJECT_CLASS(klass); - atkObjectClass->initialize = webkitWebViewBaseAccessibleInitialize; - atkObjectClass->ref_state_set = webkitWebViewBaseAccessibleRefStateSet; - atkObjectClass->get_index_in_parent = webkitWebViewBaseAccessibleGetIndexInParent; -} - -WebKitWebViewBaseAccessible* webkitWebViewBaseAccessibleNew(GtkWidget* widget) -{ - AtkObject* object = ATK_OBJECT(g_object_new(WEBKIT_TYPE_WEB_VIEW_BASE_ACCESSIBLE, NULL)); - atk_object_initialize(object, widget); - return WEBKIT_WEB_VIEW_BASE_ACCESSIBLE(object); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBaseAccessible.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBaseAccessible.h deleted file mode 100644 index 3e932c3cd..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBaseAccessible.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitWebViewBaseAccessible_h -#define WebKitWebViewBaseAccessible_h - -#include <atk/atk.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_WEB_VIEW_BASE_ACCESSIBLE (webkit_web_view_base_accessible_get_type()) -#define WEBKIT_WEB_VIEW_BASE_ACCESSIBLE(object) (G_TYPE_CHECK_INSTANCE_CAST((object), WEBKIT_TYPE_WEB_VIEW_BASE_ACCESSIBLE, WebKitWebViewBaseAccessible)) -#define WEBKIT_WEB_VIEW_BASE_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_VIEW_BASE_ACCESSIBLE, WebKitWebViewBaseAccessibleClass)) -#define WEBKIT_IS_WEB_VIEW_BASE_ACCESSIBLE(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), WEBKIT_TYPE_WEB_VIEW_BASE_ACCESSIBLE)) -#define WEBKIT_IS_WEB_VIEW_BASE_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_VIEW_BASE_ACCESSIBLE)) -#define WEBKIT_WEB_VIEW_BASE_ACCESSIBLE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), WEBKIT_TYPE_WEB_VIEW_BASE_ACCESSIBLE, WebKitWebViewBaseAccessibleClass)) - -typedef struct _WebKitWebViewBaseAccessible WebKitWebViewBaseAccessible; -typedef struct _WebKitWebViewBaseAccessibleClass WebKitWebViewBaseAccessibleClass; -typedef struct _WebKitWebViewBaseAccessiblePrivate WebKitWebViewBaseAccessiblePrivate; - - -struct _WebKitWebViewBaseAccessible { - AtkSocket parent; - /*< private >*/ - WebKitWebViewBaseAccessiblePrivate* priv; -}; - -struct _WebKitWebViewBaseAccessibleClass { - AtkSocketClass parentClass; -}; - -GType webkit_web_view_base_accessible_get_type(); - -WebKitWebViewBaseAccessible* webkitWebViewBaseAccessibleNew(GtkWidget*); - -G_END_DECLS - -#endif // WebKitWebViewBaseAccessible_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h deleted file mode 100644 index e30fd949e..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. - * Copyright (C) 2011 Igalia S.L. - * - * 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 WebKitWebViewBasePrivate_h -#define WebKitWebViewBasePrivate_h - -#include "WebContextMenuProxyGtk.h" -#include "WebKitPrivate.h" -#include "WebKitWebViewBase.h" -#include "WebPageProxy.h" - -WebKitWebViewBase* webkitWebViewBaseCreate(WebKit::WebContext*, WebKit::WebPageGroup*); -GtkIMContext* webkitWebViewBaseGetIMContext(WebKitWebViewBase*); -WebKit::WebPageProxy* webkitWebViewBaseGetPage(WebKitWebViewBase*); -void webkitWebViewBaseCreateWebPage(WebKitWebViewBase*, WebKit::WebContext*, WebKit::WebPageGroup*); -void webkitWebViewBaseSetTooltipText(WebKitWebViewBase*, const char*); -void webkitWebViewBaseSetTooltipArea(WebKitWebViewBase*, const WebCore::IntRect&); -void webkitWebViewBaseForwardNextKeyEvent(WebKitWebViewBase*); -void webkitWebViewBaseStartDrag(WebKitWebViewBase*, const WebCore::DragData&, PassRefPtr<WebKit::ShareableBitmap> dragImage); -void webkitWebViewBaseChildMoveResize(WebKitWebViewBase*, GtkWidget*, const WebCore::IntRect&); -void webkitWebViewBaseEnterFullScreen(WebKitWebViewBase*); -void webkitWebViewBaseExitFullScreen(WebKitWebViewBase*); -void webkitWebViewBaseInitializeFullScreenClient(WebKitWebViewBase*, const WKFullScreenClientGtk*); -void webkitWebViewBaseSetInspectorViewHeight(WebKitWebViewBase*, unsigned height); -void webkitWebViewBaseSetActiveContextMenuProxy(WebKitWebViewBase*, WebKit::WebContextMenuProxyGtk*); -WebKit::WebContextMenuProxyGtk* webkitWebViewBaseGetActiveContextMenuProxy(WebKitWebViewBase*); -GdkEvent* webkitWebViewBaseTakeContextMenuEvent(WebKitWebViewBase*); -void webkitWebViewBaseSetInputMethodState(WebKitWebViewBase*, bool enabled); -void webkitWebViewBaseUpdateTextInputState(WebKitWebViewBase*); - -#if USE(TEXTURE_MAPPER_GL) -void webkitWebViewBaseQueueDrawOfAcceleratedCompositingResults(WebKitWebViewBase*); -#endif - -void webkitWebViewBaseSetFocus(WebKitWebViewBase*, bool focused); -bool webkitWebViewBaseIsInWindowActive(WebKitWebViewBase*); -bool webkitWebViewBaseIsFocused(WebKitWebViewBase*); -bool webkitWebViewBaseIsVisible(WebKitWebViewBase*); -bool webkitWebViewBaseIsInWindow(WebKitWebViewBase*); - -typedef void (*WebKitWebViewBaseDownloadRequestHandler) (WebKitWebViewBase*, WebKit::DownloadProxy*); -void webkitWebViewBaseSetDownloadRequestHandler(WebKitWebViewBase*, WebKitWebViewBaseDownloadRequestHandler); -void webkitWebViewBaseHandleDownloadRequest(WebKitWebViewBase*, WebKit::DownloadProxy*); - -void webkitWebViewBaseAddAuthenticationDialog(WebKitWebViewBase*, GtkWidget* authDialog); -void webkitWebViewBaseCancelAuthenticationDialog(WebKitWebViewBase*); -void webkitWebViewBaseAddWebInspector(WebKitWebViewBase*, GtkWidget* inspector); - -#endif // WebKitWebViewBasePrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewGroup.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewGroup.cpp deleted file mode 100644 index 998c5c0c1..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewGroup.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Copyright (C) 2013 Igalia S.L. - * - * 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 "WebKitWebViewGroup.h" - -#include "ImmutableArray.h" -#include "WebKitPrivate.h" -#include "WebKitSettingsPrivate.h" -#include "WebKitWebViewGroupPrivate.h" -#include <glib/gi18n-lib.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -using namespace WebKit; - -/** - * SECTION: WebKitWebViewGroup - * @Short_description: Group of web views - * @Title: WebKitWebViewGroup - * @See_also: #WebKitWebView, #WebKitSettings - * - * A WebKitWebViewGroup represents a group of #WebKitWebView<!-- -->s that - * share things like settings. There's a default WebKitWebViewGroup where - * all #WebKitWebView<!-- -->s of the same #WebKitWebContext are added by default. - * To create a #WebKitWebView in a different WebKitWebViewGroup you can use - * webkit_web_view_new_with_group(). - * - * WebKitWebViewGroups are identified by a unique name given when the group is - * created with webkit_web_view_group_new(). - * WebKitWebViewGroups have a #WebKitSettings to control the settings of all - * #WebKitWebView<!-- -->s of the group. You can get the settings with - * webkit_web_view_group_get_settings() to handle the settings, or you can set - * your own #WebKitSettings with webkit_web_view_group_set_settings(). When - * the #WebKitSettings of a WebKitWebViewGroup changes, the signal notify::settings - * is emitted on the group. - */ - -enum { - PROP_0, - - PROP_SETTINGS -}; - -struct _WebKitWebViewGroupPrivate { - RefPtr<WebPageGroup> pageGroup; - CString name; - GRefPtr<WebKitSettings> settings; -}; - -WEBKIT_DEFINE_TYPE(WebKitWebViewGroup, webkit_web_view_group, G_TYPE_OBJECT) - -static void webkitWebViewGroupSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec) -{ - WebKitWebViewGroup* group = WEBKIT_WEB_VIEW_GROUP(object); - - switch (propId) { - case PROP_SETTINGS: - webkit_web_view_group_set_settings(group, WEBKIT_SETTINGS(g_value_get_object(value))); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static void webkitWebViewGroupGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) -{ - WebKitWebViewGroup* group = WEBKIT_WEB_VIEW_GROUP(object); - - switch (propId) { - case PROP_SETTINGS: - g_value_set_object(value, webkit_web_view_group_get_settings(group)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static void webkitWebViewGroupConstructed(GObject* object) -{ - G_OBJECT_CLASS(webkit_web_view_group_parent_class)->constructed(object); - - WebKitWebViewGroupPrivate* priv = WEBKIT_WEB_VIEW_GROUP(object)->priv; - priv->settings = adoptGRef(webkit_settings_new()); -} - -static void webkit_web_view_group_class_init(WebKitWebViewGroupClass* hitTestResultClass) -{ - GObjectClass* objectClass = G_OBJECT_CLASS(hitTestResultClass); - objectClass->set_property = webkitWebViewGroupSetProperty; - objectClass->get_property = webkitWebViewGroupGetProperty; - objectClass->constructed = webkitWebViewGroupConstructed; - - /** - * WebKitWebViewGroup:settings: - * - * The #WebKitSettings of the web view group. - */ - g_object_class_install_property( - objectClass, - PROP_SETTINGS, - g_param_spec_object( - "settings", - _("Settings"), - _("The settings of the web view group"), - WEBKIT_TYPE_SETTINGS, - WEBKIT_PARAM_READWRITE)); -} - -static void webkitWebViewGroupAttachSettingsToPageGroup(WebKitWebViewGroup* group) -{ - group->priv->pageGroup->setPreferences(webkitSettingsGetPreferences(group->priv->settings.get())); -} - -WebKitWebViewGroup* webkitWebViewGroupCreate(WebPageGroup* pageGroup) -{ - WebKitWebViewGroup* group = WEBKIT_WEB_VIEW_GROUP(g_object_new(WEBKIT_TYPE_WEB_VIEW_GROUP, NULL)); - group->priv->pageGroup = pageGroup; - webkitWebViewGroupAttachSettingsToPageGroup(group); - return group; -} - -WebPageGroup* webkitWebViewGroupGetPageGroup(WebKitWebViewGroup* group) -{ - return group->priv->pageGroup.get(); -} - -/** - * webkit_web_view_group_new: - * @name: (allow-none): the name of the group - * - * Creates a new #WebKitWebViewGroup with the given @name. - * If @name is %NULL a unique identifier name will be created - * automatically. - * The newly created #WebKitWebViewGroup doesn't contain any - * #WebKitWebView, web views are added to the new group when created - * with webkit_web_view_new_with_group() passing the group. - * - * Returns: (transfer full): a new #WebKitWebViewGroup - */ -WebKitWebViewGroup* webkit_web_view_group_new(const char* name) -{ - WebKitWebViewGroup* group = WEBKIT_WEB_VIEW_GROUP(g_object_new(WEBKIT_TYPE_WEB_VIEW_GROUP, NULL)); - group->priv->pageGroup = WebPageGroup::create(name ? String::fromUTF8(name) : String()); - webkitWebViewGroupAttachSettingsToPageGroup(group); - return group; -} - -/** - * webkit_web_view_group_get_name: - * @group: a #WebKitWebViewGroup - * - * Gets the name that uniquely identifies the #WebKitWebViewGroup. - * - * Returns: the name of @group - */ -const char* webkit_web_view_group_get_name(WebKitWebViewGroup* group) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW_GROUP(group), 0); - - WebKitWebViewGroupPrivate* priv = group->priv; - if (priv->name.isNull()) - priv->name = priv->pageGroup->identifier().utf8(); - - return priv->name.data(); -} - -/** - * webkit_web_view_group_get_settings: - * @group: a #WebKitWebViewGroup - * - * Gets the #WebKitSettings of the #WebKitWebViewGroup. - * - * Returns: (transfer none): the settings of @group - */ -WebKitSettings* webkit_web_view_group_get_settings(WebKitWebViewGroup* group) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW_GROUP(group), 0); - - return group->priv->settings.get(); -} - -/** - * webkit_web_view_group_set_settings: - * @group: a #WebKitWebViewGroup - * @settings: a #WebKitSettings - * - * Sets a new #WebKitSettings for the #WebKitWebViewGroup. The settings will - * affect to all the #WebKitWebView<!-- -->s of the group. - * #WebKitWebViewGroup<!-- -->s always have a #WebKitSettings so if you just want to - * modify a setting you can use webkit_web_view_group_get_settings() and modify the - * returned #WebKitSettings instead. - * Setting the same #WebKitSettings multiple times doesn't have any effect. - * You can monitor the settings of a #WebKitWebViewGroup by connecting to the - * notify::settings signal of @group. - */ -void webkit_web_view_group_set_settings(WebKitWebViewGroup* group, WebKitSettings* settings) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW_GROUP(group)); - g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); - - if (group->priv->settings == settings) - return; - - group->priv->settings = settings; - webkitWebViewGroupAttachSettingsToPageGroup(group); - g_object_notify(G_OBJECT(group), "settings"); -} - -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_INJECTED_CONTENT_FRAMES_ALL, WebCore::InjectInAllFrames); -COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_INJECTED_CONTENT_FRAMES_TOP_ONLY, WebCore::InjectInTopFrameOnly); - -static PassRefPtr<ImmutableArray> toImmutableArray(const char* const* list) -{ - if (!list) - return 0; - - Vector<RefPtr<APIObject> > entries; - while (*list) { - entries.append(WebString::createFromUTF8String(*list)); - list++; - } - return ImmutableArray::adopt(entries); -} - -/** - * webkit_web_view_group_add_user_style_sheet: - * @group: a #WebKitWebViewGroup - * @source: the source of the style_sheet to inject - * @base_uri: (allow-none): the base URI to use when processing the style_sheet contents or %NULL for about:blank - * @whitelist: (array zero-terminated=1) (allow-none): a whitelist of URI patterns or %NULL - * @blacklist: (array zero-terminated=1) (allow-none): a blacklist of URI patterns or %NULL - * @injected_frames: a #WebKitInjectedContentFrames describing to which frames the style_sheet should apply - * - * Inject an external style sheet into pages. It is possible to only apply the style sheet - * to some URIs by passing non-null values for @whitelist or @blacklist. Passing a %NULL - * whitelist implies that all URIs are on the whitelist. The style sheet is applied if a URI matches - * the whitelist and not the blacklist. URI patterns must be of the form [protocol]://[host]/[path] - * where the host and path components can contain the wildcard character ('*') to represent zero - * or more other characters. - */ -void webkit_web_view_group_add_user_style_sheet(WebKitWebViewGroup* group, const char* source, const char* baseURI, const char* const* whitelist, const char* const* blacklist, WebKitInjectedContentFrames injectedFrames) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW_GROUP(group)); - g_return_if_fail(source); - - RefPtr<ImmutableArray> webWhitelist = toImmutableArray(whitelist); - RefPtr<ImmutableArray> webBlacklist = toImmutableArray(blacklist); - - // We always use UserStyleUserLevel to match the behavior of WKPageGroupAddUserStyleSheet. - group->priv->pageGroup->addUserStyleSheet( - String::fromUTF8(source), - String::fromUTF8(baseURI), - webWhitelist.get(), - webBlacklist.get(), - static_cast<WebCore::UserContentInjectedFrames>(injectedFrames), - WebCore::UserStyleUserLevel); -} - -/** - * webkit_web_view_group_remove_all_user_style_sheets: - * @group: a #WebKitWebViewGroup - * - * Remove all style sheets previously injected into this #WebKitWebViewGroup - * via webkit_web_view_group_add_user_style_sheet(). - */ -void webkit_web_view_group_remove_all_user_style_sheets(WebKitWebViewGroup* group) -{ - g_return_if_fail(WEBKIT_IS_WEB_VIEW_GROUP(group)); - group->priv->pageGroup->removeAllUserStyleSheets(); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewGroup.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewGroup.h deleted file mode 100644 index 685f19904..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewGroup.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2013 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitWebViewGroup_h -#define WebKitWebViewGroup_h - -#include <glib-object.h> -#include <webkit2/WebKitDefines.h> -#include <webkit2/WebKitSettings.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_WEB_VIEW_GROUP (webkit_web_view_group_get_type()) -#define WEBKIT_WEB_VIEW_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_VIEW_GROUP, WebKitWebViewGroup)) -#define WEBKIT_IS_WEB_VIEW_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_VIEW_GROUP)) -#define WEBKIT_WEB_VIEW_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_VIEW_GROUP, WebKitWebViewGroupClass)) -#define WEBKIT_IS_WEB_VIEW_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_VIEW_GROUP)) -#define WEBKIT_WEB_VIEW_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_VIEW_GROUP, WebKitWebViewGroupClass)) - -typedef struct _WebKitWebViewGroup WebKitWebViewGroup; -typedef struct _WebKitWebViewGroupClass WebKitWebViewGroupClass; -typedef struct _WebKitWebViewGroupPrivate WebKitWebViewGroupPrivate; - -struct _WebKitWebViewGroup { - GObject parent; - - WebKitWebViewGroupPrivate *priv; -}; - -struct _WebKitWebViewGroupClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -/** - * WebKitInjectedContentFrames: - * @WEBKIT_INJECTED_CONTENT_FRAMES_ALL: Content will be injected into all frames. - * @WEBKIT_INJECTED_CONTENT_FRAMES_TOP_ONLY: Content will only be injected into the main frame. - * - * Enum values used for determining into which frames content is injected. - */ -typedef enum { - WEBKIT_INJECTED_CONTENT_FRAMES_ALL, - WEBKIT_INJECTED_CONTENT_FRAMES_TOP_ONLY, -} WebKitInjectedContentFrames; - -WEBKIT_API GType -webkit_web_view_group_get_type (void); - -WEBKIT_API WebKitWebViewGroup * -webkit_web_view_group_new (const gchar *name); - -WEBKIT_API const gchar * -webkit_web_view_group_get_name (WebKitWebViewGroup *group); - -WEBKIT_API WebKitSettings * -webkit_web_view_group_get_settings (WebKitWebViewGroup *group); - -WEBKIT_API void -webkit_web_view_group_set_settings (WebKitWebViewGroup *group, - WebKitSettings *settings); - -WEBKIT_API void -webkit_web_view_group_add_user_style_sheet (WebKitWebViewGroup *group, - const gchar *source, - const gchar *base_uri, - const gchar * const *whitelist, - const gchar * const *blacklist, - WebKitInjectedContentFrames injected_frames); - -WEBKIT_API void -webkit_web_view_group_remove_all_user_style_sheets (WebKitWebViewGroup *group); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewGroupPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewGroupPrivate.h deleted file mode 100644 index 5fd865610..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewGroupPrivate.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2013 Igalia S.L. - * - * 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 WebKitWebViewGroupPrivate_h -#define WebKitWebViewGroupPrivate_h - -#include "WebKitWebViewGroup.h" -#include "WebPageGroup.h" - -WebKitWebViewGroup* webkitWebViewGroupCreate(WebKit::WebPageGroup*); -WebKit::WebPageGroup* webkitWebViewGroupGetPageGroup(WebKitWebViewGroup*); - -#endif // WebKitWebViewGroupPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h deleted file mode 100644 index eb1f27db2..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * Portions Copyright (c) 2011 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 WebKitWebViewPrivate_h -#define WebKitWebViewPrivate_h - -#include "WebImage.h" -#include "WebKitWebView.h" -#include <wtf/text/CString.h> - -void webkitWebViewLoadChanged(WebKitWebView*, WebKitLoadEvent); -void webkitWebViewLoadFailed(WebKitWebView*, WebKitLoadEvent, const char* failingURI, GError*); -void webkitWebViewLoadFailedWithTLSErrors(WebKitWebView*, const char* failingURI, GError *, GTlsCertificateFlags, GTlsCertificate*); -void webkitWebViewSetEstimatedLoadProgress(WebKitWebView*, double estimatedLoadProgress); -void webkitWebViewSetTitle(WebKitWebView*, const CString&); -void webkitWebViewUpdateURI(WebKitWebView*); -WebKit::WebPageProxy* webkitWebViewCreateNewPage(WebKitWebView*, WebKit::ImmutableDictionary* windowFeatures); -void webkitWebViewReadyToShowPage(WebKitWebView*); -void webkitWebViewRunAsModal(WebKitWebView*); -void webkitWebViewClosePage(WebKitWebView*); -void webkitWebViewRunJavaScriptAlert(WebKitWebView*, const CString& message); -bool webkitWebViewRunJavaScriptConfirm(WebKitWebView*, const CString& message); -CString webkitWebViewRunJavaScriptPrompt(WebKitWebView*, const CString& message, const CString& defaultText); -void webkitWebViewMakePermissionRequest(WebKitWebView*, WebKitPermissionRequest*); -void webkitWebViewMakePolicyDecision(WebKitWebView*, WebKitPolicyDecisionType, WebKitPolicyDecision*); -void webkitWebViewMouseTargetChanged(WebKitWebView*, WebKit::WebHitTestResult*, unsigned modifiers); -void webkitWebViewPrintFrame(WebKitWebView*, WebKit::WebFrameProxy*); -void webkitWebViewResourceLoadStarted(WebKitWebView*, WebKit::WebFrameProxy*, uint64_t resourceIdentifier, WebKitURIRequest*); -void webkitWebViewRunFileChooserRequest(WebKitWebView*, WebKitFileChooserRequest*); -WebKitWebResource* webkitWebViewGetLoadingWebResource(WebKitWebView*, uint64_t resourceIdentifier); -void webKitWebViewDidReceiveSnapshot(WebKitWebView*, uint64_t callbackID, WebKit::WebImage*); -void webkitWebViewRemoveLoadingWebResource(WebKitWebView*, uint64_t resourceIdentifier); -bool webkitWebViewEnterFullScreen(WebKitWebView*); -bool webkitWebViewLeaveFullScreen(WebKitWebView*); -void webkitWebViewPopulateContextMenu(WebKitWebView*, WebKit::ImmutableArray* proposedMenu, WebKit::WebHitTestResult*); -void webkitWebViewSubmitFormRequest(WebKitWebView*, WebKitFormSubmissionRequest*); -void webkitWebViewHandleAuthenticationChallenge(WebKitWebView*, WebKit::AuthenticationChallengeProxy*); -void webkitWebViewInsecureContentDetected(WebKitWebView*, WebKitInsecureContentEvent); -void webkitWebViewWebProcessCrashed(WebKitWebView*); - -#endif // WebKitWebViewPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.cpp deleted file mode 100644 index bdfc72589..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.cpp +++ /dev/null @@ -1,545 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 "WebKitWindowProperties.h" - -#include "ImmutableDictionary.h" -#include "WebKitPrivate.h" -#include "WebKitWindowPropertiesPrivate.h" -#include "WebNumber.h" -#include "WebURLRequest.h" -#include <WebCore/IntRect.h> -#include <glib/gi18n-lib.h> - -using namespace WebKit; -using namespace WebCore; - -/** - * SECTION: WebKitWindowProperties - * @short_description: Window properties of a #WebKitWebView - * @title: WebKitWindowProperties - * @see_also: #WebKitWebView::ready-to-show - * - * The content of a #WebKitWebView can request to change certain - * properties of the window containing the view. This can include the x, y position - * of the window, the width and height but also if a toolbar, - * scrollbar, statusbar, locationbar should be visible to the user, - * and the request to show the #WebKitWebView fullscreen. - * - * The #WebKitWebView::ready-to-show signal handler is the proper place - * to apply the initial window properties. Then you can monitor the - * #WebKitWindowProperties by connecting to ::notify signal. - * - * <informalexample><programlisting> - * static void ready_to_show_cb (WebKitWebView *web_view, gpointer user_data) - * { - * GtkWidget *window; - * WebKitWindowProperties *window_properties; - * gboolean visible; - * - * /<!-- -->* Create the window to contain the WebKitWebView *<!-- -->/ - * window = browser_window_new (); - * gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (web_view)); - * gtk_widget_show (GTK_WIDGET (web_view)); - * - * /<!-- -->* Get the WebKitWindowProperties of the web view and monitor it *<!-- -->/ - * window_properties = webkit_web_view_get_window_properties (web_view); - * g_signal_connect (window_properties, "notify::geometry", - * G_CALLBACK (window_geometry_changed), window); - * g_signal_connect (window_properties, "notify::toolbar-visible", - * G_CALLBACK (window_toolbar_visibility_changed), window); - * g_signal_connect (window_properties, "notify::menubar-visible", - * G_CALLBACK (window_menubar_visibility_changed), window); - * .... - * - * /<!-- -->* Apply the window properties before showing the window *<!-- -->/ - * visible = webkit_window_properties_get_toolbar_visible (window_properties); - * browser_window_set_toolbar_visible (BROWSER_WINDOW (window), visible); - * visible = webkit_window_properties_get_menubar_visible (window_properties); - * browser_window_set_menubar_visible (BROWSER_WINDOW (window), visible); - * .... - * - * if (webkit_window_properties_get_fullscreen (window_properties)) { - * gtk_window_fullscreen (GTK_WINDOW (window)); - * } else { - * GdkRectangle geometry; - * - * gtk_window_set_resizable (GTK_WINDOW (window), - * webkit_window_properties_get_resizable (window_properties)); - * webkit_window_properties_get_geometry (window_properties, &geometry); - * gtk_window_move (GTK_WINDOW (window), geometry.x, geometry.y); - * gtk_window_resize (GTK_WINDOW (window), geometry.width, geometry.height); - * } - * - * gtk_widget_show (window); - * } - * </programlisting></informalexample> - */ - -enum { - PROP_0, - - PROP_GEOMETRY, - PROP_TOOLBAR_VISIBLE, - PROP_STATUSBAR_VISIBLE, - PROP_SCROLLBARS_VISIBLE, - PROP_MENUBAR_VISIBLE, - PROP_LOCATIONBAR_VISIBLE, - PROP_RESIZABLE, - PROP_FULLSCREEN -}; - -struct _WebKitWindowPropertiesPrivate { - GdkRectangle geometry; - - bool toolbarVisible : 1; - bool statusbarVisible : 1; - bool scrollbarsVisible : 1; - bool menubarVisible : 1; - bool locationbarVisible : 1; - - bool resizable : 1; - bool fullscreen : 1; -}; - -WEBKIT_DEFINE_TYPE(WebKitWindowProperties, webkit_window_properties, G_TYPE_OBJECT) - -static void webkitWindowPropertiesGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) -{ - WebKitWindowProperties* windowProperties = WEBKIT_WINDOW_PROPERTIES(object); - - switch (propId) { - case PROP_GEOMETRY: - g_value_set_boxed(value, &windowProperties->priv->geometry); - break; - case PROP_TOOLBAR_VISIBLE: - g_value_set_boolean(value, webkit_window_properties_get_toolbar_visible(windowProperties)); - break; - case PROP_STATUSBAR_VISIBLE: - g_value_set_boolean(value, webkit_window_properties_get_statusbar_visible(windowProperties)); - break; - case PROP_SCROLLBARS_VISIBLE: - g_value_set_boolean(value, webkit_window_properties_get_scrollbars_visible(windowProperties)); - break; - case PROP_MENUBAR_VISIBLE: - g_value_set_boolean(value, webkit_window_properties_get_menubar_visible(windowProperties)); - break; - case PROP_LOCATIONBAR_VISIBLE: - g_value_set_boolean(value, webkit_window_properties_get_locationbar_visible(windowProperties)); - break; - case PROP_RESIZABLE: - g_value_set_boolean(value, webkit_window_properties_get_resizable(windowProperties)); - break; - case PROP_FULLSCREEN: - g_value_set_boolean(value, webkit_window_properties_get_fullscreen(windowProperties)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static void webkitWindowPropertiesSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec) -{ - WebKitWindowProperties* windowProperties = WEBKIT_WINDOW_PROPERTIES(object); - - switch (propId) { - case PROP_GEOMETRY: - if (GdkRectangle* geometry = static_cast<GdkRectangle*>(g_value_get_boxed(value))) - windowProperties->priv->geometry = *geometry; - break; - case PROP_TOOLBAR_VISIBLE: - windowProperties->priv->toolbarVisible = g_value_get_boolean(value); - break; - case PROP_STATUSBAR_VISIBLE: - windowProperties->priv->statusbarVisible = g_value_get_boolean(value); - break; - case PROP_SCROLLBARS_VISIBLE: - windowProperties->priv->scrollbarsVisible = g_value_get_boolean(value); - break; - case PROP_MENUBAR_VISIBLE: - windowProperties->priv->menubarVisible = g_value_get_boolean(value); - break; - case PROP_LOCATIONBAR_VISIBLE: - windowProperties->priv->locationbarVisible = g_value_get_boolean(value); - break; - case PROP_RESIZABLE: - windowProperties->priv->resizable = g_value_get_boolean(value); - break; - case PROP_FULLSCREEN: - windowProperties->priv->fullscreen = g_value_get_boolean(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); - } -} - -static void webkit_window_properties_class_init(WebKitWindowPropertiesClass* requestClass) -{ - GObjectClass* objectClass = G_OBJECT_CLASS(requestClass); - objectClass->get_property = webkitWindowPropertiesGetProperty; - objectClass->set_property = webkitWindowPropertiesSetProperty; - - GParamFlags paramFlags = static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); - - /** - * WebKitWebWindowProperties:geometry: - * - * The size and position of the window on the screen. - */ - g_object_class_install_property(objectClass, - PROP_GEOMETRY, - g_param_spec_boxed("geometry", - _("Geometry"), - _("The size and position of the window on the screen."), - GDK_TYPE_RECTANGLE, - paramFlags)); - - /** - * WebKitWebWindowProperties:toolbar-visible: - * - * Whether the toolbar should be visible for the window. - */ - g_object_class_install_property(objectClass, - PROP_TOOLBAR_VISIBLE, - g_param_spec_boolean("toolbar-visible", - _("Toolbar Visible"), - _("Whether the toolbar should be visible for the window."), - TRUE, - paramFlags)); - - /** - * WebKitWebWindowProperties:statusbar-visible: - * - * Whether the statusbar should be visible for the window. - */ - g_object_class_install_property(objectClass, - PROP_STATUSBAR_VISIBLE, - g_param_spec_boolean("statusbar-visible", - _("Statusbar Visible"), - _("Whether the statusbar should be visible for the window."), - TRUE, - paramFlags)); - - /** - * WebKitWebWindowProperties:scrollbars-visible: - * - * Whether the scrollbars should be visible for the window. - */ - g_object_class_install_property(objectClass, - PROP_SCROLLBARS_VISIBLE, - g_param_spec_boolean("scrollbars-visible", - _("Scrollbars Visible"), - _("Whether the scrollbars should be visible for the window."), - TRUE, - paramFlags)); - - /** - * WebKitWebWindowProperties:menubar-visible: - * - * Whether the menubar should be visible for the window. - */ - g_object_class_install_property(objectClass, - PROP_MENUBAR_VISIBLE, - g_param_spec_boolean("menubar-visible", - _("Menubar Visible"), - _("Whether the menubar should be visible for the window."), - TRUE, - paramFlags)); - - /** - * WebKitWebWindowProperties:locationbar-visible: - * - * Whether the locationbar should be visible for the window. - */ - g_object_class_install_property(objectClass, - PROP_LOCATIONBAR_VISIBLE, - g_param_spec_boolean("locationbar-visible", - _("Locationbar Visible"), - _("Whether the locationbar should be visible for the window."), - TRUE, - paramFlags)); - /** - * WebKitWebWindowProperties:resizable: - * - * Whether the window can be resized. - */ - g_object_class_install_property(objectClass, - PROP_RESIZABLE, - g_param_spec_boolean("resizable", - _("Resizable"), - _("Whether the window can be resized."), - TRUE, - paramFlags)); - - /** - * WebKitWebWindowProperties:fullscreen: - * - * Whether window will be displayed fullscreen. - */ - g_object_class_install_property(objectClass, - PROP_FULLSCREEN, - g_param_spec_boolean("fullscreen", - _("Fullscreen"), - _("Whether window will be displayed fullscreen."), - FALSE, - paramFlags)); -} - -WebKitWindowProperties* webkitWindowPropertiesCreate() -{ - return WEBKIT_WINDOW_PROPERTIES(g_object_new(WEBKIT_TYPE_WINDOW_PROPERTIES, NULL)); -} - -void webkitWindowPropertiesSetGeometry(WebKitWindowProperties* windowProperties, GdkRectangle* geometry) -{ - if (windowProperties->priv->geometry.x == geometry->x - && windowProperties->priv->geometry.y == geometry->y - && windowProperties->priv->geometry.width == geometry->width - && windowProperties->priv->geometry.height == geometry->height) - return; - windowProperties->priv->geometry = *geometry; - g_object_notify(G_OBJECT(windowProperties), "geometry"); -} - -void webkitWindowPropertiesSetToolbarVisible(WebKitWindowProperties* windowProperties, bool toolbarsVisible) -{ - if (windowProperties->priv->toolbarVisible == toolbarsVisible) - return; - windowProperties->priv->toolbarVisible = toolbarsVisible; - g_object_notify(G_OBJECT(windowProperties), "toolbar-visible"); -} - -void webkitWindowPropertiesSetMenubarVisible(WebKitWindowProperties* windowProperties, bool menuBarVisible) -{ - if (windowProperties->priv->menubarVisible == menuBarVisible) - return; - windowProperties->priv->menubarVisible = menuBarVisible; - g_object_notify(G_OBJECT(windowProperties), "menubar-visible"); -} - -void webkitWindowPropertiesSetStatusbarVisible(WebKitWindowProperties* windowProperties, bool statusBarVisible) -{ - if (windowProperties->priv->statusbarVisible == statusBarVisible) - return; - windowProperties->priv->statusbarVisible = statusBarVisible; - g_object_notify(G_OBJECT(windowProperties), "statusbar-visible"); -} - -void webkitWindowPropertiesSetLocationbarVisible(WebKitWindowProperties* windowProperties, bool locationBarVisible) -{ - if (windowProperties->priv->locationbarVisible == locationBarVisible) - return; - windowProperties->priv->locationbarVisible = locationBarVisible; - g_object_notify(G_OBJECT(windowProperties), "locationbar-visible"); -} - -void webkitWindowPropertiesSetScrollbarsVisible(WebKitWindowProperties* windowProperties, bool scrollBarsVisible) -{ - if (windowProperties->priv->scrollbarsVisible == scrollBarsVisible) - return; - windowProperties->priv->scrollbarsVisible = scrollBarsVisible; - g_object_notify(G_OBJECT(windowProperties), "scrollbars-visible"); -} - -void webkitWindowPropertiesSetResizable(WebKitWindowProperties* windowProperties, bool resizable) -{ - if (windowProperties->priv->resizable == resizable) - return; - windowProperties->priv->resizable = resizable; - g_object_notify(G_OBJECT(windowProperties), "resizable"); -} - -void webkitWindowPropertiesSetFullscreen(WebKitWindowProperties* windowProperties, bool fullscreen) -{ - if (windowProperties->priv->fullscreen == fullscreen) - return; - windowProperties->priv->fullscreen = fullscreen; - g_object_notify(G_OBJECT(windowProperties), "fullscreen"); -} - -void webkitWindowPropertiesUpdateFromWebWindowFeatures(WebKitWindowProperties* windowProperties, ImmutableDictionary* features) -{ - GdkRectangle geometry = windowProperties->priv->geometry; - - WebDouble* doubleValue = static_cast<WebDouble*>(features->get("x")); - if (doubleValue) - geometry.x = doubleValue->value(); - - doubleValue = static_cast<WebDouble*>(features->get("y")); - if (doubleValue) - geometry.y = doubleValue->value(); - - doubleValue = static_cast<WebDouble*>(features->get("width")); - if (doubleValue) - geometry.width = doubleValue->value(); - - doubleValue = static_cast<WebDouble*>(features->get("height")); - if (doubleValue) - geometry.height = doubleValue->value(); - webkitWindowPropertiesSetGeometry(windowProperties, &geometry); - - WebBoolean* booleanValue = static_cast<WebBoolean*>(features->get("menuBarVisible")); - if (booleanValue) - webkitWindowPropertiesSetMenubarVisible(windowProperties, booleanValue->value()); - - booleanValue = static_cast<WebBoolean*>(features->get("statusBarVisible")); - if (booleanValue) - webkitWindowPropertiesSetStatusbarVisible(windowProperties, booleanValue->value()); - - booleanValue = static_cast<WebBoolean*>(features->get("toolBarVisible")); - if (booleanValue) - webkitWindowPropertiesSetToolbarVisible(windowProperties, booleanValue->value()); - - booleanValue = static_cast<WebBoolean*>(features->get("locationBarVisible")); - if (booleanValue) - webkitWindowPropertiesSetLocationbarVisible(windowProperties, booleanValue->value()); - - booleanValue = static_cast<WebBoolean*>(features->get("scrollbarsVisible")); - if (booleanValue) - webkitWindowPropertiesSetScrollbarsVisible(windowProperties, booleanValue->value()); - - booleanValue = static_cast<WebBoolean*>(features->get("resizable")); - if (booleanValue) - webkitWindowPropertiesSetResizable(windowProperties, booleanValue->value()); - - booleanValue = static_cast<WebBoolean*>(features->get("fullscreen")); - if (booleanValue) - webkitWindowPropertiesSetFullscreen(windowProperties, booleanValue->value()); -} - -/** - * webkit_window_properties_get_geometry: - * @window_properties: a #WebKitWindowProperties - * @geometry: (out): return location for the window geometry - * - * Get the geometry the window should have on the screen when shown. - */ -void webkit_window_properties_get_geometry(WebKitWindowProperties* windowProperties, GdkRectangle* geometry) -{ - g_return_if_fail(WEBKIT_IS_WINDOW_PROPERTIES(windowProperties)); - g_return_if_fail(geometry); - - *geometry = windowProperties->priv->geometry; -} - -/** - * webkit_window_properties_get_toolbar_visible: - * @window_properties: a #WebKitWindowProperties - * - * Get whether the window should have the toolbar visible or not. - * - * Returns: %TRUE if toolbar should be visible or %FALSE otherwise. - */ -gboolean webkit_window_properties_get_toolbar_visible(WebKitWindowProperties* windowProperties) -{ - g_return_val_if_fail(WEBKIT_IS_WINDOW_PROPERTIES(windowProperties), TRUE); - - return windowProperties->priv->toolbarVisible; -} - -/** - * webkit_window_properties_get_statusbar_visible: - * @window_properties: a #WebKitWindowProperties - * - * Get whether the window should have the statusbar visible or not. - * - * Returns: %TRUE if statusbar should be visible or %FALSE otherwise. - */ -gboolean webkit_window_properties_get_statusbar_visible(WebKitWindowProperties* windowProperties) -{ - g_return_val_if_fail(WEBKIT_IS_WINDOW_PROPERTIES(windowProperties), TRUE); - - return windowProperties->priv->statusbarVisible; -} - -/** - * webkit_window_properties_get_scrollbars_visible: - * @window_properties: a #WebKitWindowProperties - * - * Get whether the window should have the scrollbars visible or not. - * - * Returns: %TRUE if scrollbars should be visible or %FALSE otherwise. - */ -gboolean webkit_window_properties_get_scrollbars_visible(WebKitWindowProperties* windowProperties) -{ - g_return_val_if_fail(WEBKIT_IS_WINDOW_PROPERTIES(windowProperties), TRUE); - - return windowProperties->priv->scrollbarsVisible; -} - -/** - * webkit_window_properties_get_menubar_visible: - * @window_properties: a #WebKitWindowProperties - * - * Get whether the window should have the menubar visible or not. - * - * Returns: %TRUE if menubar should be visible or %FALSE otherwise. - */ -gboolean webkit_window_properties_get_menubar_visible(WebKitWindowProperties* windowProperties) -{ - g_return_val_if_fail(WEBKIT_IS_WINDOW_PROPERTIES(windowProperties), TRUE); - - return windowProperties->priv->menubarVisible; -} - -/** - * webkit_window_properties_get_locationbar_visible: - * @window_properties: a #WebKitWindowProperties - * - * Get whether the window should have the locationbar visible or not. - * - * Returns: %TRUE if locationbar should be visible or %FALSE otherwise. - */ -gboolean webkit_window_properties_get_locationbar_visible(WebKitWindowProperties* windowProperties) -{ - g_return_val_if_fail(WEBKIT_IS_WINDOW_PROPERTIES(windowProperties), TRUE); - - return windowProperties->priv->locationbarVisible; -} - -/** - * webkit_window_properties_get_resizable: - * @window_properties: a #WebKitWindowProperties - * - * Get whether the window should be resizable by the user or not. - * - * Returns: %TRUE if the window should be resizable or %FALSE otherwise. - */ -gboolean webkit_window_properties_get_resizable(WebKitWindowProperties* windowProperties) -{ - g_return_val_if_fail(WEBKIT_IS_WINDOW_PROPERTIES(windowProperties), TRUE); - - return windowProperties->priv->resizable; -} - -/** - * webkit_window_properties_get_fullscreen: - * @window_properties: a #WebKitWindowProperties - * - * Get whether the window should be shown in fullscreen state or not. - * - * Returns: %TRUE if the window should be fullscreen or %FALSE otherwise. - */ -gboolean webkit_window_properties_get_fullscreen(WebKitWindowProperties* windowProperties) -{ - g_return_val_if_fail(WEBKIT_IS_WINDOW_PROPERTIES(windowProperties), FALSE); - - return windowProperties->priv->fullscreen; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.h deleted file mode 100644 index edbcee98d..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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. - */ - -#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) -#error "Only <webkit2/webkit2.h> can be included directly." -#endif - -#ifndef WebKitWindowProperties_h -#define WebKitWindowProperties_h - -#include <glib-object.h> -#include <gtk/gtk.h> -#include <webkit2/WebKitDefines.h> - -G_BEGIN_DECLS - -#define WEBKIT_TYPE_WINDOW_PROPERTIES (webkit_window_properties_get_type()) -#define WEBKIT_WINDOW_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WINDOW_PROPERTIES, WebKitWindowProperties)) -#define WEBKIT_IS_WINDOW_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WINDOW_PROPERTIES)) -#define WEBKIT_WINDOW_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WINDOW_PROPERTIES, WebKitWindowPropertiesClass)) -#define WEBKIT_IS_WINDOW_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WINDOW_PROPERTIES)) -#define WEBKIT_WINDOW_PROPERTIES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WINDOW_PROPERTIES, WebKitWindowPropertiesClass)) - -typedef struct _WebKitWindowProperties WebKitWindowProperties; -typedef struct _WebKitWindowPropertiesClass WebKitWindowPropertiesClass; -typedef struct _WebKitWindowPropertiesPrivate WebKitWindowPropertiesPrivate; - -struct _WebKitWindowProperties { - GObject parent; - - /*< private >*/ - WebKitWindowPropertiesPrivate *priv; -}; - -struct _WebKitWindowPropertiesClass { - GObjectClass parent_class; - - void (*_webkit_reserved0) (void); - void (*_webkit_reserved1) (void); - void (*_webkit_reserved2) (void); - void (*_webkit_reserved3) (void); -}; - -WEBKIT_API GType -webkit_window_properties_get_type (void); - -WEBKIT_API void -webkit_window_properties_get_geometry (WebKitWindowProperties *window_properties, - GdkRectangle *geometry); -WEBKIT_API gboolean -webkit_window_properties_get_toolbar_visible (WebKitWindowProperties *window_properties); - -WEBKIT_API gboolean -webkit_window_properties_get_statusbar_visible (WebKitWindowProperties *window_properties); - -WEBKIT_API gboolean -webkit_window_properties_get_scrollbars_visible (WebKitWindowProperties *window_properties); - -WEBKIT_API gboolean -webkit_window_properties_get_menubar_visible (WebKitWindowProperties *window_properties); - -WEBKIT_API gboolean -webkit_window_properties_get_locationbar_visible (WebKitWindowProperties *window_properties); - -WEBKIT_API gboolean -webkit_window_properties_get_resizable (WebKitWindowProperties *window_properties); - -WEBKIT_API gboolean -webkit_window_properties_get_fullscreen (WebKitWindowProperties *window_properties); - -G_END_DECLS - -#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWindowPropertiesPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWindowPropertiesPrivate.h deleted file mode 100644 index 8ec17b4ea..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWindowPropertiesPrivate.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * Portions Copyright (c) 2011 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 WebKitWindowPropertiesPrivate_h -#define WebKitWindowPropertiesPrivate_h - -#include "WebKitPrivate.h" -#include "WebKitWindowProperties.h" - -WebKitWindowProperties* webkitWindowPropertiesCreate(); -void webkitWindowPropertiesUpdateFromWebWindowFeatures(WebKitWindowProperties*, WebKit::ImmutableDictionary* features); -void webkitWindowPropertiesSetGeometry(WebKitWindowProperties*, GdkRectangle*); -void webkitWindowPropertiesSetToolbarVisible(WebKitWindowProperties*, bool toolbarsVisible); -void webkitWindowPropertiesSetMenubarVisible(WebKitWindowProperties*, bool menuBarVisible); -void webkitWindowPropertiesSetStatusbarVisible(WebKitWindowProperties*, bool statusBarVisible); -void webkitWindowPropertiesSetScrollbarsVisible(WebKitWindowProperties*, bool scrollBarsVisible); -void webkitWindowPropertiesSetResizable(WebKitWindowProperties*, bool resizable); -void webkitWindowPropertiesSetFullscreen(WebKitWindowProperties*, bool fullscreen); - -#endif // WebKitWindowPropertiesPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebViewBaseInputMethodFilter.cpp b/Source/WebKit2/UIProcess/API/gtk/WebViewBaseInputMethodFilter.cpp deleted file mode 100644 index 8b87c1522..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebViewBaseInputMethodFilter.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebViewBaseInputMethodFilter.h" - -#include "NativeWebKeyboardEvent.h" -#include "WebKitWebViewBasePrivate.h" -#include "WebPageProxy.h" -#include <WebCore/Color.h> -#include <WebCore/CompositionResults.h> -#include <WebCore/Editor.h> - -using namespace WebCore; - -namespace WebKit { - -void WebViewBaseInputMethodFilter::setWebView(WebKitWebViewBase* webView) -{ - GtkInputMethodFilter::setWidget(GTK_WIDGET(webView)); - - m_webPageProxy = webkitWebViewBaseGetPage(webView); - ASSERT(m_webPageProxy); -} - -bool WebViewBaseInputMethodFilter::canEdit() -{ - return true; -} - -bool WebViewBaseInputMethodFilter::sendSimpleKeyEvent(GdkEventKey* event, WTF::String simpleString, EventFakedForComposition faked) -{ - ASSERT(m_webPageProxy); - m_webPageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event), - CompositionResults(simpleString), faked)); - return true; -} - -bool WebViewBaseInputMethodFilter::sendKeyEventWithCompositionResults(GdkEventKey* event, ResultsToSend resultsToSend, EventFakedForComposition faked) -{ - ASSERT(m_webPageProxy); - m_webPageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event), - CompositionResults(CompositionResults::WillSendCompositionResultsSoon), - faked)); - - if (resultsToSend & Composition && !m_confirmedComposition.isNull()) - confirmCompositionText(m_confirmedComposition); - if (resultsToSend & Preedit && !m_preedit.isNull()) - setPreedit(m_preedit, m_cursorOffset); - return true; -} - -void WebViewBaseInputMethodFilter::confirmCompositionText(String text) -{ - ASSERT(m_webPageProxy); - m_webPageProxy->confirmComposition(text, -1, 0); -} - -void WebViewBaseInputMethodFilter::confirmCurrentComposition() -{ - ASSERT(m_webPageProxy); - m_webPageProxy->confirmComposition(String(), -1, 0); -} - -void WebViewBaseInputMethodFilter::cancelCurrentComposition() -{ - ASSERT(m_webPageProxy); - m_webPageProxy->cancelComposition(); -} - -void WebViewBaseInputMethodFilter::setPreedit(String newPreedit, int cursorOffset) -{ - // TODO: We should parse the PangoAttrList that we get from the IM context here. - Vector<CompositionUnderline> underlines; - underlines.append(CompositionUnderline(0, newPreedit.length(), Color(1, 1, 1), false)); - - ASSERT(m_webPageProxy); - m_webPageProxy->setComposition(newPreedit, underlines, - m_cursorOffset, m_cursorOffset, - 0 /* replacement start */, - 0 /* replacement end */); -} - -} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/API/gtk/WebViewBaseInputMethodFilter.h b/Source/WebKit2/UIProcess/API/gtk/WebViewBaseInputMethodFilter.h deleted file mode 100644 index 9cde8b12d..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/WebViewBaseInputMethodFilter.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebViewBaseInputMethodFilter_h -#define WebViewBaseInputMethodFilter_h - -#include "GtkInputMethodFilter.h" -#include "WebPageProxy.h" - -typedef struct _WebKitWebViewBase WebKitWebViewBase; - -namespace WebKit { - -class WebViewBaseInputMethodFilter : public WebCore::GtkInputMethodFilter { -public: - void setWebView(WebKitWebViewBase*); - -protected: - virtual bool sendSimpleKeyEvent(GdkEventKey*, WTF::String eventString, EventFakedForComposition); - virtual bool sendKeyEventWithCompositionResults(GdkEventKey*, ResultsToSend, EventFakedForComposition); - virtual bool canEdit(); - virtual void confirmCompositionText(String); - virtual void confirmCurrentComposition(); - virtual void cancelCurrentComposition(); - virtual void setPreedit(String, int cursorOffset); - -private: - WebPageProxy* m_webPageProxy; -}; - -} // namespace WebKit - -#endif // WebViewBaseInputMethodFilter_h diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml deleted file mode 100644 index 2fa7ebacf..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" - "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [ -<!ENTITY version SYSTEM "version.xml"> -]> -<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude"> - <bookinfo> - <title>WebKit2GTK+ Reference Manual</title> - <releaseinfo>for WebKit2GTK+ &version;</releaseinfo> - </bookinfo> - - <chapter> - <title>Class Overview</title> - <xi:include href="xml/WebKitWebContext.xml"/> - <xi:include href="xml/WebKitWebView.xml"/> - <xi:include href="xml/WebKitBackForwardList.xml"/> - <xi:include href="xml/WebKitBackForwardListItem.xml"/> - <xi:include href="xml/WebKitSettings.xml"/> - <xi:include href="xml/WebKitURIRequest.xml"/> - <xi:include href="xml/WebKitURIResponse.xml"/> - <xi:include href="xml/WebKitWindowProperties.xml"/> - <xi:include href="xml/WebKitDownload.xml"/> - <xi:include href="xml/WebKitPermissionRequest.xml"/> - <xi:include href="xml/WebKitGeolocationPermissionRequest.xml"/> - <xi:include href="xml/WebKitPolicyDecision.xml"/> - <xi:include href="xml/WebKitNavigationPolicyDecision.xml"/> - <xi:include href="xml/WebKitResponsePolicyDecision.xml"/> - <xi:include href="xml/WebKitHitTestResult.xml"/> - <xi:include href="xml/WebKitPrintOperation.xml"/> - <xi:include href="xml/WebKitWebResource.xml"/> - <xi:include href="xml/WebKitError.xml"/> - <xi:include href="xml/WebKitFaviconDatabase.xml"/> - <xi:include href="xml/WebKitFileChooserRequest.xml"/> - <xi:include href="xml/WebKitFindController.xml"/> - <xi:include href="xml/WebKitCookieManager.xml"/> - <xi:include href="xml/WebKitPlugin.xml"/> - <xi:include href="xml/WebKitWebInspector.xml"/> - <xi:include href="xml/WebKitURISchemeRequest.xml"/> - <xi:include href="xml/WebKitVersion.xml"/> - <xi:include href="xml/WebKitContextMenu.xml"/> - <xi:include href="xml/WebKitContextMenuItem.xml"/> - <xi:include href="xml/WebKitFormSubmissionRequest.xml"/> - <xi:include href="xml/WebKitSecurityManager.xml"/> - <xi:include href="xml/WebKitWebViewGroup.xml"/> - </chapter> - - <chapter> - <title>Web Extensions</title> - <xi:include href="xml/WebKitWebExtension.xml"/> - <xi:include href="xml/WebKitWebPage.xml"/> - </chapter> - - <index id="index-all"> - <title>Index</title> - </index> - <xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include> -</book> diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt deleted file mode 100644 index f280c62df..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt +++ /dev/null @@ -1,1014 +0,0 @@ -<SECTION> -<FILE>WebKitWebViewBase</FILE> -<TITLE>WebKitWebViewBase</TITLE> -WebKitWebViewBase - -<SUBSECTION Standard> -WebKitWebViewBaseClass -WEBKIT_WEB_VIEW_BASE -WEBKIT_IS_WEB_VIEW_BASE -WEBKIT_TYPE_WEB_VIEW_BASE -WEBKIT_WEB_VIEW_BASE_CLASS -WEBKIT_IS_WEB_VIEW_BASE_CLASS -WEBKIT_WEB_VIEW_BASE_GET_CLASS - -<SUBSECTION Private> -webkit_web_view_base_get_type -WebKitWebViewBasePrivate -WEBKIT_API -WEBKIT_OBSOLETE_API -</SECTION> - -<SECTION> -<FILE>WebKitWebContext</FILE> -<TITLE>WebKitWebContext</TITLE> -WebKitWebContext -WebKitCacheModel -WebKitTLSErrorsPolicy -webkit_web_context_get_default -webkit_web_context_get_cache_model -webkit_web_context_set_cache_model -webkit_web_context_clear_cache -webkit_web_context_download_uri -webkit_web_context_get_cookie_manager -webkit_web_context_get_favicon_database -webkit_web_context_set_favicon_database_directory -webkit_web_context_get_favicon_database_directory -webkit_web_context_get_security_manager -webkit_web_context_set_additional_plugins_directory -webkit_web_context_get_plugins -webkit_web_context_get_plugins_finish -webkit_web_context_get_spell_checking_enabled -webkit_web_context_set_spell_checking_enabled -webkit_web_context_get_spell_checking_languages -webkit_web_context_set_spell_checking_languages -webkit_web_context_set_preferred_languages -webkit_web_context_set_tls_errors_policy -webkit_web_context_get_tls_errors_policy -webkit_web_context_set_web_extensions_directory -webkit_web_context_prefetch_dns -webkit_web_context_set_disk_cache_directory - -<SUBSECTION URI Scheme> -WebKitURISchemeRequestCallback -webkit_web_context_register_uri_scheme - -<SUBSECTION Standard> -WebKitWebContextClass -WEBKIT_WEB_CONTEXT -WEBKIT_IS_WEB_CONTEXT -WEBKIT_TYPE_WEB_CONTEXT -WEBKIT_WEB_CONTEXT_CLASS -WEBKIT_IS_WEB_CONTEXT_CLASS -WEBKIT_WEB_CONTEXT_GET_CLASS - -<SUBSECTION Private> -WebKitWebContextPrivate -webkit_web_context_get_type -</SECTION> - -<SECTION> -<FILE>WebKitWebView</FILE> -<TITLE>WebKitWebView</TITLE> -WebKitWebView -WebKitLoadEvent -WebKitPolicyDecisionType -WebKitSaveMode -WebKitViewMode -WebKitInsecureContentEvent -WebKitSnapshotOptions -WebKitSnapshotRegion - -<SUBSECTION Editing Commands> -WEBKIT_EDITING_COMMAND_CUT -WEBKIT_EDITING_COMMAND_COPY -WEBKIT_EDITING_COMMAND_PASTE -WEBKIT_EDITING_COMMAND_SELECT_ALL -WEBKIT_EDITING_COMMAND_UNDO -WEBKIT_EDITING_COMMAND_REDO - -<SUBSECTION> -webkit_web_view_new -webkit_web_view_new_with_context -webkit_web_view_new_with_group -webkit_web_view_get_context -webkit_web_view_get_group -webkit_web_view_load_uri -webkit_web_view_load_html -webkit_web_view_load_alternate_html -webkit_web_view_load_plain_text -webkit_web_view_load_request -webkit_web_view_can_go_back -webkit_web_view_go_back -webkit_web_view_can_go_forward -webkit_web_view_go_forward -webkit_web_view_get_title -webkit_web_view_get_page_id -webkit_web_view_reload -webkit_web_view_reload_bypass_cache -webkit_web_view_stop_loading -webkit_web_view_is_loading -webkit_web_view_get_estimated_load_progress -webkit_web_view_get_custom_charset -webkit_web_view_set_custom_charset -webkit_web_view_get_back_forward_list -webkit_web_view_go_to_back_forward_list_item -webkit_web_view_get_uri -webkit_web_view_get_favicon -webkit_web_view_set_settings -webkit_web_view_get_settings -webkit_web_view_get_window_properties -webkit_web_view_set_zoom_level -webkit_web_view_get_zoom_level -webkit_web_view_can_execute_editing_command -webkit_web_view_can_execute_editing_command_finish -webkit_web_view_execute_editing_command -webkit_web_view_get_find_controller -webkit_web_view_get_inspector -webkit_web_view_get_javascript_global_context -webkit_web_view_run_javascript -webkit_web_view_run_javascript_finish -webkit_web_view_run_javascript_from_gresource -webkit_web_view_run_javascript_from_gresource_finish -webkit_web_view_can_show_mime_type -webkit_web_view_save -webkit_web_view_save_finish -webkit_web_view_save_to_file -webkit_web_view_save_to_file_finish -webkit_web_view_download_uri -webkit_web_view_set_view_mode -webkit_web_view_get_view_mode -webkit_web_view_get_tls_info -webkit_web_view_get_snapshot -webkit_web_view_get_snapshot_finish - -<SUBSECTION WebKitJavascriptResult> -WebKitJavascriptResult -webkit_javascript_result_ref -webkit_javascript_result_unref -webkit_javascript_result_get_global_context -webkit_javascript_result_get_value - -<SUBSECTION WebKitScriptDialog> -WebKitScriptDialog -WebKitScriptDialogType -webkit_script_dialog_get_dialog_type -webkit_script_dialog_get_message -webkit_script_dialog_confirm_set_confirmed -webkit_script_dialog_prompt_get_default_text -webkit_script_dialog_prompt_set_text -webkit_web_view_get_main_resource - -<SUBSECTION Standard> -WebKitWebViewClass -WEBKIT_WEB_VIEW -WEBKIT_IS_WEB_VIEW -WEBKIT_TYPE_WEB_VIEW -WEBKIT_WEB_VIEW_CLASS -WEBKIT_IS_WEB_VIEW_CLASS -WEBKIT_WEB_VIEW_GET_CLASS -WEBKIT_TYPE_JAVASCRIPT_RESULT -WEBKIT_TYPE_SCRIPT_DIALOG - -<SUBSECTION Private> -webkit_web_view_get_type -webkit_javascript_result_get_type -webkit_script_dialog_get_type -WebKitWebViewPrivate -</SECTION> - -<SECTION> -<FILE>WebKitBackForwardList</FILE> -WebKitBackForwardList -webkit_back_forward_list_get_length -webkit_back_forward_list_get_current_item -webkit_back_forward_list_get_back_item -webkit_back_forward_list_get_forward_item -webkit_back_forward_list_get_nth_item -webkit_back_forward_list_get_back_list -webkit_back_forward_list_get_back_list_with_limit -webkit_back_forward_list_get_forward_list -webkit_back_forward_list_get_forward_list_with_limit - -<SUBSECTION Standard> -WebKitBackForwardListClass -WEBKIT_TYPE_BACK_FORWARD_LIST -WEBKIT_BACK_FORWARD_LIST -WEBKIT_IS_BACK_FORWARD_LIST -WEBKIT_BACK_FORWARD_LIST_CLASS -WEBKIT_IS_BACK_FORWARD_LIST_CLASS -WEBKIT_BACK_FORWARD_LIST_GET_CLASS - -<SUBSECTION Private> -WebKitBackForwardListPrivate -webkit_back_forward_list_get_type -</SECTION> - -<SECTION> -<FILE>WebKitBackForwardListItem</FILE> -WebKitBackForwardListItem -webkit_back_forward_list_item_get_title -webkit_back_forward_list_item_get_uri -webkit_back_forward_list_item_get_original_uri - -<SUBSECTION Standard> -WebKitBackForwardListItemClass -WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM -WEBKIT_BACK_FORWARD_LIST_ITEM -WEBKIT_IS_BACK_FORWARD_LIST_ITEM -WEBKIT_BACK_FORWARD_LIST_ITEM_CLASS -WEBKIT_IS_BACK_FORWARD_LIST_ITEM_CLASS -WEBKIT_BACK_FORWARD_LIST_ITEM_GET_CLASS - -<SUBSECTION Private> -WebKitBackForwardListItemPrivate -webkit_back_forward_list_item_get_type -</SECTION> - -<SECTION> -<FILE>WebKitSettings</FILE> -WebKitSettings -webkit_settings_new -webkit_settings_new_with_settings -webkit_settings_get_auto_load_images -webkit_settings_set_auto_load_images -webkit_settings_get_enable_frame_flattening -webkit_settings_set_enable_frame_flattening -webkit_settings_get_enable_html5_database -webkit_settings_set_enable_html5_database -webkit_settings_get_enable_html5_local_storage -webkit_settings_set_enable_html5_local_storage -webkit_settings_get_enable_hyperlink_auditing -webkit_settings_set_enable_hyperlink_auditing -webkit_settings_get_enable_java -webkit_settings_set_enable_java -webkit_settings_get_enable_javascript -webkit_settings_set_enable_javascript -webkit_settings_get_enable_offline_web_application_cache -webkit_settings_set_enable_offline_web_application_cache -webkit_settings_get_enable_plugins -webkit_settings_set_enable_plugins -webkit_settings_get_enable_xss_auditor -webkit_settings_set_enable_xss_auditor -webkit_settings_get_javascript_can_open_windows_automatically -webkit_settings_set_javascript_can_open_windows_automatically -webkit_settings_get_load_icons_ignoring_image_load_setting -webkit_settings_set_load_icons_ignoring_image_load_setting -webkit_settings_get_default_font_family -webkit_settings_set_default_font_family -webkit_settings_get_monospace_font_family -webkit_settings_set_monospace_font_family -webkit_settings_get_serif_font_family -webkit_settings_set_serif_font_family -webkit_settings_get_sans_serif_font_family -webkit_settings_set_sans_serif_font_family -webkit_settings_get_cursive_font_family -webkit_settings_set_cursive_font_family -webkit_settings_get_fantasy_font_family -webkit_settings_set_fantasy_font_family -webkit_settings_get_pictograph_font_family -webkit_settings_set_pictograph_font_family -webkit_settings_get_default_font_size -webkit_settings_set_default_font_size -webkit_settings_get_default_monospace_font_size -webkit_settings_set_default_monospace_font_size -webkit_settings_get_minimum_font_size -webkit_settings_set_minimum_font_size -webkit_settings_get_default_charset -webkit_settings_set_default_charset -webkit_settings_get_enable_private_browsing -webkit_settings_set_enable_private_browsing -webkit_settings_get_enable_developer_extras -webkit_settings_set_enable_developer_extras -webkit_settings_get_enable_resizable_text_areas -webkit_settings_set_enable_resizable_text_areas -webkit_settings_get_enable_tabs_to_links -webkit_settings_set_enable_tabs_to_links -webkit_settings_get_enable_dns_prefetching -webkit_settings_set_enable_dns_prefetching -webkit_settings_get_enable_caret_browsing -webkit_settings_set_enable_caret_browsing -webkit_settings_get_enable_fullscreen -webkit_settings_set_enable_fullscreen -webkit_settings_get_print_backgrounds -webkit_settings_set_print_backgrounds -webkit_settings_get_enable_webaudio -webkit_settings_set_enable_webaudio -webkit_settings_get_enable_webgl -webkit_settings_set_enable_webgl -webkit_settings_set_allow_modal_dialogs -webkit_settings_get_allow_modal_dialogs -webkit_settings_get_zoom_text_only -webkit_settings_set_zoom_text_only -webkit_settings_get_javascript_can_access_clipboard -webkit_settings_set_javascript_can_access_clipboard -webkit_settings_get_media_playback_requires_user_gesture -webkit_settings_set_media_playback_requires_user_gesture -webkit_settings_get_media_playback_allows_inline -webkit_settings_set_media_playback_allows_inline -webkit_settings_get_draw_compositing_indicators -webkit_settings_set_draw_compositing_indicators -webkit_settings_get_enable_site_specific_quirks -webkit_settings_set_enable_site_specific_quirks -webkit_settings_get_enable_page_cache -webkit_settings_set_enable_page_cache -webkit_settings_get_user_agent -webkit_settings_set_user_agent -webkit_settings_set_user_agent_with_application_details -webkit_settings_get_enable_smooth_scrolling -webkit_settings_set_enable_smooth_scrolling -webkit_settings_get_enable_accelerated_2d_canvas -webkit_settings_set_enable_accelerated_2d_canvas -webkit_settings_get_enable_write_console_messages_to_stdout -webkit_settings_set_enable_write_console_messages_to_stdout - -<SUBSECTION Standard> -WebKitSettingsClass -WEBKIT_TYPE_SETTINGS -WEBKIT_SETTINGS -WEBKIT_IS_SETTINGS -WEBKIT_SETTINGS_CLASS -WEBKIT_IS_SETTINGS_CLASS -WEBKIT_SETTINGS_GET_CLASS - -<SUBSECTION Private> -WebKitSettingsPrivate -webkit_settings_get_type -</SECTION> - -<SECTION> -<FILE>WebKitURIRequest</FILE> -WebKitURIRequest -webkit_uri_request_new -webkit_uri_request_get_uri -webkit_uri_request_set_uri -webkit_uri_request_get_http_headers - -<SUBSECTION Standard> -WebKitURIRequestClass -WEBKIT_TYPE_URI_REQUEST -WEBKIT_URI_REQUEST -WEBKIT_IS_URI_REQUEST -WEBKIT_URI_REQUEST_CLASS -WEBKIT_IS_URI_REQUEST_CLASS -WEBKIT_URI_REQUEST_GET_CLASS - -<SUBSECTION Private> -WebKitURIRequestPrivate -webkit_uri_request_get_type -</SECTION> - -<SECTION> -<FILE>WebKitURIResponse</FILE> -WebKitURIResponse -webkit_uri_response_get_uri -webkit_uri_response_get_status_code -webkit_uri_response_get_content_length -webkit_uri_response_get_mime_type -webkit_uri_response_get_suggested_filename - -<SUBSECTION Standard> -WebKitURIResponseClass -WEBKIT_TYPE_URI_RESPONSE -WEBKIT_URI_RESPONSE -WEBKIT_IS_URI_RESPONSE -WEBKIT_URI_RESPONSE_CLASS -WEBKIT_IS_URI_RESPONSE_CLASS -WEBKIT_URI_RESPONSE_GET_CLASS - -<SUBSECTION Private> -WebKitURIResponsePrivate -webkit_uri_response_get_type -</SECTION> - -<SECTION> -<FILE>WebKitWindowProperties</FILE> -WebKitWindowProperties -webkit_window_properties_get_geometry -webkit_window_properties_get_toolbar_visible -webkit_window_properties_get_statusbar_visible -webkit_window_properties_get_scrollbars_visible -webkit_window_properties_get_menubar_visible -webkit_window_properties_get_locationbar_visible -webkit_window_properties_get_resizable -webkit_window_properties_get_fullscreen - -<SUBSECTION Standard> -WebKitWindowPropertiesClass -WEBKIT_TYPE_WINDOW_PROPERTIES -WEBKIT_WINDOW_PROPERTIES -WEBKIT_IS_WINDOW_PROPERTIES -WEBKIT_WINDOW_PROPERTIES_CLASS -WEBKIT_IS_WINDOW_PROPERTIES_CLASS -WEBKIT_WINDOW_PROPERTIES_GET_CLASS - -<SUBSECTION Private> -WebKitWindowPropertiesPrivate -webkit_window_properties_get_type -</SECTION> - -<SECTION> -<FILE>WebKitDownload</FILE> -WebKitDownload -webkit_download_get_request -webkit_download_get_destination -webkit_download_set_destination -webkit_download_get_response -webkit_download_cancel -webkit_download_get_estimated_progress -webkit_download_get_elapsed_time -webkit_download_get_received_data_length -webkit_download_get_web_view - -<SUBSECTION Standard> -WebKitDownloadClass -WEBKIT_TYPE_DOWNLOAD -WEBKIT_DOWNLOAD -WEBKIT_IS_DOWNLOAD -WEBKIT_DOWNLOAD_CLASS -WEBKIT_IS_DOWNLOAD_CLASS -WEBKIT_DOWNLOAD_GET_CLASS - -<SUBSECTION Private> -WebKitDownloadPrivate -webkit_download_get_type -</SECTION> - -<SECTION> -<FILE>WebKitPermissionRequest</FILE> -WebKitPermissionRequest -webkit_permission_request_allow -webkit_permission_request_deny - -<SUBSECTION Standard> -WebKitPermissionRequestIface -WEBKIT_TYPE_PERMISSION_REQUEST -WEBKIT_PERMISSION_REQUEST -WEBKIT_IS_PERMISSION_REQUEST -WEBKIT_PERMISSION_REQUEST_GET_IFACE - -<SUBSECTION Private> -webkit_permission_request_get_type -</SECTION> - -<SECTION> -<FILE>WebKitGeolocationPermissionRequest</FILE> -WebKitGeolocationPermissionRequest - -<SUBSECTION Standard> -WebKitGeolocationPermissionRequestClass -WEBKIT_TYPE_GEOLOCATION_PERMISSION_REQUEST -WEBKIT_GEOLOCATION_PERMISSION_REQUEST -WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST -WEBKIT_GEOLOCATION_PERMISSION_REQUEST_CLASS -WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST_CLASS -WEBKIT_GEOLOCATION_PERMISSION_REQUEST_GET_CLASS - -<SUBSECTION Private> -WebKitGeolocationPermissionRequestPrivate -webkit_geolocation_permission_request_get_type -</SECTION> - -<SECTION> -<FILE>WebKitPolicyDecision</FILE> -WebKitPolicyDecision -webkit_policy_decision_download -webkit_policy_decision_ignore -webkit_policy_decision_use - -<SUBSECTION Standard> -WebKitPolicyDecisionClass -WEBKIT_TYPE_POLICY_DECISION -WEBKIT_POLICY_DECISION -WEBKIT_IS_POLICY_DECISION -WEBKIT_POLICY_DECISION_CLASS -WEBKIT_IS_POLICY_DECISION_CLASS -WEBKIT_POLICY_DECISION_GET_CLASS - -<SUBSECTION Private> -WebKitPolicyDecisionPrivate -webkit_policy_decision_get_type -</SECTION> - -<SECTION> -<FILE>WebKitNavigationPolicyDecision</FILE> -WebKitNavigationPolicyDecision -WebKitNavigationType -webkit_navigation_policy_decision_get_frame_name -webkit_navigation_policy_decision_get_modifiers -webkit_navigation_policy_decision_get_mouse_button -webkit_navigation_policy_decision_get_navigation_type -webkit_navigation_policy_decision_get_request - -<SUBSECTION Standard> -WebKitNavigationPolicyDecisionClass -WEBKIT_TYPE_NAVIGATION_POLICY_DECISION -WEBKIT_NAVIGATION_POLICY_DECISION -WEBKIT_IS_NAVIGATION_POLICY_DECISION -WEBKIT_NAVIGATION_POLICY_DECISION_CLASS -WEBKIT_IS_NAVIGATION_POLICY_DECISION_CLASS -WEBKIT_NAVIGATION_POLICY_DECISION_GET_CLASS - -<SUBSECTION Private> -WebKitNavigationPolicyDecisionPrivate -webkit_navigation_policy_decision_get_type -</SECTION> - -<SECTION> -<FILE>WebKitResponsePolicyDecision</FILE> -WebKitResponsePolicyDecision -webkit_response_policy_decision_get_request -webkit_response_policy_decision_get_response - -<SUBSECTION Standard> -WebKitResponsePolicyDecisionClass -WEBKIT_TYPE_RESPONSE_POLICY_DECISION -WEBKIT_RESPONSE_POLICY_DECISION -WEBKIT_IS_RESPONSE_POLICY_DECISION -WEBKIT_RESPONSE_POLICY_DECISION_CLASS -WEBKIT_IS_RESPONSE_POLICY_DECISION_CLASS -WEBKIT_RESPONSE_POLICY_DECISION_GET_CLASS - -<SUBSECTION Private> -WebKitResponsePolicyDecisionPrivate -webkit_response_policy_decision_get_type -</SECTION> - -<SECTION> -<FILE>WebKitHitTestResult</FILE> -WebKitHitTestResult -WebKitHitTestResultContext -webkit_hit_test_result_get_context -webkit_hit_test_result_context_is_link -webkit_hit_test_result_context_is_image -webkit_hit_test_result_context_is_media -webkit_hit_test_result_context_is_editable -webkit_hit_test_result_get_link_uri -webkit_hit_test_result_get_link_title -webkit_hit_test_result_get_link_label -webkit_hit_test_result_get_image_uri -webkit_hit_test_result_get_media_uri -webkit_hit_test_result_context_is_scrollbar - -<SUBSECTION Standard> -WebKitHitTestResultClass -WEBKIT_TYPE_HIT_TEST_RESULT -WEBKIT_HIT_TEST_RESULT -WEBKIT_IS_HIT_TEST_RESULT -WEBKIT_HIT_TEST_RESULT_CLASS -WEBKIT_IS_HIT_TEST_RESULT_CLASS -WEBKIT_HIT_TEST_RESULT_GET_CLASS - -<SUBSECTION Private> -WebKitHitTestResultPrivate -webkit_hit_test_result_get_type -</SECTION> - -<SECTION> -<FILE>WebKitPrintOperation</FILE> -WebKitPrintOperation -WebKitPrintOperationResponse -webkit_print_operation_new -webkit_print_operation_get_print_settings -webkit_print_operation_set_print_settings -webkit_print_operation_get_page_setup -webkit_print_operation_set_page_setup -webkit_print_operation_run_dialog -webkit_print_operation_print - -<SUBSECTION Standard> -WebKitPrintOperationClass -WEBKIT_TYPE_PRINT_OPERATION -WEBKIT_PRINT_OPERATION -WEBKIT_IS_PRINT_OPERATION -WEBKIT_PRINT_OPERATION_CLASS -WEBKIT_IS_PRINT_OPERATION_CLASS -WEBKIT_PRINT_OPERATION_GET_CLASS - -<SUBSECTION Private> -WebKitPrintOperationPrivate -webkit_print_operation_get_type -</SECTION> - -<SECTION> -<FILE>WebKitWebResource</FILE> -WebKitWebResource -webkit_web_resource_get_uri -webkit_web_resource_get_response -webkit_web_resource_get_data -webkit_web_resource_get_data_finish - -<SUBSECTION Standard> -WebKitWebResourceClass -WEBKIT_TYPE_WEB_RESOURCE -WEBKIT_WEB_RESOURCE -WEBKIT_IS_WEB_RESOURCE -WEBKIT_WEB_RESOURCE_CLASS -WEBKIT_IS_WEB_RESOURCE_CLASS -WEBKIT_WEB_RESOURCE_GET_CLASS - -<SUBSECTION Private> -WebKitWebResourcePrivate -webkit_web_resource_get_type -</SECTION> - -<SECTION> -<FILE>WebKitError</FILE> -WEBKIT_NETWORK_ERROR -WEBKIT_PLUGIN_ERROR -WEBKIT_POLICY_ERROR -WEBKIT_DOWNLOAD_ERROR -WEBKIT_PRINT_ERROR -WEBKIT_JAVASCRIPT_ERROR -WEBKIT_SNAPSHOT_ERROR -WebKitNetworkError -WebKitPluginError -WebKitPolicyError -WebKitDownloadError -WebKitPrintError -WebKitJavascriptError -WebKitSnapshotError -webkit_network_error_quark -webkit_plugin_error_quark -webkit_policy_error_quark -webkit_download_error_quark -webkit_print_error_quark -webkit_javascript_error_quark -webkit_snapshot_error_quark -</SECTION> - -<SECTION> -<FILE>WebKitFaviconDatabase</FILE> -WebKitFaviconDatabase -WEBKIT_FAVICON_DATABASE_ERROR -WebKitFaviconDatabaseError -webkit_favicon_database_get_favicon -webkit_favicon_database_get_favicon_finish -webkit_favicon_database_get_favicon_uri -webkit_favicon_database_clear - -<SUBSECTION Standard> -WebKitFaviconDatabaseClass -WEBKIT_TYPE_FAVICON_DATABASE -WEBKIT_FAVICON_DATABASE -WEBKIT_IS_FAVICON_DATABASE -WEBKIT_FAVICON_DATABASE_CLASS -WEBKIT_IS_FAVICON_DATABASE_CLASS -WEBKIT_FAVICON_DATABASE_GET_CLASS - -<SUBSECTION Private> -WebKitFaviconDatabasePrivate -webkit_favicon_database_get_type -webkit_favicon_database_error_quark -</SECTION> - -<SECTION> -<FILE>WebKitFileChooserRequest</FILE> -WebKitFileChooserRequest -webkit_file_chooser_request_get_mime_types -webkit_file_chooser_request_get_mime_types_filter -webkit_file_chooser_request_get_select_multiple -webkit_file_chooser_request_select_files -webkit_file_chooser_request_get_selected_files -webkit_file_chooser_request_cancel - -<SUBSECTION Standard> -WebKitFileChooserRequestClass -WEBKIT_TYPE_FILE_CHOOSER_REQUEST -WEBKIT_FILE_CHOOSER_REQUEST -WEBKIT_IS_FILE_CHOOSER_REQUEST -WEBKIT_FILE_CHOOSER_REQUEST_CLASS -WEBKIT_IS_FILE_CHOOSER_REQUEST_CLASS -WEBKIT_FILE_CHOOSER_REQUEST_GET_CLASS - -<SUBSECTION Private> -WebKitFileChooserRequestPrivate -webkit_file_chooser_request_get_type -</SECTION> - -<SECTION> -<FILE>WebKitFindController</FILE> -WebKitFindController -WebKitFindOptions -webkit_find_controller_search -webkit_find_controller_search_finish -webkit_find_controller_search_next -webkit_find_controller_search_previous -webkit_find_controller_get_search_text -webkit_find_controller_count_matches -webkit_find_controller_get_options -webkit_find_controller_get_max_match_count -webkit_find_controller_get_web_view - -<SUBSECTION Standard> -WebKitFindControllerClass -WEBKIT_TYPE_FIND_CONTROLLER -WEBKIT_FIND_CONTROLLER -WEBKIT_IS_FIND_CONTROLLER -WEBKIT_FIND_CONTROLLER_CLASS -WEBKIT_IS_FIND_CONTROLLER_CLASS -WEBKIT_FIND_CONTROLLER_GET_CLASS - -<SUBSECTION Private> -WebKitFindControllerPrivate -webkit_find_controller_get_type -</SECTION> - -<SECTION> -<FILE>WebKitCookieManager</FILE> -WebKitCookieManager -WebKitCookiePersistentStorage -WebKitCookieAcceptPolicy -webkit_cookie_manager_set_persistent_storage -webkit_cookie_manager_set_accept_policy -webkit_cookie_manager_get_accept_policy -webkit_cookie_manager_get_accept_policy_finish -webkit_cookie_manager_get_domains_with_cookies -webkit_cookie_manager_get_domains_with_cookies_finish -webkit_cookie_manager_delete_cookies_for_domain -webkit_cookie_manager_delete_all_cookies - -<SUBSECTION Standard> -WebKitCookieManagerClass -WEBKIT_TYPE_COOKIE_MANAGER -WEBKIT_COOKIE_MANAGER -WEBKIT_IS_COOKIE_MANAGER -WEBKIT_COOKIE_MANAGER_CLASS -WEBKIT_IS_COOKIE_MANAGER_CLASS -WEBKIT_COOKIE_MANAGER_GET_CLASS - -<SUBSECTION Private> -WebKitCookieManagerPrivate -webkit_cookie_manager_get_type -</SECTION> - -<SECTION> -<FILE>WebKitPlugin</FILE> -WebKitPlugin -webkit_plugin_get_name -webkit_plugin_get_description -webkit_plugin_get_path -webkit_plugin_get_mime_info_list - -<SUBSECTION WebKitMimeInfo> -WebKitMimeInfo -webkit_mime_info_ref -webkit_mime_info_unref -webkit_mime_info_get_mime_type -webkit_mime_info_get_description -webkit_mime_info_get_extensions - -<SUBSECTION Standard> -WebKitPluginClass -WEBKIT_TYPE_PLUGIN -WEBKIT_PLUGIN -WEBKIT_IS_PLUGIN -WEBKIT_PLUGIN_CLASS -WEBKIT_IS_PLUGIN_CLASS -WEBKIT_PLUGIN_GET_CLASS -WEBKIT_TYPE_MIME_INFO - -<SUBSECTION Private> -webkit_plugin_get_type -webkit_mime_info_get_type -WebKitPluginPrivate -</SECTION> - -<SECTION> -<FILE>WebKitWebInspector</FILE> -WebKitWebInspector -webkit_web_inspector_get_web_view -webkit_web_inspector_get_inspected_uri -webkit_web_inspector_is_attached -webkit_web_inspector_attach -webkit_web_inspector_detach -webkit_web_inspector_show -webkit_web_inspector_close -webkit_web_inspector_get_attached_height - -<SUBSECTION Standard> -WebKitWebInspectorClass -WEBKIT_TYPE_WEB_INSPECTOR -WEBKIT_WEB_INSPECTOR -WEBKIT_IS_WEB_INSPECTOR -WEBKIT_WEB_INSPECTOR_CLASS -WEBKIT_IS_WEB_INSPECTOR_CLASS -WEBKIT_WEB_INSPECTOR_GET_CLASS - -<SUBSECTION Private> -webkit_web_inspector_get_type -WebKitWebInspectorPrivate -</SECTION> - -<SECTION> -<FILE>WebKitURISchemeRequest</FILE> -WebKitURISchemeRequest -webkit_uri_scheme_request_get_scheme -webkit_uri_scheme_request_get_uri -webkit_uri_scheme_request_get_path -webkit_uri_scheme_request_get_web_view -webkit_uri_scheme_request_finish -webkit_uri_scheme_request_finish_error - -<SUBSECTION Standard> -WebKitURISchemeRequestClass -WEBKIT_TYPE_URI_SCHEME_REQUEST -WEBKIT_URI_SCHEME_REQUEST -WEBKIT_IS_URI_SCHEME_REQUEST -WEBKIT_URI_SCHEME_REQUEST_CLASS -WEBKIT_IS_URI_SCHEME_REQUEST_CLASS -WEBKIT_URI_SCHEME_REQUEST_GET_CLASS - -<SUBSECTION Private> -WebKitURISchemeRequestPrivate -webkit_uri_scheme_request_get_type -</SECTION> - -<SECTION> -<FILE>WebKitVersion</FILE> -webkit_get_major_version -webkit_get_minor_version -webkit_get_micro_version - -<SUBSECTION> -WEBKIT_MAJOR_VERSION -WEBKIT_MINOR_VERSION -WEBKIT_MICRO_VERSION -WEBKIT_CHECK_VERSION -</SECTION> - -<SECTION> -<FILE>WebKitContextMenu</FILE> -WebKitContextMenu -webkit_context_menu_new -webkit_context_menu_new_with_items -webkit_context_menu_prepend -webkit_context_menu_append -webkit_context_menu_insert -webkit_context_menu_move_item -webkit_context_menu_get_items -webkit_context_menu_get_n_items -webkit_context_menu_first -webkit_context_menu_last -webkit_context_menu_get_item_at_position -webkit_context_menu_remove -webkit_context_menu_remove_all - -<SUBSECTION Standard> -WebKitContextMenuClass -WEBKIT_TYPE_CONTEXT_MENU -WEBKIT_CONTEXT_MENU -WEBKIT_IS_CONTEXT_MENU -WEBKIT_CONTEXT_MENU_CLASS -WEBKIT_IS_CONTEXT_MENU_CLASS -WEBKIT_CONTEXT_MENU_GET_CLASS - -<SUBSECTION Private> -WebKitContextMenuPrivate -webkit_context_menu_get_type -</SECTION> - -<SECTION> -<FILE>WebKitContextMenuItem</FILE> -WebKitContextMenuItem -WebKitContextMenuAction -webkit_context_menu_item_new -webkit_context_menu_item_new_from_stock_action -webkit_context_menu_item_new_from_stock_action_with_label -webkit_context_menu_item_new_with_submenu -webkit_context_menu_item_new_separator -webkit_context_menu_item_get_action -webkit_context_menu_item_get_stock_action -webkit_context_menu_item_is_separator -webkit_context_menu_item_set_submenu -webkit_context_menu_item_get_submenu - -<SUBSECTION Standard> -WebKitContextMenuItemClass -WEBKIT_TYPE_CONTEXT_MENU_ITEM -WEBKIT_CONTEXT_MENU_ITEM -WEBKIT_IS_CONTEXT_MENU_ITEM -WEBKIT_CONTEXT_MENU_ITEM_CLASS -WEBKIT_IS_CONTEXT_MENU_ITEM_CLASS -WEBKIT_CONTEXT_MENU_ITEM_GET_CLASS - -<SUBSECTION Private> -WebKitContextMenuItemPrivate -webkit_context_menu_item_get_type -</SECTION> - -<SECTION> -<FILE>WebKitFormSubmissionRequest</FILE> -WebKitFormSubmissionRequest -webkit_form_submission_request_get_text_fields -webkit_form_submission_request_submit - -<SUBSECTION Standard> -WebKitFormSubmissionRequestClass -WEBKIT_TYPE_FORM_SUBMISSION_REQUEST -WEBKIT_FORM_SUBMISSION_REQUEST -WEBKIT_IS_FORM_SUBMISSION_REQUEST -WEBKIT_FORM_SUBMISSION_REQUEST_CLASS -WEBKIT_IS_FORM_SUBMISSION_REQUEST_CLASS -WEBKIT_FORM_SUBMISSION_REQUEST_GET_CLASS - -<SUBSECTION Private> -WebKitFormSubmissionRequestPrivate -webkit_form_submission_request_get_type -</SECTION> - -<SECTION> -<FILE>WebKitSecurityManager</FILE> -WebKitSecurityManager -webkit_security_manager_register_uri_scheme_as_local -webkit_security_manager_uri_scheme_is_local -webkit_security_manager_register_uri_scheme_as_no_access -webkit_security_manager_uri_scheme_is_no_access -webkit_security_manager_register_uri_scheme_as_display_isolated -webkit_security_manager_uri_scheme_is_display_isolated -webkit_security_manager_register_uri_scheme_as_secure -webkit_security_manager_uri_scheme_is_secure -webkit_security_manager_register_uri_scheme_as_cors_enabled -webkit_security_manager_uri_scheme_is_cors_enabled -webkit_security_manager_register_uri_scheme_as_empty_document -webkit_security_manager_uri_scheme_is_empty_document - -<SUBSECTION Standard> -WebKitSecurityManagerClass -WEBKIT_TYPE_SECURITY_MANAGER -WEBKIT_SECURITY_MANAGER -WEBKIT_IS_SECURITY_MANAGER -WEBKIT_SECURITY_MANAGER_CLASS -WEBKIT_IS_SECURITY_MANAGER_CLASS -WEBKIT_SECURITY_MANAGER_GET_CLASS - -<SUBSECTION Private> -WebKitSecurityManagerPrivate -webkit_security_manager_get_type -</SECTION> - -<SECTION> -<FILE>WebKitWebViewGroup</FILE> -WebKitWebViewGroup -WebKitInjectedContentFrames -webkit_web_view_group_new -webkit_web_view_group_get_name -webkit_web_view_group_get_settings -webkit_web_view_group_set_settings -webkit_web_view_group_add_user_style_sheet -webkit_web_view_group_remove_all_user_style_sheets - -<SUBSECTION Standard> -WebKitWebViewGroupClass -WEBKIT_TYPE_WEB_VIEW_GROUP -WEBKIT_WEB_VIEW_GROUP -WEBKIT_IS_WEB_VIEW_GROUP -WEBKIT_WEB_VIEW_GROUP_CLASS -WEBKIT_IS_WEB_VIEW_GROUP_CLASS -WEBKIT_WEB_VIEW_GROUP_GET_CLASS - -<SUBSECTION Private> -WebKitWebViewGroupPrivate -webkit_web_view_group_get_type -</SECTION> - -<SECTION> -<FILE>WebKitWebExtension</FILE> -WebKitWebExtension -WebKitWebExtensionInitializeFunction -webkit_web_extension_get_page - -<SUBSECTION Standard> -WebKitWebExtensionClass -WEBKIT_TYPE_WEB_EXTENSION -WEBKIT_WEB_EXTENSION -WEBKIT_IS_WEB_EXTENSION -WEBKIT_WEB_EXTENSION_CLASS -WEBKIT_IS_WEB_EXTENSION_CLASS -WEBKIT_WEB_EXTENSION_GET_CLASS - -<SUBSECTION Private> -WebKitWebExtensionPrivate -webkit_web_extension_get_type -</SECTION> - -<SECTION> -<FILE>WebKitWebPage</FILE> -WebKitWebPage -webkit_web_page_get_dom_document -webkit_web_page_get_id -webkit_web_page_get_uri - -<SUBSECTION Standard> -WebKitWebPageClass -WEBKIT_TYPE_WEB_PAGE -WEBKIT_WEB_PAGE -WEBKIT_IS_WEB_PAGE -WEBKIT_WEB_PAGE_CLASS -WEBKIT_IS_WEB_PAGE_CLASS -WEBKIT_WEB_PAGE_GET_CLASS - -<SUBSECTION Private> -WebKitWebPagePrivate -webkit_web_page_get_type -</SECTION> diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types deleted file mode 100644 index 5d97f69be..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types +++ /dev/null @@ -1,26 +0,0 @@ -#include <webkit2/webkit2.h> -webkit_web_view_get_type -webkit_web_view_base_get_type -webkit_web_context_get_type -webkit_back_forward_list_get_type -webkit_back_forward_list_item_get_type -webkit_settings_get_type -webkit_uri_response_get_type -webkit_uri_request_get_type -webkit_window_properties_get_type -webkit_download_get_type -webkit_file_chooser_request_get_type -webkit_find_controller_get_type -webkit_script_dialog_get_type -webkit_javascript_result_get_type -webkit_web_resource_get_type -webkit_cookie_manager_get_type -webkit_plugin_get_type -webkit_mime_info_get_type -webkit_web_inspector_get_type -webkit_uri_scheme_request_get_type -webkit_context_menu_get_type -webkit_context_menu_item_get_type -webkit_web_view_group_get_type -webkit_web_extension_get_type -webkit_web_page_get_type diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/AccessibilityTestServer.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/AccessibilityTestServer.cpp deleted file mode 100644 index a8bbbc3fa..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/AccessibilityTestServer.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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 <gtk/gtk.h> -#include <webkit2/webkit2.h> - -static void loadChangedCallback(WebKitWebView*, WebKitLoadEvent loadEvent, gpointer) -{ - // Send a message to the parent process when we're ready. - if (loadEvent == WEBKIT_LOAD_FINISHED) - g_print("OK"); -} - -int main(int argc, char** argv) -{ - // Make sure that both GAIL and the ATK bridge are loaded. - g_setenv("GTK_MODULES", "gail:atk-bridge", TRUE); - - gtk_init(&argc, &argv); - - WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new()); - webkit_web_view_load_html(webView, - "<html>" - " <body>" - " <h1>This is a test</h1>" - " <p>This is a paragraph with some plain text.</p>" - " <p>This paragraph contains <a href=\"http://www.webkitgtk.org\">a link</a> in the middle.</p>" - " </body>" - "</html>", - 0); - - GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(webView)); - gtk_widget_show_all(window); - - g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), 0); - g_signal_connect(webView, "load-changed", G_CALLBACK(loadChangedCallback), 0); - - gtk_main(); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am b/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am deleted file mode 100644 index 7510b617c..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am +++ /dev/null @@ -1,271 +0,0 @@ -if ENABLE_WEBKIT2 - -TEST_PROGS += \ - Programs/WebKit2APITests/InspectorTestServer \ - Programs/WebKit2APITests/TestBackForwardList \ - Programs/WebKit2APITests/TestContextMenu \ - Programs/WebKit2APITests/TestCookieManager \ - Programs/WebKit2APITests/TestDownloads \ - Programs/WebKit2APITests/TestInspector \ - Programs/WebKit2APITests/TestInspectorServer \ - Programs/WebKit2APITests/TestLoaderClient \ - Programs/WebKit2APITests/TestPrinting \ - Programs/WebKit2APITests/TestResources \ - Programs/WebKit2APITests/TestSSL \ - Programs/WebKit2APITests/TestWebExtensions \ - Programs/WebKit2APITests/TestWebKitVersion \ - Programs/WebKit2APITests/TestWebKitFaviconDatabase \ - Programs/WebKit2APITests/TestWebKitFindController \ - Programs/WebKit2APITests/TestWebKitPolicyClient \ - Programs/WebKit2APITests/TestWebKitSettings \ - Programs/WebKit2APITests/TestWebKitWebContext \ - Programs/WebKit2APITests/TestWebKitWebView \ - Programs/WebKit2APITests/TestWebKitWebViewGroup \ - Programs/WebKit2APITests/TestWebViewEditor - -noinst_PROGRAMS += $(TEST_PROGS) - -if HAVE_ATSPI2 -TEST_PROGS += Programs/WebKit2APITests/TestWebKitAccessibility - -noinst_PROGRAMS += Programs/WebKit2APITests/AccessibilityTestServer -endif - -webkit2_tests_cppflags = \ - -DWEBKIT_EXEC_PATH=\"${shell pwd}/$(top_builddir)/Programs\" \ - -DWEBKIT_SRC_DIR=\"${shell pwd}/${srcdir}\" \ - -DWEBKIT_DERIVED_SRC_DIR=\"${shell pwd}/${top_builddir}/DerivedSources\" \ - -DWEBKIT_TEST_PLUGIN_DIR=\"${shell pwd}/${top_builddir}/TestNetscapePlugin/.libs\" \ - -DWEBKIT_TEST_WEB_EXTENSIONS_DIR=\"${shell pwd}/${top_builddir}/Libraries/WebExtensions/.libs\" \ - -DWEBKIT_INJECTED_BUNDLE_PATH=\"${shell pwd}/$(top_builddir)/.libs\" \ - $(javascriptcore_cppflags) \ - -I$(srcdir)/Source/JavaScriptCore \ - -I$(srcdir)/Source \ - -I$(srcdir)/Source/WebKit2 \ - -I$(top_builddir)/DerivedSources/WebKit2/include \ - -I$(top_builddir)/DerivedSources/WebKit2/webkit2gtk \ - -I$(top_builddir)/DerivedSources/WebKit2/webkit2gtk/include \ - -I$(srcdir)/Source/WebKit2/UIProcess/API/gtk \ - $(global_cppflags) \ - $(FREETYPE_CFLAGS) \ - $(GLIB_CFLAGS) \ - $(GTK_CFLAGS) \ - $(LIBSOUP_CFLAGS) - -webkit2_tests_ldadd = \ - Libraries/libWebKit2APITestCore.la \ - libjavascriptcoregtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \ - libwebkit2gtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \ - $(FREETYPE_LIBS) \ - $(GEOCLUE_LIBS) \ - $(GLIB_LIBS) \ - $(GTK_LIBS) \ - $(LIBSOUP_LIBS) - -webkit2_tests_ldflags = \ - -no-install \ - -no-fast-install - -Programs/resources/webkit2gtk-tests-resources.gresource: Source/WebKit2/UIProcess/API/gtk/tests/resources/webkit2gtk-tests.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/Source/WebKit2/UIProcess/API/gtk/tests/resources/webkit2gtk-tests.gresource.xml) - $(AM_V_at)mkdir -p ${GENPROGRAMS}/resources - $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) $< - -Programs/resources/inspector/inspectorPageIndex.html: Source/WebKit2/UIProcess/InspectorServer/front-end/inspectorPageIndex.html - $(AM_V_at)mkdir -p ${GENPROGRAMS}/resources/inspector - $(AM_V_GEN)cp $(srcdir)/Source/WebKit2/UIProcess/InspectorServer/front-end/inspectorPageIndex.html ${GENPROGRAMS}/resources/inspector - -DISTCLEANFILES += \ - Programs/resources/webkit2gtk-tests-resources.gresource \ - Programs/resources/inspector/inspectorPageIndex.html - -noinst_DATA += \ - Programs/resources/webkit2gtk-tests-resources.gresource \ - Programs/resources/inspector/inspectorPageIndex.html - -noinst_LTLIBRARIES += Libraries/libWebKit2APITestCore.la -Libraries_libWebKit2APITestCore_la_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp \ - Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h \ - Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.cpp \ - Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.h \ - Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.cpp \ - Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.h \ - Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp \ - Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h \ - Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp \ - Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h -Libraries_libWebKit2APITestCore_la_CPPFLAGS = $(webkit2_tests_cppflags) - -noinst_LTLIBRARIES += Libraries/WebExtensions/libWebExtensionTest.la -Libraries_WebExtensions_libWebExtensionTest_la_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/WebExtensionTest.cpp - -Libraries_WebExtensions_libWebExtensionTest_la_LDFLAGS = \ - -rpath ${shell pwd}/$(top_builddir)/Libraries/WebExtensions/.libs \ - $(no_undefined) \ - -avoid-version \ - -module - -Libraries_WebExtensions_libWebExtensionTest_la_CPPFLAGS = \ - -I$(srcdir)/Source/WebKit2/WebProcess/InjectedBundle/API/gtk \ - -I$(top_builddir)/DerivedSources \ - -I$(top_builddir)/DerivedSources/WebKit2/webkit2extension/include \ - -DWEBKIT2_COMPILATION \ - $(webkit2_tests_cppflags) - -Libraries_WebExtensions_libWebExtensionTest_la_CXXFLAGS = \ - $(global_cxxflags) - -Libraries_WebExtensions_libWebExtensionTest_la_CFLAGS = \ - $(global_cflags) - - -EXTRA_DIST += \ - Source/WebKit2/UIProcess/API/gtk/tests/resources/test-cert.pem \ - Source/WebKit2/UIProcess/API/gtk/tests/resources/test-key.pem \ - Source/WebKit2/UIProcess/API/gtk/tests/resources/webkit2gtk-tests.gresource.xml \ - Source/WebKit2/UIProcess/API/gtk/tests/resources/link-title.js - -Programs_WebKit2APITests_TestWebKitWebContext_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp -Programs_WebKit2APITests_TestWebKitWebContext_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_TestWebKitWebContext_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_TestWebKitWebContext_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_TestWebKitWebView_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp -Programs_WebKit2APITests_TestWebKitWebView_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_TestWebKitWebView_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_TestWebKitWebView_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_TestLoaderClient_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp -Programs_WebKit2APITests_TestLoaderClient_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_TestLoaderClient_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_TestLoaderClient_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_TestWebKitSettings_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp -Programs_WebKit2APITests_TestWebKitSettings_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_TestWebKitSettings_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_TestWebKitSettings_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_InspectorTestServer_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/InspectorTestServer.cpp -Programs_WebKit2APITests_InspectorTestServer_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_InspectorTestServer_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_InspectorTestServer_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_TestBackForwardList_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp -Programs_WebKit2APITests_TestBackForwardList_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_TestBackForwardList_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_TestBackForwardList_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_TestWebKitPolicyClient_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitPolicyClient.cpp -Programs_WebKit2APITests_TestWebKitPolicyClient_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_TestWebKitPolicyClient_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_TestWebKitPolicyClient_LDFLAGS = $(webkit2_tests_ldflags) - -if HAVE_ATSPI2 -Programs_WebKit2APITests_AccessibilityTestServer_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/AccessibilityTestServer.cpp -Programs_WebKit2APITests_AccessibilityTestServer_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_AccessibilityTestServer_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_AccessibilityTestServer_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_TestWebKitAccessibility_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitAccessibility.cpp -Programs_WebKit2APITests_TestWebKitAccessibility_CPPFLAGS = $(webkit2_tests_cppflags) $(ATSPI2_CFLAGS) -Programs_WebKit2APITests_TestWebKitAccessibility_LDADD = $(webkit2_tests_ldadd) $(ATSPI2_LIBS) -Programs_WebKit2APITests_TestWebKitAccessibility_LDFLAGS = $(webkit2_tests_ldflags) -endif - -Programs_WebKit2APITests_TestDownloads_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp -Programs_WebKit2APITests_TestDownloads_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_TestDownloads_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_TestDownloads_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_TestWebViewEditor_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestWebViewEditor.cpp -Programs_WebKit2APITests_TestWebViewEditor_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_TestWebViewEditor_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_TestWebViewEditor_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_TestPrinting_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestPrinting.cpp -Programs_WebKit2APITests_TestPrinting_CPPFLAGS = $(webkit2_tests_cppflags) $(GTK_UNIX_PRINTING_CFLAGS) -Programs_WebKit2APITests_TestPrinting_LDADD = $(webkit2_tests_ldadd) $(GTK_UNIX_PRINTING_LIBS) -Programs_WebKit2APITests_TestPrinting_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_TestWebKitFaviconDatabase_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFaviconDatabase.cpp -Programs_WebKit2APITests_TestWebKitFaviconDatabase_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_TestWebKitFaviconDatabase_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_TestWebKitFaviconDatabase_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_TestWebKitFindController_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFindController.cpp -Programs_WebKit2APITests_TestWebKitFindController_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_TestWebKitFindController_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_TestWebKitFindController_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_TestResources_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp -Programs_WebKit2APITests_TestResources_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_TestResources_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_TestResources_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_TestCookieManager_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestCookieManager.cpp -Programs_WebKit2APITests_TestCookieManager_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_TestCookieManager_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_TestCookieManager_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_TestInspector_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestInspector.cpp -Programs_WebKit2APITests_TestInspector_CPPFLAGS = \ - -DWEBKIT_INSPECTOR_PATH=\"${shell pwd}/${top_builddir}/resources/inspector\" \ - $(webkit2_tests_cppflags) -Programs_WebKit2APITests_TestInspector_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_TestInspector_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_TestInspectorServer_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestInspectorServer.cpp -Programs_WebKit2APITests_TestInspectorServer_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_TestInspectorServer_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_TestInspectorServer_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_TestWebKitVersion_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitVersion.cpp -Programs_WebKit2APITests_TestWebKitVersion_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_TestWebKitVersion_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_TestWebKitVersion_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_TestContextMenu_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestContextMenu.cpp -Programs_WebKit2APITests_TestContextMenu_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_TestContextMenu_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_TestContextMenu_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_TestSSL_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestSSL.cpp -Programs_WebKit2APITests_TestSSL_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_TestSSL_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_TestSSL_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_TestWebExtensions_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestWebExtensions.cpp -Programs_WebKit2APITests_TestWebExtensions_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_TestWebExtensions_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_TestWebExtensions_LDFLAGS = $(webkit2_tests_ldflags) - -Programs_WebKit2APITests_TestWebKitWebViewGroup_SOURCES = \ - Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebViewGroup.cpp -Programs_WebKit2APITests_TestWebKitWebViewGroup_CPPFLAGS = $(webkit2_tests_cppflags) -Programs_WebKit2APITests_TestWebKitWebViewGroup_LDADD = $(webkit2_tests_ldadd) -Programs_WebKit2APITests_TestWebKitWebViewGroup_LDFLAGS = $(webkit2_tests_ldflags) - -endif # ENABLE_WEBKIT2 diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/InspectorTestServer.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/InspectorTestServer.cpp deleted file mode 100644 index 7c9dc900c..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/InspectorTestServer.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2012 Samsung Electronics Ltd. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT OWNER OR 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 "config.h" - -#include <gtk/gtk.h> -#include <webkit2/webkit2.h> - -static void loadChangedCallback(WebKitWebView*, WebKitLoadEvent loadEvent, gpointer) -{ - // Send a message to the parent process when we're ready. - if (loadEvent == WEBKIT_LOAD_FINISHED) - g_print("OK"); -} - -int main(int argc, char** argv) -{ - gtk_init(&argc, &argv); - - // Overwrite WEBKIT_INSPECTOR_SERVER variable with default value. - g_setenv("WEBKIT_INSPECTOR_SERVER", "127.0.0.1:2999", TRUE); - - // Overwrite WEBKIT_INSPECTOR_SERVER_PATH variable to point to inspector resources folder. - const gchar* inspectorResourcesPath = g_getenv("WEBKIT_INSPECTOR_PATH"); - g_setenv("WEBKIT_INSPECTOR_SERVER_PATH", inspectorResourcesPath, TRUE); - - WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new()); - webkit_settings_set_enable_developer_extras(webkit_web_view_get_settings(webView), TRUE); - webkit_web_view_load_html(webView, - "<html><body><p>WebKitGTK+ Inspector Test Server</p></body></html>", - "http://127.0.0.1:2999/"); - - GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(webView)); - gtk_widget_show_all(window); - - g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), 0); - g_signal_connect(webView, "load-changed", G_CALLBACK(loadChangedCallback), 0); - - gtk_main(); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp deleted file mode 100644 index df3420492..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 "LoadTrackingTest.h" - -#include <webkit2/webkit2.h> - -static void loadChangedCallback(WebKitWebView* webView, WebKitLoadEvent loadEvent, LoadTrackingTest* test) -{ - switch (loadEvent) { - case WEBKIT_LOAD_STARTED: - g_assert(webkit_web_view_is_loading(webView)); - g_assert_cmpstr(test->m_activeURI.data(), ==, webkit_web_view_get_uri(webView)); - test->provisionalLoadStarted(); - break; - case WEBKIT_LOAD_REDIRECTED: - g_assert(webkit_web_view_is_loading(webView)); - test->m_activeURI = webkit_web_view_get_uri(webView); - if (!test->m_redirectURI.isNull()) - g_assert_cmpstr(test->m_redirectURI.data(), ==, test->m_activeURI.data()); - test->provisionalLoadReceivedServerRedirect(); - break; - case WEBKIT_LOAD_COMMITTED: { - g_assert(webkit_web_view_is_loading(webView)); - g_assert_cmpstr(test->m_activeURI.data(), ==, webkit_web_view_get_uri(webView)); - - // Check that on committed we always have a main resource with a response. - WebKitWebResource* resource = webkit_web_view_get_main_resource(webView); - g_assert(resource); - g_assert(webkit_web_resource_get_response(resource)); - - test->loadCommitted(); - break; - } - case WEBKIT_LOAD_FINISHED: - g_assert(!webkit_web_view_is_loading(webView)); - if (!test->m_loadFailed) - g_assert_cmpstr(test->m_activeURI.data(), ==, webkit_web_view_get_uri(webView)); - test->loadFinished(); - break; - default: - g_assert_not_reached(); - } -} - -static void loadFailedCallback(WebKitWebView* webView, WebKitLoadEvent loadEvent, const char* failingURI, GError* error, LoadTrackingTest* test) -{ - test->m_loadFailed = true; - test->m_error.set(g_error_copy(error)); - - switch (loadEvent) { - case WEBKIT_LOAD_STARTED: - g_assert(!webkit_web_view_is_loading(webView)); - g_assert_cmpstr(test->m_activeURI.data(), ==, webkit_web_view_get_uri(webView)); - g_assert(error); - test->provisionalLoadFailed(failingURI, error); - break; - case WEBKIT_LOAD_COMMITTED: - g_assert(!webkit_web_view_is_loading(webView)); - g_assert_cmpstr(test->m_activeURI.data(), ==, webkit_web_view_get_uri(webView)); - g_assert(error); - test->loadFailed(failingURI, error); - break; - default: - g_assert_not_reached(); - } -} - -static void estimatedProgressChangedCallback(GObject*, GParamSpec*, LoadTrackingTest* test) -{ - test->estimatedProgressChanged(); -} - -LoadTrackingTest::LoadTrackingTest() - : m_runLoadUntilCompletion(false) - , m_loadFailed(false) -{ - g_signal_connect(m_webView, "load-changed", G_CALLBACK(loadChangedCallback), this); - g_signal_connect(m_webView, "load-failed", G_CALLBACK(loadFailedCallback), this); - g_signal_connect(m_webView, "notify::estimated-load-progress", G_CALLBACK(estimatedProgressChangedCallback), this); - - g_assert(!webkit_web_view_get_uri(m_webView)); -} - -LoadTrackingTest::~LoadTrackingTest() -{ - g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); -} - -void LoadTrackingTest::waitUntilLoadFinished() -{ - m_estimatedProgress = 0; - m_runLoadUntilCompletion = true; - g_main_loop_run(m_mainLoop); -} - -void LoadTrackingTest::provisionalLoadStarted() -{ - m_loadEvents.append(ProvisionalLoadStarted); -} - -void LoadTrackingTest::provisionalLoadReceivedServerRedirect() -{ - m_loadEvents.append(ProvisionalLoadReceivedServerRedirect); -} - -void LoadTrackingTest::provisionalLoadFailed(const gchar* failingURI, GError* error) -{ - m_loadEvents.append(ProvisionalLoadFailed); -} - -void LoadTrackingTest::loadCommitted() -{ - m_loadEvents.append(LoadCommitted); -} - -void LoadTrackingTest::loadFinished() -{ - m_loadEvents.append(LoadFinished); - if (m_runLoadUntilCompletion) - g_main_loop_quit(m_mainLoop); -} - -void LoadTrackingTest::loadFailed(const gchar* failingURI, GError* error) -{ - m_loadEvents.append(LoadFailed); -} - -void LoadTrackingTest::estimatedProgressChanged() -{ - double progress = webkit_web_view_get_estimated_load_progress(m_webView); - g_assert_cmpfloat(m_estimatedProgress, <, progress); - m_estimatedProgress = progress; -} - -void LoadTrackingTest::loadURI(const char* uri) -{ - m_loadEvents.clear(); - m_estimatedProgress = 0; - m_error.clear(); - WebViewTest::loadURI(uri); -} - -void LoadTrackingTest::loadHtml(const char* html, const char* baseURI) -{ - m_loadEvents.clear(); - m_estimatedProgress = 0; - m_error.clear(); - WebViewTest::loadHtml(html, baseURI); -} - -void LoadTrackingTest::loadPlainText(const char* plainText) -{ - m_loadEvents.clear(); - m_estimatedProgress = 0; - m_error.clear(); - WebViewTest::loadPlainText(plainText); -} - -void LoadTrackingTest::loadRequest(WebKitURIRequest* request) -{ - m_loadEvents.clear(); - m_estimatedProgress = 0; - m_error.clear(); - WebViewTest::loadRequest(request); -} - -void LoadTrackingTest::reload() -{ - m_loadEvents.clear(); - m_estimatedProgress = 0; - m_error.clear(); - webkit_web_view_reload(m_webView); -} - -void LoadTrackingTest::goBack() -{ - m_loadEvents.clear(); - m_estimatedProgress = 0; - m_error.clear(); - WebViewTest::goBack(); -} - -void LoadTrackingTest::goForward() -{ - m_loadEvents.clear(); - m_estimatedProgress = 0; - m_error.clear(); - WebViewTest::goForward(); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h b/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h deleted file mode 100644 index a3cf7843d..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 LoadTrackingTest_h -#define LoadTrackingTest_h - -#include "TestMain.h" -#include "WebViewTest.h" -#include <wtf/Vector.h> - -class LoadTrackingTest : public WebViewTest { -public: - MAKE_GLIB_TEST_FIXTURE(LoadTrackingTest); - LoadTrackingTest(); - virtual ~LoadTrackingTest(); - void waitUntilLoadFinished(); - - virtual void provisionalLoadStarted(); - virtual void provisionalLoadReceivedServerRedirect(); - virtual void provisionalLoadFailed(const gchar* failingURI, GError*); - virtual void loadCommitted(); - virtual void loadFinished(); - virtual void loadFailed(const char* failingURI, GError*); - virtual void estimatedProgressChanged(); - - void loadURI(const char* uri); - void loadHtml(const char* html, const char* baseURI); - void loadPlainText(const char* plainText); - void loadRequest(WebKitURIRequest*); - void reload(); - void goBack(); - void goForward(); - - void setRedirectURI(const char* uri) { m_redirectURI = uri; } - - enum LoadEvents { - ProvisionalLoadStarted, - ProvisionalLoadReceivedServerRedirect, - ProvisionalLoadFailed, - LoadCommitted, - LoadFinished, - LoadFailed - }; - bool m_runLoadUntilCompletion; - bool m_loadFailed; - GOwnPtr<GError> m_error; - Vector<LoadEvents> m_loadEvents; - float m_estimatedProgress; - CString m_redirectURI; -}; - -#endif // LoadTrackingTest_h diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp deleted file mode 100644 index b479366a4..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 "WebKitTestServer.h" -#include "WebViewTest.h" -#include <gtk/gtk.h> -#include <libsoup/soup.h> -#include <string.h> -#include <webkit2/webkit2.h> - -// Back forward list limit is 100 by default. -static const int kBackForwardListLimit = 100; - -static WebKitTestServer* kServer; - -static void serverCallback(SoupServer* server, SoupMessage* msg, const char* path, GHashTable* query, SoupClientContext* context, gpointer data) -{ - if (msg->method != SOUP_METHOD_GET) { - soup_message_set_status(msg, SOUP_STATUS_NOT_IMPLEMENTED); - return; - } - - if (g_str_has_suffix(path, "favicon.ico")) { - soup_message_set_status(msg, SOUP_STATUS_NOT_FOUND); - return; - } - - soup_message_set_status(msg, SOUP_STATUS_OK); - - char* body = g_strdup_printf("<html><title>%s</title><body>%s</body></html>", path + 1, path + 1); - soup_message_body_append(msg->response_body, SOUP_MEMORY_TAKE, body, strlen(body)); - - soup_message_body_complete(msg->response_body); -} - -class BackForwardListTest: public WebViewTest { -public: - MAKE_GLIB_TEST_FIXTURE(BackForwardListTest); - - enum { - Backward, - Forward - }; - - enum { - CurrentItem = 1 << 0, - AddedItem = 1 << 1, - RemovedItems = 1 << 2 - }; - - static void checkItem(WebKitBackForwardListItem* item, const char* title, const char* uri, const char* originalURI) - { - g_assert(item); - g_assert_cmpstr(webkit_back_forward_list_item_get_uri(item), ==, uri); - g_assert_cmpstr(webkit_back_forward_list_item_get_title(item), == , title); - g_assert_cmpstr(webkit_back_forward_list_item_get_original_uri(item), ==, originalURI); - } - - static void checkItemIndex(WebKitBackForwardList* list) - { - g_assert(webkit_back_forward_list_get_nth_item(list, -1) == webkit_back_forward_list_get_back_item(list)); - g_assert(webkit_back_forward_list_get_nth_item(list, 0) == webkit_back_forward_list_get_current_item(list)); - g_assert(webkit_back_forward_list_get_nth_item(list, 1) == webkit_back_forward_list_get_forward_item(list)); - } - - static void checkList(WebKitBackForwardList* list, unsigned type, WebKitBackForwardListItem** items, unsigned nItems) - { - GList* listItems = type == BackForwardListTest::Backward ? webkit_back_forward_list_get_back_list(list) : - webkit_back_forward_list_get_forward_list(list); - g_assert(listItems); - - unsigned i = 0; - for (GList* listItem = listItems; listItem; listItem = g_list_next(listItem), i++) { - g_assert_cmpuint(i, <, nItems); - g_assert(listItem->data == items[i]); - } - g_list_free(listItems); - } - - static void backForwardListChanged(WebKitBackForwardList* list, WebKitBackForwardListItem* addedItem, GList* removedItems, BackForwardListTest* test) - { - test->m_hasChanged = true; - - if (test->m_changedFlags & BackForwardListTest::AddedItem) { - g_assert(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(addedItem)); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(addedItem)); - } else - g_assert(!addedItem); - - if (test->m_changedFlags & BackForwardListTest::RemovedItems) { - g_assert(removedItems); - for (GList* iter = removedItems; iter; iter = iter->next) { - g_assert(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(iter->data)); - if (test->m_expectedRemovedItems) - g_assert(g_list_find(test->m_expectedRemovedItems, iter->data)); - } - - } else - g_assert(!removedItems); - } - - BackForwardListTest() - : m_list(webkit_web_view_get_back_forward_list(m_webView)) - , m_changedFlags(0) - , m_hasChanged(false) - , m_expectedRemovedItems(0) - { - g_signal_connect(m_list, "changed", G_CALLBACK(backForwardListChanged), this); - assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_list)); - } - - ~BackForwardListTest() - { - g_signal_handlers_disconnect_matched(m_list, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); - } - - void waitUntilLoadFinished() - { - m_hasChanged = false; - WebViewTest::waitUntilLoadFinished(); - g_assert(m_hasChanged); - } - - void waitUntilLoadFinishedAndCheckRemovedItems(GList* removedItems) - { - m_expectedRemovedItems = removedItems; - waitUntilLoadFinished(); - m_expectedRemovedItems = 0; - } - - WebKitBackForwardList* m_list; - unsigned long m_changedFlags; - bool m_hasChanged; - GList* m_expectedRemovedItems; -}; - -static void testBackForwardListNavigation(BackForwardListTest* test, gconstpointer) -{ - WebKitBackForwardListItem* items[1]; - - g_assert(!webkit_web_view_can_go_back(test->m_webView)); - g_assert(!webkit_web_view_can_go_forward(test->m_webView)); - - g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 0); - g_assert(!webkit_back_forward_list_get_current_item(test->m_list)); - g_assert(!webkit_back_forward_list_get_back_item(test->m_list)); - g_assert(!webkit_back_forward_list_get_forward_item(test->m_list)); - BackForwardListTest::checkItemIndex(test->m_list); - g_assert(!webkit_back_forward_list_get_back_list(test->m_list)); - g_assert(!webkit_back_forward_list_get_forward_list(test->m_list)); - - CString uriPage1 = kServer->getURIForPath("/Page1"); - test->m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem; - test->loadURI(uriPage1.data()); - test->waitUntilLoadFinished(); - - g_assert(!webkit_web_view_can_go_back(test->m_webView)); - g_assert(!webkit_web_view_can_go_forward(test->m_webView)); - - g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 1); - WebKitBackForwardListItem* itemPage1 = webkit_back_forward_list_get_current_item(test->m_list); - BackForwardListTest::checkItem(itemPage1, "Page1", uriPage1.data(), uriPage1.data()); - g_assert(!webkit_back_forward_list_get_back_item(test->m_list)); - g_assert(!webkit_back_forward_list_get_forward_item(test->m_list)); - BackForwardListTest::checkItemIndex(test->m_list); - g_assert(!webkit_back_forward_list_get_back_list(test->m_list)); - g_assert(!webkit_back_forward_list_get_forward_list(test->m_list)); - - CString uriPage2 = kServer->getURIForPath("/Page2"); - test->m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem; - test->loadURI(uriPage2.data()); - test->waitUntilLoadFinished(); - - g_assert(webkit_web_view_can_go_back(test->m_webView)); - g_assert(!webkit_web_view_can_go_forward(test->m_webView)); - - g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 2); - WebKitBackForwardListItem* itemPage2 = webkit_back_forward_list_get_current_item(test->m_list); - BackForwardListTest::checkItem(itemPage2, "Page2", uriPage2.data(), uriPage2.data()); - g_assert(webkit_back_forward_list_get_back_item(test->m_list) == itemPage1); - g_assert(!webkit_back_forward_list_get_forward_item(test->m_list)); - BackForwardListTest::checkItemIndex(test->m_list); - items[0] = itemPage1; - BackForwardListTest::checkList(test->m_list, BackForwardListTest::Backward, items, 1); - g_assert(!webkit_back_forward_list_get_forward_list(test->m_list)); - - test->m_changedFlags = BackForwardListTest::CurrentItem; - test->goBack(); - test->waitUntilLoadFinished(); - - g_assert(!webkit_web_view_can_go_back(test->m_webView)); - g_assert(webkit_web_view_can_go_forward(test->m_webView)); - - g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 2); - g_assert(itemPage1 == webkit_back_forward_list_get_current_item(test->m_list)); - BackForwardListTest::checkItem(webkit_back_forward_list_get_current_item(test->m_list), "Page1", uriPage1.data(), uriPage1.data()); - g_assert(!webkit_back_forward_list_get_back_item(test->m_list)); - g_assert(webkit_back_forward_list_get_forward_item(test->m_list) == itemPage2); - BackForwardListTest::checkItemIndex(test->m_list); - g_assert(!webkit_back_forward_list_get_back_list(test->m_list)); - items[0] = itemPage2; - BackForwardListTest::checkList(test->m_list, BackForwardListTest::Forward, items, 1); - - test->m_changedFlags = BackForwardListTest::CurrentItem; - test->goForward(); - test->waitUntilLoadFinished(); - - g_assert(webkit_web_view_can_go_back(test->m_webView)); - g_assert(!webkit_web_view_can_go_forward(test->m_webView)); - - g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 2); - g_assert(itemPage2 == webkit_back_forward_list_get_current_item(test->m_list)); - BackForwardListTest::checkItem(webkit_back_forward_list_get_current_item(test->m_list), "Page2", uriPage2.data(), uriPage2.data()); - g_assert(webkit_back_forward_list_get_back_item(test->m_list) == itemPage1); - g_assert(!webkit_back_forward_list_get_forward_item(test->m_list)); - BackForwardListTest::checkItemIndex(test->m_list); - items[0] = itemPage1; - BackForwardListTest::checkList(test->m_list, BackForwardListTest::Backward, items, 1); - g_assert(!webkit_back_forward_list_get_forward_list(test->m_list)); - - test->m_changedFlags = BackForwardListTest::CurrentItem; - test->goToBackForwardListItem(itemPage1); - test->waitUntilLoadFinished(); - - g_assert(itemPage1 == webkit_back_forward_list_get_current_item(test->m_list)); -} - -static void testBackForwardListLimitAndCache(BackForwardListTest* test, gconstpointer) -{ - for (int i = 0; i < kBackForwardListLimit; i++) { - GOwnPtr<char> path(g_strdup_printf("/Page%d", i)); - test->m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem; - test->loadURI(kServer->getURIForPath(path.get()).data()); - test->waitUntilLoadFinished(); - } - - g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, kBackForwardListLimit); - WebKitBackForwardListItem* itemPageFirst = webkit_back_forward_list_get_nth_item(test->m_list, -(kBackForwardListLimit - 1)); - GOwnPtr<GList> removedItems(g_list_prepend(0, itemPageFirst)); - - GOwnPtr<char> path(g_strdup_printf("/Page%d", kBackForwardListLimit)); - test->m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem | BackForwardListTest::RemovedItems; - test->loadURI(kServer->getURIForPath(path.get()).data()); - test->waitUntilLoadFinishedAndCheckRemovedItems(removedItems.get()); - - g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, kBackForwardListLimit); -} - -void beforeAll() -{ - kServer = new WebKitTestServer(); - kServer->run(serverCallback); - - BackForwardListTest::add("BackForwardList", "navigation", testBackForwardListNavigation); - BackForwardListTest::add("BackForwardList", "list-limit-and-cache", testBackForwardListLimitAndCache); -} - -void afterAll() -{ - delete kServer; -} - diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestContextMenu.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestContextMenu.cpp deleted file mode 100644 index c361f8baf..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestContextMenu.cpp +++ /dev/null @@ -1,846 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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 "WebViewTest.h" -#include <wtf/gobject/GRefPtr.h> - -class ContextMenuTest: public WebViewTest { -public: - enum ContextMenuItemStateFlags { - Visible = 1 << 0, - Enabled = 1 << 1, - Checked = 1 << 2 - }; - - void checkContextMenuEvent(GdkEvent* event) - { - g_assert(event); - g_assert_cmpint(event->type, ==, GDK_BUTTON_PRESS); - g_assert_cmpint(event->button.button, ==, 3); - g_assert_cmpint(event->button.x, ==, m_menuPositionX); - g_assert_cmpint(event->button.y, ==, m_menuPositionY); - } - - static gboolean contextMenuCallback(WebKitWebView* webView, WebKitContextMenu* contextMenu, GdkEvent* event, WebKitHitTestResult* hitTestResult, ContextMenuTest* test) - { - g_assert(WEBKIT_IS_CONTEXT_MENU(contextMenu)); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(contextMenu)); - test->checkContextMenuEvent(event); - g_assert(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult)); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(hitTestResult)); - - return test->contextMenu(contextMenu, event, hitTestResult); - } - - static void contextMenuDismissedCallback(WebKitWebView*, ContextMenuTest* test) - { - test->contextMenuDismissed(); - } - - ContextMenuTest() - : m_menuPositionX(0) - , m_menuPositionY(0) - { - g_signal_connect(m_webView, "context-menu", G_CALLBACK(contextMenuCallback), this); - g_signal_connect(m_webView, "context-menu-dismissed", G_CALLBACK(contextMenuDismissedCallback), this); - } - - ~ContextMenuTest() - { - g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); - } - - virtual bool contextMenu(WebKitContextMenu*, GdkEvent*, WebKitHitTestResult*) = 0; - - virtual void contextMenuDismissed() - { - quitMainLoop(); - } - - GtkMenu* getPopupMenu() - { - GOwnPtr<GList> toplevels(gtk_window_list_toplevels()); - for (GList* iter = toplevels.get(); iter; iter = g_list_next(iter)) { - if (!GTK_IS_WINDOW(iter->data)) - continue; - - GtkWidget* child = gtk_bin_get_child(GTK_BIN(iter->data)); - if (!GTK_IS_MENU(child)) - continue; - - if (gtk_menu_get_attach_widget(GTK_MENU(child)) == GTK_WIDGET(m_webView)) - return GTK_MENU(child); - } - g_assert_not_reached(); - return 0; - } - - bool shouldShowInputMethodsMenu() - { - GtkSettings* settings = gtk_widget_get_settings(GTK_WIDGET(m_webView)); - if (!settings) - return true; - - gboolean showInputMethodMenu; - g_object_get(settings, "gtk-show-input-method-menu", &showInputMethodMenu, NULL); - return showInputMethodMenu; - } - - void checkActionState(GtkAction* action, unsigned state) - { - if (state & Visible) - g_assert(gtk_action_get_visible(action)); - else - g_assert(!gtk_action_get_visible(action)); - - if (state & Enabled) - g_assert(gtk_action_get_sensitive(action)); - else - g_assert(!gtk_action_get_sensitive(action)); - - if (GTK_IS_TOGGLE_ACTION(action)) { - if (state & Checked) - g_assert(gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action))); - else - g_assert(!gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action))); - } - } - - GList* checkCurrentItemIsStockActionAndGetNext(GList* items, WebKitContextMenuAction stockAction, unsigned state) - { - g_assert(items); - g_assert(WEBKIT_IS_CONTEXT_MENU_ITEM(items->data)); - - WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(items->data); - assertObjectIsDeletedWhenTestFinishes(G_OBJECT(item)); - - GtkAction* action = webkit_context_menu_item_get_action(item); - g_assert(GTK_IS_ACTION(action)); - - g_assert_cmpint(webkit_context_menu_item_get_stock_action(item), ==, stockAction); - - checkActionState(action, state); - - return g_list_next(items); - } - - GList* checkCurrentItemIsCustomActionAndGetNext(GList* items, const char* label, unsigned state) - { - g_assert(items); - g_assert(WEBKIT_IS_CONTEXT_MENU_ITEM(items->data)); - - WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(items->data); - assertObjectIsDeletedWhenTestFinishes(G_OBJECT(item)); - - GtkAction* action = webkit_context_menu_item_get_action(item); - g_assert(GTK_IS_ACTION(action)); - - g_assert_cmpint(webkit_context_menu_item_get_stock_action(item), ==, WEBKIT_CONTEXT_MENU_ACTION_CUSTOM); - g_assert_cmpstr(gtk_action_get_label(action), ==, label); - - checkActionState(action, state); - - return g_list_next(items); - } - - GList* checkCurrentItemIsSubMenuAndGetNext(GList* items, const char* label, unsigned state, GList** subMenuIter) - { - g_assert(items); - g_assert(WEBKIT_IS_CONTEXT_MENU_ITEM(items->data)); - - WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(items->data); - assertObjectIsDeletedWhenTestFinishes(G_OBJECT(item)); - - GtkAction* action = webkit_context_menu_item_get_action(item); - g_assert(GTK_IS_ACTION(action)); - - g_assert_cmpstr(gtk_action_get_label(action), ==, label); - checkActionState(action, state); - - WebKitContextMenu* subMenu = webkit_context_menu_item_get_submenu(item); - g_assert(WEBKIT_IS_CONTEXT_MENU(subMenu)); - if (subMenuIter) - *subMenuIter = webkit_context_menu_get_items(subMenu); - - return g_list_next(items); - } - - GList* checkCurrentItemIsSeparatorAndGetNext(GList* items) - { - g_assert(items); - g_assert(WEBKIT_IS_CONTEXT_MENU_ITEM(items->data)); - - WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(items->data); - g_assert(webkit_context_menu_item_is_separator(item)); - - return g_list_next(items); - } - - static gboolean doRightClickIdleCallback(ContextMenuTest* test) - { - test->clickMouseButton(test->m_menuPositionX, test->m_menuPositionY, 3); - return FALSE; - } - - void showContextMenuAtPositionAndWaitUntilFinished(int x, int y) - { - m_menuPositionX = x; - m_menuPositionY = y; - g_idle_add(reinterpret_cast<GSourceFunc>(doRightClickIdleCallback), this); - g_main_loop_run(m_mainLoop); - } - - void showContextMenuAndWaitUntilFinished() - { - showContextMenuAtPositionAndWaitUntilFinished(0, 0); - } - - static gboolean simulateEscKeyIdleCallback(ContextMenuTest* test) - { - test->keyStroke(GDK_KEY_Escape); - return FALSE; - } - - void dismissContextMenuAndWaitUntilFinished() - { - g_idle_add(reinterpret_cast<GSourceFunc>(simulateEscKeyIdleCallback), this); - g_main_loop_run(m_mainLoop); - } - - double m_menuPositionX; - double m_menuPositionY; -}; - -class ContextMenuDefaultTest: public ContextMenuTest { -public: - MAKE_GLIB_TEST_FIXTURE(ContextMenuDefaultTest); - - enum DefaultMenuType { - Navigation, - Link, - Image, - LinkImage, - Video, - Editable - }; - - ContextMenuDefaultTest() - : m_expectedMenuType(Navigation) - { - } - - bool contextMenu(WebKitContextMenu* contextMenu, GdkEvent* event, WebKitHitTestResult* hitTestResult) - { - GList* iter = webkit_context_menu_get_items(contextMenu); - - switch (m_expectedMenuType) { - case Navigation: - g_assert(!webkit_hit_test_result_context_is_link(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_image(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_GO_BACK, Visible); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_GO_FORWARD, Visible); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_STOP, Visible); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_RELOAD, Visible | Enabled); - break; - case Link: - g_assert(webkit_hit_test_result_context_is_link(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_image(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK, Visible | Enabled); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK_IN_NEW_WINDOW, Visible | Enabled); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_LINK_TO_DISK, Visible | Enabled); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_COPY_LINK_TO_CLIPBOARD, Visible | Enabled); - break; - case Image: - g_assert(!webkit_hit_test_result_context_is_link(hitTestResult)); - g_assert(webkit_hit_test_result_context_is_image(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_IMAGE_IN_NEW_WINDOW, Visible | Enabled); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_IMAGE_TO_DISK, Visible | Enabled); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_COPY_IMAGE_TO_CLIPBOARD, Visible | Enabled); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_COPY_IMAGE_URL_TO_CLIPBOARD, Visible | Enabled); - break; - case LinkImage: - g_assert(webkit_hit_test_result_context_is_link(hitTestResult)); - g_assert(webkit_hit_test_result_context_is_image(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK, Visible | Enabled); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK_IN_NEW_WINDOW, Visible | Enabled); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_LINK_TO_DISK, Visible | Enabled); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_COPY_LINK_TO_CLIPBOARD, Visible | Enabled); - iter = checkCurrentItemIsSeparatorAndGetNext(iter); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_IMAGE_IN_NEW_WINDOW, Visible | Enabled); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_IMAGE_TO_DISK, Visible | Enabled); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_COPY_IMAGE_TO_CLIPBOARD, Visible | Enabled); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_COPY_IMAGE_URL_TO_CLIPBOARD, Visible | Enabled); - break; - case Video: - g_assert(!webkit_hit_test_result_context_is_link(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_image(hitTestResult)); - g_assert(webkit_hit_test_result_context_is_media(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PLAY, Visible | Enabled); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_MEDIA_MUTE, Visible); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_CONTROLS, Visible | Enabled | Checked); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_LOOP, Visible | Enabled); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_ENTER_VIDEO_FULLSCREEN, Visible); - iter = checkCurrentItemIsSeparatorAndGetNext(iter); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_COPY_VIDEO_LINK_TO_CLIPBOARD, Visible | Enabled); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_VIDEO_IN_NEW_WINDOW, Visible | Enabled); - break; - case Editable: - g_assert(!webkit_hit_test_result_context_is_link(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_image(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); - g_assert(webkit_hit_test_result_context_is_editable(hitTestResult)); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_CUT, Visible); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_COPY, Visible); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_PASTE, Visible | Enabled); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_DELETE, Visible); - iter = checkCurrentItemIsSeparatorAndGetNext(iter); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_SELECT_ALL, Visible | Enabled); - if (shouldShowInputMethodsMenu()) { - iter = checkCurrentItemIsSeparatorAndGetNext(iter); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_INPUT_METHODS, Visible | Enabled); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_UNICODE, Visible | Enabled); - } - break; - default: - g_assert_not_reached(); - } - - if (webkit_settings_get_enable_developer_extras(webkit_web_view_get_settings(m_webView))) { - iter = checkCurrentItemIsSeparatorAndGetNext(iter); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_INSPECT_ELEMENT, Visible | Enabled); - } - g_assert(!iter); - - quitMainLoop(); - - return true; - } - - DefaultMenuType m_expectedMenuType; -}; - -static void testContextMenuDefaultMenu(ContextMenuDefaultTest* test, gconstpointer) -{ - test->showInWindowAndWaitUntilMapped(); - - const char* linksHTML = - "<html><body>" - " <a style='position:absolute; left:1; top:1' href='http://www.webkitgtk.org' title='WebKitGTK+ Title'>WebKitGTK+ Website</a>" - " <img style='position:absolute; left:1; top:10' src='0xdeadbeef' width=5 height=5></img>" - " <a style='position:absolute; left:1; top:20' href='http://www.webkitgtk.org/logo' title='WebKitGTK+ Logo'><img src='0xdeadbeef' width=5 height=5></img></a>" - " <input style='position:absolute; left:1; top:30' size='10'></input>" - " <video style='position:absolute; left:1; top:50' width='300' height='300' controls='controls' preload='none'><source src='movie.ogg' type='video/ogg' /></video>" - "</body></html>"; - test->loadHtml(linksHTML, "file:///"); - test->waitUntilLoadFinished(); - - // Context menu for document. - test->m_expectedMenuType = ContextMenuDefaultTest::Navigation; - test->showContextMenuAtPositionAndWaitUntilFinished(0, 0); - - // Context menu for link. - test->m_expectedMenuType = ContextMenuDefaultTest::Link; - test->showContextMenuAtPositionAndWaitUntilFinished(1, 1); - - // Context menu for image. - test->m_expectedMenuType = ContextMenuDefaultTest::Image; - test->showContextMenuAtPositionAndWaitUntilFinished(1, 10); - - // Enable developer extras now, so that inspector element - // will be shown in the default context menu. - webkit_settings_set_enable_developer_extras(webkit_web_view_get_settings(test->m_webView), TRUE); - - // Context menu for image link. - test->m_expectedMenuType = ContextMenuDefaultTest::LinkImage; - test->showContextMenuAtPositionAndWaitUntilFinished(1, 20); - - // Context menu for image video. - test->m_expectedMenuType = ContextMenuDefaultTest::Video; - test->showContextMenuAtPositionAndWaitUntilFinished(1, 50); - - // Context menu for editable. - test->m_expectedMenuType = ContextMenuDefaultTest::Editable; - test->showContextMenuAtPositionAndWaitUntilFinished(5, 35); -} - -class ContextMenuCustomTest: public ContextMenuTest { -public: - MAKE_GLIB_TEST_FIXTURE(ContextMenuCustomTest); - - ContextMenuCustomTest() - : m_itemToActivateLabel(0) - , m_activated(false) - , m_toggled(false) - { - } - - bool contextMenu(WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult* hitTestResult) - { - // Append our custom item to the default menu. - webkit_context_menu_append(contextMenu, webkit_context_menu_item_new(m_action.get())); - quitMainLoop(); - - return false; - } - - GtkMenuItem* getMenuItem(GtkMenu* menu, const gchar* itemLabel) - { - GOwnPtr<GList> items(gtk_container_get_children(GTK_CONTAINER(menu))); - for (GList* iter = items.get(); iter; iter = g_list_next(iter)) { - GtkMenuItem* child = GTK_MENU_ITEM(iter->data); - if (g_str_equal(itemLabel, gtk_menu_item_get_label(child))) - return child; - } - g_assert_not_reached(); - return 0; - } - - void activateMenuItem() - { - g_assert(m_itemToActivateLabel); - GtkMenu* menu = getPopupMenu(); - GtkMenuItem* item = getMenuItem(menu, m_itemToActivateLabel); - gtk_menu_shell_activate_item(GTK_MENU_SHELL(menu), GTK_WIDGET(item), TRUE); - m_itemToActivateLabel = 0; - } - - static gboolean activateMenuItemIdleCallback(gpointer userData) - { - ContextMenuCustomTest* test = static_cast<ContextMenuCustomTest*>(userData); - test->activateMenuItem(); - return FALSE; - } - - void activateCustomMenuItemAndWaitUntilActivated(const char* actionLabel) - { - m_activated = m_toggled = false; - m_itemToActivateLabel = actionLabel; - g_idle_add(activateMenuItemIdleCallback, this); - g_main_loop_run(m_mainLoop); - } - - void toggleCustomMenuItemAndWaitUntilToggled(const char* actionLabel) - { - activateCustomMenuItemAndWaitUntilActivated(actionLabel); - } - - static void actionActivatedCallback(GtkAction*, ContextMenuCustomTest* test) - { - test->m_activated = true; - } - - static void actionToggledCallback(GtkAction*, ContextMenuCustomTest* test) - { - test->m_toggled = true; - } - - void setAction(GtkAction* action) - { - m_action = action; - if (GTK_IS_TOGGLE_ACTION(action)) - g_signal_connect(action, "toggled", G_CALLBACK(actionToggledCallback), this); - else - g_signal_connect(action, "activate", G_CALLBACK(actionActivatedCallback), this); - } - - GRefPtr<GtkAction> m_action; - const char* m_itemToActivateLabel; - bool m_activated; - bool m_toggled; -}; - -static void testContextMenuPopulateMenu(ContextMenuCustomTest* test, gconstpointer) -{ - test->showInWindowAndWaitUntilMapped(); - - test->loadHtml("<html><body>WebKitGTK+ Context menu tests</body></html>", "file:///"); - test->waitUntilLoadFinished(); - - // Create a custom menu item. - GRefPtr<GtkAction> action = adoptGRef(gtk_action_new("WebKitGTK+CustomAction", "Custom _Action", 0, 0)); - test->setAction(action.get()); - test->showContextMenuAndWaitUntilFinished(); - test->activateCustomMenuItemAndWaitUntilActivated(gtk_action_get_label(action.get())); - g_assert(test->m_activated); - g_assert(!test->m_toggled); - - // Create a custom toggle menu item. - GRefPtr<GtkAction> toggleAction = adoptGRef(GTK_ACTION(gtk_toggle_action_new("WebKitGTK+CustomToggleAction", "Custom _Toggle Action", 0, 0))); - test->setAction(toggleAction.get()); - test->showContextMenuAndWaitUntilFinished(); - test->toggleCustomMenuItemAndWaitUntilToggled(gtk_action_get_label(toggleAction.get())); - g_assert(!test->m_activated); - g_assert(test->m_toggled); -} - -class ContextMenuCustomFullTest: public ContextMenuTest { -public: - MAKE_GLIB_TEST_FIXTURE(ContextMenuCustomFullTest); - - bool contextMenu(WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult*) - { - // Clear proposed menu and build our own. - webkit_context_menu_remove_all(contextMenu); - g_assert_cmpint(webkit_context_menu_get_n_items(contextMenu), ==, 0); - - // Add actions from stock. - webkit_context_menu_prepend(contextMenu, webkit_context_menu_item_new_from_stock_action(WEBKIT_CONTEXT_MENU_ACTION_GO_BACK)); - webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_from_stock_action(WEBKIT_CONTEXT_MENU_ACTION_GO_FORWARD)); - webkit_context_menu_insert(contextMenu, webkit_context_menu_item_new_separator(), 2); - - // Add custom actions. - GRefPtr<GtkAction> action = adoptGRef(gtk_action_new("WebKitGTK+CustomAction", "Custom _Action", 0, 0)); - gtk_action_set_sensitive(action.get(), FALSE); - webkit_context_menu_insert(contextMenu, webkit_context_menu_item_new(action.get()), -1); - GRefPtr<GtkAction> toggleAction = adoptGRef(GTK_ACTION(gtk_toggle_action_new("WebKitGTK+CustomToggleAction", "Custom _Toggle Action", 0, 0))); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(toggleAction.get()), TRUE); - webkit_context_menu_append(contextMenu, webkit_context_menu_item_new(toggleAction.get())); - webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator()); - - // Add a submenu. - GRefPtr<WebKitContextMenu> subMenu = adoptGRef(webkit_context_menu_new()); - assertObjectIsDeletedWhenTestFinishes(G_OBJECT(subMenu.get())); - webkit_context_menu_insert(subMenu.get(), webkit_context_menu_item_new_from_stock_action_with_label(WEBKIT_CONTEXT_MENU_ACTION_STOP, "Stop Load"), 0); - webkit_context_menu_insert(subMenu.get(), webkit_context_menu_item_new_from_stock_action(WEBKIT_CONTEXT_MENU_ACTION_RELOAD), -1); - webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_with_submenu("Load options", subMenu.get())); - webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator()); - - // Move Load submenu before custom actions. - webkit_context_menu_move_item(contextMenu, webkit_context_menu_last(contextMenu), 3); - webkit_context_menu_move_item(contextMenu, webkit_context_menu_last(contextMenu), 3); - - // If last item is a separator, remove it. - if (webkit_context_menu_item_is_separator(webkit_context_menu_last(contextMenu))) - webkit_context_menu_remove(contextMenu, webkit_context_menu_last(contextMenu)); - - // Check the menu. - GList* iter = webkit_context_menu_get_items(contextMenu); - - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_GO_BACK, Visible | Enabled); - iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_GO_FORWARD, Visible | Enabled); - iter = checkCurrentItemIsSeparatorAndGetNext(iter); - - GList* subMenuIter = 0; - iter = checkCurrentItemIsSubMenuAndGetNext(iter, "Load options", Visible | Enabled, &subMenuIter); - subMenuIter = checkCurrentItemIsStockActionAndGetNext(subMenuIter, WEBKIT_CONTEXT_MENU_ACTION_STOP, Visible | Enabled); - subMenuIter = checkCurrentItemIsStockActionAndGetNext(subMenuIter, WEBKIT_CONTEXT_MENU_ACTION_RELOAD, Visible | Enabled); - iter = checkCurrentItemIsSeparatorAndGetNext(iter); - - iter = checkCurrentItemIsCustomActionAndGetNext(iter, "Custom _Action", Visible); - iter = checkCurrentItemIsCustomActionAndGetNext(iter, "Custom _Toggle Action", Visible | Enabled | Checked); - g_assert(!iter); - - quitMainLoop(); - - return true; - } -}; - -static void testContextMenuCustomMenu(ContextMenuCustomFullTest* test, gconstpointer) -{ - test->showInWindowAndWaitUntilMapped(); - - test->loadHtml("<html><body>WebKitGTK+ Context menu tests</body></html>", "file:///"); - test->waitUntilLoadFinished(); - - test->showContextMenuAndWaitUntilFinished(); -} - -class ContextMenuDisabledTest: public ContextMenuTest { -public: - MAKE_GLIB_TEST_FIXTURE(ContextMenuDisabledTest); - - enum DisableMode { - IgnoreClicks, - IgnoreDefaultMenu - }; - - static gboolean buttonPressEventCallback(GtkWidget*, GdkEvent* event, ContextMenuDisabledTest* test) - { - if (event->button.button != 3) - return FALSE; - return test->rightButtonPressed(); - } - - ContextMenuDisabledTest() - : m_disableMode(IgnoreClicks) - { - g_signal_connect(m_webView, "button-press-event", G_CALLBACK(buttonPressEventCallback), this); - } - - bool contextMenu(WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult*) - { - if (m_disableMode == IgnoreClicks) - g_assert_not_reached(); - else - quitMainLoop(); - - return true; - } - - bool rightButtonPressed() - { - if (m_disableMode == IgnoreClicks) { - quitMainLoopAfterProcessingPendingEvents(); - return true; - } - return false; - } - - DisableMode m_disableMode; -}; - -static void testContextMenuDisableMenu(ContextMenuDisabledTest* test, gconstpointer) -{ - test->showInWindowAndWaitUntilMapped(); - - test->loadHtml("<html><body>WebKitGTK+ Context menu tests</body></html>", "file:///"); - test->waitUntilLoadFinished(); - - test->m_disableMode = ContextMenuDisabledTest::IgnoreDefaultMenu; - test->showContextMenuAndWaitUntilFinished(); - - test->m_disableMode = ContextMenuDisabledTest::IgnoreClicks; - test->showContextMenuAndWaitUntilFinished(); -} - -class ContextMenuSubmenuTest: public ContextMenuTest { -public: - MAKE_GLIB_TEST_FIXTURE(ContextMenuSubmenuTest); - - bool contextMenu(WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult*) - { - size_t menuSize = webkit_context_menu_get_n_items(contextMenu); - GRefPtr<WebKitContextMenu> subMenu = adoptGRef(webkit_context_menu_new()); - webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_with_submenu("SubMenuItem", subMenu.get())); - g_assert_cmpuint(webkit_context_menu_get_n_items(contextMenu), ==, menuSize + 1); - - GRefPtr<WebKitContextMenu> subMenu2 = adoptGRef(webkit_context_menu_new()); - GRefPtr<WebKitContextMenuItem> item = webkit_context_menu_item_new_from_stock_action(WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK); - - // Add submenu to newly created item. - g_assert(!webkit_context_menu_item_get_submenu(item.get())); - webkit_context_menu_item_set_submenu(item.get(), subMenu2.get()); - g_assert(webkit_context_menu_item_get_submenu(item.get()) == subMenu2.get()); - - // Replace the submenu. - webkit_context_menu_item_set_submenu(item.get(), 0); - g_assert(!webkit_context_menu_item_get_submenu(item.get())); - - // Try to add a submenu already added to another item. - removeLogFatalFlag(G_LOG_LEVEL_WARNING); - webkit_context_menu_item_set_submenu(item.get(), subMenu.get()); - addLogFatalFlag(G_LOG_LEVEL_WARNING); - g_assert(!webkit_context_menu_item_get_submenu(item.get())); - - // A removed submenu shouldn't have a parent. - webkit_context_menu_item_set_submenu(item.get(), subMenu2.get()); - g_assert(webkit_context_menu_item_get_submenu(item.get()) == subMenu2.get()); - - quitMainLoop(); - - return true; - } -}; - -static void testContextMenuSubMenu(ContextMenuSubmenuTest* test, gconstpointer) -{ - test->showInWindowAndWaitUntilMapped(); - - test->loadHtml("<html><body>WebKitGTK+ Context menu tests</body></html>", "file:///"); - test->waitUntilLoadFinished(); - - test->showContextMenuAndWaitUntilFinished(); -} - -class ContextMenuDismissedTest: public ContextMenuTest { -public: - MAKE_GLIB_TEST_FIXTURE(ContextMenuDismissedTest); - - ContextMenuDismissedTest() - : m_dismissed(false) - { - } - - bool contextMenu(WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult*) - { - quitMainLoop(); - // Show the default context menu. - return false; - } - - void contextMenuDismissed() - { - m_dismissed = true; - ContextMenuTest::contextMenuDismissed(); - } - - void showContextMenuAndWaitUntilDismissed() - { - showContextMenuAndWaitUntilFinished(); - dismissContextMenuAndWaitUntilFinished(); - } - - bool m_dismissed; -}; - -static void testContextMenuDismissed(ContextMenuDismissedTest* test, gconstpointer) -{ - test->showInWindowAndWaitUntilMapped(); - - test->loadHtml("<html><body>WebKitGTK+ Context menu tests</body></html>", "file:///"); - test->waitUntilLoadFinished(); - - test->showContextMenuAndWaitUntilDismissed(); - g_assert(test->m_dismissed); -} - -class ContextMenuSmartSeparatorsTest: public ContextMenuTest { -public: - MAKE_GLIB_TEST_FIXTURE(ContextMenuSmartSeparatorsTest); - - bool contextMenu(WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult*) - { - webkit_context_menu_remove_all(contextMenu); - - webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator()); - webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator()); - webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_from_stock_action(WEBKIT_CONTEXT_MENU_ACTION_GO_BACK)); - webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_from_stock_action(WEBKIT_CONTEXT_MENU_ACTION_GO_FORWARD)); - webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator()); - webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator()); - webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_from_stock_action(WEBKIT_CONTEXT_MENU_ACTION_COPY)); - webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator()); - webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_from_stock_action(WEBKIT_CONTEXT_MENU_ACTION_INSPECT_ELEMENT)); - webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator()); - webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator()); - - quitMainLoop(); - - return false; - } - - GtkMenu* showContextMenuAndGetGtkMenu() - { - showContextMenuAndWaitUntilFinished(); - return getPopupMenu(); - } -}; - -static void testContextMenuSmartSeparators(ContextMenuSmartSeparatorsTest* test, gconstpointer) -{ - test->showInWindowAndWaitUntilMapped(); - - test->loadHtml("<html><body>WebKitGTK+ Context menu tests</body></html>", "file:///"); - test->waitUntilLoadFinished(); - - GtkMenu* menu = test->showContextMenuAndGetGtkMenu(); - g_assert(menu); - - // Leading and trailing separators are not added to the context menu. - GOwnPtr<GList> menuItems(gtk_container_get_children(GTK_CONTAINER(menu))); - g_assert_cmpuint(g_list_length(menuItems.get()), ==, 6); - GtkWidget* item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 0)); - g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 1)); - g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 2)); - g_assert(GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 3)); - g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 4)); - g_assert(GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 5)); - g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - - // Hiding a menu item between two separators hides the following separator. - GtkAction* action = gtk_activatable_get_related_action(GTK_ACTIVATABLE(g_list_nth_data(menuItems.get(), 3))); - gtk_action_set_visible(action, FALSE); - menuItems.set(gtk_container_get_children(GTK_CONTAINER(menu))); - g_assert_cmpuint(g_list_length(menuItems.get()), ==, 6); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 0)); - g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 1)); - g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 2)); - g_assert(GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 3)); - g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && !gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 4)); - g_assert(GTK_IS_SEPARATOR_MENU_ITEM(item) && !gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 5)); - g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - gtk_action_set_visible(action, TRUE); - - // Showing an action between two separators shows the hidden separator. - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 0)); - g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 1)); - g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 2)); - g_assert(GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 3)); - g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 4)); - g_assert(GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 5)); - g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - - // Trailing separators are hidden too. - action = gtk_activatable_get_related_action(GTK_ACTIVATABLE(g_list_nth_data(menuItems.get(), 5))); - gtk_action_set_visible(action, FALSE); - menuItems.set(gtk_container_get_children(GTK_CONTAINER(menu))); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 0)); - g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 1)); - g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 2)); - g_assert(GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 3)); - g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 4)); - g_assert(GTK_IS_SEPARATOR_MENU_ITEM(item) && !gtk_widget_get_visible(item)); - item = GTK_WIDGET(g_list_nth_data(menuItems.get(), 5)); - g_assert(!GTK_IS_SEPARATOR_MENU_ITEM(item) && !gtk_widget_get_visible(item)); -} - -void beforeAll() -{ - ContextMenuDefaultTest::add("WebKitWebView", "default-menu", testContextMenuDefaultMenu); - ContextMenuCustomTest::add("WebKitWebView", "populate-menu", testContextMenuPopulateMenu); - ContextMenuCustomFullTest::add("WebKitWebView", "custom-menu", testContextMenuCustomMenu); - ContextMenuDisabledTest::add("WebKitWebView", "disable-menu", testContextMenuDisableMenu); - ContextMenuSubmenuTest::add("WebKitWebView", "submenu", testContextMenuSubMenu); - ContextMenuDismissedTest::add("WebKitWebView", "menu-dismissed", testContextMenuDismissed); - ContextMenuSmartSeparatorsTest::add("WebKitWebView", "smart-separators", testContextMenuSmartSeparators); -} - -void afterAll() -{ -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestCookieManager.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestCookieManager.cpp deleted file mode 100644 index adc6b5b9b..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestCookieManager.cpp +++ /dev/null @@ -1,331 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitTestServer.h" -#include "WebViewTest.h" -#include <glib/gstdio.h> - -static WebKitTestServer* kServer; -static char* kTempDirectory; - -static const char* kFirstPartyDomain = "127.0.0.1"; -static const char* kThirdPartyDomain = "localhost"; -static const char* kIndexHtmlFormat = - "<html><body>" - " <p>WebKitGTK+ Cookie Manager test</p>" - " <img src='http://localhost:%u/image.png' width=5 height=5></img>" - "</body></html>"; - -class CookieManagerTest: public WebViewTest { -public: - MAKE_GLIB_TEST_FIXTURE(CookieManagerTest); - - static void cookiesChangedCallback(WebKitCookieManager*, CookieManagerTest* test) - { - test->m_cookiesChanged = true; - if (test->m_finishLoopWhenCookiesChange) - g_main_loop_quit(test->m_mainLoop); - } - - CookieManagerTest() - : WebViewTest() - , m_cookieManager(webkit_web_context_get_cookie_manager(webkit_web_view_get_context(m_webView))) - , m_acceptPolicy(WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY) - , m_domains(0) - , m_cookiesChanged(false) - , m_finishLoopWhenCookiesChange(false) - { - g_signal_connect(m_cookieManager, "changed", G_CALLBACK(cookiesChangedCallback), this); - } - - ~CookieManagerTest() - { - g_strfreev(m_domains); - g_signal_handlers_disconnect_matched(m_cookieManager, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); - if (m_cookiesTextFile) - g_unlink(m_cookiesTextFile.get()); - if (m_cookiesSQLiteFile) - g_unlink(m_cookiesSQLiteFile.get()); - } - - void setPersistentStorage(WebKitCookiePersistentStorage storage) - { - const char* filename = 0; - switch (storage) { - case WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT: - if (!m_cookiesTextFile) - m_cookiesTextFile.set(g_build_filename(kTempDirectory, "cookies.txt", NULL)); - filename = m_cookiesTextFile.get(); - break; - case WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE: - if (!m_cookiesSQLiteFile) - m_cookiesSQLiteFile.set(g_build_filename(kTempDirectory, "cookies.db", NULL)); - filename = m_cookiesSQLiteFile.get(); - break; - default: - g_assert_not_reached(); - } - webkit_cookie_manager_set_persistent_storage(m_cookieManager, filename, storage); - } - - static void getAcceptPolicyReadyCallback(GObject* object, GAsyncResult* result, gpointer userData) - { - GOwnPtr<GError> error; - WebKitCookieAcceptPolicy policy = webkit_cookie_manager_get_accept_policy_finish(WEBKIT_COOKIE_MANAGER(object), result, &error.outPtr()); - g_assert(!error.get()); - - CookieManagerTest* test = static_cast<CookieManagerTest*>(userData); - test->m_acceptPolicy = policy; - g_main_loop_quit(test->m_mainLoop); - } - - WebKitCookieAcceptPolicy getAcceptPolicy() - { - m_acceptPolicy = WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY; - webkit_cookie_manager_get_accept_policy(m_cookieManager, 0, getAcceptPolicyReadyCallback, this); - g_main_loop_run(m_mainLoop); - - return m_acceptPolicy; - } - - void setAcceptPolicy(WebKitCookieAcceptPolicy policy) - { - webkit_cookie_manager_set_accept_policy(m_cookieManager, policy); - } - - static void getDomainsReadyCallback(GObject* object, GAsyncResult* result, gpointer userData) - { - GOwnPtr<GError> error; - char** domains = webkit_cookie_manager_get_domains_with_cookies_finish(WEBKIT_COOKIE_MANAGER(object), result, &error.outPtr()); - g_assert(!error.get()); - - CookieManagerTest* test = static_cast<CookieManagerTest*>(userData); - test->m_domains = domains; - g_main_loop_quit(test->m_mainLoop); - } - - char** getDomains() - { - g_strfreev(m_domains); - m_domains = 0; - webkit_cookie_manager_get_domains_with_cookies(m_cookieManager, 0, getDomainsReadyCallback, this); - g_main_loop_run(m_mainLoop); - - return m_domains; - } - - bool hasDomain(const char* domain) - { - if (!m_domains) - return false; - - for (size_t i = 0; m_domains[i]; ++i) - if (g_str_equal(m_domains[i], domain)) - return true; - return false; - } - - void deleteCookiesForDomain(const char* domain) - { - webkit_cookie_manager_delete_cookies_for_domain(m_cookieManager, domain); - } - - void deleteAllCookies() - { - webkit_cookie_manager_delete_all_cookies(m_cookieManager); - } - - void waitUntilCookiesChanged() - { - m_cookiesChanged = false; - m_finishLoopWhenCookiesChange = true; - g_main_loop_run(m_mainLoop); - m_finishLoopWhenCookiesChange = false; - } - - WebKitCookieManager* m_cookieManager; - WebKitCookieAcceptPolicy m_acceptPolicy; - char** m_domains; - bool m_cookiesChanged; - bool m_finishLoopWhenCookiesChange; - GOwnPtr<char> m_cookiesTextFile; - GOwnPtr<char> m_cookiesSQLiteFile; -}; - -static void testCookieManagerAcceptPolicy(CookieManagerTest* test, gconstpointer) -{ - // Default policy is NO_THIRD_PARTY. - g_assert_cmpint(test->getAcceptPolicy(), ==, WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY); - test->loadURI(kServer->getURIForPath("/index.html").data()); - test->waitUntilLoadFinished(); - char** domains = test->getDomains(); - g_assert(domains); - g_assert_cmpint(g_strv_length(domains), ==, 1); - g_assert_cmpstr(domains[0], ==, kFirstPartyDomain); - test->deleteAllCookies(); - - test->setAcceptPolicy(WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS); - g_assert_cmpint(test->getAcceptPolicy(), ==, WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS); - test->loadURI(kServer->getURIForPath("/index.html").data()); - test->waitUntilLoadFinished(); - domains = test->getDomains(); - g_assert(domains); - g_assert_cmpint(g_strv_length(domains), ==, 2); - g_assert(test->hasDomain(kFirstPartyDomain)); - g_assert(test->hasDomain(kThirdPartyDomain)); - test->deleteAllCookies(); - - test->setAcceptPolicy(WEBKIT_COOKIE_POLICY_ACCEPT_NEVER); - g_assert_cmpint(test->getAcceptPolicy(), ==, WEBKIT_COOKIE_POLICY_ACCEPT_NEVER); - test->loadURI(kServer->getURIForPath("/index.html").data()); - test->waitUntilLoadFinished(); - domains = test->getDomains(); - g_assert(domains); - g_assert_cmpint(g_strv_length(domains), ==, 0); -} - -static void testCookieManagerDeleteCookies(CookieManagerTest* test, gconstpointer) -{ - test->setAcceptPolicy(WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS); - test->loadURI(kServer->getURIForPath("/index.html").data()); - test->waitUntilLoadFinished(); - g_assert_cmpint(g_strv_length(test->getDomains()), ==, 2); - - // Delete first party cookies. - test->deleteCookiesForDomain(kFirstPartyDomain); - g_assert_cmpint(g_strv_length(test->getDomains()), ==, 1); - - // Delete third party cookies. - test->deleteCookiesForDomain(kThirdPartyDomain); - g_assert_cmpint(g_strv_length(test->getDomains()), ==, 0); - - test->loadURI(kServer->getURIForPath("/index.html").data()); - test->waitUntilLoadFinished(); - g_assert_cmpint(g_strv_length(test->getDomains()), ==, 2); - - // Delete all cookies. - test->deleteAllCookies(); - g_assert_cmpint(g_strv_length(test->getDomains()), ==, 0); -} - -static void testCookieManagerCookiesChanged(CookieManagerTest* test, gconstpointer) -{ - g_assert(!test->m_cookiesChanged); - test->setAcceptPolicy(WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS); - test->loadURI(kServer->getURIForPath("/index.html").data()); - test->waitUntilLoadFinished(); - g_assert(test->m_cookiesChanged); - - test->deleteCookiesForDomain(kFirstPartyDomain); - test->waitUntilCookiesChanged(); - g_assert(test->m_cookiesChanged); - - test->deleteAllCookies(); - test->waitUntilCookiesChanged(); - g_assert(test->m_cookiesChanged); -} - -static void testCookieManagerPersistentStorage(CookieManagerTest* test, gconstpointer) -{ - test->setAcceptPolicy(WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS); - - // Text storage using a new file. - test->setPersistentStorage(WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT); - char** domains = test->getDomains(); - g_assert(domains); - g_assert_cmpint(g_strv_length(domains), ==, 0); - - test->loadURI(kServer->getURIForPath("/index.html").data()); - test->waitUntilLoadFinished(); - g_assert(test->m_cookiesChanged); - domains = test->getDomains(); - g_assert(domains); - g_assert_cmpint(g_strv_length(domains), ==, 2); - - - // SQLite storage using a new file. - test->setPersistentStorage(WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE); - domains = test->getDomains(); - g_assert(domains); - g_assert_cmpint(g_strv_length(domains), ==, 0); - - test->loadURI(kServer->getURIForPath("/index.html").data()); - test->waitUntilLoadFinished(); - g_assert(test->m_cookiesChanged); - domains = test->getDomains(); - g_assert(domains); - g_assert_cmpint(g_strv_length(domains), ==, 2); - - // Text storage using an existing file. - test->setPersistentStorage(WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT); - domains = test->getDomains(); - g_assert(domains); - g_assert_cmpint(g_strv_length(domains), ==, 2); - test->deleteAllCookies(); - g_assert_cmpint(g_strv_length(test->getDomains()), ==, 0); - - // SQLite storage with an existing file. - test->setPersistentStorage(WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE); - domains = test->getDomains(); - g_assert(domains); - g_assert_cmpint(g_strv_length(domains), ==, 2); - test->deleteAllCookies(); - g_assert_cmpint(g_strv_length(test->getDomains()), ==, 0); -} - -static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer) -{ - if (message->method != SOUP_METHOD_GET) { - soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED); - return; - } - - soup_message_set_status(message, SOUP_STATUS_OK); - if (g_str_equal(path, "/index.html")) { - char* indexHtml = g_strdup_printf(kIndexHtmlFormat, soup_server_get_port(server)); - soup_message_headers_replace(message->response_headers, "Set-Cookie", "foo=bar; Max-Age=60"); - soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, indexHtml, strlen(indexHtml)); - } else if (g_str_equal(path, "/image.png")) - soup_message_headers_replace(message->response_headers, "Set-Cookie", "baz=qux; Max-Age=60"); - else - soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); - soup_message_body_complete(message->response_body); -} - -void beforeAll() -{ - kServer = new WebKitTestServer(); - kServer->run(serverCallback); - - kTempDirectory = g_dir_make_tmp("WebKit2Tests-XXXXXX", 0); - g_assert(kTempDirectory); - - CookieManagerTest::add("WebKitCookieManager", "accept-policy", testCookieManagerAcceptPolicy); - CookieManagerTest::add("WebKitCookieManager", "delete-cookies", testCookieManagerDeleteCookies); - CookieManagerTest::add("WebKitCookieManager", "cookies-changed", testCookieManagerCookiesChanged); - CookieManagerTest::add("WebKitCookieManager", "persistent-storage", testCookieManagerPersistentStorage); -} - -void afterAll() -{ - delete kServer; - g_rmdir(kTempDirectory); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp deleted file mode 100644 index ce159906c..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp +++ /dev/null @@ -1,522 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitTestServer.h" -#include "WebViewTest.h" -#include <glib/gstdio.h> -#include <gtk/gtk.h> -#include <libsoup/soup.h> -#include <string.h> -#include <webkit2/webkit2.h> -#include <wtf/Vector.h> -#include <wtf/gobject/GOwnPtr.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -static char* kTempDirectory; - -class DownloadTest: public Test { -public: - MAKE_GLIB_TEST_FIXTURE(DownloadTest); - - enum DownloadEvent { - Started, - ReceivedResponse, - CreatedDestination, - ReceivedData, - Failed, - Finished - }; - - static void receivedResponseCallback(WebKitDownload* download, GParamSpec*, DownloadTest* test) - { - g_assert(webkit_download_get_response(download)); - test->receivedResponse(download); - } - - static gboolean createdDestinationCallback(WebKitDownload* download, const gchar* destination, DownloadTest* test) - { - g_assert(webkit_download_get_destination(download)); - g_assert_cmpstr(webkit_download_get_destination(download), ==, destination); - test->createdDestination(download, destination); - return TRUE; - } - - static gboolean receivedDataCallback(WebKitDownload* download, guint64 dataLength, DownloadTest* test) - { - test->receivedData(download, dataLength); - return TRUE; - } - - static gboolean finishedCallback(WebKitDownload* download, DownloadTest* test) - { - test->finished(download); - return TRUE; - } - - static gboolean failedCallback(WebKitDownload* download, GError* error, DownloadTest* test) - { - g_assert(error); - test->failed(download, error); - return TRUE; - } - - static gboolean decideDestinationCallback(WebKitDownload* download, const gchar* suggestedFilename, DownloadTest* test) - { - g_assert(suggestedFilename); - test->decideDestination(download, suggestedFilename); - return TRUE; - } - - static void downloadStartedCallback(WebKitWebContext* context, WebKitDownload* download, DownloadTest* test) - { - g_assert(webkit_download_get_request(download)); - test->started(download); - g_signal_connect(download, "notify::response", G_CALLBACK(receivedResponseCallback), test); - g_signal_connect(download, "created-destination", G_CALLBACK(createdDestinationCallback), test); - g_signal_connect(download, "received-data", G_CALLBACK(receivedDataCallback), test); - g_signal_connect(download, "finished", G_CALLBACK(finishedCallback), test); - g_signal_connect(download, "failed", G_CALLBACK(failedCallback), test); - g_signal_connect(download, "decide-destination", G_CALLBACK(decideDestinationCallback), test); - } - - DownloadTest() - : m_webContext(webkit_web_context_get_default()) - , m_mainLoop(g_main_loop_new(0, TRUE)) - , m_downloadSize(0) - { - g_signal_connect(m_webContext, "download-started", G_CALLBACK(downloadStartedCallback), this); - } - - ~DownloadTest() - { - g_signal_handlers_disconnect_matched(m_webContext, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); - g_main_loop_unref(m_mainLoop); - } - - virtual void started(WebKitDownload* download) - { - m_downloadEvents.append(Started); - } - - virtual void receivedResponse(WebKitDownload* download) - { - m_downloadEvents.append(ReceivedResponse); - } - - virtual void createdDestination(WebKitDownload* download, const char* destination) - { - m_downloadEvents.append(CreatedDestination); - } - - virtual void receivedData(WebKitDownload* download, guint64 dataLength) - { - m_downloadSize += dataLength; - if (!m_downloadEvents.contains(ReceivedData)) - m_downloadEvents.append(ReceivedData); - } - - virtual void finished(WebKitDownload* download) - { - g_assert_cmpuint(m_downloadSize, ==, webkit_download_get_received_data_length(download)); - m_downloadEvents.append(Finished); - g_main_loop_quit(m_mainLoop); - } - - virtual void failed(WebKitDownload* download, GError* error) - { - m_downloadEvents.append(Failed); - } - - virtual void decideDestination(WebKitDownload* download, const gchar* suggestedFilename) - { - GOwnPtr<char> destination(g_build_filename(kTempDirectory, suggestedFilename, NULL)); - GOwnPtr<char> destinationURI(g_filename_to_uri(destination.get(), 0, 0)); - webkit_download_set_destination(download, destinationURI.get()); - } - - WebKitDownload* downloadURIAndWaitUntilFinishes(const CString& requestURI) - { - WebKitDownload* download = webkit_web_context_download_uri(m_webContext, requestURI.data()); - assertObjectIsDeletedWhenTestFinishes(G_OBJECT(download)); - - WebKitURIRequest* request = webkit_download_get_request(download); - g_assert(request); - ASSERT_CMP_CSTRING(webkit_uri_request_get_uri(request), ==, requestURI); - - g_main_loop_run(m_mainLoop); - - return download; - } - - void checkDestinationAndDeleteFile(WebKitDownload* download, const char* expectedName) - { - if (!webkit_download_get_destination(download)) - return; - GRefPtr<GFile> destFile = adoptGRef(g_file_new_for_uri(webkit_download_get_destination(download))); - GOwnPtr<char> destBasename(g_file_get_basename(destFile.get())); - g_assert_cmpstr(destBasename.get(), ==, expectedName); - - g_file_delete(destFile.get(), 0, 0); - } - - WebKitWebContext* m_webContext; - GMainLoop* m_mainLoop; - Vector<DownloadEvent> m_downloadEvents; - guint64 m_downloadSize; -}; - -static void testDownloadLocalFile(DownloadTest* test, gconstpointer) -{ - GOwnPtr<char> sourcePath(g_build_filename(Test::getWebKit1TestResoucesDir().data(), "test.pdf", NULL)); - GRefPtr<GFile> source = adoptGRef(g_file_new_for_path(sourcePath.get())); - GRefPtr<GFileInfo> sourceInfo = adoptGRef(g_file_query_info(source.get(), G_FILE_ATTRIBUTE_STANDARD_SIZE, static_cast<GFileQueryInfoFlags>(0), 0, 0)); - GOwnPtr<char> sourceURI(g_file_get_uri(source.get())); - GRefPtr<WebKitDownload> download = adoptGRef(test->downloadURIAndWaitUntilFinishes(sourceURI.get())); - g_assert(!webkit_download_get_web_view(download.get())); - - Vector<DownloadTest::DownloadEvent>& events = test->m_downloadEvents; - g_assert_cmpint(events.size(), ==, 5); - g_assert_cmpint(events[0], ==, DownloadTest::Started); - g_assert_cmpint(events[1], ==, DownloadTest::ReceivedResponse); - g_assert_cmpint(events[2], ==, DownloadTest::CreatedDestination); - g_assert_cmpint(events[3], ==, DownloadTest::ReceivedData); - g_assert_cmpint(events[4], ==, DownloadTest::Finished); - - WebKitURIRequest* request = webkit_download_get_request(download.get()); - g_assert(request); - g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, sourceURI.get()); - - g_assert_cmpint(test->m_downloadSize, ==, g_file_info_get_size(sourceInfo.get())); - g_assert(webkit_download_get_destination(download.get())); - g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), ==, 1); - test->checkDestinationAndDeleteFile(download.get(), "test.pdf"); -} - -class DownloadErrorTest: public DownloadTest { -public: - MAKE_GLIB_TEST_FIXTURE(DownloadErrorTest); - - DownloadErrorTest() - : m_expectedError(WEBKIT_DOWNLOAD_ERROR_NETWORK) - { - } - - void receivedResponse(WebKitDownload* download) - { - DownloadTest::receivedResponse(download); - if (m_expectedError == WEBKIT_DOWNLOAD_ERROR_CANCELLED_BY_USER) - webkit_download_cancel(download); - } - - void createdDestination(WebKitDownload* download, const char* destination) - { - g_assert_not_reached(); - } - - void failed(WebKitDownload* download, GError* error) - { - g_assert(g_error_matches(error, WEBKIT_DOWNLOAD_ERROR, m_expectedError)); - DownloadTest::failed(download, error); - } - - void decideDestination(WebKitDownload* download, const gchar* suggestedFilename) - { - if (m_expectedError != WEBKIT_DOWNLOAD_ERROR_DESTINATION) { - DownloadTest::decideDestination(download, suggestedFilename); - return; - } - webkit_download_set_destination(download, "file:///foo/bar"); - } - - WebKitDownloadError m_expectedError; -}; - -static void testDownloadLocalFileError(DownloadErrorTest* test, gconstpointer) -{ - test->m_expectedError = WEBKIT_DOWNLOAD_ERROR_NETWORK; - GRefPtr<WebKitDownload> download = adoptGRef(test->downloadURIAndWaitUntilFinishes("file:///foo/bar")); - g_assert(!webkit_download_get_web_view(download.get())); - - Vector<DownloadTest::DownloadEvent>& events = test->m_downloadEvents; - g_assert_cmpint(events.size(), ==, 3); - g_assert_cmpint(events[0], ==, DownloadTest::Started); - g_assert_cmpint(events[1], ==, DownloadTest::Failed); - g_assert_cmpint(events[2], ==, DownloadTest::Finished); - events.clear(); - g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), <, 1); - - test->m_expectedError = WEBKIT_DOWNLOAD_ERROR_DESTINATION; - GOwnPtr<char> path(g_build_filename(Test::getWebKit1TestResoucesDir().data(), "test.pdf", NULL)); - GRefPtr<GFile> file = adoptGRef(g_file_new_for_path(path.get())); - GOwnPtr<char> uri(g_file_get_uri(file.get())); - download = adoptGRef(test->downloadURIAndWaitUntilFinishes(uri.get())); - g_assert(!webkit_download_get_web_view(download.get())); - - g_assert_cmpint(events.size(), ==, 4); - g_assert_cmpint(events[0], ==, DownloadTest::Started); - g_assert_cmpint(events[1], ==, DownloadTest::ReceivedResponse); - g_assert_cmpint(events[2], ==, DownloadTest::Failed); - g_assert_cmpint(events[3], ==, DownloadTest::Finished); - events.clear(); - g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), <, 1); - test->checkDestinationAndDeleteFile(download.get(), "bar"); - - test->m_expectedError = WEBKIT_DOWNLOAD_ERROR_CANCELLED_BY_USER; - download = adoptGRef(test->downloadURIAndWaitUntilFinishes(uri.get())); - g_assert(!webkit_download_get_web_view(download.get())); - - g_assert_cmpint(events.size(), ==, 4); - g_assert_cmpint(events[0], ==, DownloadTest::Started); - g_assert_cmpint(events[1], ==, DownloadTest::ReceivedResponse); - g_assert_cmpint(events[2], ==, DownloadTest::Failed); - g_assert_cmpint(events[3], ==, DownloadTest::Finished); - events.clear(); - g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), <, 1); - test->checkDestinationAndDeleteFile(download.get(), "test.pdf"); -} - -static WebKitTestServer* kServer; -static const char* kServerSuggestedFilename = "webkit-downloaded-file"; - -static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer) -{ - if (message->method != SOUP_METHOD_GET) { - soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED); - return; - } - - GOwnPtr<char> filePath(g_build_filename(Test::getWebKit1TestResoucesDir().data(), path, NULL)); - char* contents; - gsize contentsLength; - if (!g_file_get_contents(filePath.get(), &contents, &contentsLength, 0)) { - soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); - soup_message_body_complete(message->response_body); - return; - } - - soup_message_set_status(message, SOUP_STATUS_OK); - - GOwnPtr<char> contentDisposition(g_strdup_printf("filename=%s", kServerSuggestedFilename)); - soup_message_headers_append(message->response_headers, "Content-Disposition", contentDisposition.get()); - soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, contents, contentsLength); - - soup_message_body_complete(message->response_body); -} - -static void testDownloadRemoteFile(DownloadTest* test, gconstpointer) -{ - GRefPtr<WebKitDownload> download = adoptGRef(test->downloadURIAndWaitUntilFinishes(kServer->getURIForPath("/test.pdf"))); - g_assert(!webkit_download_get_web_view(download.get())); - - Vector<DownloadTest::DownloadEvent>& events = test->m_downloadEvents; - g_assert_cmpint(events.size(), ==, 5); - g_assert_cmpint(events[0], ==, DownloadTest::Started); - g_assert_cmpint(events[1], ==, DownloadTest::ReceivedResponse); - g_assert_cmpint(events[2], ==, DownloadTest::CreatedDestination); - g_assert_cmpint(events[3], ==, DownloadTest::ReceivedData); - g_assert_cmpint(events[4], ==, DownloadTest::Finished); - events.clear(); - - WebKitURIRequest* request = webkit_download_get_request(download.get()); - g_assert(request); - ASSERT_CMP_CSTRING(webkit_uri_request_get_uri(request), ==, kServer->getURIForPath("/test.pdf")); - - g_assert(webkit_download_get_destination(download.get())); - g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), ==, 1); - test->checkDestinationAndDeleteFile(download.get(), kServerSuggestedFilename); -} - -static void testDownloadRemoteFileError(DownloadErrorTest* test, gconstpointer) -{ - test->m_expectedError = WEBKIT_DOWNLOAD_ERROR_NETWORK; - GRefPtr<WebKitDownload> download = adoptGRef(test->downloadURIAndWaitUntilFinishes(kServer->getURIForPath("/foo"))); - g_assert(!webkit_download_get_web_view(download.get())); - - Vector<DownloadTest::DownloadEvent>& events = test->m_downloadEvents; - g_assert_cmpint(events.size(), ==, 4); - g_assert_cmpint(events[0], ==, DownloadTest::Started); - g_assert_cmpint(events[1], ==, DownloadTest::ReceivedResponse); - g_assert_cmpint(events[2], ==, DownloadTest::Failed); - g_assert_cmpint(events[3], ==, DownloadTest::Finished); - events.clear(); - WebKitURIResponse* response = webkit_download_get_response(download.get()); - g_assert_cmpuint(webkit_uri_response_get_status_code(response), ==, 404); - g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), <, 1); - - test->m_expectedError = WEBKIT_DOWNLOAD_ERROR_DESTINATION; - download = adoptGRef(test->downloadURIAndWaitUntilFinishes(kServer->getURIForPath("/test.pdf"))); - g_assert(!webkit_download_get_web_view(download.get())); - - g_assert_cmpint(events.size(), ==, 4); - g_assert_cmpint(events[0], ==, DownloadTest::Started); - g_assert_cmpint(events[1], ==, DownloadTest::ReceivedResponse); - g_assert_cmpint(events[2], ==, DownloadTest::Failed); - g_assert_cmpint(events[3], ==, DownloadTest::Finished); - events.clear(); - g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), <, 1); - test->checkDestinationAndDeleteFile(download.get(), "bar"); - - test->m_expectedError = WEBKIT_DOWNLOAD_ERROR_CANCELLED_BY_USER; - download = adoptGRef(test->downloadURIAndWaitUntilFinishes(kServer->getURIForPath("/test.pdf"))); - g_assert(!webkit_download_get_web_view(download.get())); - - g_assert_cmpint(events.size(), ==, 4); - g_assert_cmpint(events[0], ==, DownloadTest::Started); - g_assert_cmpint(events[1], ==, DownloadTest::ReceivedResponse); - g_assert_cmpint(events[2], ==, DownloadTest::Failed); - g_assert_cmpint(events[3], ==, DownloadTest::Finished); - events.clear(); - g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), <, 1); - test->checkDestinationAndDeleteFile(download.get(), kServerSuggestedFilename); -} - -class WebViewDownloadTest: public WebViewTest { -public: - MAKE_GLIB_TEST_FIXTURE(WebViewDownloadTest); - - static void downloadStartedCallback(WebKitWebContext* context, WebKitDownload* download, WebViewDownloadTest* test) - { - test->m_download = download; - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(download)); - test->quitMainLoop(); - } - - WebViewDownloadTest() - { - g_signal_connect(webkit_web_view_get_context(m_webView), "download-started", G_CALLBACK(downloadStartedCallback), this); - } - - ~WebViewDownloadTest() - { - g_signal_handlers_disconnect_matched(webkit_web_view_get_context(m_webView), G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); - } - - void waitUntilDownloadStarted() - { - m_download = 0; - g_main_loop_run(m_mainLoop); - g_assert(m_download.get()); - } - - static gboolean downloadDecideDestinationCallback(WebKitDownload* download, const gchar* suggestedFilename, WebViewDownloadTest* test) - { - GOwnPtr<char> destination(g_build_filename(kTempDirectory, suggestedFilename, NULL)); - GOwnPtr<char> destinationURI(g_filename_to_uri(destination.get(), 0, 0)); - webkit_download_set_destination(download, destinationURI.get()); - return TRUE; - } - - static void downloadFinishedCallback(WebKitDownload* download, WebViewDownloadTest* test) - { - test->quitMainLoop(); - } - - void waitUntilDownloadFinished() - { - g_signal_connect(m_download.get(), "decide-destination", G_CALLBACK(downloadDecideDestinationCallback), this); - g_signal_connect(m_download.get(), "finished", G_CALLBACK(downloadFinishedCallback), this); - g_main_loop_run(m_mainLoop); - } - - GRefPtr<WebKitDownload> m_download; -}; - -static void testWebViewDownloadURI(WebViewDownloadTest* test, gconstpointer) -{ - GRefPtr<WebKitDownload> download = adoptGRef(webkit_web_view_download_uri(test->m_webView, kServer->getURIForPath("/test.pdf").data())); - test->waitUntilDownloadStarted(); - g_assert(test->m_webView == webkit_download_get_web_view(download.get())); - test->waitUntilDownloadFinished(); - - GRefPtr<GFile> downloadFile = adoptGRef(g_file_new_for_uri(webkit_download_get_destination(download.get()))); - GRefPtr<GFileInfo> downloadFileInfo = adoptGRef(g_file_query_info(downloadFile.get(), G_FILE_ATTRIBUTE_STANDARD_SIZE, static_cast<GFileQueryInfoFlags>(0), 0, 0)); - g_assert_cmpint(g_file_info_get_size(downloadFileInfo.get()), >, 0); - g_file_delete(downloadFile.get(), 0, 0); -} - -class PolicyResponseDownloadTest: public WebViewDownloadTest { -public: - MAKE_GLIB_TEST_FIXTURE(PolicyResponseDownloadTest); - - static gboolean decidePolicyCallback(WebKitWebView* webView, WebKitPolicyDecision* decision, WebKitPolicyDecisionType type, PolicyResponseDownloadTest* test) - { - if (type != WEBKIT_POLICY_DECISION_TYPE_RESPONSE) - return FALSE; - - webkit_policy_decision_download(decision); - return TRUE; - } - - PolicyResponseDownloadTest() - { - g_signal_connect(m_webView, "decide-policy", G_CALLBACK(decidePolicyCallback), this); - } - - ~PolicyResponseDownloadTest() - { - g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); - } - - void cancelDownloadAndWaitUntilFinished() - { - webkit_download_cancel(m_download.get()); - waitUntilDownloadFinished(); - m_download = 0; - } -}; - -static void testPolicyResponseDownload(PolicyResponseDownloadTest* test, gconstpointer) -{ - // Test that a download started by the the policy checker contains the web view. - CString requestURI = kServer->getURIForPath("/test.pdf").data(); - test->loadURI(requestURI.data()); - test->waitUntilDownloadStarted(); - - WebKitURIRequest* request = webkit_download_get_request(test->m_download.get()); - g_assert(request); - ASSERT_CMP_CSTRING(webkit_uri_request_get_uri(request), ==, requestURI); - - g_assert(test->m_webView == webkit_download_get_web_view(test->m_download.get())); - test->cancelDownloadAndWaitUntilFinished(); -} - -void beforeAll() -{ - kServer = new WebKitTestServer(); - kServer->run(serverCallback); - - kTempDirectory = g_dir_make_tmp("WebKit2Tests-XXXXXX", 0); - g_assert(kTempDirectory); - - DownloadTest::add("Downloads", "local-file", testDownloadLocalFile); - DownloadErrorTest::add("Downloads", "local-file-error", testDownloadLocalFileError); - DownloadTest::add("Downloads", "remote-file", testDownloadRemoteFile); - DownloadErrorTest::add("Downloads", "remote-file-error", testDownloadRemoteFileError); - WebViewDownloadTest::add("WebKitWebView", "download-uri", testWebViewDownloadURI); - PolicyResponseDownloadTest::add("Downloads", "policy-decision-download", testPolicyResponseDownload); -} - -void afterAll() -{ - delete kServer; - g_rmdir(kTempDirectory); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestInspector.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestInspector.cpp deleted file mode 100644 index aa80888b3..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestInspector.cpp +++ /dev/null @@ -1,356 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebViewTest.h" -#include <wtf/gobject/GRefPtr.h> - -class InspectorTest: public WebViewTest { -public: - MAKE_GLIB_TEST_FIXTURE(InspectorTest); - - enum InspectorEvents { - OpenWindow, - BringToFront, - Closed, - Attach, - Detach - }; - - static gboolean openWindowCallback(WebKitWebInspector*, InspectorTest* test) - { - return test->openWindow(); - } - - static gboolean bringToFrontCallback(WebKitWebInspector*, InspectorTest* test) - { - return test->bringToFront(); - } - - static void closedCallback(WebKitWebInspector*, InspectorTest* test) - { - return test->closed(); - } - - static gboolean attachCallback(WebKitWebInspector*, InspectorTest* test) - { - return test->attach(); - } - - static gboolean detachCallback(WebKitWebInspector*, InspectorTest* test) - { - return test->detach(); - } - - static const unsigned gMinimumAttachedInspectorWidth = 750; - static const unsigned gMinimumAttachedInspectorHeight = 250; - - InspectorTest() - : WebViewTest() - , m_inspector(webkit_web_view_get_inspector(m_webView)) - { - webkit_settings_set_enable_developer_extras(webkit_web_view_get_settings(m_webView), TRUE); - assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_inspector)); - g_signal_connect(m_inspector, "open-window", G_CALLBACK(openWindowCallback), this); - g_signal_connect(m_inspector, "bring-to-front", G_CALLBACK(bringToFrontCallback), this); - g_signal_connect(m_inspector, "closed", G_CALLBACK(closedCallback), this); - g_signal_connect(m_inspector, "attach", G_CALLBACK(attachCallback), this); - g_signal_connect(m_inspector, "detach", G_CALLBACK(detachCallback), this); - } - - ~InspectorTest() - { - g_signal_handlers_disconnect_matched(m_inspector, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); - } - - virtual bool openWindow() - { - m_events.append(OpenWindow); - g_main_loop_quit(m_mainLoop); - return TRUE; - } - - virtual bool bringToFront() - { - m_events.append(BringToFront); - g_main_loop_quit(m_mainLoop); - return FALSE; - } - - virtual void closed() - { - m_events.append(Closed); - } - - virtual bool attach() - { - m_events.append(Attach); - return TRUE; - } - - virtual bool detach() - { - m_events.append(Detach); - return TRUE; - } - - - static gboolean showIdle(InspectorTest* test) - { - webkit_web_inspector_show(test->m_inspector); - return FALSE; - } - - void show() - { - g_idle_add(reinterpret_cast<GSourceFunc>(showIdle), this); - g_main_loop_run(m_mainLoop); - } - - void resizeViewAndAttach() - { - // Resize the view to make room for the inspector. - resizeView(gMinimumAttachedInspectorWidth, (gMinimumAttachedInspectorHeight + 1) * 4 / 3); - webkit_web_inspector_attach(m_inspector); - } - - static gboolean detachIdle(InspectorTest* test) - { - webkit_web_inspector_detach(test->m_inspector); - return FALSE; - } - - void detachAndWaitUntilWindowOpened() - { - g_idle_add(reinterpret_cast<GSourceFunc>(detachIdle), this); - g_main_loop_run(m_mainLoop); - } - - void close() - { - webkit_web_inspector_close(m_inspector); - } - - WebKitWebInspector* m_inspector; - Vector<InspectorEvents> m_events; -}; - -static void testInspectorDefault(InspectorTest* test, gconstpointer) -{ - test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL); - test->resizeView(200, 200); - test->loadHtml("<html><body><p>WebKitGTK+ Inspector test</p></body></html>", 0); - test->waitUntilLoadFinished(); - - test->show(); - // We don't add the view to a container, so consume the weak ref with GRefPtr. - GRefPtr<WebKitWebViewBase> inspectorView = webkit_web_inspector_get_web_view(test->m_inspector); - g_assert(inspectorView.get()); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(inspectorView.get())); - g_assert(!webkit_web_inspector_is_attached(test->m_inspector)); - g_assert_cmpuint(webkit_web_inspector_get_attached_height(test->m_inspector), ==, 0); - Vector<InspectorTest::InspectorEvents>& events = test->m_events; - g_assert_cmpint(events.size(), ==, 1); - g_assert_cmpint(events[0], ==, InspectorTest::OpenWindow); - test->m_events.clear(); - - test->show(); - events = test->m_events; - g_assert_cmpint(events.size(), ==, 1); - g_assert_cmpint(events[0], ==, InspectorTest::BringToFront); - test->m_events.clear(); - - test->resizeViewAndAttach(); - g_assert(webkit_web_inspector_is_attached(test->m_inspector)); - g_assert_cmpuint(webkit_web_inspector_get_attached_height(test->m_inspector), >=, InspectorTest::gMinimumAttachedInspectorHeight); - events = test->m_events; - g_assert_cmpint(events.size(), ==, 1); - g_assert_cmpint(events[0], ==, InspectorTest::Attach); - test->m_events.clear(); - - test->detachAndWaitUntilWindowOpened(); - g_assert(!webkit_web_inspector_is_attached(test->m_inspector)); - events = test->m_events; - g_assert_cmpint(events.size(), ==, 2); - g_assert_cmpint(events[0], ==, InspectorTest::Detach); - g_assert_cmpint(events[1], ==, InspectorTest::OpenWindow); - test->m_events.clear(); - - test->close(); - events = test->m_events; - g_assert_cmpint(events.size(), ==, 1); - g_assert_cmpint(events[0], ==, InspectorTest::Closed); - test->m_events.clear(); -} - -class CustomInspectorTest: public InspectorTest { -public: - MAKE_GLIB_TEST_FIXTURE(CustomInspectorTest); - - CustomInspectorTest() - : InspectorTest() - , m_inspectorWindow(0) - { - } - - ~CustomInspectorTest() - { - if (m_inspectorWindow) - gtk_widget_destroy(m_inspectorWindow); - } - - bool openWindow() - { - g_assert(!m_inspectorWindow); - m_inspectorWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); - WebKitWebViewBase* inspectorView = webkit_web_inspector_get_web_view(m_inspector); - g_assert(inspectorView); - gtk_container_add(GTK_CONTAINER(m_inspectorWindow), GTK_WIDGET(inspectorView)); - gtk_widget_show_all(m_inspectorWindow); - - return InspectorTest::openWindow(); - } - - void closed() - { - if (m_inspectorWindow) { - gtk_widget_destroy(m_inspectorWindow); - m_inspectorWindow = 0; - } - - return InspectorTest::closed(); - } - - bool attach() - { - GRefPtr<WebKitWebViewBase> inspectorView = webkit_web_inspector_get_web_view(m_inspector); - if (m_inspectorWindow) { - gtk_container_remove(GTK_CONTAINER(m_inspectorWindow), GTK_WIDGET(inspectorView.get())); - gtk_widget_destroy(m_inspectorWindow); - m_inspectorWindow = 0; - } - - GtkWidget* pane; - if (gtk_bin_get_child(GTK_BIN(m_parentWindow)) == GTK_WIDGET(m_webView)) { - GRefPtr<WebKitWebView> inspectedView = m_webView; - gtk_container_remove(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView)); - pane = gtk_paned_new(GTK_ORIENTATION_VERTICAL); - gtk_paned_add1(GTK_PANED(pane), GTK_WIDGET(m_webView)); - gtk_container_add(GTK_CONTAINER(m_parentWindow), pane); - gtk_widget_show_all(pane); - } else - pane = gtk_bin_get_child(GTK_BIN(m_parentWindow)); - gtk_paned_set_position(GTK_PANED(pane), webkit_web_inspector_get_attached_height(m_inspector)); - gtk_paned_add2(GTK_PANED(pane), GTK_WIDGET(inspectorView.get())); - - return InspectorTest::attach(); - } - - bool detach() - { - GRefPtr<WebKitWebViewBase> inspectorView = webkit_web_inspector_get_web_view(m_inspector); - GtkWidget* pane = gtk_bin_get_child(GTK_BIN(m_parentWindow)); - g_assert(GTK_IS_PANED(pane)); - gtk_container_remove(GTK_CONTAINER(pane), GTK_WIDGET(inspectorView.get())); - return InspectorTest::detach(); - } - - void destroyWindow() - { - g_assert(m_inspectorWindow); - gtk_widget_destroy(m_inspectorWindow); - m_inspectorWindow = 0; - } - - GtkWidget* m_inspectorWindow; -}; - -static void testInspectorManualAttachDetach(CustomInspectorTest* test, gconstpointer) -{ - test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL); - test->resizeView(200, 200); - test->loadHtml("<html><body><p>WebKitGTK+ Inspector test</p></body></html>", 0); - test->waitUntilLoadFinished(); - - test->show(); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(webkit_web_inspector_get_web_view(test->m_inspector))); - g_assert(!webkit_web_inspector_is_attached(test->m_inspector)); - Vector<InspectorTest::InspectorEvents>& events = test->m_events; - g_assert_cmpint(events.size(), ==, 1); - g_assert_cmpint(events[0], ==, InspectorTest::OpenWindow); - test->m_events.clear(); - - test->resizeViewAndAttach(); - g_assert(webkit_web_inspector_is_attached(test->m_inspector)); - g_assert_cmpuint(webkit_web_inspector_get_attached_height(test->m_inspector), >=, InspectorTest::gMinimumAttachedInspectorHeight); - events = test->m_events; - g_assert_cmpint(events.size(), ==, 1); - g_assert_cmpint(events[0], ==, InspectorTest::Attach); - test->m_events.clear(); - - test->detachAndWaitUntilWindowOpened(); - g_assert(!webkit_web_inspector_is_attached(test->m_inspector)); - events = test->m_events; - g_assert_cmpint(events.size(), ==, 2); - g_assert_cmpint(events[0], ==, InspectorTest::Detach); - g_assert_cmpint(events[1], ==, InspectorTest::OpenWindow); - test->m_events.clear(); - - test->resizeViewAndAttach(); - g_assert(webkit_web_inspector_is_attached(test->m_inspector)); - test->m_events.clear(); - test->close(); - events = test->m_events; - g_assert_cmpint(events.size(), ==, 2); - g_assert_cmpint(events[0], ==, InspectorTest::Detach); - g_assert_cmpint(events[1], ==, InspectorTest::Closed); - test->m_events.clear(); -} - -static void testInspectorCustomContainerDestroyed(CustomInspectorTest* test, gconstpointer) -{ - test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL); - test->resizeView(200, 200); - test->loadHtml("<html><body><p>WebKitGTK+ Inspector test</p></body></html>", 0); - test->waitUntilLoadFinished(); - - test->show(); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(webkit_web_inspector_get_web_view(test->m_inspector))); - g_assert(!webkit_web_inspector_is_attached(test->m_inspector)); - - test->m_events.clear(); - test->destroyWindow(); - Vector<InspectorTest::InspectorEvents>& events = test->m_events; - g_assert_cmpint(events.size(), ==, 1); - g_assert_cmpint(events[0], ==, InspectorTest::Closed); - test->m_events.clear(); -} - -void beforeAll() -{ - g_setenv("WEBKIT_INSPECTOR_PATH", WEBKIT_INSPECTOR_PATH, FALSE); - InspectorTest::add("WebKitWebInspector", "default", testInspectorDefault); - CustomInspectorTest::add("WebKitWebInspector", "manual-attach-detach", testInspectorManualAttachDetach); - CustomInspectorTest::add("WebKitWebInspector", "custom-container-destroyed", testInspectorCustomContainerDestroyed); -} - -void afterAll() -{ -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestInspectorServer.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestInspectorServer.cpp deleted file mode 100644 index 35fb3fcdc..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestInspectorServer.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (C) 2012 Samsung Electronics Ltd. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT OWNER OR 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 "config.h" - -#include "WebViewTest.h" -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/WTFString.h> - -// Name of the test server application creating the webView object. -static const char* gTestServerAppName = "InspectorTestServer"; - -// Max seconds to wait for the test server before inspecting it. -static const int gMaxWaitForChild = 5; - -// The PID for the test server running, so we can kill it if needed. -static GPid gChildProcessPid = 0; - -// Whether the child has replied and it's ready. -static bool gChildIsReady = false; - -static void stopTestServer() -{ - // Do nothing if there's no server running. - if (!gChildProcessPid) - return; - - g_spawn_close_pid(gChildProcessPid); - kill(gChildProcessPid, SIGTERM); - gChildProcessPid = 0; -} - -static void sigAbortHandler(int sigNum) -{ - // Just stop the test server if SIGABRT was received. - stopTestServer(); -} - -static gpointer testServerMonitorThreadFunc(gpointer) -{ - // Wait for the specified timeout to happen. - g_usleep(gMaxWaitForChild * G_USEC_PER_SEC); - - // Kill the child process if not ready yet. - if (!gChildIsReady) - stopTestServer(); - - g_thread_exit(0); - return 0; -} - -static void startTestServerMonitor() -{ - gChildIsReady = false; - g_thread_new("TestServerMonitor", testServerMonitorThreadFunc, 0); -} - -static void startTestServer() -{ - // Prepare argv[] for spawning the server process. - GOwnPtr<char> testServerPath(g_build_filename(WEBKIT_EXEC_PATH, "WebKit2APITests", gTestServerAppName, NULL)); - - // We install a handler to ensure that we kill the child process - // if the parent dies because of whatever the reason is. - signal(SIGABRT, sigAbortHandler); - - char* testServerArgv[2]; - testServerArgv[0] = testServerPath.get(); - testServerArgv[1] = 0; - - // Spawn the server, getting its stdout file descriptor to set a - // communication channel, so we know when it's ready. - int childStdout = 0; - g_assert(g_spawn_async_with_pipes(0, testServerArgv, 0, static_cast<GSpawnFlags>(0), 0, 0, - &gChildProcessPid, 0, &childStdout, 0, 0)); - - // Start monitoring the test server (in a separate thread) to - // ensure we don't block on the child process more than a timeout. - startTestServerMonitor(); - - char msg[2]; - GIOChannel* ioChannel = g_io_channel_unix_new(childStdout); - if (g_io_channel_read_chars(ioChannel, msg, 2, 0, 0) == G_IO_STATUS_NORMAL) { - // Check whether the server sent a message saying it's ready - // and store the result globally, so the monitor can see it. - gChildIsReady = msg[0] == 'O' && msg[1] == 'K'; - } - g_io_channel_unref(ioChannel); - close(childStdout); - - // The timeout was reached and the server is not ready yet, so - // stop it inmediately, and let the unit tests fail. - if (!gChildIsReady) - stopTestServer(); -} - -class InspectorServerTest: public WebViewTest { -public: - MAKE_GLIB_TEST_FIXTURE(InspectorServerTest); - - InspectorServerTest() - : WebViewTest() - { - } - - bool getPageList() - { - loadHtml("<script type=\"text/javascript\">\n" - "var pages;\n" - "var xhr = new XMLHttpRequest;\n" - "xhr.open(\"GET\", \"/pagelist.json\");\n" - "xhr.onload = function(e) {\n" - "if (xhr.status == 200) {\n" - "pages = JSON.parse(xhr.responseText);\n" - "document.title = \"OK\";\n" - "} else \n" - "document.title = \"FAIL\";\n" - "}\n" - "xhr.send();\n" - "</script>\n", - "http://127.0.0.1:2999/"); - - waitUntilTitleChanged(); - - if (!strcmp(webkit_web_view_get_title(m_webView), "OK")) - return true; - - return false; - } - - ~InspectorServerTest() - { - } -}; - -// Test to get inspector server page list from the test server. -// Should contain only one entry pointing to http://127.0.0.1:2999/webinspector/inspector.html?page=1 -static void testInspectorServerPageList(InspectorServerTest* test, gconstpointer) -{ - GOwnPtr<GError> error; - - test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL); - g_assert(test->getPageList()); - - WebKitJavascriptResult* javascriptResult = test->runJavaScriptAndWaitUntilFinished("pages.length;", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - g_assert_cmpint(WebViewTest::javascriptResultToNumber(javascriptResult), ==, 1); - - javascriptResult = test->runJavaScriptAndWaitUntilFinished("pages[0].id;", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - int pageId = WebViewTest::javascriptResultToNumber(javascriptResult); - - GOwnPtr<char> valueString; - javascriptResult = test->runJavaScriptAndWaitUntilFinished("pages[0].url;", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - valueString.set(WebViewTest::javascriptResultToCString(javascriptResult)); - g_assert_cmpstr(valueString.get(), ==, "http://127.0.0.1:2999/"); - - javascriptResult = test->runJavaScriptAndWaitUntilFinished("pages[0].inspectorUrl;", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - valueString.set(WebViewTest::javascriptResultToCString(javascriptResult)); - String validInspectorURL = String("/inspector.html?page=") + String::number(pageId); - ASSERT_CMP_CSTRING(valueString.get(), ==, validInspectorURL.utf8()); -} - -// Test sending a raw remote debugging message through our web socket server. -// For this specific message see: http://code.google.com/chrome/devtools/docs/protocol/tot/runtime.html#command-evaluate -static void testRemoteDebuggingMessage(InspectorServerTest* test, gconstpointer) -{ - test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL); - - test->loadHtml("<script type=\"text/javascript\">\n" - "var socket = new WebSocket('ws://127.0.0.1:2999/devtools/page/1');\n" - "socket.onmessage = function(message) {\n" - "var response = JSON.parse(message.data);\n" - "if (response.id === 1)\n" - "document.title = response.result.result.value;\n" - "else\n" - "document.title = \"FAIL\";\n" - "}\n" - "socket.onopen = function() {\n" - "socket.send('{\"id\": 1, \"method\": \"Runtime.evaluate\", \"params\": {\"expression\": \"2 + 2\" } }');\n" - "}\n" - "</script>", - "http://127.0.0.1:2999/"); - test->waitUntilTitleChanged(); - - g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, "4"); -} - -static void openRemoteDebuggingSession(InspectorServerTest* test, gconstpointer) -{ - // To test the whole pipeline this exploits a behavior of the inspector front-end which won't provide any title unless the - // debugging session was established correctly through web socket. It should be something like "Web Inspector - <Page URL>". - // In our case page URL should be http://127.0.0.1:2999/ - // So this test case will fail if: - // - The page list didn't return a valid inspector URL - // - Or the front-end couldn't be loaded through the inspector HTTP server - // - Or the web socket connection couldn't be established between the front-end and the page through the inspector server - // Let's see if this test isn't raising too many false positives, in which case we should use a better predicate if available. - - test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL); - - g_assert(test->getPageList()); - - GOwnPtr<GError> error; - WebKitJavascriptResult* javascriptResult = test->runJavaScriptAndWaitUntilFinished("pages[0].inspectorUrl;", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - - String resolvedURL = String("http://127.0.0.1:2999/") + String::fromUTF8(WebViewTest::javascriptResultToCString(javascriptResult)); - test->loadURI(resolvedURL.utf8().data()); - test->waitUntilTitleChanged(); - - g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, "Web Inspector - http://127.0.0.1:2999/"); -} - - -void beforeAll() -{ - // Overwrite WEBKIT_INSPECTOR_SERVER variable with default IP address but different port to avoid conflict with the test inspector server page. - g_setenv("WEBKIT_INSPECTOR_SERVER", "127.0.0.1:2998", TRUE); - - startTestServer(); - InspectorServerTest::add("WebKitWebInspectorServer", "test-page-list", testInspectorServerPageList); - InspectorServerTest::add("WebKitWebInspectorServer", "test-remote-debugging-message", testRemoteDebuggingMessage); - InspectorServerTest::add("WebKitWebInspectorServer", "test-open-debugging-session", openRemoteDebuggingSession); - -} - -void afterAll() -{ - stopTestServer(); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp deleted file mode 100644 index 331915e00..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp +++ /dev/null @@ -1,465 +0,0 @@ -/* - * Copyright (C) 2009, 2010 Gustavo Noronha Silva - * Copyright (C) 2009, 2011 Igalia S.L. - * Portions Copyright (c) 2011 Motorola Mobility, 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 "config.h" - -#include "LoadTrackingTest.h" -#include "WebKitTestBus.h" -#include "WebKitTestServer.h" -#include "WebViewTest.h" -#include <gtk/gtk.h> -#include <libsoup/soup.h> -#include <wtf/text/CString.h> - -static WebKitTestBus* bus; -static WebKitTestServer* kServer; - -const char* kDNTHeaderNotPresent = "DNT header not present"; - -static void testLoadingStatus(LoadTrackingTest* test, gconstpointer data) -{ - test->setRedirectURI(kServer->getURIForPath("/normal").data()); - test->loadURI(kServer->getURIForPath("/redirect").data()); - test->waitUntilLoadFinished(); - - Vector<LoadTrackingTest::LoadEvents>& events = test->m_loadEvents; - g_assert_cmpint(events.size(), ==, 4); - g_assert_cmpint(events[0], ==, LoadTrackingTest::ProvisionalLoadStarted); - g_assert_cmpint(events[1], ==, LoadTrackingTest::ProvisionalLoadReceivedServerRedirect); - g_assert_cmpint(events[2], ==, LoadTrackingTest::LoadCommitted); - g_assert_cmpint(events[3], ==, LoadTrackingTest::LoadFinished); -} - -static void testLoadingError(LoadTrackingTest* test, gconstpointer) -{ - test->loadURI(kServer->getURIForPath("/error").data()); - test->waitUntilLoadFinished(); - - Vector<LoadTrackingTest::LoadEvents>& events = test->m_loadEvents; - g_assert_cmpint(events.size(), ==, 3); - g_assert_cmpint(events[0], ==, LoadTrackingTest::ProvisionalLoadStarted); - g_assert_cmpint(events[1], ==, LoadTrackingTest::ProvisionalLoadFailed); - g_assert_cmpint(events[2], ==, LoadTrackingTest::LoadFinished); -} - -static void assertNormalLoadHappened(Vector<LoadTrackingTest::LoadEvents>& events) -{ - g_assert_cmpint(events.size(), ==, 3); - g_assert_cmpint(events[0], ==, LoadTrackingTest::ProvisionalLoadStarted); - g_assert_cmpint(events[1], ==, LoadTrackingTest::LoadCommitted); - g_assert_cmpint(events[2], ==, LoadTrackingTest::LoadFinished); -} - -static void testLoadHtml(LoadTrackingTest* test, gconstpointer) -{ - test->loadHtml("<html><body>Hello WebKit-GTK+</body></html>", 0); - test->waitUntilLoadFinished(); - assertNormalLoadHappened(test->m_loadEvents); -} - -static void testLoadAlternateHTML(LoadTrackingTest* test, gconstpointer) -{ - test->loadAlternateHTML("<html><body>Alternate page</body></html>", "http://error-page.foo/", 0); - test->waitUntilLoadFinished(); - assertNormalLoadHappened(test->m_loadEvents); -} - -static void testLoadPlainText(LoadTrackingTest* test, gconstpointer) -{ - test->loadPlainText("Hello WebKit-GTK+"); - test->waitUntilLoadFinished(); - assertNormalLoadHappened(test->m_loadEvents); -} - -static void testLoadRequest(LoadTrackingTest* test, gconstpointer) -{ - GRefPtr<WebKitURIRequest> request(webkit_uri_request_new(kServer->getURIForPath("/normal").data())); - test->loadRequest(request.get()); - test->waitUntilLoadFinished(); - assertNormalLoadHappened(test->m_loadEvents); -} - -class LoadStopTrackingTest : public LoadTrackingTest { -public: - MAKE_GLIB_TEST_FIXTURE(LoadStopTrackingTest); - - virtual void loadCommitted() - { - LoadTrackingTest::loadCommitted(); - webkit_web_view_stop_loading(m_webView); - } - virtual void loadFailed(const gchar* failingURI, GError* error) - { - g_assert(g_error_matches(error, WEBKIT_NETWORK_ERROR, WEBKIT_NETWORK_ERROR_CANCELLED)); - LoadTrackingTest::loadFailed(failingURI, error); - } -}; - -static void testLoadCancelled(LoadStopTrackingTest* test, gconstpointer) -{ - test->loadURI(kServer->getURIForPath("/cancelled").data()); - test->waitUntilLoadFinished(); - - Vector<LoadTrackingTest::LoadEvents>& events = test->m_loadEvents; - g_assert_cmpint(events.size(), ==, 4); - g_assert_cmpint(events[0], ==, LoadTrackingTest::ProvisionalLoadStarted); - g_assert_cmpint(events[1], ==, LoadTrackingTest::LoadCommitted); - g_assert_cmpint(events[2], ==, LoadTrackingTest::LoadFailed); - g_assert_cmpint(events[3], ==, LoadTrackingTest::LoadFinished); -} - -static void testWebViewTitle(LoadTrackingTest* test, gconstpointer) -{ - g_assert(!webkit_web_view_get_title(test->m_webView)); - test->loadHtml("<html><head><title>Welcome to WebKit-GTK+!</title></head></html>", 0); - test->waitUntilLoadFinished(); - g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, "Welcome to WebKit-GTK+!"); -} - -static void testWebViewReload(LoadTrackingTest* test, gconstpointer) -{ - // Check that nothing happens when there's nothing to reload. - test->reload(); - test->wait(0.25); // Wait for a quarter of a second. - - test->loadURI(kServer->getURIForPath("/normal").data()); - test->waitUntilLoadFinished(); - assertNormalLoadHappened(test->m_loadEvents); - - test->reload(); - test->waitUntilLoadFinished(); - assertNormalLoadHappened(test->m_loadEvents); -} - -static void testLoadProgress(LoadTrackingTest* test, gconstpointer) -{ - test->loadURI(kServer->getURIForPath("/normal").data()); - test->waitUntilLoadFinished(); - g_assert_cmpfloat(test->m_estimatedProgress, ==, 1); -} - -static void testWebViewHistoryLoad(LoadTrackingTest* test, gconstpointer) -{ - test->loadURI(kServer->getURIForPath("/normal").data()); - test->waitUntilLoadFinished(); - assertNormalLoadHappened(test->m_loadEvents); - - test->loadURI(kServer->getURIForPath("/normal2").data()); - test->waitUntilLoadFinished(); - assertNormalLoadHappened(test->m_loadEvents); - - // Check that load process is the same for pages loaded from history cache. - test->goBack(); - test->waitUntilLoadFinished(); - assertNormalLoadHappened(test->m_loadEvents); - - test->goForward(); - test->waitUntilLoadFinished(); - assertNormalLoadHappened(test->m_loadEvents); -} - -class ViewURITrackingTest: public LoadTrackingTest { -public: - MAKE_GLIB_TEST_FIXTURE(ViewURITrackingTest); - - static void uriChanged(GObject*, GParamSpec*, ViewURITrackingTest* test) - { - g_assert_cmpstr(test->m_activeURI.data(), !=, webkit_web_view_get_uri(test->m_webView)); - test->m_activeURI = webkit_web_view_get_uri(test->m_webView); - } - - ViewURITrackingTest() - : m_activeURI(webkit_web_view_get_uri(m_webView)) - { - g_assert(m_activeURI.isNull()); - g_signal_connect(m_webView, "notify::uri", G_CALLBACK(uriChanged), this); - } - - void provisionalLoadStarted() - { - checkActiveURI("/redirect"); - } - - void provisionalLoadReceivedServerRedirect() - { - checkActiveURI("/normal"); - } - - void loadCommitted() - { - checkActiveURI("/normal"); - } - - void loadFinished() - { - checkActiveURI("/normal"); - LoadTrackingTest::loadFinished(); - } - - CString m_activeURI; - -private: - void checkActiveURI(const char* uri) - { - ASSERT_CMP_CSTRING(m_activeURI, ==, kServer->getURIForPath(uri)); - } -}; - -static void testWebViewActiveURI(ViewURITrackingTest* test, gconstpointer) -{ - test->loadURI(kServer->getURIForPath("/redirect").data()); - test->waitUntilLoadFinished(); -} - -class ViewIsLoadingTest: public LoadTrackingTest { -public: - MAKE_GLIB_TEST_FIXTURE(ViewIsLoadingTest); - - static void isLoadingChanged(GObject*, GParamSpec*, ViewIsLoadingTest* test) - { - if (webkit_web_view_is_loading(test->m_webView)) - test->beginLoad(); - else - test->endLoad(); - } - - ViewIsLoadingTest() - { - g_signal_connect(m_webView, "notify::is-loading", G_CALLBACK(isLoadingChanged), this); - } - - void beginLoad() - { - // New load, load-started hasn't been emitted yet. - g_assert(m_loadEvents.isEmpty()); - g_assert_cmpstr(webkit_web_view_get_uri(m_webView), ==, m_activeURI.data()); - } - - void endLoad() - { - // Load finish, load-finished and load-failed haven't been emitted yet. - g_assert(!m_loadEvents.isEmpty()); - g_assert(!m_loadEvents.contains(LoadTrackingTest::LoadFinished)); - g_assert(!m_loadEvents.contains(LoadTrackingTest::LoadFailed)); - } -}; - -static void testWebViewIsLoading(ViewIsLoadingTest* test, gconstpointer) -{ - test->loadURI(kServer->getURIForPath("/normal").data()); - test->waitUntilLoadFinished(); - - test->reload(); - test->waitUntilLoadFinished(); - - test->loadURI(kServer->getURIForPath("/error").data()); - test->waitUntilLoadFinished(); - - test->loadURI(kServer->getURIForPath("/normal").data()); - test->waitUntilLoadFinished(); - test->loadURI(kServer->getURIForPath("/normal2").data()); - test->waitUntilLoadFinished(); - - test->goBack(); - test->waitUntilLoadFinished(); - - test->goForward(); - test->waitUntilLoadFinished(); -} - -class WebPageURITest: public WebViewTest { -public: - MAKE_GLIB_TEST_FIXTURE(WebPageURITest); - - static void webPageURIChangedCallback(GDBusConnection*, const char*, const char*, const char*, const char*, GVariant* result, WebPageURITest* test) - { - const char* uri; - g_variant_get(result, "(&s)", &uri); - test->m_webPageURIs.append(uri); - } - - static void webViewURIChanged(GObject*, GParamSpec*, WebPageURITest* test) - { - test->m_webViewURIs.append(webkit_web_view_get_uri(test->m_webView)); - } - - WebPageURITest() - { - GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy("org.webkit.gtk.WebExtensionTest", - "/org/webkit/gtk/WebExtensionTest", "org.webkit.gtk.WebExtensionTest", m_mainLoop)); - m_uriChangedSignalID = g_dbus_connection_signal_subscribe( - g_dbus_proxy_get_connection(proxy.get()), - 0, - "org.webkit.gtk.WebExtensionTest", - "URIChanged", - "/org/webkit/gtk/WebExtensionTest", - 0, - G_DBUS_SIGNAL_FLAGS_NONE, - reinterpret_cast<GDBusSignalCallback>(webPageURIChangedCallback), - this, - 0); - g_assert(m_uriChangedSignalID); - - g_signal_connect(m_webView, "notify::uri", G_CALLBACK(webViewURIChanged), this); - } - - ~WebPageURITest() - { - g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); - g_dbus_connection_signal_unsubscribe(bus->connection(), m_uriChangedSignalID); - } - - unsigned m_uriChangedSignalID; - Vector<CString> m_webPageURIs; - Vector<CString> m_webViewURIs; -}; - -static void testWebPageURI(WebPageURITest* test, gconstpointer) -{ - test->loadURI(kServer->getURIForPath("/redirect").data()); - test->waitUntilLoadFinished(); - - g_assert_cmpint(test->m_webPageURIs.size(), ==, test->m_webViewURIs.size()); - for (size_t i = 0; i < test->m_webPageURIs.size(); ++i) - ASSERT_CMP_CSTRING(test->m_webPageURIs[i], ==, test->m_webViewURIs[i]); - - g_assert_cmpint(test->m_webPageURIs.size(), ==, 2); - ASSERT_CMP_CSTRING(test->m_webPageURIs[0], ==, kServer->getURIForPath("/redirect")); - ASSERT_CMP_CSTRING(test->m_webPageURIs[1], ==, kServer->getURIForPath("/normal")); - -} - -static void testURIRequestHTTPHeaders(WebViewTest* test, gconstpointer) -{ - GRefPtr<WebKitURIRequest> uriRequest = adoptGRef(webkit_uri_request_new("file:///foo/bar")); - g_assert(uriRequest.get()); - g_assert_cmpstr(webkit_uri_request_get_uri(uriRequest.get()), ==, "file:///foo/bar"); - g_assert(!webkit_uri_request_get_http_headers(uriRequest.get())); - - // Load a request with no Do Not Track header. - webkit_uri_request_set_uri(uriRequest.get(), kServer->getURIForPath("/do-not-track-header").data()); - test->loadRequest(uriRequest.get()); - test->waitUntilLoadFinished(); - - size_t mainResourceDataSize = 0; - const char* mainResourceData = test->mainResourceData(mainResourceDataSize); - g_assert_cmpint(mainResourceDataSize, ==, strlen(kDNTHeaderNotPresent)); - g_assert(!strncmp(mainResourceData, kDNTHeaderNotPresent, mainResourceDataSize)); - - // Add the Do Not Track header and load the request again. - SoupMessageHeaders* headers = webkit_uri_request_get_http_headers(uriRequest.get()); - g_assert(headers); - soup_message_headers_append(headers, "DNT", "1"); - test->loadRequest(uriRequest.get()); - test->waitUntilLoadFinished(); - - mainResourceData = test->mainResourceData(mainResourceDataSize); - g_assert_cmpint(mainResourceDataSize, ==, 1); - g_assert(!strncmp(mainResourceData, "1", mainResourceDataSize)); - - // Load a URI for which the web extension will add the Do Not Track header. - test->loadURI(kServer->getURIForPath("/add-do-not-track-header").data()); - test->waitUntilLoadFinished(); - - mainResourceData = test->mainResourceData(mainResourceDataSize); - g_assert_cmpint(mainResourceDataSize, ==, 1); - g_assert(!strncmp(mainResourceData, "1", mainResourceDataSize)); -} - -static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer) -{ - static const char* responseString = "<html><body>Testing!Testing!Testing!Testing!Testing!Testing!Testing!" - "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!" - "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!" - "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!" - "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!" - "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!" - "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!" - "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!</body></html>"; - - if (message->method != SOUP_METHOD_GET) { - soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED); - return; - } - - soup_message_set_status(message, SOUP_STATUS_OK); - - if (g_str_has_prefix(path, "/normal")) - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, responseString, strlen(responseString)); - else if (g_str_equal(path, "/error")) - soup_message_set_status(message, SOUP_STATUS_CANT_CONNECT); - else if (g_str_equal(path, "/redirect")) { - soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY); - soup_message_headers_append(message->response_headers, "Location", "/normal"); - } else if (g_str_equal(path, "/cancelled")) { - soup_message_headers_set_encoding(message->response_headers, SOUP_ENCODING_CHUNKED); - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, responseString, strlen(responseString)); - soup_server_unpause_message(server, message); - return; - } else if (g_str_equal(path, "/do-not-track-header") || g_str_equal(path, "/add-do-not-track-header")) { - const char* doNotTrack = soup_message_headers_get_one(message->request_headers, "DNT"); - if (doNotTrack) - soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, doNotTrack, strlen(doNotTrack)); - else - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, kDNTHeaderNotPresent, strlen(kDNTHeaderNotPresent)); - soup_message_set_status(message, SOUP_STATUS_OK); - } else - soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); - - soup_message_body_complete(message->response_body); -} - -void beforeAll() -{ - webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR); - bus = new WebKitTestBus(); - if (!bus->run()) - return; - - kServer = new WebKitTestServer(); - kServer->run(serverCallback); - - LoadTrackingTest::add("WebKitWebView", "loading-status", testLoadingStatus); - LoadTrackingTest::add("WebKitWebView", "loading-error", testLoadingError); - LoadTrackingTest::add("WebKitWebView", "load-html", testLoadHtml); - LoadTrackingTest::add("WebKitWebView", "load-alternate-html", testLoadAlternateHTML); - LoadTrackingTest::add("WebKitWebView", "load-plain-text", testLoadPlainText); - LoadTrackingTest::add("WebKitWebView", "load-request", testLoadRequest); - LoadStopTrackingTest::add("WebKitWebView", "stop-loading", testLoadCancelled); - LoadTrackingTest::add("WebKitWebView", "title", testWebViewTitle); - LoadTrackingTest::add("WebKitWebView", "progress", testLoadProgress); - LoadTrackingTest::add("WebKitWebView", "reload", testWebViewReload); - LoadTrackingTest::add("WebKitWebView", "history-load", testWebViewHistoryLoad); - - // This test checks that web view notify::uri signal is correctly emitted - // and the uri is already updated when loader client signals are emitted. - ViewURITrackingTest::add("WebKitWebView", "active-uri", testWebViewActiveURI); - - ViewIsLoadingTest::add("WebKitWebView", "is-loading", testWebViewIsLoading); - WebPageURITest::add("WebKitWebPage", "get-uri", testWebPageURI); - WebViewTest::add("WebKitURIRequest", "http-headers", testURIRequestHTTPHeaders); -} - -void afterAll() -{ - delete bus; - delete kServer; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp deleted file mode 100644 index 6ac35f8ca..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 "TestMain.h" - -#include <glib/gstdio.h> -#include <gtk/gtk.h> -#include <webkit2/webkit2.h> -#include <wtf/gobject/GOwnPtr.h> - -void beforeAll(); -void afterAll(); - -static void registerGResource(void) -{ - GOwnPtr<char> resourcesPath(g_build_filename(WEBKIT_EXEC_PATH, "resources", "webkit2gtk-tests-resources.gresource", NULL)); - GResource* resource = g_resource_load(resourcesPath.get(), 0); - g_assert(resource); - - g_resources_register(resource); - g_resource_unref(resource); -} - -static void removeNonEmptyDirectory(const char* directoryPath) -{ - GDir* directory = g_dir_open(directoryPath, 0, 0); - g_assert(directory); - const char* fileName; - while ((fileName = g_dir_read_name(directory))) { - GOwnPtr<char> filePath(g_build_filename(directoryPath, fileName, NULL)); - g_unlink(filePath.get()); - } - g_dir_close(directory); - g_rmdir(directoryPath); -} - -int main(int argc, char** argv) -{ - gtk_test_init(&argc, &argv, 0); - g_setenv("WEBKIT_EXEC_PATH", WEBKIT_EXEC_PATH, FALSE); - g_setenv("WEBKIT_INJECTED_BUNDLE_PATH", WEBKIT_INJECTED_BUNDLE_PATH, FALSE); - g_setenv("LC_ALL", "C", TRUE); - g_test_bug_base("https://bugs.webkit.org/"); - - registerGResource(); - - GOwnPtr<char> diskCacheTempDirectory(g_dir_make_tmp("WebKit2TestsDiskCache-XXXXXX", 0)); - g_assert(diskCacheTempDirectory.get()); - webkit_web_context_set_disk_cache_directory(webkit_web_context_get_default(), diskCacheTempDirectory.get()); - - beforeAll(); - int returnValue = g_test_run(); - afterAll(); - - removeNonEmptyDirectory(diskCacheTempDirectory.get()); - - return returnValue; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h b/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h deleted file mode 100644 index 02c90709c..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 TestMain_h -#define TestMain_h - -#include <cairo.h> -#include <glib-object.h> -#include <wtf/HashSet.h> -#include <wtf/gobject/GOwnPtr.h> -#include <wtf/text/CString.h> - -#define MAKE_GLIB_TEST_FIXTURE(ClassName) \ - static void setUp(ClassName* fixture, gconstpointer data) \ - { \ - new (fixture) ClassName; \ - } \ - static void tearDown(ClassName* fixture, gconstpointer data) \ - { \ - fixture->~ClassName(); \ - } \ - static void add(const char* suiteName, const char* testName, void (*testFunc)(ClassName*, const void*)) \ - { \ - GOwnPtr<gchar> testPath(g_strdup_printf("/webkit2/%s/%s", suiteName, testName)); \ - g_test_add(testPath.get(), ClassName, 0, ClassName::setUp, testFunc, ClassName::tearDown); \ - } - -#define ASSERT_CMP_CSTRING(s1, cmp, s2) \ - do { CString __s1 = (s1); CString __s2 = (s2); \ - if (g_strcmp0(__s1.data(), __s2.data()) cmp 0) ; else \ - g_assertion_message_cmpstr(G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - #s1 " " #cmp " " #s2, __s1.data(), #cmp, __s2.data()); } while (0) - -class Test { -public: - MAKE_GLIB_TEST_FIXTURE(Test); - - ~Test() - { - if (m_watchedObjects.isEmpty()) - return; - - g_print("Leaked objects:"); - HashSet<GObject*>::const_iterator end = m_watchedObjects.end(); - for (HashSet<GObject*>::const_iterator it = m_watchedObjects.begin(); it != end; ++it) - g_print(" %s(%p)", g_type_name_from_instance(reinterpret_cast<GTypeInstance*>(*it)), *it); - g_print("\n"); - - g_assert(m_watchedObjects.isEmpty()); - } - - static void objectFinalized(Test* test, GObject* finalizedObject) - { - test->m_watchedObjects.remove(finalizedObject); - } - - void assertObjectIsDeletedWhenTestFinishes(GObject* object) - { - m_watchedObjects.add(object); - g_object_weak_ref(object, reinterpret_cast<GWeakNotify>(objectFinalized), this); - } - - static CString getWebKit1TestResoucesDir() - { - GOwnPtr<char> resourcesDir(g_build_filename(WEBKIT_SRC_DIR, "Source", "WebKit", "gtk", "tests", "resources", NULL)); - return resourcesDir.get(); - } - - static CString getResourcesDir() - { - GOwnPtr<char> resourcesDir(g_build_filename(WEBKIT_SRC_DIR, "Source", "WebKit2", "UIProcess", "API", "gtk", "tests", "resources", NULL)); - return resourcesDir.get(); - } - - void addLogFatalFlag(unsigned flag) - { - unsigned fatalMask = g_log_set_always_fatal(static_cast<GLogLevelFlags>(G_LOG_FATAL_MASK)); - fatalMask |= flag; - g_log_set_always_fatal(static_cast<GLogLevelFlags>(fatalMask)); - } - - void removeLogFatalFlag(unsigned flag) - { - unsigned fatalMask = g_log_set_always_fatal(static_cast<GLogLevelFlags>(G_LOG_FATAL_MASK)); - fatalMask &= ~flag; - g_log_set_always_fatal(static_cast<GLogLevelFlags>(fatalMask)); - } - - static bool cairoSurfacesEqual(cairo_surface_t* s1, cairo_surface_t* s2) - { - return (cairo_image_surface_get_format(s1) == cairo_image_surface_get_format(s2) - && cairo_image_surface_get_width(s1) == cairo_image_surface_get_width(s2) - && cairo_image_surface_get_height(s1) == cairo_image_surface_get_height(s2) - && cairo_image_surface_get_stride(s1) == cairo_image_surface_get_stride(s2) - && !memcmp(const_cast<const void*>(reinterpret_cast<void*>(cairo_image_surface_get_data(s1))), - const_cast<const void*>(reinterpret_cast<void*>(cairo_image_surface_get_data(s2))), - cairo_image_surface_get_height(s1)*cairo_image_surface_get_stride(s1))); - } - - HashSet<GObject*> m_watchedObjects; -}; - -#endif // TestMain_h diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestPrinting.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestPrinting.cpp deleted file mode 100644 index 72c2cfbbd..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestPrinting.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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 "WebViewTest.h" -#include <glib/gstdio.h> -#include <wtf/gobject/GRefPtr.h> - -#ifdef HAVE_GTK_UNIX_PRINTING -#include <gtk/gtkunixprint.h> -#endif - -static char* kTempDirectory; - -static void testPrintOperationPrintSettings(WebViewTest* test, gconstpointer) -{ - GRefPtr<WebKitPrintOperation> printOperation = adoptGRef(webkit_print_operation_new(test->m_webView)); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(printOperation.get())); - - g_assert(!webkit_print_operation_get_print_settings(printOperation.get())); - g_assert(!webkit_print_operation_get_page_setup(printOperation.get())); - - GRefPtr<GtkPrintSettings> printSettings = adoptGRef(gtk_print_settings_new()); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(printSettings.get())); - - GRefPtr<GtkPageSetup> pageSetup = adoptGRef(gtk_page_setup_new()); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(pageSetup.get())); - - webkit_print_operation_set_print_settings(printOperation.get(), printSettings.get()); - webkit_print_operation_set_page_setup(printOperation.get(), pageSetup.get()); - - g_assert(webkit_print_operation_get_print_settings(printOperation.get()) == printSettings.get()); - g_assert(webkit_print_operation_get_page_setup(printOperation.get()) == pageSetup.get()); -} - -static gboolean webViewPrintCallback(WebKitWebView* webView, WebKitPrintOperation* printOperation, WebViewTest* test) -{ - g_assert(webView == test->m_webView); - - g_assert(WEBKIT_IS_PRINT_OPERATION(printOperation)); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(printOperation)); - - g_assert(!webkit_print_operation_get_print_settings(printOperation)); - g_assert(!webkit_print_operation_get_page_setup(printOperation)); - - g_main_loop_quit(test->m_mainLoop); - - return TRUE; -} - -static void testWebViewPrint(WebViewTest* test, gconstpointer) -{ - g_signal_connect(test->m_webView, "print", G_CALLBACK(webViewPrintCallback), test); - test->loadHtml("<html><body onLoad=\"print();\">WebKitGTK+ printing test</body></html>", 0); - g_main_loop_run(test->m_mainLoop); -} - -#ifdef HAVE_GTK_UNIX_PRINTING -class PrintTest: public WebViewTest { -public: - MAKE_GLIB_TEST_FIXTURE(PrintTest); - - static void printFinishedCallback(WebKitPrintOperation*, PrintTest* test) - { - g_main_loop_quit(test->m_mainLoop); - } - - static void printFailedCallback(WebKitPrintOperation*, GError* error, PrintTest* test) - { - g_assert(test->m_expectedError); - g_assert(error); - g_assert(g_error_matches(error, WEBKIT_PRINT_ERROR, test->m_expectedError)); - } - - PrintTest() - : m_expectedError(0) - { - m_printOperation = adoptGRef(webkit_print_operation_new(m_webView)); - assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_printOperation.get())); - g_signal_connect(m_printOperation.get(), "finished", G_CALLBACK(printFinishedCallback), this); - g_signal_connect(m_printOperation.get(), "failed", G_CALLBACK(printFailedCallback), this); - } - - static gboolean testPrintOperationPrintPrinter(GtkPrinter* printer, gpointer userData) - { - if (strcmp(gtk_printer_get_name(printer), "Print to File")) - return FALSE; - - GtkPrinter** foundPrinter = static_cast<GtkPrinter**>(userData); - *foundPrinter = static_cast<GtkPrinter*>(g_object_ref(printer)); - return TRUE; - } - - GtkPrinter* findPrintToFilePrinter() - { - GtkPrinter* printer = 0; - gtk_enumerate_printers(testPrintOperationPrintPrinter, &printer, 0, TRUE); - return printer; - } - - void waitUntilPrintFinished() - { - g_main_loop_run(m_mainLoop); - } - - GRefPtr<WebKitPrintOperation> m_printOperation; - unsigned int m_expectedError; -}; - -static void testPrintOperationPrint(PrintTest* test, gconstpointer) -{ - test->loadHtml("<html><body>WebKitGTK+ printing test</body></html>", 0); - test->waitUntilLoadFinished(); - - GRefPtr<GtkPrinter> printer = adoptGRef(test->findPrintToFilePrinter()); - if (!printer) { - g_message("%s", "Cannot test WebKitPrintOperation/print: no suitable printer found"); - return; - } - - GOwnPtr<char> outputFilename(g_build_filename(kTempDirectory, "webkit-print.pdf", NULL)); - GRefPtr<GFile> outputFile = adoptGRef(g_file_new_for_path(outputFilename.get())); - GOwnPtr<char> outputURI(g_file_get_uri(outputFile.get())); - - GRefPtr<GtkPrintSettings> printSettings = adoptGRef(gtk_print_settings_new()); - gtk_print_settings_set_printer(printSettings.get(), gtk_printer_get_name(printer.get())); - gtk_print_settings_set(printSettings.get(), GTK_PRINT_SETTINGS_OUTPUT_URI, outputURI.get()); - - webkit_print_operation_set_print_settings(test->m_printOperation.get(), printSettings.get()); - webkit_print_operation_print(test->m_printOperation.get()); - test->waitUntilPrintFinished(); - - GRefPtr<GFileInfo> fileInfo = adoptGRef(g_file_query_info(outputFile.get(), G_FILE_ATTRIBUTE_STANDARD_SIZE "," G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, - static_cast<GFileQueryInfoFlags>(0), 0, 0)); - g_assert(fileInfo.get()); - g_assert_cmpint(g_file_info_get_size(fileInfo.get()), >, 0); - g_assert_cmpstr(g_file_info_get_content_type(fileInfo.get()), ==, "application/pdf"); - - g_file_delete(outputFile.get(), 0, 0); -} - -static void testPrintOperationErrors(PrintTest* test, gconstpointer) -{ - test->loadHtml("<html><body>WebKitGTK+ printing errors test</body></html>", 0); - test->waitUntilLoadFinished(); - - GRefPtr<GtkPrinter> printer = adoptGRef(test->findPrintToFilePrinter()); - if (!printer) { - g_message("%s", "Cannot test WebKitPrintOperation/print: no suitable printer found"); - return; - } - - // General Error: invalid filename. - test->m_expectedError = WEBKIT_PRINT_ERROR_GENERAL; - GRefPtr<GtkPrintSettings> printSettings = adoptGRef(gtk_print_settings_new()); - gtk_print_settings_set_printer(printSettings.get(), gtk_printer_get_name(printer.get())); - gtk_print_settings_set(printSettings.get(), GTK_PRINT_SETTINGS_OUTPUT_URI, "file:///foo/bar"); - webkit_print_operation_set_print_settings(test->m_printOperation.get(), printSettings.get()); - webkit_print_operation_print(test->m_printOperation.get()); - test->waitUntilPrintFinished(); - - // Printer not found error. - test->m_expectedError = WEBKIT_PRINT_ERROR_PRINTER_NOT_FOUND; - gtk_print_settings_set_printer(printSettings.get(), "The fake WebKit printer"); - webkit_print_operation_print(test->m_printOperation.get()); - test->waitUntilPrintFinished(); - - // No pages to print: print even pages for a single page document. - test->m_expectedError = WEBKIT_PRINT_ERROR_INVALID_PAGE_RANGE; - gtk_print_settings_set_printer(printSettings.get(), gtk_printer_get_name(printer.get())); - gtk_print_settings_set_page_set(printSettings.get(), GTK_PAGE_SET_EVEN); - webkit_print_operation_print(test->m_printOperation.get()); - test->waitUntilPrintFinished(); -} -#endif // HAVE_GTK_UNIX_PRINTING - -void beforeAll() -{ - kTempDirectory = g_dir_make_tmp("WebKit2Tests-XXXXXX", 0); - g_assert(kTempDirectory); - - WebViewTest::add("WebKitPrintOperation", "printing-settings", testPrintOperationPrintSettings); - WebViewTest::add("WebKitWebView", "print", testWebViewPrint); -#ifdef HAVE_GTK_UNIX_PRINTING - PrintTest::add("WebKitPrintOperation", "print", testPrintOperationPrint); - PrintTest::add("WebKitPrintOperation", "print-errors", testPrintOperationErrors); -#endif -} - -void afterAll() -{ - g_rmdir(kTempDirectory); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp deleted file mode 100644 index a24b6fdff..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp +++ /dev/null @@ -1,735 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitTestServer.h" -#include "WebViewTest.h" -#include <wtf/gobject/GRefPtr.h> - -static WebKitTestServer* kServer; - -static const char* kIndexHtml = - "<html><head>" - " <link rel='stylesheet' href='/style.css' type='text/css'>" - " <script language='javascript' src='/javascript.js'></script>" - "</head><body>WebKitGTK+ resources test</body></html>"; - -static const char* kStyleCSS = - "body {" - " margin: 0px;" - " padding: 0px;" - " font-family: sans-serif;" - " background: url(/blank.ico) 0 0 no-repeat;" - " color: black;" - "}"; - -static const char* kJavascript = "function foo () { var a = 1; }"; - -class ResourcesTest: public WebViewTest { -public: - MAKE_GLIB_TEST_FIXTURE(ResourcesTest); - - static void resourceSentRequestCallback(WebKitWebResource* resource, WebKitURIRequest* request, WebKitURIResponse* redirectResponse, ResourcesTest* test) - { - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request)); - if (redirectResponse) - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(redirectResponse)); - test->resourceSentRequest(resource, request, redirectResponse); - } - - static void resourceReceivedResponseCallback(WebKitWebResource* resource, GParamSpec*, ResourcesTest* test) - { - g_assert(webkit_web_resource_get_response(resource)); - test->resourceReceivedResponse(resource); - } - - static void resourceReceivedDataCallback(WebKitWebResource* resource, guint64 bytesReceived, ResourcesTest* test) - { - test->resourceReceivedData(resource, bytesReceived); - } - - static void resourceFinishedCallback(WebKitWebResource* resource, ResourcesTest* test) - { - test->resourceFinished(resource); - } - - static void resourceFailedCallback(WebKitWebResource* resource, GError* error, ResourcesTest* test) - { - g_assert(error); - test->resourceFailed(resource, error); - } - - static void resourceLoadStartedCallback(WebKitWebView* webView, WebKitWebResource* resource, WebKitURIRequest* request, ResourcesTest* test) - { - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(resource)); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request)); - - // Ignore favicons. - if (g_str_has_suffix(webkit_uri_request_get_uri(request), "favicon.ico")) - return; - - test->resourceLoadStarted(resource, request); - g_signal_connect(resource, "sent-request", G_CALLBACK(resourceSentRequestCallback), test); - g_signal_connect(resource, "notify::response", G_CALLBACK(resourceReceivedResponseCallback), test); - g_signal_connect(resource, "received-data", G_CALLBACK(resourceReceivedDataCallback), test); - g_signal_connect(resource, "finished", G_CALLBACK(resourceFinishedCallback), test); - g_signal_connect(resource, "failed", G_CALLBACK(resourceFailedCallback), test); - } - - void clearSubresources() - { - g_list_free_full(m_subresources, reinterpret_cast<GDestroyNotify>(g_object_unref)); - m_subresources = 0; - } - - ResourcesTest() - : WebViewTest() - , m_resourcesLoaded(0) - , m_resourcesToLoad(0) - , m_resourceDataSize(0) - , m_subresources(0) - { - g_signal_connect(m_webView, "resource-load-started", G_CALLBACK(resourceLoadStartedCallback), this); - } - - ~ResourcesTest() - { - clearSubresources(); - } - - virtual void resourceLoadStarted(WebKitWebResource* resource, WebKitURIRequest* request) - { - } - - virtual void resourceSentRequest(WebKitWebResource* resource, WebKitURIRequest* request, WebKitURIResponse* redirectResponse) - { - } - - virtual void resourceReceivedResponse(WebKitWebResource* resource) - { - } - - virtual void resourceReceivedData(WebKitWebResource* resource, guint64 bytesReceived) - { - } - - virtual void resourceFinished(WebKitWebResource* resource) - { - g_signal_handlers_disconnect_matched(resource, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); - if (webkit_web_view_get_main_resource(m_webView) != resource) - m_subresources = g_list_prepend(m_subresources, g_object_ref(resource)); - if (++m_resourcesLoaded == m_resourcesToLoad) - g_main_loop_quit(m_mainLoop); - } - - virtual void resourceFailed(WebKitWebResource* resource, GError* error) - { - g_assert_not_reached(); - } - - void waitUntilResourcesLoaded(size_t resourcesCount) - { - m_resourcesLoaded = 0; - m_resourcesToLoad = resourcesCount; - clearSubresources(); - g_main_loop_run(m_mainLoop); - } - - GList* subresources() - { - return m_subresources; - } - - static void resourceGetDataCallback(GObject* object, GAsyncResult* result, gpointer userData) - { - size_t dataSize; - GOwnPtr<GError> error; - unsigned char* data = webkit_web_resource_get_data_finish(WEBKIT_WEB_RESOURCE(object), result, &dataSize, &error.outPtr()); - g_assert(!error.get()); - g_assert(data); - g_assert_cmpint(dataSize, >, 0); - - ResourcesTest* test = static_cast<ResourcesTest*>(userData); - test->m_resourceData.set(reinterpret_cast<char*>(data)); - test->m_resourceDataSize = dataSize; - g_main_loop_quit(test->m_mainLoop); - } - - void checkResourceData(WebKitWebResource* resource) - { - m_resourceDataSize = 0; - webkit_web_resource_get_data(resource, 0, resourceGetDataCallback, this); - g_main_loop_run(m_mainLoop); - - const char* uri = webkit_web_resource_get_uri(resource); - if (uri == kServer->getURIForPath("/")) { - g_assert_cmpint(m_resourceDataSize, ==, strlen(kIndexHtml)); - g_assert(!strncmp(m_resourceData.get(), kIndexHtml, m_resourceDataSize)); - } else if (uri == kServer->getURIForPath("/style.css")) { - g_assert_cmpint(m_resourceDataSize, ==, strlen(kStyleCSS)); - g_assert(!strncmp(m_resourceData.get(), kStyleCSS, m_resourceDataSize)); - } else if (uri == kServer->getURIForPath("/javascript.js")) { - g_assert_cmpint(m_resourceDataSize, ==, strlen(kJavascript)); - g_assert(!strncmp(m_resourceData.get(), kJavascript, m_resourceDataSize)); - } else - g_assert_not_reached(); - m_resourceData.clear(); - } - - size_t m_resourcesLoaded; - size_t m_resourcesToLoad; - GOwnPtr<char> m_resourceData; - size_t m_resourceDataSize; - GList* m_subresources; -}; - -static void testWebViewResources(ResourcesTest* test, gconstpointer) -{ - // Nothing loaded yet, there shoulnd't be resources. - g_assert(!webkit_web_view_get_main_resource(test->m_webView)); - g_assert(!test->subresources()); - - // Load simple page without subresources. - test->loadHtml("<html><body>Testing WebKitGTK+</body></html>", 0); - test->waitUntilLoadFinished(); - WebKitWebResource* resource = webkit_web_view_get_main_resource(test->m_webView); - g_assert(resource); - g_assert_cmpstr(webkit_web_view_get_uri(test->m_webView), ==, webkit_web_resource_get_uri(resource)); - g_assert(!test->subresources()); - - // Load simple page with subresources. - test->loadURI(kServer->getURIForPath("/").data()); - test->waitUntilResourcesLoaded(4); - - resource = webkit_web_view_get_main_resource(test->m_webView); - g_assert(resource); - g_assert_cmpstr(webkit_web_view_get_uri(test->m_webView), ==, webkit_web_resource_get_uri(resource)); - GList* subresources = test->subresources(); - g_assert(subresources); - g_assert_cmpint(g_list_length(subresources), ==, 3); - -#if 0 - // Load the same URI again. - // FIXME: we need a workaround for bug https://bugs.webkit.org/show_bug.cgi?id=78510. - test->loadURI(kServer->getURIForPath("/").data()); - test->waitUntilResourcesLoaded(4); -#endif - - // Reload. - webkit_web_view_reload_bypass_cache(test->m_webView); - test->waitUntilResourcesLoaded(4); -} - -class SingleResourceLoadTest: public ResourcesTest { -public: - MAKE_GLIB_TEST_FIXTURE(SingleResourceLoadTest); - - enum LoadEvents { - Started, - SentRequest, - Redirected, - ReceivedResponse, - ReceivedData, - Finished, - Failed - }; - - SingleResourceLoadTest() - : ResourcesTest() - , m_resourceDataReceived(0) - { - m_resourcesToLoad = 2; - } - - void resourceLoadStarted(WebKitWebResource* resource, WebKitURIRequest* request) - { - if (resource == webkit_web_view_get_main_resource(m_webView)) - return; - - m_resourceDataReceived = 0; - m_resource = resource; - m_loadEvents.append(Started); - } - - void resourceSentRequest(WebKitWebResource* resource, WebKitURIRequest* request, WebKitURIResponse* redirectResponse) - { - if (resource != m_resource) - return; - - if (redirectResponse) - m_loadEvents.append(Redirected); - else - m_loadEvents.append(SentRequest); - } - - void resourceReceivedResponse(WebKitWebResource* resource) - { - if (resource != m_resource) - return; - - m_loadEvents.append(ReceivedResponse); - } - - void resourceReceivedData(WebKitWebResource* resource, guint64 bytesReceived) - { - if (resource != m_resource) - return; - - m_resourceDataReceived += bytesReceived; - if (!m_loadEvents.contains(ReceivedData)) - m_loadEvents.append(ReceivedData); - } - - void resourceFinished(WebKitWebResource* resource) - { - if (resource != m_resource) { - ResourcesTest::resourceFinished(resource); - return; - } - - if (!m_loadEvents.contains(Failed)) { - WebKitURIResponse* response = webkit_web_resource_get_response(m_resource.get()); - g_assert(response); - g_assert_cmpint(webkit_uri_response_get_content_length(response), ==, m_resourceDataReceived); - } - m_loadEvents.append(Finished); - ResourcesTest::resourceFinished(resource); - } - - void resourceFailed(WebKitWebResource* resource, GError* error) - { - if (resource == m_resource) - m_loadEvents.append(Failed); - } - - void waitUntilResourceLoadFinished() - { - m_resource = 0; - m_resourcesLoaded = 0; - g_main_loop_run(m_mainLoop); - } - - WebKitURIResponse* waitUntilResourceLoadFinishedAndReturnURIResponse() - { - waitUntilResourceLoadFinished(); - g_assert(m_resource); - return webkit_web_resource_get_response(m_resource.get()); - } - - GRefPtr<WebKitWebResource> m_resource; - Vector<LoadEvents> m_loadEvents; - guint64 m_resourceDataReceived; -}; - -static void testWebResourceLoading(SingleResourceLoadTest* test, gconstpointer) -{ - test->loadURI(kServer->getURIForPath("/javascript.html").data()); - test->waitUntilResourceLoadFinished(); - g_assert(test->m_resource); - Vector<SingleResourceLoadTest::LoadEvents>& events = test->m_loadEvents; - g_assert_cmpint(events.size(), ==, 5); - g_assert_cmpint(events[0], ==, SingleResourceLoadTest::Started); - g_assert_cmpint(events[1], ==, SingleResourceLoadTest::SentRequest); - g_assert_cmpint(events[2], ==, SingleResourceLoadTest::ReceivedResponse); - g_assert_cmpint(events[3], ==, SingleResourceLoadTest::ReceivedData); - g_assert_cmpint(events[4], ==, SingleResourceLoadTest::Finished); - events.clear(); - - test->loadURI(kServer->getURIForPath("/redirected-css.html").data()); - test->waitUntilResourceLoadFinished(); - g_assert(test->m_resource); - g_assert_cmpint(events.size(), ==, 6); - g_assert_cmpint(events[0], ==, SingleResourceLoadTest::Started); - g_assert_cmpint(events[1], ==, SingleResourceLoadTest::SentRequest); - g_assert_cmpint(events[2], ==, SingleResourceLoadTest::Redirected); - g_assert_cmpint(events[3], ==, SingleResourceLoadTest::ReceivedResponse); - g_assert_cmpint(events[4], ==, SingleResourceLoadTest::ReceivedData); - g_assert_cmpint(events[5], ==, SingleResourceLoadTest::Finished); - events.clear(); - - test->loadURI(kServer->getURIForPath("/invalid-css.html").data()); - test->waitUntilResourceLoadFinished(); - g_assert(test->m_resource); - g_assert_cmpint(events.size(), ==, 4); - g_assert_cmpint(events[0], ==, SingleResourceLoadTest::Started); - g_assert_cmpint(events[1], ==, SingleResourceLoadTest::SentRequest); - g_assert_cmpint(events[2], ==, SingleResourceLoadTest::Failed); - g_assert_cmpint(events[3], ==, SingleResourceLoadTest::Finished); - events.clear(); -} - -static void testWebResourceResponse(SingleResourceLoadTest* test, gconstpointer) -{ - // No cached resource: First load. - test->loadURI(kServer->getURIForPath("/javascript.html").data()); - WebKitURIResponse* response = test->waitUntilResourceLoadFinishedAndReturnURIResponse(); - g_assert_cmpint(webkit_uri_response_get_status_code(response), ==, SOUP_STATUS_OK); - - // No cached resource: Second load. - test->loadURI(kServer->getURIForPath("/javascript.html").data()); - response = test->waitUntilResourceLoadFinishedAndReturnURIResponse(); - g_assert_cmpint(webkit_uri_response_get_status_code(response), ==, SOUP_STATUS_OK); - - // No cached resource: Reload. - webkit_web_view_reload(test->m_webView); - response = test->waitUntilResourceLoadFinishedAndReturnURIResponse(); - g_assert_cmpint(webkit_uri_response_get_status_code(response), ==, SOUP_STATUS_OK); - - // Cached resource: First load. - test->loadURI(kServer->getURIForPath("/image.html").data()); - response = test->waitUntilResourceLoadFinishedAndReturnURIResponse(); - g_assert_cmpint(webkit_uri_response_get_status_code(response), ==, SOUP_STATUS_OK); - - // Cached resource: Second load. - test->loadURI(kServer->getURIForPath("/image.html").data()); - response = test->waitUntilResourceLoadFinishedAndReturnURIResponse(); - g_assert_cmpint(webkit_uri_response_get_status_code(response), ==, SOUP_STATUS_OK); - - // Cached resource: Reload. - webkit_web_view_reload(test->m_webView); - response = test->waitUntilResourceLoadFinishedAndReturnURIResponse(); - g_assert_cmpint(webkit_uri_response_get_status_code(response), ==, SOUP_STATUS_NOT_MODIFIED); -} - -static void testWebResourceMimeType(SingleResourceLoadTest* test, gconstpointer) -{ - test->loadURI(kServer->getURIForPath("/javascript.html").data()); - WebKitURIResponse* response = test->waitUntilResourceLoadFinishedAndReturnURIResponse(); - g_assert_cmpstr(webkit_uri_response_get_mime_type(response), ==, "text/javascript"); - - test->loadURI(kServer->getURIForPath("/image.html").data()); - response = test->waitUntilResourceLoadFinishedAndReturnURIResponse(); - g_assert_cmpstr(webkit_uri_response_get_mime_type(response), ==, "image/vnd.microsoft.icon"); - - test->loadURI(kServer->getURIForPath("/redirected-css.html").data()); - response = test->waitUntilResourceLoadFinishedAndReturnURIResponse(); - g_assert_cmpstr(webkit_uri_response_get_mime_type(response), ==, "text/css"); -} - -static void testWebResourceSuggestedFilename(SingleResourceLoadTest* test, gconstpointer) -{ - test->loadURI(kServer->getURIForPath("/javascript.html").data()); - WebKitURIResponse* response = test->waitUntilResourceLoadFinishedAndReturnURIResponse(); - g_assert_cmpstr(webkit_uri_response_get_suggested_filename(response), ==, "JavaScript.js"); - - test->loadURI(kServer->getURIForPath("/image.html").data()); - response = test->waitUntilResourceLoadFinishedAndReturnURIResponse(); - g_assert(!webkit_uri_response_get_suggested_filename(response)); -} - -class ResourceURITrackingTest: public SingleResourceLoadTest { -public: - MAKE_GLIB_TEST_FIXTURE(ResourceURITrackingTest); - - ResourceURITrackingTest() - : SingleResourceLoadTest() - { - } - - static void uriChanged(WebKitWebResource* resource, GParamSpec*, ResourceURITrackingTest* test) - { - g_assert(resource == test->m_resource.get()); - g_assert_cmpstr(test->m_activeURI.data(), !=, webkit_web_resource_get_uri(test->m_resource.get())); - test->m_activeURI = webkit_web_resource_get_uri(test->m_resource.get()); - } - - void resourceLoadStarted(WebKitWebResource* resource, WebKitURIRequest* request) - { - if (resource == webkit_web_view_get_main_resource(m_webView)) - return; - - m_resource = resource; - m_activeURI = webkit_web_resource_get_uri(resource); - checkActiveURI("/redirected.css"); - g_assert_cmpstr(m_activeURI.data(), ==, webkit_uri_request_get_uri(request)); - g_signal_connect(resource, "notify::uri", G_CALLBACK(uriChanged), this); - } - - void resourceSentRequest(WebKitWebResource* resource, WebKitURIRequest* request, WebKitURIResponse* redirectResponse) - { - if (resource != m_resource) - return; - - if (redirectResponse) - checkActiveURI("/simple-style.css"); - else - checkActiveURI("/redirected.css"); - g_assert_cmpstr(m_activeURI.data(), ==, webkit_uri_request_get_uri(request)); - } - - void resourceReceivedResponse(WebKitWebResource* resource) - { - if (resource != m_resource) - return; - - checkActiveURI("/simple-style.css"); - } - - void resourceReceivedData(WebKitWebResource* resource, guint64 bytesReceived) - { - } - - void resourceFinished(WebKitWebResource* resource) - { - if (resource == m_resource) - checkActiveURI("/simple-style.css"); - ResourcesTest::resourceFinished(resource); - } - - void resourceFailed(WebKitWebResource*, GError*) - { - g_assert_not_reached(); - } - - CString m_activeURI; - -private: - void checkActiveURI(const char* uri) - { - ASSERT_CMP_CSTRING(m_activeURI, ==, kServer->getURIForPath(uri)); - } -}; - -static void testWebResourceActiveURI(ResourceURITrackingTest* test, gconstpointer) -{ - test->loadURI(kServer->getURIForPath("/redirected-css.html").data()); - test->waitUntilResourceLoadFinished(); -} - -static void testWebResourceGetData(ResourcesTest* test, gconstpointer) -{ - test->loadURI(kServer->getURIForPath("/").data()); - // FIXME: this should be 4 instead of 3, but we don't get the css image resource - // due to bug https://bugs.webkit.org/show_bug.cgi?id=78510. - test->waitUntilResourcesLoaded(3); - - WebKitWebResource* resource = webkit_web_view_get_main_resource(test->m_webView); - g_assert(resource); - test->checkResourceData(resource); - - GList* subresources = test->subresources(); - for (GList* item = subresources; item; item = g_list_next(item)) - test->checkResourceData(WEBKIT_WEB_RESOURCE(item->data)); -} - -static void testWebViewResourcesHistoryCache(SingleResourceLoadTest* test, gconstpointer) -{ - CString javascriptURI = kServer->getURIForPath("/javascript.html"); - test->loadURI(javascriptURI.data()); - test->waitUntilResourceLoadFinished(); - WebKitWebResource* resource = webkit_web_view_get_main_resource(test->m_webView); - g_assert(resource); - g_assert_cmpstr(webkit_web_resource_get_uri(resource), ==, javascriptURI.data()); - - CString simpleStyleCSSURI = kServer->getURIForPath("/simple-style-css.html"); - test->loadURI(simpleStyleCSSURI.data()); - test->waitUntilResourceLoadFinished(); - resource = webkit_web_view_get_main_resource(test->m_webView); - g_assert(resource); - g_assert_cmpstr(webkit_web_resource_get_uri(resource), ==, simpleStyleCSSURI.data()); - - test->goBack(); - test->waitUntilResourceLoadFinished(); - resource = webkit_web_view_get_main_resource(test->m_webView); - g_assert(resource); - g_assert_cmpstr(webkit_web_resource_get_uri(resource), ==, javascriptURI.data()); - - test->goForward(); - test->waitUntilResourceLoadFinished(); - resource = webkit_web_view_get_main_resource(test->m_webView); - g_assert(resource); - g_assert_cmpstr(webkit_web_resource_get_uri(resource), ==, simpleStyleCSSURI.data()); -} - -class SendRequestTest: public SingleResourceLoadTest { -public: - MAKE_GLIB_TEST_FIXTURE(SendRequestTest); - - void resourceSentRequest(WebKitWebResource* resource, WebKitURIRequest* request, WebKitURIResponse* redirectResponse) - { - if (resource != m_resource) - return; - - g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, m_expectedNewResourceURI.data()); - g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, webkit_web_resource_get_uri(resource)); - - SingleResourceLoadTest::resourceSentRequest(resource, request, redirectResponse); - } - - void resourceFailed(WebKitWebResource* resource, GError* error) - { - if (resource != m_resource) - return; - - g_assert_cmpstr(webkit_web_resource_get_uri(resource), ==, m_expectedCancelledResourceURI.data()); - g_assert_error(error, WEBKIT_NETWORK_ERROR, WEBKIT_NETWORK_ERROR_CANCELLED); - - SingleResourceLoadTest::resourceFailed(resource, error); - } - - void setExpectedNewResourceURI(const CString& uri) - { - m_expectedNewResourceURI = uri; - } - - void setExpectedCancelledResourceURI(const CString& uri) - { - m_expectedCancelledResourceURI = uri; - } - - CString m_expectedNewResourceURI; - CString m_expectedCancelledResourceURI; -}; - -static void testWebResourceSendRequest(SendRequestTest* test, gconstpointer) -{ - test->setExpectedNewResourceURI(kServer->getURIForPath("/javascript.js")); - test->loadURI(kServer->getURIForPath("relative-javascript.html").data()); - test->waitUntilResourceLoadFinished(); - g_assert(test->m_resource); - - Vector<SingleResourceLoadTest::LoadEvents>& events = test->m_loadEvents; - g_assert_cmpint(events.size(), ==, 5); - g_assert_cmpint(events[0], ==, SingleResourceLoadTest::Started); - g_assert_cmpint(events[1], ==, SingleResourceLoadTest::SentRequest); - g_assert_cmpint(events[2], ==, SingleResourceLoadTest::ReceivedResponse); - g_assert_cmpint(events[3], ==, SingleResourceLoadTest::ReceivedData); - g_assert_cmpint(events[4], ==, SingleResourceLoadTest::Finished); - events.clear(); - - // Cancel request. - test->setExpectedCancelledResourceURI(kServer->getURIForPath("/cancel-this.js")); - test->loadURI(kServer->getURIForPath("/resource-to-cancel.html").data()); - test->waitUntilResourceLoadFinished(); - g_assert(test->m_resource); - - g_assert_cmpint(events.size(), ==, 3); - g_assert_cmpint(events[0], ==, SingleResourceLoadTest::Started); - g_assert_cmpint(events[1], ==, SingleResourceLoadTest::Failed); - g_assert_cmpint(events[2], ==, SingleResourceLoadTest::Finished); - events.clear(); -} - -static void addCacheHTTPHeadersToResponse(SoupMessage* message) -{ - // The actual date doesn't really matter. - SoupDate* soupDate = soup_date_new_from_now(0); - GOwnPtr<char> date(soup_date_to_string(soupDate, SOUP_DATE_HTTP)); - soup_message_headers_append(message->response_headers, "Last-Modified", date.get()); - soup_date_free(soupDate); - soup_message_headers_append(message->response_headers, "Cache-control", "public, max-age=31536000"); - soupDate = soup_date_new_from_now(3600); - date.set(soup_date_to_string(soupDate, SOUP_DATE_HTTP)); - soup_message_headers_append(message->response_headers, "Expires", date.get()); - soup_date_free(soupDate); -} - -static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer) -{ - if (message->method != SOUP_METHOD_GET) { - soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED); - return; - } - - soup_message_set_status(message, SOUP_STATUS_OK); - - if (soup_message_headers_get_one(message->request_headers, "If-Modified-Since")) { - soup_message_set_status(message, SOUP_STATUS_NOT_MODIFIED); - soup_message_body_complete(message->response_body); - return; - } - - if (g_str_equal(path, "/")) { - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, kIndexHtml, strlen(kIndexHtml)); - } else if (g_str_equal(path, "/javascript.html")) { - static const char* javascriptHtml = "<html><head><script language='javascript' src='/javascript.js'></script></head><body></body></html>"; - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, javascriptHtml, strlen(javascriptHtml)); - } else if (g_str_equal(path, "/image.html")) { - static const char* imageHTML = "<html><body><img src='/blank.ico'></img></body></html>"; - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, imageHTML, strlen(imageHTML)); - } else if (g_str_equal(path, "/redirected-css.html")) { - static const char* redirectedCSSHtml = "<html><head><link rel='stylesheet' href='/redirected.css' type='text/css'></head><body></html>"; - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, redirectedCSSHtml, strlen(redirectedCSSHtml)); - } else if (g_str_equal(path, "/invalid-css.html")) { - static const char* invalidCSSHtml = "<html><head><link rel='stylesheet' href='/invalid.css' type='text/css'></head><body></html>"; - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, invalidCSSHtml, strlen(invalidCSSHtml)); - } else if (g_str_equal(path, "/simple-style-css.html")) { - static const char* simpleStyleCSSHtml = "<html><head><link rel='stylesheet' href='/simple-style.css' type='text/css'></head><body></html>"; - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, simpleStyleCSSHtml, strlen(simpleStyleCSSHtml)); - } else if (g_str_equal(path, "/style.css")) { - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, kStyleCSS, strlen(kStyleCSS)); - addCacheHTTPHeadersToResponse(message); - } else if (g_str_equal(path, "/javascript.js")) { - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, kJavascript, strlen(kJavascript)); - soup_message_headers_append(message->response_headers, "Content-Type", "text/javascript"); - soup_message_headers_append(message->response_headers, "Content-Disposition", "filename=JavaScript.js"); - } else if (g_str_equal(path, "/relative-javascript.html")) { - static const char* javascriptRelativeHTML = "<html><head><script language='javascript' src='remove-this/javascript.js'></script></head><body></body></html>"; - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, javascriptRelativeHTML, strlen(javascriptRelativeHTML)); - } else if (g_str_equal(path, "/resource-to-cancel.html")) { - static const char* resourceToCancelHTML = "<html><head><script language='javascript' src='cancel-this.js'></script></head><body></body></html>"; - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, resourceToCancelHTML, strlen(resourceToCancelHTML)); - } else if (g_str_equal(path, "/blank.ico")) { - GOwnPtr<char> filePath(g_build_filename(Test::getWebKit1TestResoucesDir().data(), path, NULL)); - char* contents; - gsize contentsLength; - g_file_get_contents(filePath.get(), &contents, &contentsLength, 0); - soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, contents, contentsLength); - addCacheHTTPHeadersToResponse(message); - } else if (g_str_equal(path, "/simple-style.css")) { - static const char* simpleCSS = - "body {" - " margin: 0px;" - " padding: 0px;" - "}"; - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, simpleCSS, strlen(simpleCSS)); - soup_message_headers_append(message->response_headers, "Content-Type", "text/css"); - } else if (g_str_equal(path, "/redirected.css")) { - soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY); - soup_message_headers_append(message->response_headers, "Location", "/simple-style.css"); - } else if (g_str_equal(path, "/invalid.css")) - soup_message_set_status(message, SOUP_STATUS_CANT_CONNECT); - else - soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); - soup_message_body_complete(message->response_body); -} - -void beforeAll() -{ - kServer = new WebKitTestServer(); - kServer->run(serverCallback); - - webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR); - - ResourcesTest::add("WebKitWebView", "resources", testWebViewResources); - SingleResourceLoadTest::add("WebKitWebResource", "loading", testWebResourceLoading); - SingleResourceLoadTest::add("WebKitWebResource", "response", testWebResourceResponse); - SingleResourceLoadTest::add("WebKitWebResource", "mime-type", testWebResourceMimeType); - SingleResourceLoadTest::add("WebKitWebResource", "suggested-filename", testWebResourceSuggestedFilename); - ResourceURITrackingTest::add("WebKitWebResource", "active-uri", testWebResourceActiveURI); - ResourcesTest::add("WebKitWebResource", "get-data", testWebResourceGetData); - SingleResourceLoadTest::add("WebKitWebView", "history-cache", testWebViewResourcesHistoryCache); - SendRequestTest::add("WebKitWebPage", "send-request", testWebResourceSendRequest); -} - -void afterAll() -{ - delete kServer; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestSSL.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestSSL.cpp deleted file mode 100644 index db6ccc852..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestSSL.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "LoadTrackingTest.h" -#include "WebKitTestServer.h" -#include <gtk/gtk.h> - -static WebKitTestServer* kHttpsServer; -static WebKitTestServer* kHttpServer; - -static const char* indexHTML = "<html><body>Testing WebKit2GTK+ SSL</body></htmll>"; -static const char* insecureContentHTML = "<html><script src=\"%s\"></script><body><p>Text + image <img src=\"%s\" align=\"right\"/></p></body></html>"; - -class SSLTest: public LoadTrackingTest { -public: - MAKE_GLIB_TEST_FIXTURE(SSLTest); - - SSLTest() - : m_tlsErrors(static_cast<GTlsCertificateFlags>(0)) - { - } - - virtual void provisionalLoadFailed(const gchar* failingURI, GError* error) - { - g_assert_error(error, SOUP_HTTP_ERROR, SOUP_STATUS_SSL_FAILED); - LoadTrackingTest::provisionalLoadFailed(failingURI, error); - } - - virtual void loadCommitted() - { - GTlsCertificate* certificate = 0; - webkit_web_view_get_tls_info(m_webView, &certificate, &m_tlsErrors); - m_certificate = certificate; - LoadTrackingTest::loadCommitted(); - } - - void waitUntilLoadFinished() - { - m_certificate = 0; - m_tlsErrors = static_cast<GTlsCertificateFlags>(0); - LoadTrackingTest::waitUntilLoadFinished(); - } - - GRefPtr<GTlsCertificate> m_certificate; - GTlsCertificateFlags m_tlsErrors; -}; - -static void testSSL(SSLTest* test, gconstpointer) -{ - test->loadURI(kHttpsServer->getURIForPath("/").data()); - test->waitUntilLoadFinished(); - g_assert(test->m_certificate); - // We always expect errors because we are using a self-signed certificate, - // but only G_TLS_CERTIFICATE_UNKNOWN_CA flags should be present. - g_assert(test->m_tlsErrors); - g_assert_cmpuint(test->m_tlsErrors, ==, G_TLS_CERTIFICATE_UNKNOWN_CA); - - // Non HTTPS loads shouldn't have a certificate nor errors. - test->loadHtml(indexHTML, 0); - test->waitUntilLoadFinished(); - g_assert(!test->m_certificate); - g_assert(!test->m_tlsErrors); -} - -class InsecureContentTest: public WebViewTest { -public: - MAKE_GLIB_TEST_FIXTURE(InsecureContentTest); - - InsecureContentTest() - : m_insecureContentRun(false) - , m_insecureContentDisplayed(false) - { - g_signal_connect(m_webView, "insecure-content-detected", G_CALLBACK(insecureContentDetectedCallback), this); - } - - static void insecureContentDetectedCallback(WebKitWebView* webView, WebKitInsecureContentEvent event, InsecureContentTest* test) - { - g_assert(webView == test->m_webView); - - if (event == WEBKIT_INSECURE_CONTENT_RUN) - test->m_insecureContentRun = true; - - if (event == WEBKIT_INSECURE_CONTENT_DISPLAYED) - test->m_insecureContentDisplayed = true; - } - - bool m_insecureContentRun; - bool m_insecureContentDisplayed; -}; - -static void testInsecureContent(InsecureContentTest* test, gconstpointer) -{ - test->loadURI(kHttpsServer->getURIForPath("/insecure-content/").data()); - test->waitUntilLoadFinished(); - - g_assert(test->m_insecureContentRun); - g_assert(test->m_insecureContentDisplayed); -} - -static void testTLSErrorsPolicy(SSLTest* test, gconstpointer) -{ - WebKitWebContext* context = webkit_web_view_get_context(test->m_webView); - // TLS errors are ignored by default. - g_assert(webkit_web_context_get_tls_errors_policy(context) == WEBKIT_TLS_ERRORS_POLICY_IGNORE); - test->loadURI(kHttpsServer->getURIForPath("/").data()); - test->waitUntilLoadFinished(); - g_assert(!test->m_loadFailed); - - webkit_web_context_set_tls_errors_policy(context, WEBKIT_TLS_ERRORS_POLICY_FAIL); - test->loadURI(kHttpsServer->getURIForPath("/").data()); - test->waitUntilLoadFinished(); - g_assert(test->m_loadFailed); - g_assert(test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed)); - g_assert(!test->m_loadEvents.contains(LoadTrackingTest::LoadCommitted)); -} - -static void httpsServerCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer) -{ - if (message->method != SOUP_METHOD_GET) { - soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED); - return; - } - - if (g_str_equal(path, "/")) { - soup_message_set_status(message, SOUP_STATUS_OK); - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, indexHTML, strlen(indexHTML)); - soup_message_body_complete(message->response_body); - } else if (g_str_equal(path, "/insecure-content/")) { - GOwnPtr<char> responseHTML(g_strdup_printf(insecureContentHTML, kHttpServer->getURIForPath("/test-script").data(), kHttpServer->getURIForPath("/test-image").data())); - soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, responseHTML.get(), strlen(responseHTML.get())); - soup_message_set_status(message, SOUP_STATUS_OK); - soup_message_body_complete(message->response_body); - } else - soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); -} - -static void httpServerCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer) -{ - if (message->method != SOUP_METHOD_GET) { - soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED); - return; - } - - if (g_str_equal(path, "/test-script")) { - GOwnPtr<char> pathToFile(g_build_filename(Test::getResourcesDir().data(), "link-title.js", NULL)); - char* contents; - gsize length; - g_file_get_contents(pathToFile.get(), &contents, &length, 0); - - soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, contents, length); - soup_message_set_status(message, SOUP_STATUS_OK); - soup_message_body_complete(message->response_body); - } else if (g_str_equal(path, "/test-image")) { - GOwnPtr<char> pathToFile(g_build_filename(Test::getWebKit1TestResoucesDir().data(), "blank.ico", NULL)); - char* contents; - gsize length; - g_file_get_contents(pathToFile.get(), &contents, &length, 0); - - soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, contents, length); - soup_message_set_status(message, SOUP_STATUS_OK); - soup_message_body_complete(message->response_body); - } else - soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); -} - -void beforeAll() -{ - kHttpsServer = new WebKitTestServer(WebKitTestServer::ServerHTTPS); - kHttpsServer->run(httpsServerCallback); - - kHttpServer = new WebKitTestServer(WebKitTestServer::ServerHTTP); - kHttpServer->run(httpServerCallback); - - SSLTest::add("WebKitWebView", "ssl", testSSL); - InsecureContentTest::add("WebKitWebView", "insecure-content", testInsecureContent); - SSLTest::add("WebKitWebContext", "tls-errors-policy", testTLSErrorsPolicy); -} - -void afterAll() -{ - delete kHttpsServer; - delete kHttpServer; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebExtensions.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebExtensions.cpp deleted file mode 100644 index 527cc936c..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebExtensions.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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 "WebKitTestBus.h" -#include "WebViewTest.h" -#include <wtf/gobject/GRefPtr.h> - -static WebKitTestBus* bus; - -static void testWebExtensionGetTitle(WebViewTest* test, gconstpointer) -{ - test->loadHtml("<html><head><title>WebKitGTK+ Web Extensions Test</title></head><body></body></html>", 0); - test->waitUntilLoadFinished(); - - GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy("org.webkit.gtk.WebExtensionTest", - "/org/webkit/gtk/WebExtensionTest" , "org.webkit.gtk.WebExtensionTest", test->m_mainLoop)); - GRefPtr<GVariant> result = adoptGRef(g_dbus_proxy_call_sync( - proxy.get(), - "GetTitle", - g_variant_new("(t)", webkit_web_view_get_page_id(test->m_webView)), - G_DBUS_CALL_FLAGS_NONE, - -1, 0, 0)); - g_assert(result); - - const char* title; - g_variant_get(result.get(), "(&s)", &title); - g_assert_cmpstr(title, ==, "WebKitGTK+ Web Extensions Test"); -} - -static void documentLoadedCallback(GDBusConnection*, const char*, const char*, const char*, const char*, GVariant*, WebViewTest* test) -{ - g_main_loop_quit(test->m_mainLoop); -} - -static void testDocumentLoadedSignal(WebViewTest* test, gconstpointer) -{ - GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy("org.webkit.gtk.WebExtensionTest", - "/org/webkit/gtk/WebExtensionTest", "org.webkit.gtk.WebExtensionTest", test->m_mainLoop)); - GDBusConnection* connection = g_dbus_proxy_get_connection(proxy.get()); - guint id = g_dbus_connection_signal_subscribe(connection, - 0, - "org.webkit.gtk.WebExtensionTest", - "DocumentLoaded", - "/org/webkit/gtk/WebExtensionTest", - 0, - G_DBUS_SIGNAL_FLAGS_NONE, - reinterpret_cast<GDBusSignalCallback>(documentLoadedCallback), - test, - 0); - g_assert(id); - - test->loadHtml("<html><head><title>WebKitGTK+ Web Extensions Test</title></head><body></body></html>", 0); - g_main_loop_run(test->m_mainLoop); - g_dbus_connection_signal_unsubscribe(connection, id); -} - -static gboolean webProcessCrashedCallback(WebKitWebView*, WebViewTest* test) -{ - test->quitMainLoop(); - - return FALSE; -} - -static void testWebKitWebViewProcessCrashed(WebViewTest* test, gconstpointer) -{ - test->loadHtml("<html></html>", 0); - test->waitUntilLoadFinished(); - - g_signal_connect(test->m_webView, "web-process-crashed", - G_CALLBACK(webProcessCrashedCallback), test); - - GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy("org.webkit.gtk.WebExtensionTest", - "/org/webkit/gtk/WebExtensionTest", "org.webkit.gtk.WebExtensionTest", test->m_mainLoop)); - - GRefPtr<GVariant> result = adoptGRef(g_dbus_proxy_call_sync( - proxy.get(), - "AbortProcess", - 0, - G_DBUS_CALL_FLAGS_NONE, - -1, 0, 0)); - g_assert(!result); - g_main_loop_run(test->m_mainLoop); -} - -void beforeAll() -{ - webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR); - bus = new WebKitTestBus(); - if (!bus->run()) - return; - - WebViewTest::add("WebKitWebExtension", "dom-document-title", testWebExtensionGetTitle); - WebViewTest::add("WebKitWebExtension", "document-loaded-signal", testDocumentLoadedSignal); - WebViewTest::add("WebKitWebView", "web-process-crashed", testWebKitWebViewProcessCrashed); -} - -void afterAll() -{ - delete bus; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitAccessibility.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitAccessibility.cpp deleted file mode 100644 index d3750c005..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitAccessibility.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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 "TestMain.h" -#include "WebViewTest.h" - -// The libatspi headers don't use G_BEGIN_DECLS -extern "C" { -#include <atspi/atspi.h> -} - -#include <errno.h> -#include <fcntl.h> -#include <glib.h> -#include <signal.h> -#include <unistd.h> -#include <wtf/PassRefPtr.h> -#include <wtf/gobject/GOwnPtr.h> -#include <wtf/gobject/GRefPtr.h> - -// Name of the test server application creating the webView object. -static const char* kTestServerAppName = "AccessibilityTestServer"; - -// Max seconds to wait for the test server before inspecting it. -static const int kMaxWaitForChild = 5; - -// The PID for the test server running, so we can kill it if needed. -static GPid kChildProcessPid = 0; - -// Whether the child has replied and it's ready. -static bool kChildIsReady = false; - -static void stopTestServer() -{ - // Do nothing if there's no server running. - if (!kChildProcessPid) - return; - - g_spawn_close_pid(kChildProcessPid); - kill(kChildProcessPid, SIGTERM); - kChildProcessPid = 0; -} - -static void sigAbortHandler(int sigNum) -{ - // Just stop the test server if SIGABRT was received. - stopTestServer(); -} - -static gpointer testServerMonitorThreadFunc(gpointer) -{ - // Wait for the specified timeout to happen. - g_usleep(kMaxWaitForChild * G_USEC_PER_SEC); - - // Kill the child process if not ready yet. - if (!kChildIsReady) - stopTestServer(); - - g_thread_exit(0); - return 0; -} - -static void startTestServerMonitor() -{ - kChildIsReady = false; - g_thread_new("TestServerMonitor", testServerMonitorThreadFunc, 0); -} - -static void startTestServer() -{ - // Prepare argv[] for spawning the server process. - GOwnPtr<char> testServerPath(g_build_filename(WEBKIT_EXEC_PATH, "WebKit2APITests", kTestServerAppName, NULL)); - - char* testServerArgv[2]; - testServerArgv[0] = testServerPath.get(); - testServerArgv[1] = 0; - - // Spawn the server, getting its stdout file descriptor to set a - // communication channel, so we know when it's ready. - int childStdout = 0; - if (!g_spawn_async_with_pipes(0, testServerArgv, 0, static_cast<GSpawnFlags>(0), 0, 0, - &kChildProcessPid, 0, &childStdout, 0, 0)) { - close(childStdout); - return; - } - - // Start monitoring the test server (in a separate thread) to - // ensure we don't block on the child process more than a timeout. - startTestServerMonitor(); - - char msg[2]; - GIOChannel* ioChannel = g_io_channel_unix_new(childStdout); - if (g_io_channel_read_chars(ioChannel, msg, 2, 0, 0) == G_IO_STATUS_NORMAL) { - // Check whether the server sent a message saying it's ready - // and store the result globally, so the monitor can see it. - kChildIsReady = msg[0] == 'O' && msg[1] == 'K'; - } - g_io_channel_unref(ioChannel); - close(childStdout); - - // The timeout was reached and the server is not ready yet, so - // stop it inmediately, and let the unit tests fail. - if (!kChildIsReady) - stopTestServer(); -} - -static void checkAtspiAccessible(AtspiAccessible* accessible, const char* targetName, AtspiRole targetRole) -{ - g_assert(ATSPI_IS_ACCESSIBLE(accessible)); - - GOwnPtr<char> name(atspi_accessible_get_name(accessible, 0)); - g_assert_cmpstr(targetName, ==, name.get()); - g_assert_cmpint(targetRole, ==, atspi_accessible_get_role(accessible, 0)); -} - -static GRefPtr<AtspiAccessible> findTestServerApplication() -{ - // Only one desktop is supported by ATSPI at the moment. - GRefPtr<AtspiAccessible> desktop = adoptGRef(atspi_get_desktop(0)); - - // Look for the server application in the list of apps. - GRefPtr<AtspiAccessible> current; - int childCount = atspi_accessible_get_child_count(desktop.get(), 0); - for (int i = 0; i < childCount; i++) { - current = adoptGRef(atspi_accessible_get_child_at_index(desktop.get(), i, 0)); - if (!g_strcmp0(atspi_accessible_get_name(current.get(), 0), kTestServerAppName)) - return current; - } - - return 0; -} - -static void testAtspiBasicHierarchy(WebViewTest* test, gconstpointer) -{ - // The test server's accessibility object (UI Process). - GRefPtr<AtspiAccessible> testServerApp = findTestServerApplication(); - g_assert(ATSPI_IS_ACCESSIBLE(testServerApp.get())); - checkAtspiAccessible(testServerApp.get(), "AccessibilityTestServer", ATSPI_ROLE_APPLICATION); - - // The main window's accessibility object (UI Process). - GRefPtr<AtspiAccessible> currentParent = testServerApp; - GRefPtr<AtspiAccessible> currentChild = adoptGRef(atspi_accessible_get_child_at_index(currentParent.get(), 0, 0)); - g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get())); - checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_FRAME); - - // The WebView's accessibility object (UI Process). - currentParent = currentChild; - currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0); - g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get())); - checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_FILLER); - - // The WebPage's accessibility object (Web Process). - currentParent = currentChild; - currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0); - g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get())); - checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_FILLER); - - // HTML root element's accessible element (Web Process). - currentParent = currentChild; - currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0); - g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get())); - - // HTML body's accessible element (Web Process). - currentParent = currentChild; - currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0); - g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get())); - checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_DOCUMENT_FRAME); - - // HTML H1's accessible element (Web Process). - currentParent = currentChild; - currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0); - g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get())); - checkAtspiAccessible(currentChild.get(), "This is a test", ATSPI_ROLE_HEADING); - - // HTML first paragraph's accessible element (Web Process). - currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 1, 0); - g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get())); - checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_PARAGRAPH); - - // HTML second paragraph's accessible element (Web Process). - currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 2, 0); - g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get())); - checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_PARAGRAPH); - - // HTML link's accessible element (Web Process). - currentParent = currentChild; - currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0); - g_assert(ATSPI_IS_ACCESSIBLE(currentChild.get())); - checkAtspiAccessible(currentChild.get(), "a link", ATSPI_ROLE_LINK); -} - -void beforeAll() -{ - // We install a handler to ensure that we kill the child process - // if the parent dies because of whatever the reason is. - signal(SIGABRT, sigAbortHandler); - - // Start the accessibility test server and load the tests. - startTestServer(); - WebViewTest::add("WebKitAccessibility", "atspi-basic-hierarchy", testAtspiBasicHierarchy); -} - -void afterAll() -{ - // Ensure we stop the server. - stopTestServer(); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFaviconDatabase.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFaviconDatabase.cpp deleted file mode 100644 index 1a06f7496..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFaviconDatabase.cpp +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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 "WebKitTestServer.h" -#include "WebViewTest.h" -#include <glib/gstdio.h> -#include <libsoup/soup.h> -#include <wtf/gobject/GOwnPtr.h> - -static WebKitTestServer* kServer; -static char* kTempDirectory; - -class FaviconDatabaseTest: public WebViewTest { -public: - MAKE_GLIB_TEST_FIXTURE(FaviconDatabaseTest); - - FaviconDatabaseTest() - : m_webContext(webkit_web_context_get_default()) - , m_favicon(0) - , m_error(0) - , m_faviconNotificationReceived(false) - { - WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(m_webContext); - g_signal_connect(database, "favicon-changed", G_CALLBACK(faviconChangedCallback), this); - } - - ~FaviconDatabaseTest() - { - if (m_favicon) - cairo_surface_destroy(m_favicon); - - WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(m_webContext); - g_signal_handlers_disconnect_matched(database, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); - } - - static void faviconChangedCallback(WebKitFaviconDatabase* database, const char* pageURI, const char* faviconURI, FaviconDatabaseTest* test) - { - if (!g_strcmp0(webkit_web_view_get_uri(test->m_webView), pageURI)) - test->m_faviconURI = faviconURI; - } - - static void viewFaviconChangedCallback(WebKitWebView* webView, GParamSpec* pspec, gpointer data) - { - FaviconDatabaseTest* test = static_cast<FaviconDatabaseTest*>(data); - g_assert(test->m_webView == webView); - test->m_faviconNotificationReceived = true; - test->quitMainLoop(); - } - - static void getFaviconCallback(GObject* sourceObject, GAsyncResult* result, void* data) - { - FaviconDatabaseTest* test = static_cast<FaviconDatabaseTest*>(data); - WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(test->m_webContext); - test->m_favicon = webkit_favicon_database_get_favicon_finish(database, result, &test->m_error.outPtr()); - test->quitMainLoop(); - } - - void waitUntilFaviconChanged() - { - m_faviconNotificationReceived = false; - unsigned long handlerID = g_signal_connect(m_webView, "notify::favicon", G_CALLBACK(viewFaviconChangedCallback), this); - g_main_loop_run(m_mainLoop); - g_signal_handler_disconnect(m_webView, handlerID); - } - - void getFaviconForPageURIAndWaitUntilReady(const char* pageURI) - { - m_error.clear(); - if (m_favicon) { - cairo_surface_destroy(m_favicon); - m_favicon = 0; - } - - WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(m_webContext); - webkit_favicon_database_get_favicon(database, pageURI, 0, getFaviconCallback, this); - g_main_loop_run(m_mainLoop); - } - - WebKitWebContext* m_webContext; - cairo_surface_t* m_favicon; - CString m_faviconURI; - GOwnPtr<GError> m_error; - bool m_faviconNotificationReceived; -}; - -static void -serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable* query, SoupClientContext* context, void* data) -{ - if (message->method != SOUP_METHOD_GET) { - soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED); - return; - } - - if (g_str_equal(path, "/favicon.ico")) { - soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); - soup_message_body_complete(message->response_body); - return; - } - - char* contents; - gsize length; - if (g_str_equal(path, "/icon/favicon.ico")) { - GOwnPtr<char> pathToFavicon(g_build_filename(Test::getWebKit1TestResoucesDir().data(), "blank.ico", NULL)); - g_file_get_contents(pathToFavicon.get(), &contents, &length, 0); - soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, contents, length); - } else if (g_str_equal(path, "/nofavicon")) { - static const char* noFaviconHTML = "<html><head><body>test</body></html>"; - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, noFaviconHTML, strlen(noFaviconHTML)); - } else { - static const char* contentsHTML = "<html><head><link rel='icon' href='/icon/favicon.ico' type='image/x-ico; charset=binary'></head><body>test</body></html>"; - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, contentsHTML, strlen(contentsHTML)); - } - - soup_message_set_status(message, SOUP_STATUS_OK); - soup_message_body_complete(message->response_body); -} - -static void testNotInitialized(FaviconDatabaseTest* test) -{ - // Try to retrieve a valid favicon from a not initialized database. - test->getFaviconForPageURIAndWaitUntilReady(kServer->getURIForPath("/foo").data()); - g_assert(!test->m_favicon); - g_assert(test->m_error); - g_assert_cmpint(test->m_error->code, ==, WEBKIT_FAVICON_DATABASE_ERROR_NOT_INITIALIZED); -} - -static void testSetDirectory(FaviconDatabaseTest* test) -{ - webkit_web_context_set_favicon_database_directory(test->m_webContext, kTempDirectory); - g_assert_cmpstr(kTempDirectory, ==, webkit_web_context_get_favicon_database_directory(test->m_webContext)); -} - -static void testClearDatabase(FaviconDatabaseTest* test) -{ - WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(test->m_webContext); - webkit_favicon_database_clear(database); - - GOwnPtr<char> iconURI(webkit_favicon_database_get_favicon_uri(database, kServer->getURIForPath("/foo").data())); - g_assert(!iconURI); -} - -static void testGetFavicon(FaviconDatabaseTest* test) -{ - // We need to load the page first to ensure the icon data will be - // in the database in case there's an associated favicon. - test->loadURI(kServer->getURIForPath("/foo").data()); - test->waitUntilFaviconChanged(); - CString faviconURI = kServer->getURIForPath("/icon/favicon.ico"); - - // Check the API retrieving a valid favicon. - test->getFaviconForPageURIAndWaitUntilReady(kServer->getURIForPath("/foo").data()); - g_assert(test->m_favicon); - g_assert_cmpstr(test->m_faviconURI.data(), ==, faviconURI.data()); - g_assert(!test->m_error); - - // Check that width and height match those from blank.ico (16x16 favicon). - g_assert_cmpint(cairo_image_surface_get_width(test->m_favicon), ==, 16); - g_assert_cmpint(cairo_image_surface_get_height(test->m_favicon), ==, 16); - - // Check that another page with the same favicon return the same icon. - cairo_surface_t* favicon = cairo_surface_reference(test->m_favicon); - test->loadURI(kServer->getURIForPath("/bar").data()); - // It's a new page in the database, so favicon will change twice, first to reset it - // and then when the icon is loaded. - test->waitUntilFaviconChanged(); - test->waitUntilFaviconChanged(); - test->getFaviconForPageURIAndWaitUntilReady(kServer->getURIForPath("/bar").data()); - g_assert(test->m_favicon); - g_assert_cmpstr(test->m_faviconURI.data(), ==, faviconURI.data()); - g_assert(test->m_favicon == favicon); - g_assert(!test->m_error); - cairo_surface_destroy(favicon); - - // Check the API retrieving an invalid favicon. - test->loadURI(kServer->getURIForPath("/nofavicon").data()); - test->waitUntilFaviconChanged(); - - test->getFaviconForPageURIAndWaitUntilReady(kServer->getURIForPath("/nofavicon").data()); - g_assert(!test->m_favicon); - g_assert(test->m_error); -} - -static void testGetFaviconURI(FaviconDatabaseTest* test) -{ - WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(test->m_webContext); - - CString baseURI = kServer->getURIForPath("/foo"); - GOwnPtr<char> iconURI(webkit_favicon_database_get_favicon_uri(database, baseURI.data())); - ASSERT_CMP_CSTRING(iconURI.get(), ==, kServer->getURIForPath("/icon/favicon.ico")); -} - -static void testWebViewFavicon(FaviconDatabaseTest* test) -{ - test->m_faviconURI = CString(); - - cairo_surface_t* iconFromWebView = webkit_web_view_get_favicon(test->m_webView); - g_assert(!iconFromWebView); - - test->loadURI(kServer->getURIForPath("/foo").data()); - test->waitUntilFaviconChanged(); - g_assert(test->m_faviconNotificationReceived); - // The icon is known and hasn't changed in the database, so notify::favicon is emitted - // but WebKitFaviconDatabase::icon-changed isn't. - g_assert(test->m_faviconURI.isNull()); - - iconFromWebView = webkit_web_view_get_favicon(test->m_webView); - g_assert(iconFromWebView); - g_assert_cmpuint(cairo_image_surface_get_width(iconFromWebView), ==, 16); - g_assert_cmpuint(cairo_image_surface_get_height(iconFromWebView), ==, 16); -} - -static void testFaviconDatabase(FaviconDatabaseTest* test, gconstpointer) -{ - // These tests depend on this order to run properly so we declare them in a single one. - // See https://bugs.webkit.org/show_bug.cgi?id=111434. - testNotInitialized(test); - testSetDirectory(test); - testGetFavicon(test); - testGetFaviconURI(test); - testWebViewFavicon(test); - testClearDatabase(test); -} - -void beforeAll() -{ - // Start a soup server for testing. - kServer = new WebKitTestServer(); - kServer->run(serverCallback); - - kTempDirectory = g_dir_make_tmp("WebKit2Tests-XXXXXX", 0); - g_assert(kTempDirectory); - - // Add tests to the suite. - FaviconDatabaseTest::add("WebKitFaviconDatabase", "favicon-database-test", testFaviconDatabase); -} - -static void webkitFaviconDatabaseFinalizedCallback(gpointer, GObject*) -{ - if (!g_file_test(kTempDirectory, G_FILE_TEST_IS_DIR)) - return; - - GOwnPtr<char> filename(g_build_filename(kTempDirectory, "WebpageIcons.db", NULL)); - g_unlink(filename.get()); - - g_rmdir(kTempDirectory); -} - -void afterAll() -{ - delete kServer; - - // Delete the temporary files after the IconDatabase has been - // closed, that is, once WebKitFaviconDatabase is being destroyed. - WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(webkit_web_context_get_default()); - g_object_weak_ref(G_OBJECT(database), webkitFaviconDatabaseFinalizedCallback, 0); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFindController.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFindController.cpp deleted file mode 100644 index d2eef4ca4..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFindController.cpp +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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 "LoadTrackingTest.h" -#include <gtk/gtk.h> -#include <webkit2/webkit2.h> -#include <wtf/gobject/GRefPtr.h> - -static const char* testString = "<html><body>first testing second testing secondHalf</body></html>"; - -class FindControllerTest: public WebViewTest { -public: - MAKE_GLIB_TEST_FIXTURE(FindControllerTest); - - FindControllerTest() - : m_findController(webkit_web_view_get_find_controller(m_webView)) - , m_runFindUntilCompletion(false) - { - assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_findController.get())); - } - - ~FindControllerTest() - { - if (m_findController) - g_signal_handlers_disconnect_matched(m_findController.get(), G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); - } - - void find(const char* searchText, guint32 findOptions, guint maxMatchCount) - { - g_signal_connect(m_findController.get(), "found-text", G_CALLBACK(foundTextCallback), this); - g_signal_connect(m_findController.get(), "failed-to-find-text", G_CALLBACK(failedToFindTextCallback), this); - webkit_find_controller_search(m_findController.get(), searchText, findOptions, maxMatchCount); - } - - void count(const char* searchText, guint32 findOptions, guint maxMatchCount) - { - g_signal_connect(m_findController.get(), "counted-matches", G_CALLBACK(countedMatchesCallback), this); - webkit_find_controller_count_matches(m_findController.get(), searchText, findOptions, maxMatchCount); - } - - void waitUntilFindFinished() - { - m_runFindUntilCompletion = true; - g_main_loop_run(m_mainLoop); - } - - GRefPtr<WebKitFindController> m_findController; - bool m_textFound; - unsigned m_matchCount; - -private: - bool m_runFindUntilCompletion; - - static void foundTextCallback(WebKitFindController*, guint matchCount, FindControllerTest* test) - { - test->m_textFound = true; - test->m_matchCount = matchCount; - if (test->m_runFindUntilCompletion) - g_main_loop_quit(test->m_mainLoop); - } - - static void failedToFindTextCallback(WebKitFindController*, FindControllerTest* test) - { - test->m_textFound = false; - if (test->m_runFindUntilCompletion) - g_main_loop_quit(test->m_mainLoop); - } - - static void countedMatchesCallback(WebKitFindController*, guint matchCount, FindControllerTest* test) - { - test->m_matchCount = matchCount; - if (test->m_runFindUntilCompletion) - g_main_loop_quit(test->m_mainLoop); - } -}; - -static void testFindControllerTextFound(FindControllerTest* test, gconstpointer) -{ - test->loadHtml(testString, 0); - test->waitUntilLoadFinished(); - - test->find("testing", WEBKIT_FIND_OPTIONS_NONE, 1); - test->waitUntilFindFinished(); - - g_assert(test->m_textFound); -} - -static void testFindControllerTextNotFound(FindControllerTest* test, gconstpointer) -{ - test->loadHtml(testString, 0); - test->waitUntilLoadFinished(); - - test->find("notFound", WEBKIT_FIND_OPTIONS_NONE, 1); - test->waitUntilFindFinished(); - - g_assert(!test->m_textFound); -} - -static void testFindControllerMatchCount(FindControllerTest* test, gconstpointer) -{ - test->loadHtml(testString, 0); - test->waitUntilLoadFinished(); - - test->find("testing", WEBKIT_FIND_OPTIONS_NONE, 2); - test->waitUntilFindFinished(); - - g_assert(test->m_matchCount == 2); - g_assert(test->m_textFound); -} - -static void testFindControllerMaxMatchCount(FindControllerTest* test, gconstpointer) -{ - test->loadHtml(testString, 0); - test->waitUntilLoadFinished(); - - test->find("testing", WEBKIT_FIND_OPTIONS_NONE, 1); - test->waitUntilFindFinished(); - - g_assert(test->m_matchCount == G_MAXUINT); - g_assert(test->m_textFound); -} - -static void testFindControllerNext(FindControllerTest* test, gconstpointer) -{ - test->loadHtml(testString, 0); - test->waitUntilLoadFinished(); - - test->find("testing", WEBKIT_FIND_OPTIONS_NONE, 2); - test->waitUntilFindFinished(); - - g_assert(test->m_textFound); - g_assert(test->m_matchCount == 2); - - webkit_find_controller_search_next(test->m_findController.get()); - test->waitUntilFindFinished(); - - g_assert(test->m_textFound); - g_assert(test->m_matchCount == 1); - g_assert(!(webkit_find_controller_get_options(test->m_findController.get()) & WEBKIT_FIND_OPTIONS_BACKWARDS)); - - webkit_find_controller_search_next(test->m_findController.get()); - test->waitUntilFindFinished(); - - g_assert(!test->m_textFound); - g_assert(test->m_matchCount == 1); - g_assert(!(webkit_find_controller_get_options(test->m_findController.get()) & WEBKIT_FIND_OPTIONS_BACKWARDS)); -} - -static void testFindControllerPrevious(FindControllerTest* test, gconstpointer) -{ - test->loadHtml(testString, 0); - test->waitUntilLoadFinished(); - - test->find("testing", WEBKIT_FIND_OPTIONS_NONE, 2); - test->waitUntilFindFinished(); - - g_assert(test->m_matchCount == 2); - g_assert(test->m_textFound); - - webkit_find_controller_search_next(test->m_findController.get()); - test->waitUntilFindFinished(); - - g_assert(test->m_textFound); - g_assert(test->m_matchCount == 1); - g_assert(!(webkit_find_controller_get_options(test->m_findController.get()) & WEBKIT_FIND_OPTIONS_BACKWARDS)); - - webkit_find_controller_search_previous(test->m_findController.get()); - test->waitUntilFindFinished(); - - g_assert(test->m_textFound); - g_assert(test->m_matchCount == 1); - g_assert(webkit_find_controller_get_options(test->m_findController.get()) & WEBKIT_FIND_OPTIONS_BACKWARDS); -} - -static void testFindControllerCountedMatches(FindControllerTest* test, gconstpointer) -{ - test->loadHtml(testString, 0); - test->waitUntilLoadFinished(); - - test->count("testing", WEBKIT_FIND_OPTIONS_NONE, 2); - test->waitUntilFindFinished(); - - g_assert(test->m_matchCount == 2); - - test->count("first", WEBKIT_FIND_OPTIONS_NONE, 2); - test->waitUntilFindFinished(); - - g_assert(test->m_matchCount == 1); - - test->count("notFound", WEBKIT_FIND_OPTIONS_NONE, 2); - test->waitUntilFindFinished(); - - g_assert(!test->m_matchCount); -} - -static void testFindControllerOptions(FindControllerTest* test, gconstpointer) -{ - test->loadHtml(testString, 0); - test->waitUntilLoadFinished(); - - test->find("Testing", WEBKIT_FIND_OPTIONS_NONE, 2); - test->waitUntilFindFinished(); - - g_assert(!test->m_textFound); - - test->find("Testing", WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE, 2); - test->waitUntilFindFinished(); - - g_assert(test->m_textFound); - - test->find("esting", WEBKIT_FIND_OPTIONS_NONE, 2); - test->waitUntilFindFinished(); - - g_assert(test->m_textFound); - - test->find("esting", WEBKIT_FIND_OPTIONS_AT_WORD_STARTS, 2); - test->waitUntilFindFinished(); - - g_assert(!test->m_textFound); - - test->find("Half", WEBKIT_FIND_OPTIONS_AT_WORD_STARTS, 2); - test->waitUntilFindFinished(); - - g_assert(!test->m_textFound); - - test->find("Half", WEBKIT_FIND_OPTIONS_AT_WORD_STARTS | WEBKIT_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START, 2); - test->waitUntilFindFinished(); - - g_assert(test->m_textFound); - - test->find("testing", WEBKIT_FIND_OPTIONS_WRAP_AROUND, 3); - test->waitUntilFindFinished(); - g_assert(test->m_textFound); - - webkit_find_controller_search_next(test->m_findController.get()); - test->waitUntilFindFinished(); - g_assert(test->m_textFound); - - webkit_find_controller_search_next(test->m_findController.get()); - test->waitUntilFindFinished(); - g_assert(test->m_textFound); -} - -static void testFindControllerHide(FindControllerTest* test, gconstpointer) -{ - test->loadHtml(testString, 0); - test->waitUntilLoadFinished(); - - test->showInWindowAndWaitUntilMapped(); - - cairo_surface_t* originalSurface = cairo_surface_reference( - test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT, WEBKIT_SNAPSHOT_OPTIONS_NONE)); - g_assert(originalSurface); - - test->find("testing", WEBKIT_FIND_OPTIONS_NONE, 1); - test->waitUntilFindFinished(); - g_assert(test->m_textFound); - - cairo_surface_t* highlightSurface = cairo_surface_reference( - test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT, WEBKIT_SNAPSHOT_OPTIONS_NONE)); - g_assert(highlightSurface); - g_assert(!Test::cairoSurfacesEqual(originalSurface, highlightSurface)); - - WebKitFindController* findController = webkit_web_view_get_find_controller(test->m_webView); - webkit_find_controller_search_finish(findController); - webkit_web_view_execute_editing_command(test->m_webView, "Unselect"); - - cairo_surface_t* unhighlightSurface = cairo_surface_reference( - test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT, WEBKIT_SNAPSHOT_OPTIONS_NONE)); - g_assert(unhighlightSurface); - g_assert(Test::cairoSurfacesEqual(originalSurface, unhighlightSurface)); - - cairo_surface_destroy(originalSurface); - cairo_surface_destroy(highlightSurface); - cairo_surface_destroy(unhighlightSurface); -} - -static void testFindControllerInstance(FindControllerTest* test, gconstpointer) -{ - WebKitFindController* findController1 = webkit_web_view_get_find_controller(test->m_webView); - WebKitFindController* findController2 = webkit_web_view_get_find_controller(test->m_webView); - - g_assert(findController1 == findController2); -} - -static void testFindControllerGetters(FindControllerTest* test, gconstpointer) -{ - const char* searchText = "testing"; - guint maxMatchCount = 1; - guint32 findOptions = WEBKIT_FIND_OPTIONS_WRAP_AROUND | WEBKIT_FIND_OPTIONS_AT_WORD_STARTS; - WebKitFindController* findController = webkit_web_view_get_find_controller(test->m_webView); - - webkit_find_controller_search(findController, searchText, findOptions, maxMatchCount); - g_assert(webkit_find_controller_get_web_view(findController) == test->m_webView); - g_assert(!g_strcmp0(webkit_find_controller_get_search_text(findController), searchText)); - g_assert(webkit_find_controller_get_max_match_count(findController) == maxMatchCount); - g_assert(webkit_find_controller_get_options(findController) == findOptions); -} - -void beforeAll() -{ - FindControllerTest::add("WebKitFindController", "getters", testFindControllerGetters); - FindControllerTest::add("WebKitFindController", "instance", testFindControllerInstance); - FindControllerTest::add("WebKitFindController", "text-found", testFindControllerTextFound); - FindControllerTest::add("WebKitFindController", "text-not-found", testFindControllerTextNotFound); - FindControllerTest::add("WebKitFindController", "match-count", testFindControllerMatchCount); - FindControllerTest::add("WebKitFindController", "max-match-count", testFindControllerMaxMatchCount); - FindControllerTest::add("WebKitFindController", "next", testFindControllerNext); - FindControllerTest::add("WebKitFindController", "previous", testFindControllerPrevious); - FindControllerTest::add("WebKitFindController", "counted-matches", testFindControllerCountedMatches); - FindControllerTest::add("WebKitFindController", "options", testFindControllerOptions); - FindControllerTest::add("WebKitFindController", "hide", testFindControllerHide); -} - -void afterAll() -{ -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitPolicyClient.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitPolicyClient.cpp deleted file mode 100644 index abbfd652a..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitPolicyClient.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "LoadTrackingTest.h" -#include "WebKitTestServer.h" -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -static WebKitTestServer* kServer; - -class PolicyClientTest: public LoadTrackingTest { -public: - MAKE_GLIB_TEST_FIXTURE(PolicyClientTest); - - enum PolicyDecisionResponse { - Use, - Ignore, - Download, - None - }; - - PolicyClientTest() - : LoadTrackingTest() - , m_policyDecisionResponse(None) - , m_policyDecisionTypeFilter(0) - , m_respondToPolicyDecisionAsynchronously(false) - , m_haltMainLoopAfterMakingDecision(false) - { - g_signal_connect(m_webView, "decide-policy", G_CALLBACK(decidePolicyCallback), this); - } - - static gboolean quitMainLoopLater(GMainLoop* loop) - { - g_main_loop_quit(loop); - return FALSE; - } - - static void respondToPolicyDecision(PolicyClientTest* test, WebKitPolicyDecision* decision) - { - switch (test->m_policyDecisionResponse) { - case Use: - webkit_policy_decision_use(decision); - break; - case Ignore: - webkit_policy_decision_ignore(decision); - break; - case Download: - webkit_policy_decision_download(decision); - break; - case None: - break; - } - - if (test->m_haltMainLoopAfterMakingDecision) - g_idle_add(reinterpret_cast<GSourceFunc>(quitMainLoopLater), test->m_mainLoop); - } - - static gboolean respondToPolicyDecisionLater(PolicyClientTest* test) - { - respondToPolicyDecision(test, test->m_previousPolicyDecision.get()); - test->m_previousPolicyDecision = 0; - return FALSE; - } - - static gboolean decidePolicyCallback(WebKitWebView* webView, WebKitPolicyDecision* decision, WebKitPolicyDecisionType type, PolicyClientTest* test) - { - if (test->m_policyDecisionTypeFilter != type) - return FALSE; - - test->m_previousPolicyDecision = decision; - if (test->m_respondToPolicyDecisionAsynchronously) { - g_idle_add(reinterpret_cast<GSourceFunc>(respondToPolicyDecisionLater), test); - return TRUE; - } - - respondToPolicyDecision(test, decision); - - // We return FALSE here to ensure that the default policy decision - // handler doesn't override whatever we use here. - return FALSE; - } - - PolicyDecisionResponse m_policyDecisionResponse; - int m_policyDecisionTypeFilter; - bool m_respondToPolicyDecisionAsynchronously; - bool m_haltMainLoopAfterMakingDecision; - GRefPtr<WebKitPolicyDecision> m_previousPolicyDecision; -}; - -static void testNavigationPolicy(PolicyClientTest* test, gconstpointer) -{ - test->m_policyDecisionTypeFilter = WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION; - - test->m_policyDecisionResponse = PolicyClientTest::Use; - test->loadHtml("<html/>", "http://webkitgtk.org/"); - test->waitUntilLoadFinished(); - g_assert_cmpint(test->m_loadEvents.size(), ==, 3); - - // Ideally we'd like to have a more intensive test here, but it's still pretty tricky - // to trigger different types of navigations with the GTK+ WebKit2 API. - WebKitNavigationPolicyDecision* decision = WEBKIT_NAVIGATION_POLICY_DECISION(test->m_previousPolicyDecision.get()); - g_assert_cmpint(webkit_navigation_policy_decision_get_navigation_type(decision), ==, WEBKIT_NAVIGATION_TYPE_OTHER); - g_assert_cmpint(webkit_navigation_policy_decision_get_mouse_button(decision), ==, 0); - g_assert_cmpint(webkit_navigation_policy_decision_get_modifiers(decision), ==, 0); - g_assert_cmpstr(webkit_navigation_policy_decision_get_frame_name(decision), ==, 0); - WebKitURIRequest* request = webkit_navigation_policy_decision_get_request(decision); - g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, "http://webkitgtk.org/"); - - test->m_policyDecisionResponse = PolicyClientTest::Use; - test->m_respondToPolicyDecisionAsynchronously = true; - test->loadHtml("<html/>", "http://webkitgtk.org/"); - test->waitUntilLoadFinished(); - g_assert_cmpint(test->m_loadEvents.size(), ==, 3); - - // If we are waiting until load completion, it will never complete if we ignore the - // navigation. So we tell the main loop to quit sometime later. - test->m_policyDecisionResponse = PolicyClientTest::Ignore; - test->m_respondToPolicyDecisionAsynchronously = false; - test->m_haltMainLoopAfterMakingDecision = true; - test->loadHtml("<html/>", "http://webkitgtk.org/"); - test->waitUntilLoadFinished(); - g_assert_cmpint(test->m_loadEvents.size(), ==, 0); - - test->m_policyDecisionResponse = PolicyClientTest::Ignore; - test->loadHtml("<html/>", "http://webkitgtk.org/"); - test->waitUntilLoadFinished(); - g_assert_cmpint(test->m_loadEvents.size(), ==, 0); -} - -static void testResponsePolicy(PolicyClientTest* test, gconstpointer) -{ - test->m_policyDecisionTypeFilter = WEBKIT_POLICY_DECISION_TYPE_RESPONSE; - - test->m_policyDecisionResponse = PolicyClientTest::Use; - test->loadURI(kServer->getURIForPath("/").data()); - test->waitUntilLoadFinished(); - g_assert_cmpint(test->m_loadEvents.size(), ==, 3); - g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted); - g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted); - g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished); - - test->m_respondToPolicyDecisionAsynchronously = true; - test->loadURI(kServer->getURIForPath("/").data()); - test->waitUntilLoadFinished(); - g_assert_cmpint(test->m_loadEvents.size(), ==, 3); - g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted); - g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted); - g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished); - - test->m_respondToPolicyDecisionAsynchronously = false; - test->m_policyDecisionResponse = PolicyClientTest::Ignore; - test->loadURI(kServer->getURIForPath("/").data()); - test->waitUntilLoadFinished(); - - g_assert_cmpint(test->m_loadEvents.size(), ==, 3); - g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted); - g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::ProvisionalLoadFailed); - g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished); -} - -struct CreateCallbackData { - bool triedToOpenWindow; - GMainLoop* mainLoop; -}; - -static WebKitWebView* createCallback(WebKitWebView* webView, CreateCallbackData* data) -{ - data->triedToOpenWindow = true; - g_main_loop_quit(data->mainLoop); - return 0; -} - -static void testNewWindowPolicy(PolicyClientTest* test, gconstpointer) -{ - static const char* windowOpeningHTML = - "<html><body>" - " <a id=\"link\" href=\"http://www.google.com\" target=\"_blank\">Link</a>" - " <script>" - " var event = document.createEvent('MouseEvents');" - " event.initEvent('click', true, false);" - " document.getElementById('link').dispatchEvent(event);" - " </script>" - "</body></html>"; - test->m_policyDecisionTypeFilter = WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION; - webkit_settings_set_javascript_can_open_windows_automatically(webkit_web_view_get_settings(test->m_webView), TRUE); - - CreateCallbackData data; - data.triedToOpenWindow = false; - data.mainLoop = test->m_mainLoop; - - g_signal_connect(test->m_webView, "create", G_CALLBACK(createCallback), &data); - test->m_policyDecisionResponse = PolicyClientTest::Use; - test->loadHtml(windowOpeningHTML, "http://webkitgtk.org/"); - test->wait(1); - g_assert(data.triedToOpenWindow); - - WebKitNavigationPolicyDecision* decision = WEBKIT_NAVIGATION_POLICY_DECISION(test->m_previousPolicyDecision.get()); - g_assert_cmpstr(webkit_navigation_policy_decision_get_frame_name(decision), ==, "_blank"); - - // Using a short timeout is a bit ugly here, but it's hard to get around because if we block - // the new window signal we cannot halt the main loop in the create callback. If we - // halt the main loop in the policy decision, the create callback never executes. - data.triedToOpenWindow = false; - test->m_policyDecisionResponse = PolicyClientTest::Ignore; - test->loadHtml(windowOpeningHTML, "http://webkitgtk.org/"); - test->wait(.2); - g_assert(!data.triedToOpenWindow); -} - -static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer) -{ - if (message->method != SOUP_METHOD_GET) { - soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED); - return; - } - - if (g_str_equal(path, "/")) { - static const char* responseString = "<html><body>Testing!</body></html>"; - soup_message_set_status(message, SOUP_STATUS_OK); - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, responseString, strlen(responseString)); - soup_message_body_complete(message->response_body); - } else - soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); -} - -void beforeAll() -{ - kServer = new WebKitTestServer(); - kServer->run(serverCallback); - - PolicyClientTest::add("WebKitPolicyClient", "navigation-policy", testNavigationPolicy); - PolicyClientTest::add("WebKitPolicyClient", "response-policy", testResponsePolicy); - PolicyClientTest::add("WebKitPolicyClient", "new-window-policy", testNewWindowPolicy); -} - -void afterAll() -{ - delete kServer; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp deleted file mode 100644 index 1ee3843f9..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp +++ /dev/null @@ -1,356 +0,0 @@ -/* - * Copyright (c) 2011 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: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Motorola Mobility, Inc. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT HOLDER OR - * 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 "config.h" - -#include "TestMain.h" -#include "WebViewTest.h" -#include "WebKitTestServer.h" -#include <gtk/gtk.h> -#include <webkit2/webkit2.h> -#include <wtf/gobject/GRefPtr.h> - -static WebKitTestServer* gServer; - -static void testWebKitSettings(Test*, gconstpointer) -{ - WebKitSettings* settings = webkit_settings_new(); - - // JavaScript is enabled by default. - g_assert(webkit_settings_get_enable_javascript(settings)); - webkit_settings_set_enable_javascript(settings, FALSE); - g_assert(!webkit_settings_get_enable_javascript(settings)); - - // By default auto-load-image is true. - g_assert(webkit_settings_get_auto_load_images(settings)); - webkit_settings_set_auto_load_images(settings, FALSE); - g_assert(!webkit_settings_get_auto_load_images(settings)); - - // load-icons-ignoring-image-load-setting is false by default. - g_assert(!webkit_settings_get_load_icons_ignoring_image_load_setting(settings)); - webkit_settings_set_load_icons_ignoring_image_load_setting(settings, TRUE); - g_assert(webkit_settings_get_load_icons_ignoring_image_load_setting(settings)); - - // Offline application cache is true by default. - g_assert(webkit_settings_get_enable_offline_web_application_cache(settings)); - webkit_settings_set_enable_offline_web_application_cache(settings, FALSE); - g_assert(!webkit_settings_get_enable_offline_web_application_cache(settings)); - - // Local storage is enable by default. - g_assert(webkit_settings_get_enable_html5_local_storage(settings)); - webkit_settings_set_enable_html5_local_storage(settings, FALSE); - g_assert(!webkit_settings_get_enable_html5_local_storage(settings)); - - // HTML5 database is enabled by default. - g_assert(webkit_settings_get_enable_html5_database(settings)); - webkit_settings_set_enable_html5_database(settings, FALSE); - g_assert(!webkit_settings_get_enable_html5_database(settings)); - - // XSS Auditor is enabled by default. - g_assert(webkit_settings_get_enable_xss_auditor(settings)); - webkit_settings_set_enable_xss_auditor(settings, FALSE); - g_assert(!webkit_settings_get_enable_xss_auditor(settings)); - - // Frame flattening is disabled by default. - g_assert(!webkit_settings_get_enable_frame_flattening(settings)); - webkit_settings_set_enable_frame_flattening(settings, TRUE); - g_assert(webkit_settings_get_enable_frame_flattening(settings)); - - // Plugins are enabled by default. - g_assert(webkit_settings_get_enable_plugins(settings)); - webkit_settings_set_enable_plugins(settings, FALSE); - g_assert(!webkit_settings_get_enable_plugins(settings)); - - // Java is enabled by default. - g_assert(webkit_settings_get_enable_java(settings)); - webkit_settings_set_enable_java(settings, FALSE); - g_assert(!webkit_settings_get_enable_java(settings)); - - // By default, JavaScript can open windows automatically is disabled. - g_assert(!webkit_settings_get_javascript_can_open_windows_automatically(settings)); - webkit_settings_set_javascript_can_open_windows_automatically(settings, TRUE); - g_assert(webkit_settings_get_javascript_can_open_windows_automatically(settings)); - - // By default hyper link auditing is disabled. - g_assert(!webkit_settings_get_enable_hyperlink_auditing(settings)); - webkit_settings_set_enable_hyperlink_auditing(settings, TRUE); - g_assert(webkit_settings_get_enable_hyperlink_auditing(settings)); - - // Default font family is "sans-serif". - g_assert_cmpstr(webkit_settings_get_default_font_family(settings), ==, "sans-serif"); - webkit_settings_set_default_font_family(settings, "monospace"); - g_assert_cmpstr(webkit_settings_get_default_font_family(settings), ==, "monospace"); - - // Default monospace font family font family is "monospace". - g_assert_cmpstr(webkit_settings_get_monospace_font_family(settings), ==, "monospace"); - webkit_settings_set_monospace_font_family(settings, "sans-serif"); - g_assert_cmpstr(webkit_settings_get_monospace_font_family(settings), ==, "sans-serif"); - - // Default serif font family is "serif". - g_assert_cmpstr(webkit_settings_get_serif_font_family(settings), ==, "serif"); - webkit_settings_set_serif_font_family(settings, "sans-serif"); - g_assert_cmpstr(webkit_settings_get_serif_font_family(settings), ==, "sans-serif"); - - // Default sans serif font family is "sans-serif". - g_assert_cmpstr(webkit_settings_get_sans_serif_font_family(settings), ==, "sans-serif"); - webkit_settings_set_sans_serif_font_family(settings, "serif"); - g_assert_cmpstr(webkit_settings_get_sans_serif_font_family(settings), ==, "serif"); - - // Default cursive font family "serif". - g_assert_cmpstr(webkit_settings_get_cursive_font_family(settings), ==, "serif"); - webkit_settings_set_cursive_font_family(settings, "sans-serif"); - g_assert_cmpstr(webkit_settings_get_cursive_font_family(settings), ==, "sans-serif"); - - // Default fantasy font family is "serif". - g_assert_cmpstr(webkit_settings_get_fantasy_font_family(settings), ==, "serif"); - webkit_settings_set_fantasy_font_family(settings, "sans-serif"); - g_assert_cmpstr(webkit_settings_get_fantasy_font_family(settings), ==, "sans-serif"); - - // Default pictograph font family is "serif". - g_assert_cmpstr(webkit_settings_get_pictograph_font_family(settings), ==, "serif"); - webkit_settings_set_pictograph_font_family(settings, "sans-serif"); - g_assert_cmpstr(webkit_settings_get_pictograph_font_family(settings), ==, "sans-serif"); - - // Default font size is 16. - g_assert_cmpuint(webkit_settings_get_default_font_size(settings), ==, 16); - webkit_settings_set_default_font_size(settings, 14); - g_assert_cmpuint(webkit_settings_get_default_font_size(settings), ==, 14); - - // Default monospace font size is 13. - g_assert_cmpuint(webkit_settings_get_default_monospace_font_size(settings), ==, 13); - webkit_settings_set_default_monospace_font_size(settings, 10); - g_assert_cmpuint(webkit_settings_get_default_monospace_font_size(settings), ==, 10); - - // Default minimum font size is 0. - g_assert_cmpuint(webkit_settings_get_minimum_font_size(settings), ==, 0); - webkit_settings_set_minimum_font_size(settings, 7); - g_assert_cmpuint(webkit_settings_get_minimum_font_size(settings), ==, 7); - - // Default charset is "iso-8859-1". - g_assert_cmpstr(webkit_settings_get_default_charset(settings), ==, "iso-8859-1"); - webkit_settings_set_default_charset(settings, "utf8"); - g_assert_cmpstr(webkit_settings_get_default_charset(settings), ==, "utf8"); - - g_assert(!webkit_settings_get_enable_private_browsing(settings)); - webkit_settings_set_enable_private_browsing(settings, TRUE); - g_assert(webkit_settings_get_enable_private_browsing(settings)); - - g_assert(!webkit_settings_get_enable_developer_extras(settings)); - webkit_settings_set_enable_developer_extras(settings, TRUE); - g_assert(webkit_settings_get_enable_developer_extras(settings)); - - g_assert(webkit_settings_get_enable_resizable_text_areas(settings)); - webkit_settings_set_enable_resizable_text_areas(settings, FALSE); - g_assert(!webkit_settings_get_enable_resizable_text_areas(settings)); - - g_assert(webkit_settings_get_enable_tabs_to_links(settings)); - webkit_settings_set_enable_tabs_to_links(settings, FALSE); - g_assert(!webkit_settings_get_enable_tabs_to_links(settings)); - - g_assert(!webkit_settings_get_enable_dns_prefetching(settings)); - webkit_settings_set_enable_dns_prefetching(settings, TRUE); - g_assert(webkit_settings_get_enable_dns_prefetching(settings)); - - // Caret browsing is disabled by default. - g_assert(!webkit_settings_get_enable_caret_browsing(settings)); - webkit_settings_set_enable_caret_browsing(settings, TRUE); - g_assert(webkit_settings_get_enable_caret_browsing(settings)); - - // Fullscreen JavaScript API is disabled by default. - g_assert(!webkit_settings_get_enable_fullscreen(settings)); - webkit_settings_set_enable_fullscreen(settings, TRUE); - g_assert(webkit_settings_get_enable_fullscreen(settings)); - - // Print backgrounds is enabled by default - g_assert(webkit_settings_get_print_backgrounds(settings)); - webkit_settings_set_print_backgrounds(settings, FALSE); - g_assert(!webkit_settings_get_print_backgrounds(settings)); - - // WebAudio is disabled by default. - g_assert(!webkit_settings_get_enable_webaudio(settings)); - webkit_settings_set_enable_webaudio(settings, TRUE); - g_assert(webkit_settings_get_enable_webaudio(settings)); - - // WebGL is disabled by default. - g_assert(!webkit_settings_get_enable_webgl(settings)); - webkit_settings_set_enable_webgl(settings, TRUE); - g_assert(webkit_settings_get_enable_webgl(settings)); - - // Allow Modal Dialogs is disabled by default. - g_assert(!webkit_settings_get_allow_modal_dialogs(settings)); - webkit_settings_set_allow_modal_dialogs(settings, TRUE); - g_assert(webkit_settings_get_allow_modal_dialogs(settings)); - - // Zoom text only is disabled by default. - g_assert(!webkit_settings_get_zoom_text_only(settings)); - webkit_settings_set_zoom_text_only(settings, TRUE); - g_assert(webkit_settings_get_zoom_text_only(settings)); - - // By default, JavaScript cannot access the clipboard. - g_assert(!webkit_settings_get_javascript_can_access_clipboard(settings)); - webkit_settings_set_javascript_can_access_clipboard(settings, TRUE); - g_assert(webkit_settings_get_javascript_can_access_clipboard(settings)); - - // By default, media playback doesn't require user gestures. - g_assert(!webkit_settings_get_media_playback_requires_user_gesture(settings)); - webkit_settings_set_media_playback_requires_user_gesture(settings, TRUE); - g_assert(webkit_settings_get_media_playback_requires_user_gesture(settings)); - - // By default, inline media playback is allowed - g_assert(webkit_settings_get_media_playback_allows_inline(settings)); - webkit_settings_set_media_playback_allows_inline(settings, FALSE); - g_assert(!webkit_settings_get_media_playback_allows_inline(settings)); - - // By default, debug indicators are disabled. - g_assert(!webkit_settings_get_draw_compositing_indicators(settings)); - webkit_settings_set_draw_compositing_indicators(settings, TRUE); - g_assert(webkit_settings_get_draw_compositing_indicators(settings)); - - // By default, site specific quirks are disabled. - g_assert(!webkit_settings_get_enable_site_specific_quirks(settings)); - webkit_settings_set_enable_site_specific_quirks(settings, TRUE); - g_assert(webkit_settings_get_enable_site_specific_quirks(settings)); - - // By default, page cache is enabled. - g_assert(webkit_settings_get_enable_page_cache(settings)); - webkit_settings_set_enable_page_cache(settings, FALSE); - g_assert(!webkit_settings_get_enable_page_cache(settings)); - - // By default, smooth scrolling is disabled. - g_assert(!webkit_settings_get_enable_smooth_scrolling(settings)); - webkit_settings_set_enable_smooth_scrolling(settings, TRUE); - g_assert(webkit_settings_get_enable_smooth_scrolling(settings)); - - // By default, accelerated 2D canvas is disabled. - g_assert(!webkit_settings_get_enable_accelerated_2d_canvas(settings)); - webkit_settings_set_enable_accelerated_2d_canvas(settings, TRUE); - g_assert(webkit_settings_get_enable_accelerated_2d_canvas(settings)); - - // By default, writing of console messages to stdout is disabled. - g_assert(!webkit_settings_get_enable_write_console_messages_to_stdout(settings)); - webkit_settings_set_enable_write_console_messages_to_stdout(settings, TRUE); - g_assert(webkit_settings_get_enable_write_console_messages_to_stdout(settings)); - - g_object_unref(G_OBJECT(settings)); -} - -void testWebKitSettingsNewWithSettings(Test* test, gconstpointer) -{ - GRefPtr<WebKitSettings> settings = adoptGRef(webkit_settings_new_with_settings("enable-javascript", FALSE, - "auto-load-images", FALSE, - "load-icons-ignoring-image-load-setting", TRUE, - NULL)); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(settings.get())); - g_assert(!webkit_settings_get_enable_javascript(settings.get())); - g_assert(!webkit_settings_get_auto_load_images(settings.get())); - g_assert(webkit_settings_get_load_icons_ignoring_image_load_setting(settings.get())); -} - -static CString convertWebViewMainResourceDataToCString(WebViewTest* test) -{ - size_t mainResourceDataSize = 0; - const char* mainResourceData = test->mainResourceData(mainResourceDataSize); - return CString(mainResourceData, mainResourceDataSize); -} - -static void assertThatUserAgentIsSentInHeaders(WebViewTest* test, const CString& userAgent) -{ - test->loadURI(gServer->getURIForPath("/").data()); - test->waitUntilLoadFinished(); - ASSERT_CMP_CSTRING(convertWebViewMainResourceDataToCString(test), ==, userAgent); -} - -static void testWebKitSettingsUserAgent(WebViewTest* test, gconstpointer) -{ - GRefPtr<WebKitSettings> settings = adoptGRef(webkit_settings_new()); - CString defaultUserAgent = webkit_settings_get_user_agent(settings.get()); - webkit_web_view_set_settings(test->m_webView, settings.get()); - - g_assert(g_strstr_len(defaultUserAgent.data(), -1, "Safari")); - g_assert(g_strstr_len(defaultUserAgent.data(), -1, "Chromium")); - g_assert(g_strstr_len(defaultUserAgent.data(), -1, "Chrome")); - - webkit_settings_set_user_agent(settings.get(), 0); - g_assert_cmpstr(defaultUserAgent.data(), ==, webkit_settings_get_user_agent(settings.get())); - assertThatUserAgentIsSentInHeaders(test, defaultUserAgent.data()); - - webkit_settings_set_user_agent(settings.get(), ""); - g_assert_cmpstr(defaultUserAgent.data(), ==, webkit_settings_get_user_agent(settings.get())); - - const char* funkyUserAgent = "Funky!"; - webkit_settings_set_user_agent(settings.get(), funkyUserAgent); - g_assert_cmpstr(funkyUserAgent, ==, webkit_settings_get_user_agent(settings.get())); - assertThatUserAgentIsSentInHeaders(test, funkyUserAgent); - - webkit_settings_set_user_agent_with_application_details(settings.get(), "WebKitGTK+", 0); - const char* userAgentWithNullVersion = webkit_settings_get_user_agent(settings.get()); - g_assert_cmpstr(g_strstr_len(userAgentWithNullVersion, -1, defaultUserAgent.data()), ==, userAgentWithNullVersion); - g_assert(g_strstr_len(userAgentWithNullVersion, -1, "WebKitGTK+")); - - webkit_settings_set_user_agent_with_application_details(settings.get(), "WebKitGTK+", ""); - g_assert_cmpstr(webkit_settings_get_user_agent(settings.get()), ==, userAgentWithNullVersion); - - webkit_settings_set_user_agent_with_application_details(settings.get(), "WebCatGTK+", "3.4.5"); - const char* newUserAgent = webkit_settings_get_user_agent(settings.get()); - g_assert(g_strstr_len(newUserAgent, -1, "3.4.5")); - g_assert(g_strstr_len(newUserAgent, -1, "WebCatGTK+")); -} - -static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer) -{ - if (message->method != SOUP_METHOD_GET) { - soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED); - return; - } - - if (g_str_equal(path, "/")) { - const char* userAgent = soup_message_headers_get_one(message->request_headers, "User-Agent"); - soup_message_set_status(message, SOUP_STATUS_OK); - soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, userAgent, strlen(userAgent)); - soup_message_body_complete(message->response_body); - } else - soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); -} - -void beforeAll() -{ - gServer = new WebKitTestServer(); - gServer->run(serverCallback); - - Test::add("WebKitSettings", "webkit-settings", testWebKitSettings); - Test::add("WebKitSettings", "new-with-settings", testWebKitSettingsNewWithSettings); - WebViewTest::add("WebKitSettings", "user-agent", testWebKitSettingsUserAgent); -} - -void afterAll() -{ - delete gServer; -} - diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitVersion.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitVersion.cpp deleted file mode 100644 index e747ff962..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitVersion.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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 "TestMain.h" -#include <gtk/gtk.h> -#include <webkit2/webkit2.h> - - -static void testWebKitVersion(Test*, gconstpointer) -{ - g_assert_cmpuint(webkit_get_major_version(), ==, WEBKIT_MAJOR_VERSION); - g_assert_cmpuint(webkit_get_minor_version(), ==, WEBKIT_MINOR_VERSION); - g_assert_cmpuint(webkit_get_micro_version(), ==, WEBKIT_MICRO_VERSION); -} - -static void testWebKitCheckVersion(Test*, gconstpointer) -{ - g_assert(WEBKIT_CHECK_VERSION(WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION, WEBKIT_MICRO_VERSION)); - g_assert(!WEBKIT_CHECK_VERSION(WEBKIT_MAJOR_VERSION + 1, WEBKIT_MINOR_VERSION, WEBKIT_MICRO_VERSION)); - g_assert(!WEBKIT_CHECK_VERSION(WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION + 1, WEBKIT_MICRO_VERSION)); - g_assert(!WEBKIT_CHECK_VERSION(WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION, WEBKIT_MICRO_VERSION + 1)); -} - -void beforeAll() -{ - Test::add("WebKitVersion", "version", testWebKitVersion); - Test::add("WebKitVersion", "check-version", testWebKitCheckVersion); -} - -void afterAll() -{ -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp deleted file mode 100644 index 54e44d682..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp +++ /dev/null @@ -1,425 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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 "LoadTrackingTest.h" -#include "WebKitTestServer.h" -#include <gtk/gtk.h> -#include <webkit2/webkit2.h> -#include <wtf/HashMap.h> -#include <wtf/gobject/GOwnPtr.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/StringHash.h> - -static WebKitTestServer* kServer; - -static void testWebContextDefault(Test* test, gconstpointer) -{ - // Check there's a single instance of the default web context. - g_assert(webkit_web_context_get_default() == webkit_web_context_get_default()); -} - -class PluginsTest: public Test { -public: - MAKE_GLIB_TEST_FIXTURE(PluginsTest); - - PluginsTest() - : m_context(webkit_web_context_get_default()) - , m_mainLoop(g_main_loop_new(0, TRUE)) - , m_plugins(0) - { - webkit_web_context_set_additional_plugins_directory(m_context, WEBKIT_TEST_PLUGIN_DIR); - } - - ~PluginsTest() - { - g_main_loop_unref(m_mainLoop); - g_list_free_full(m_plugins, g_object_unref); - } - - static void getPluginsAsyncReadyCallback(GObject*, GAsyncResult* result, PluginsTest* test) - { - test->m_plugins = webkit_web_context_get_plugins_finish(test->m_context, result, 0); - g_main_loop_quit(test->m_mainLoop); - } - - GList* getPlugins() - { - g_list_free_full(m_plugins, g_object_unref); - webkit_web_context_get_plugins(m_context, 0, reinterpret_cast<GAsyncReadyCallback>(getPluginsAsyncReadyCallback), this); - g_main_loop_run(m_mainLoop); - return m_plugins; - } - - WebKitWebContext* m_context; - GMainLoop* m_mainLoop; - GList* m_plugins; -}; - -static void testWebContextGetPlugins(PluginsTest* test, gconstpointer) -{ - GList* plugins = test->getPlugins(); - g_assert(plugins); - - GRefPtr<WebKitPlugin> testPlugin; - for (GList* item = plugins; item; item = g_list_next(item)) { - WebKitPlugin* plugin = WEBKIT_PLUGIN(item->data); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(plugin)); - if (!g_strcmp0(webkit_plugin_get_name(plugin), "WebKit Test PlugIn")) { - testPlugin = plugin; - break; - } - } - g_assert(WEBKIT_IS_PLUGIN(testPlugin.get())); - - GOwnPtr<char> pluginPath(g_build_filename(WEBKIT_TEST_PLUGIN_DIR, "libtestnetscapeplugin.so", NULL)); - g_assert_cmpstr(webkit_plugin_get_path(testPlugin.get()), ==, pluginPath.get()); - g_assert_cmpstr(webkit_plugin_get_description(testPlugin.get()), ==, "Simple Netscape® plug-in that handles test content for WebKit"); - GList* mimeInfoList = webkit_plugin_get_mime_info_list(testPlugin.get()); - g_assert(mimeInfoList); - g_assert_cmpuint(g_list_length(mimeInfoList), ==, 2); - - WebKitMimeInfo* mimeInfo = static_cast<WebKitMimeInfo*>(mimeInfoList->data); - g_assert_cmpstr(webkit_mime_info_get_mime_type(mimeInfo), ==, "image/png"); - g_assert_cmpstr(webkit_mime_info_get_description(mimeInfo), ==, "png image"); - const gchar* const* extensions = webkit_mime_info_get_extensions(mimeInfo); - g_assert(extensions); - g_assert_cmpstr(extensions[0], ==, "png"); - - mimeInfoList = g_list_next(mimeInfoList); - mimeInfo = static_cast<WebKitMimeInfo*>(mimeInfoList->data); - g_assert_cmpstr(webkit_mime_info_get_mime_type(mimeInfo), ==, "application/x-webkit-test-netscape"); - g_assert_cmpstr(webkit_mime_info_get_description(mimeInfo), ==, "test netscape content"); - extensions = webkit_mime_info_get_extensions(mimeInfo); - g_assert(extensions); - g_assert_cmpstr(extensions[0], ==, "testnetscape"); -} - -static const char* kBarHTML = "<html><body>Bar</body></html>"; -static const char* kEchoHTMLFormat = "<html><body>%s</body></html>"; -static const char* errorDomain = "test"; -static const int errorCode = 10; -static const char* errorMessage = "Error message."; - -class URISchemeTest: public LoadTrackingTest { -public: - MAKE_GLIB_TEST_FIXTURE(URISchemeTest); - - struct URISchemeHandler { - URISchemeHandler() - : replyLength(0) - { - } - - URISchemeHandler(const char* reply, int replyLength, const char* mimeType) - : reply(reply) - , replyLength(replyLength) - , mimeType(mimeType) - { - } - - CString reply; - int replyLength; - CString mimeType; - }; - - static void uriSchemeRequestCallback(WebKitURISchemeRequest* request, gpointer userData) - { - URISchemeTest* test = static_cast<URISchemeTest*>(userData); - test->m_uriSchemeRequest = request; - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request)); - - g_assert(webkit_uri_scheme_request_get_web_view(request) == test->m_webView); - - GRefPtr<GInputStream> inputStream = adoptGRef(g_memory_input_stream_new()); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(inputStream.get())); - - const char* scheme = webkit_uri_scheme_request_get_scheme(request); - g_assert(scheme); - g_assert(test->m_handlersMap.contains(String::fromUTF8(scheme))); - - if (!g_strcmp0(scheme, "error")) { - GOwnPtr<GError> error(g_error_new_literal(g_quark_from_string(errorDomain), errorCode, errorMessage)); - webkit_uri_scheme_request_finish_error(request, error.get()); - return; - } - - const URISchemeHandler& handler = test->m_handlersMap.get(String::fromUTF8(scheme)); - - if (!g_strcmp0(scheme, "echo")) { - char* replyHTML = g_strdup_printf(handler.reply.data(), webkit_uri_scheme_request_get_path(request)); - g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(inputStream.get()), replyHTML, strlen(replyHTML), g_free); - } else if (!g_strcmp0(scheme, "closed")) - g_input_stream_close(inputStream.get(), 0, 0); - else if (!handler.reply.isNull()) - g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(inputStream.get()), handler.reply.data(), handler.reply.length(), 0); - - webkit_uri_scheme_request_finish(request, inputStream.get(), handler.replyLength, handler.mimeType.data()); - } - - void registerURISchemeHandler(const char* scheme, const char* reply, int replyLength, const char* mimeType) - { - m_handlersMap.set(String::fromUTF8(scheme), URISchemeHandler(reply, replyLength, mimeType)); - webkit_web_context_register_uri_scheme(webkit_web_context_get_default(), scheme, uriSchemeRequestCallback, this, 0); - } - - GRefPtr<WebKitURISchemeRequest> m_uriSchemeRequest; - HashMap<String, URISchemeHandler> m_handlersMap; -}; - -static void testWebContextURIScheme(URISchemeTest* test, gconstpointer) -{ - test->registerURISchemeHandler("foo", kBarHTML, strlen(kBarHTML), "text/html"); - test->loadURI("foo:blank"); - test->waitUntilLoadFinished(); - size_t mainResourceDataSize = 0; - const char* mainResourceData = test->mainResourceData(mainResourceDataSize); - g_assert_cmpint(mainResourceDataSize, ==, strlen(kBarHTML)); - g_assert(!strncmp(mainResourceData, kBarHTML, mainResourceDataSize)); - - test->registerURISchemeHandler("echo", kEchoHTMLFormat, -1, "text/html"); - test->loadURI("echo:hello world"); - test->waitUntilLoadFinished(); - GOwnPtr<char> echoHTML(g_strdup_printf(kEchoHTMLFormat, webkit_uri_scheme_request_get_path(test->m_uriSchemeRequest.get()))); - mainResourceDataSize = 0; - mainResourceData = test->mainResourceData(mainResourceDataSize); - g_assert_cmpint(mainResourceDataSize, ==, strlen(echoHTML.get())); - g_assert(!strncmp(mainResourceData, echoHTML.get(), mainResourceDataSize)); - - test->registerURISchemeHandler("nomime", kBarHTML, -1, 0); - test->m_loadEvents.clear(); - test->loadURI("nomime:foo bar"); - test->waitUntilLoadFinished(); - g_assert(test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed)); - - test->registerURISchemeHandler("empty", 0, 0, "text/html"); - test->m_loadEvents.clear(); - test->loadURI("empty:nothing"); - test->waitUntilLoadFinished(); - g_assert(!test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed)); - g_assert(!test->m_loadEvents.contains(LoadTrackingTest::LoadFailed)); - - test->registerURISchemeHandler("error", 0, 0, 0); - test->m_loadEvents.clear(); - test->loadURI("error:error"); - test->waitUntilLoadFinished(); - g_assert(test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed)); - g_assert(test->m_loadFailed); - g_assert_error(test->m_error.get(), g_quark_from_string(errorDomain), errorCode); - g_assert_cmpstr(test->m_error->message, ==, errorMessage); - - test->registerURISchemeHandler("closed", 0, 0, 0); - test->m_loadEvents.clear(); - test->loadURI("closed:input-stream"); - test->waitUntilLoadFinished(); - g_assert(test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed)); - g_assert(test->m_loadFailed); - g_assert_error(test->m_error.get(), G_IO_ERROR, G_IO_ERROR_CLOSED); -} - -static void testWebContextSpellChecker(Test* test, gconstpointer) -{ - WebKitWebContext* webContext = webkit_web_context_get_default(); - - // Check what happens if no spell checking language has been set. - const gchar* const* currentLanguage = webkit_web_context_get_spell_checking_languages(webContext); - g_assert(!currentLanguage); - - // Set the language to a specific one. - GRefPtr<GPtrArray> languages = adoptGRef(g_ptr_array_new()); - g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("en_US"))); - g_ptr_array_add(languages.get(), 0); - webkit_web_context_set_spell_checking_languages(webContext, reinterpret_cast<const char* const*>(languages->pdata)); - currentLanguage = webkit_web_context_get_spell_checking_languages(webContext); - g_assert_cmpuint(g_strv_length(const_cast<char**>(currentLanguage)), ==, 1); - g_assert_cmpstr(currentLanguage[0], ==, "en_US"); - - // Set the language string to list of valid languages. - g_ptr_array_remove_index_fast(languages.get(), languages->len - 1); - g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("en_GB"))); - g_ptr_array_add(languages.get(), 0); - webkit_web_context_set_spell_checking_languages(webContext, reinterpret_cast<const char* const*>(languages->pdata)); - currentLanguage = webkit_web_context_get_spell_checking_languages(webContext); - g_assert_cmpuint(g_strv_length(const_cast<char**>(currentLanguage)), ==, 2); - g_assert_cmpstr(currentLanguage[0], ==, "en_US"); - g_assert_cmpstr(currentLanguage[1], ==, "en_GB"); - - // Try passing a wrong language along with good ones. - g_ptr_array_remove_index_fast(languages.get(), languages->len - 1); - g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("bd_WR"))); - g_ptr_array_add(languages.get(), 0); - webkit_web_context_set_spell_checking_languages(webContext, reinterpret_cast<const char* const*>(languages->pdata)); - currentLanguage = webkit_web_context_get_spell_checking_languages(webContext); - g_assert_cmpuint(g_strv_length(const_cast<char**>(currentLanguage)), ==, 2); - g_assert_cmpstr(currentLanguage[0], ==, "en_US"); - g_assert_cmpstr(currentLanguage[1], ==, "en_GB"); - - // Try passing a list with only wrong languages. - languages = adoptGRef(g_ptr_array_new()); - g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("bd_WR"))); - g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("wr_BD"))); - g_ptr_array_add(languages.get(), 0); - webkit_web_context_set_spell_checking_languages(webContext, reinterpret_cast<const char* const*>(languages->pdata)); - currentLanguage = webkit_web_context_get_spell_checking_languages(webContext); - g_assert(!currentLanguage); - - // Check disabling and re-enabling spell checking. - webkit_web_context_set_spell_checking_enabled(webContext, FALSE); - g_assert(!webkit_web_context_get_spell_checking_enabled(webContext)); - webkit_web_context_set_spell_checking_enabled(webContext, TRUE); - g_assert(webkit_web_context_get_spell_checking_enabled(webContext)); -} - -static void testWebContextLanguages(WebViewTest* test, gconstpointer) -{ - static const char* expectedDefaultLanguage = "en"; - test->loadURI(kServer->getURIForPath("/").data()); - test->waitUntilLoadFinished(); - size_t mainResourceDataSize = 0; - const char* mainResourceData = test->mainResourceData(mainResourceDataSize); - g_assert_cmpuint(mainResourceDataSize, ==, strlen(expectedDefaultLanguage)); - g_assert(!strncmp(mainResourceData, expectedDefaultLanguage, mainResourceDataSize)); - - GRefPtr<GPtrArray> languages = adoptGRef(g_ptr_array_new()); - g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("en"))); - g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("ES_es"))); - g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("dE"))); - g_ptr_array_add(languages.get(), 0); - webkit_web_context_set_preferred_languages(webkit_web_context_get_default(), reinterpret_cast<const char* const*>(languages->pdata)); - - static const char* expectedLanguages = "en, es-es;q=0.90, de;q=0.80"; - test->loadURI(kServer->getURIForPath("/").data()); - test->waitUntilLoadFinished(); - mainResourceDataSize = 0; - mainResourceData = test->mainResourceData(mainResourceDataSize); - g_assert_cmpuint(mainResourceDataSize, ==, strlen(expectedLanguages)); - g_assert(!strncmp(mainResourceData, expectedLanguages, mainResourceDataSize)); -} - -static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer) -{ - if (message->method != SOUP_METHOD_GET) { - soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED); - return; - } - - if (g_str_equal(path, "/")) { - const char* acceptLanguage = soup_message_headers_get_one(message->request_headers, "Accept-Language"); - soup_message_set_status(message, SOUP_STATUS_OK); - soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, acceptLanguage, strlen(acceptLanguage)); - soup_message_body_complete(message->response_body); - } else - soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); -} - -class SecurityPolicyTest: public Test { -public: - MAKE_GLIB_TEST_FIXTURE(SecurityPolicyTest); - - enum SecurityPolicy { - Local = 1 << 1, - NoAccess = 1 << 2, - DisplayIsolated = 1 << 3, - Secure = 1 << 4, - CORSEnabled = 1 << 5, - EmptyDocument = 1 << 6 - }; - - SecurityPolicyTest() - : m_manager(webkit_web_context_get_security_manager(webkit_web_context_get_default())) - { - } - - void verifyThatSchemeMatchesPolicy(const char* scheme, unsigned policy) - { - if (policy & Local) - g_assert(webkit_security_manager_uri_scheme_is_local(m_manager, scheme)); - else - g_assert(!webkit_security_manager_uri_scheme_is_local(m_manager, scheme)); - if (policy & NoAccess) - g_assert(webkit_security_manager_uri_scheme_is_no_access(m_manager, scheme)); - else - g_assert(!webkit_security_manager_uri_scheme_is_no_access(m_manager, scheme)); - if (policy & DisplayIsolated) - g_assert(webkit_security_manager_uri_scheme_is_display_isolated(m_manager, scheme)); - else - g_assert(!webkit_security_manager_uri_scheme_is_display_isolated(m_manager, scheme)); - if (policy & Secure) - g_assert(webkit_security_manager_uri_scheme_is_secure(m_manager, scheme)); - else - g_assert(!webkit_security_manager_uri_scheme_is_secure(m_manager, scheme)); - if (policy & CORSEnabled) - g_assert(webkit_security_manager_uri_scheme_is_cors_enabled(m_manager, scheme)); - else - g_assert(!webkit_security_manager_uri_scheme_is_cors_enabled(m_manager, scheme)); - if (policy & EmptyDocument) - g_assert(webkit_security_manager_uri_scheme_is_empty_document(m_manager, scheme)); - else - g_assert(!webkit_security_manager_uri_scheme_is_empty_document(m_manager, scheme)); - } - - WebKitSecurityManager* m_manager; -}; - -static void testWebContextSecurityPolicy(SecurityPolicyTest* test, gconstpointer) -{ - // VerifyThatSchemeMatchesPolicy default policy for well known schemes. - test->verifyThatSchemeMatchesPolicy("http", SecurityPolicyTest::CORSEnabled); - test->verifyThatSchemeMatchesPolicy("https", SecurityPolicyTest::CORSEnabled | SecurityPolicyTest::Secure); - test->verifyThatSchemeMatchesPolicy("file", SecurityPolicyTest::Local); - test->verifyThatSchemeMatchesPolicy("data", SecurityPolicyTest::NoAccess | SecurityPolicyTest::Secure); - test->verifyThatSchemeMatchesPolicy("about", SecurityPolicyTest::NoAccess | SecurityPolicyTest::Secure | SecurityPolicyTest::EmptyDocument); - - // Custom scheme. - test->verifyThatSchemeMatchesPolicy("foo", 0); - - webkit_security_manager_register_uri_scheme_as_local(test->m_manager, "foo"); - test->verifyThatSchemeMatchesPolicy("foo", SecurityPolicyTest::Local); - webkit_security_manager_register_uri_scheme_as_no_access(test->m_manager, "foo"); - test->verifyThatSchemeMatchesPolicy("foo", SecurityPolicyTest::Local | SecurityPolicyTest::NoAccess); - webkit_security_manager_register_uri_scheme_as_display_isolated(test->m_manager, "foo"); - test->verifyThatSchemeMatchesPolicy("foo", SecurityPolicyTest::Local | SecurityPolicyTest::NoAccess | SecurityPolicyTest::DisplayIsolated); - webkit_security_manager_register_uri_scheme_as_secure(test->m_manager, "foo"); - test->verifyThatSchemeMatchesPolicy("foo", SecurityPolicyTest::Local | SecurityPolicyTest::NoAccess | SecurityPolicyTest::DisplayIsolated | SecurityPolicyTest::Secure); - webkit_security_manager_register_uri_scheme_as_cors_enabled(test->m_manager, "foo"); - test->verifyThatSchemeMatchesPolicy("foo", SecurityPolicyTest::Local | SecurityPolicyTest::NoAccess | SecurityPolicyTest::DisplayIsolated | SecurityPolicyTest::Secure - | SecurityPolicyTest::CORSEnabled); - webkit_security_manager_register_uri_scheme_as_empty_document(test->m_manager, "foo"); - test->verifyThatSchemeMatchesPolicy("foo", SecurityPolicyTest::Local | SecurityPolicyTest::NoAccess | SecurityPolicyTest::DisplayIsolated | SecurityPolicyTest::Secure - | SecurityPolicyTest::CORSEnabled | SecurityPolicyTest::EmptyDocument); -} - -void beforeAll() -{ - kServer = new WebKitTestServer(); - kServer->run(serverCallback); - - Test::add("WebKitWebContext", "default-context", testWebContextDefault); - PluginsTest::add("WebKitWebContext", "get-plugins", testWebContextGetPlugins); - URISchemeTest::add("WebKitWebContext", "uri-scheme", testWebContextURIScheme); - Test::add("WebKitWebContext", "spell-checker", testWebContextSpellChecker); - WebViewTest::add("WebKitWebContext", "languages", testWebContextLanguages); - SecurityPolicyTest::add("WebKitSecurityManager", "security-policy", testWebContextSecurityPolicy); -} - -void afterAll() -{ - delete kServer; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp deleted file mode 100644 index 88d77f286..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp +++ /dev/null @@ -1,1258 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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 "WebViewTest.h" -#include <JavaScriptCore/JSStringRef.h> -#include <JavaScriptCore/JSValueRef.h> -#include <glib/gstdio.h> -#include <wtf/HashSet.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/StringHash.h> - -static void testWebViewDefaultContext(WebViewTest* test, gconstpointer) -{ - g_assert(webkit_web_view_get_context(test->m_webView) == webkit_web_context_get_default()); - - // Check that a web view created with g_object_new has the default context. - GRefPtr<WebKitWebView> webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW, NULL)); - g_assert(webkit_web_view_get_context(webView.get()) == webkit_web_context_get_default()); -} - -static void testWebViewCustomCharset(WebViewTest* test, gconstpointer) -{ - g_assert(!webkit_web_view_get_custom_charset(test->m_webView)); - webkit_web_view_set_custom_charset(test->m_webView, "utf8"); - g_assert_cmpstr(webkit_web_view_get_custom_charset(test->m_webView), ==, "utf8"); - // Go back to the default charset. - webkit_web_view_set_custom_charset(test->m_webView, 0); - g_assert(!webkit_web_view_get_custom_charset(test->m_webView)); -} - -static void testWebViewSettings(WebViewTest* test, gconstpointer) -{ - WebKitSettings* defaultSettings = webkit_web_view_get_settings(test->m_webView); - g_assert(defaultSettings); - g_assert(webkit_settings_get_enable_javascript(defaultSettings)); - - GRefPtr<WebKitSettings> newSettings = adoptGRef(webkit_settings_new()); - g_object_set(G_OBJECT(newSettings.get()), "enable-javascript", FALSE, NULL); - webkit_web_view_set_settings(test->m_webView, newSettings.get()); - - WebKitSettings* settings = webkit_web_view_get_settings(test->m_webView); - g_assert(settings != defaultSettings); - g_assert(!webkit_settings_get_enable_javascript(settings)); - - GRefPtr<GtkWidget> webView2 = webkit_web_view_new(); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(webView2.get())); - webkit_web_view_set_settings(WEBKIT_WEB_VIEW(webView2.get()), settings); - g_assert(webkit_web_view_get_settings(WEBKIT_WEB_VIEW(webView2.get())) == settings); - - GRefPtr<WebKitSettings> newSettings2 = adoptGRef(webkit_settings_new()); - webkit_web_view_set_settings(WEBKIT_WEB_VIEW(webView2.get()), newSettings2.get()); - settings = webkit_web_view_get_settings(WEBKIT_WEB_VIEW(webView2.get())); - g_assert(settings == newSettings2.get()); - g_assert(webkit_settings_get_enable_javascript(settings)); -} - -static const char* kAlertDialogMessage = "WebKitGTK+ alert dialog message"; -static const char* kConfirmDialogMessage = "WebKitGTK+ confirm dialog message"; -static const char* kPromptDialogMessage = "WebKitGTK+ prompt dialog message"; -static const char* kPromptDialogReturnedText = "WebKitGTK+ prompt dialog returned text"; - -class UIClientTest: public WebViewTest { -public: - MAKE_GLIB_TEST_FIXTURE(UIClientTest); - - enum WebViewEvents { - Create, - ReadyToShow, - RunAsModal, - Close - }; - - class WindowProperties { - public: - WindowProperties() - : m_isNull(true) - , m_toolbarVisible(true) - , m_statusbarVisible(true) - , m_scrollbarsVisible(true) - , m_menubarVisible(true) - , m_locationbarVisible(true) - , m_resizable(true) - , m_fullscreen(false) - { - memset(&m_geometry, 0, sizeof(GdkRectangle)); - } - - WindowProperties(WebKitWindowProperties* windowProperties) - : m_isNull(false) - , m_toolbarVisible(webkit_window_properties_get_toolbar_visible(windowProperties)) - , m_statusbarVisible(webkit_window_properties_get_statusbar_visible(windowProperties)) - , m_scrollbarsVisible(webkit_window_properties_get_scrollbars_visible(windowProperties)) - , m_menubarVisible(webkit_window_properties_get_menubar_visible(windowProperties)) - , m_locationbarVisible(webkit_window_properties_get_locationbar_visible(windowProperties)) - , m_resizable(webkit_window_properties_get_resizable(windowProperties)) - , m_fullscreen(webkit_window_properties_get_fullscreen(windowProperties)) - { - webkit_window_properties_get_geometry(windowProperties, &m_geometry); - } - - WindowProperties(GdkRectangle* geometry, bool toolbarVisible, bool statusbarVisible, bool scrollbarsVisible, bool menubarVisible, - bool locationbarVisible, bool resizable, bool fullscreen) - : m_isNull(false) - , m_geometry(*geometry) - , m_toolbarVisible(toolbarVisible) - , m_statusbarVisible(statusbarVisible) - , m_scrollbarsVisible(scrollbarsVisible) - , m_menubarVisible(menubarVisible) - , m_locationbarVisible(locationbarVisible) - , m_resizable(resizable) - , m_fullscreen(fullscreen) - { - } - - bool isNull() const { return m_isNull; } - - void assertEqual(const WindowProperties& other) const - { - g_assert_cmpint(m_geometry.x, ==, other.m_geometry.x); - g_assert_cmpint(m_geometry.y, ==, other.m_geometry.y); - g_assert_cmpint(m_geometry.width, ==, other.m_geometry.width); - g_assert_cmpint(m_geometry.height, ==, other.m_geometry.height); - g_assert_cmpint(static_cast<int>(m_toolbarVisible), ==, static_cast<int>(other.m_toolbarVisible)); - g_assert_cmpint(static_cast<int>(m_statusbarVisible), ==, static_cast<int>(other.m_statusbarVisible)); - g_assert_cmpint(static_cast<int>(m_scrollbarsVisible), ==, static_cast<int>(other.m_scrollbarsVisible)); - g_assert_cmpint(static_cast<int>(m_menubarVisible), ==, static_cast<int>(other.m_menubarVisible)); - g_assert_cmpint(static_cast<int>(m_locationbarVisible), ==, static_cast<int>(other.m_locationbarVisible)); - g_assert_cmpint(static_cast<int>(m_resizable), ==, static_cast<int>(other.m_resizable)); - g_assert_cmpint(static_cast<int>(m_fullscreen), ==, static_cast<int>(other.m_fullscreen)); - } - - private: - bool m_isNull; - - GdkRectangle m_geometry; - - bool m_toolbarVisible; - bool m_statusbarVisible; - bool m_scrollbarsVisible; - bool m_menubarVisible; - bool m_locationbarVisible; - - bool m_resizable; - bool m_fullscreen; - }; - - static void windowPropertiesNotifyCallback(GObject*, GParamSpec* paramSpec, UIClientTest* test) - { - test->m_windowPropertiesChanged.add(g_param_spec_get_name(paramSpec)); - } - - static GtkWidget* viewCreateCallback(WebKitWebView* webView, UIClientTest* test) - { - return test->viewCreate(webView); - } - - static void viewReadyToShowCallback(WebKitWebView* webView, UIClientTest* test) - { - test->viewReadyToShow(webView); - } - - static void viewCloseCallback(WebKitWebView* webView, UIClientTest* test) - { - test->viewClose(webView); - } - - void scriptAlert(WebKitScriptDialog* dialog) - { - switch (m_scriptDialogType) { - case WEBKIT_SCRIPT_DIALOG_ALERT: - g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, kAlertDialogMessage); - break; - case WEBKIT_SCRIPT_DIALOG_CONFIRM: - g_assert(m_scriptDialogConfirmed); - g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, "confirmed"); - - break; - case WEBKIT_SCRIPT_DIALOG_PROMPT: - g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, kPromptDialogReturnedText); - break; - } - - g_main_loop_quit(m_mainLoop); - } - - void scriptConfirm(WebKitScriptDialog* dialog) - { - g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, kConfirmDialogMessage); - m_scriptDialogConfirmed = !m_scriptDialogConfirmed; - webkit_script_dialog_confirm_set_confirmed(dialog, m_scriptDialogConfirmed); - } - - void scriptPrompt(WebKitScriptDialog* dialog) - { - g_assert_cmpstr(webkit_script_dialog_get_message(dialog), ==, kPromptDialogMessage); - g_assert_cmpstr(webkit_script_dialog_prompt_get_default_text(dialog), ==, "default"); - webkit_script_dialog_prompt_set_text(dialog, kPromptDialogReturnedText); - } - - static gboolean scriptDialog(WebKitWebView*, WebKitScriptDialog* dialog, UIClientTest* test) - { - switch (webkit_script_dialog_get_dialog_type(dialog)) { - case WEBKIT_SCRIPT_DIALOG_ALERT: - test->scriptAlert(dialog); - break; - case WEBKIT_SCRIPT_DIALOG_CONFIRM: - test->scriptConfirm(dialog); - break; - case WEBKIT_SCRIPT_DIALOG_PROMPT: - test->scriptPrompt(dialog); - break; - } - - return TRUE; - } - - static void mouseTargetChanged(WebKitWebView*, WebKitHitTestResult* hitTestResult, guint modifiers, UIClientTest* test) - { - g_assert(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult)); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(hitTestResult)); - - test->m_mouseTargetHitTestResult = hitTestResult; - test->m_mouseTargetModifiers = modifiers; - g_main_loop_quit(test->m_mainLoop); - } - - static gboolean permissionRequested(WebKitWebView*, WebKitPermissionRequest* request, UIClientTest* test) - { - g_assert(WEBKIT_IS_PERMISSION_REQUEST(request)); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request)); - - if (test->m_allowPermissionRequests) - webkit_permission_request_allow(request); - else - webkit_permission_request_deny(request); - - return TRUE; - } - - UIClientTest() - : m_scriptDialogType(WEBKIT_SCRIPT_DIALOG_ALERT) - , m_scriptDialogConfirmed(true) - , m_allowPermissionRequests(false) - , m_mouseTargetModifiers(0) - { - webkit_settings_set_javascript_can_open_windows_automatically(webkit_web_view_get_settings(m_webView), TRUE); - g_signal_connect(m_webView, "create", G_CALLBACK(viewCreateCallback), this); - g_signal_connect(m_webView, "script-dialog", G_CALLBACK(scriptDialog), this); - g_signal_connect(m_webView, "mouse-target-changed", G_CALLBACK(mouseTargetChanged), this); - g_signal_connect(m_webView, "permission-request", G_CALLBACK(permissionRequested), this); - } - - ~UIClientTest() - { - g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); - } - - void waitUntilMainLoopFinishes() - { - g_main_loop_run(m_mainLoop); - } - - void setExpectedWindowProperties(const WindowProperties& windowProperties) - { - m_windowProperties = windowProperties; - } - - WebKitHitTestResult* moveMouseAndWaitUntilMouseTargetChanged(int x, int y, unsigned int mouseModifiers = 0) - { - mouseMoveTo(x, y, mouseModifiers); - g_main_loop_run(m_mainLoop); - return m_mouseTargetHitTestResult.get(); - } - - virtual GtkWidget* viewCreate(WebKitWebView* webView) - { - g_assert(webView == m_webView); - - GtkWidget* newWebView = webkit_web_view_new_with_context(webkit_web_view_get_context(webView)); - g_object_ref_sink(newWebView); - - m_webViewEvents.append(Create); - - WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(newWebView)); - g_assert(windowProperties); - assertObjectIsDeletedWhenTestFinishes(G_OBJECT(windowProperties)); - m_windowPropertiesChanged.clear(); - - g_signal_connect(windowProperties, "notify", G_CALLBACK(windowPropertiesNotifyCallback), this); - g_signal_connect(newWebView, "ready-to-show", G_CALLBACK(viewReadyToShowCallback), this); - g_signal_connect(newWebView, "close", G_CALLBACK(viewCloseCallback), this); - - return newWebView; - } - - virtual void viewReadyToShow(WebKitWebView* webView) - { - g_assert(webView != m_webView); - - WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(webView); - g_assert(windowProperties); - if (!m_windowProperties.isNull()) - WindowProperties(windowProperties).assertEqual(m_windowProperties); - - m_webViewEvents.append(ReadyToShow); - } - - virtual void viewClose(WebKitWebView* webView) - { - g_assert(webView != m_webView); - - m_webViewEvents.append(Close); - g_object_unref(webView); - - g_main_loop_quit(m_mainLoop); - } - - Vector<WebViewEvents> m_webViewEvents; - WebKitScriptDialogType m_scriptDialogType; - bool m_scriptDialogConfirmed; - bool m_allowPermissionRequests; - WindowProperties m_windowProperties; - HashSet<WTF::String> m_windowPropertiesChanged; - GRefPtr<WebKitHitTestResult> m_mouseTargetHitTestResult; - unsigned int m_mouseTargetModifiers; -}; - -static void testWebViewCreateReadyClose(UIClientTest* test, gconstpointer) -{ - test->loadHtml("<html><body onLoad=\"window.open().close();\"></html>", 0); - test->waitUntilMainLoopFinishes(); - - Vector<UIClientTest::WebViewEvents>& events = test->m_webViewEvents; - g_assert_cmpint(events.size(), ==, 3); - g_assert_cmpint(events[0], ==, UIClientTest::Create); - g_assert_cmpint(events[1], ==, UIClientTest::ReadyToShow); - g_assert_cmpint(events[2], ==, UIClientTest::Close); -} - -static gboolean checkMimeTypeForFilter(GtkFileFilter* filter, const gchar* mimeType) -{ - GtkFileFilterInfo filterInfo; - filterInfo.contains = GTK_FILE_FILTER_MIME_TYPE; - filterInfo.mime_type = mimeType; - return gtk_file_filter_filter(filter, &filterInfo); -} - -class ModalDialogsTest: public UIClientTest { -public: - MAKE_GLIB_TEST_FIXTURE(ModalDialogsTest); - - static void dialogRunAsModalCallback(WebKitWebView* webView, ModalDialogsTest* test) - { - g_assert(webView != test->m_webView); - test->m_webViewEvents.append(RunAsModal); - } - - GtkWidget* viewCreate(WebKitWebView* webView) - { - g_assert(webView == m_webView); - - GtkWidget* newWebView = UIClientTest::viewCreate(webView); - g_signal_connect(newWebView, "run-as-modal", G_CALLBACK(dialogRunAsModalCallback), this); - return newWebView; - } - - void viewReadyToShow(WebKitWebView* webView) - { - g_assert(webView != m_webView); - m_webViewEvents.append(ReadyToShow); - } -}; - -static void testWebViewAllowModalDialogs(ModalDialogsTest* test, gconstpointer) -{ - WebKitSettings* settings = webkit_web_view_get_settings(test->m_webView); - webkit_settings_set_allow_modal_dialogs(settings, TRUE); - - test->loadHtml("<html><body onload=\"window.showModalDialog('data:text/html,<html><body/><script>window.close();</script></html>')\"></body></html>", 0); - test->waitUntilMainLoopFinishes(); - - Vector<UIClientTest::WebViewEvents>& events = test->m_webViewEvents; - g_assert_cmpint(events.size(), ==, 4); - g_assert_cmpint(events[0], ==, UIClientTest::Create); - g_assert_cmpint(events[1], ==, UIClientTest::ReadyToShow); - g_assert_cmpint(events[2], ==, UIClientTest::RunAsModal); - g_assert_cmpint(events[3], ==, UIClientTest::Close); -} - -static void testWebViewDisallowModalDialogs(ModalDialogsTest* test, gconstpointer) -{ - WebKitSettings* settings = webkit_web_view_get_settings(test->m_webView); - webkit_settings_set_allow_modal_dialogs(settings, FALSE); - - test->loadHtml("<html><body onload=\"window.showModalDialog('data:text/html,<html><body/><script>window.close();</script></html>')\"></body></html>", 0); - // We need to use a timeout here because the viewClose() function - // won't ever be called as the dialog won't be created. - test->wait(1); - - Vector<UIClientTest::WebViewEvents>& events = test->m_webViewEvents; - g_assert_cmpint(events.size(), ==, 0); -} - -static void testWebViewJavaScriptDialogs(UIClientTest* test, gconstpointer) -{ - static const char* htmlOnLoadFormat = "<html><body onLoad=\"%s\"></body></html>"; - static const char* jsAlertFormat = "alert('%s')"; - static const char* jsConfirmFormat = "do { confirmed = confirm('%s'); } while (!confirmed); alert('confirmed');"; - static const char* jsPromptFormat = "alert(prompt('%s', 'default'));"; - - test->m_scriptDialogType = WEBKIT_SCRIPT_DIALOG_ALERT; - GOwnPtr<char> alertDialogMessage(g_strdup_printf(jsAlertFormat, kAlertDialogMessage)); - GOwnPtr<char> alertHTML(g_strdup_printf(htmlOnLoadFormat, alertDialogMessage.get())); - test->loadHtml(alertHTML.get(), 0); - test->waitUntilMainLoopFinishes(); - - test->m_scriptDialogType = WEBKIT_SCRIPT_DIALOG_CONFIRM; - GOwnPtr<char> confirmDialogMessage(g_strdup_printf(jsConfirmFormat, kConfirmDialogMessage)); - GOwnPtr<char> confirmHTML(g_strdup_printf(htmlOnLoadFormat, confirmDialogMessage.get())); - test->loadHtml(confirmHTML.get(), 0); - test->waitUntilMainLoopFinishes(); - - test->m_scriptDialogType = WEBKIT_SCRIPT_DIALOG_PROMPT; - GOwnPtr<char> promptDialogMessage(g_strdup_printf(jsPromptFormat, kPromptDialogMessage)); - GOwnPtr<char> promptHTML(g_strdup_printf(htmlOnLoadFormat, promptDialogMessage.get())); - test->loadHtml(promptHTML.get(), 0); - test->waitUntilMainLoopFinishes(); -} - -static void testWebViewWindowProperties(UIClientTest* test, gconstpointer) -{ - static const char* windowProrpertiesString = "left=100,top=150,width=400,height=400,location=no,menubar=no,status=no,toolbar=no,scrollbars=no"; - GdkRectangle geometry = { 100, 150, 400, 400 }; - test->setExpectedWindowProperties(UIClientTest::WindowProperties(&geometry, false, false, false, false, false, true, false)); - - GOwnPtr<char> htmlString(g_strdup_printf("<html><body onLoad=\"window.open('', '', '%s').close();\"></body></html>", windowProrpertiesString)); - test->loadHtml(htmlString.get(), 0); - test->waitUntilMainLoopFinishes(); - - static const char* propertiesChanged[] = { - "geometry", "locationbar-visible", "menubar-visible", "statusbar-visible", "toolbar-visible", "scrollbars-visible" - }; - for (size_t i = 0; i < G_N_ELEMENTS(propertiesChanged); ++i) - g_assert(test->m_windowPropertiesChanged.contains(propertiesChanged[i])); - - Vector<UIClientTest::WebViewEvents>& events = test->m_webViewEvents; - g_assert_cmpint(events.size(), ==, 3); - g_assert_cmpint(events[0], ==, UIClientTest::Create); - g_assert_cmpint(events[1], ==, UIClientTest::ReadyToShow); - g_assert_cmpint(events[2], ==, UIClientTest::Close); -} - -static void testWebViewMouseTarget(UIClientTest* test, gconstpointer) -{ - test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL); - - const char* linksHoveredHTML = - "<html><body>" - " <a style='position:absolute; left:1; top:1' href='http://www.webkitgtk.org' title='WebKitGTK+ Title'>WebKitGTK+ Website</a>" - " <img style='position:absolute; left:1; top:10' src='0xdeadbeef' width=5 height=5></img>" - " <a style='position:absolute; left:1; top:20' href='http://www.webkitgtk.org/logo' title='WebKitGTK+ Logo'><img src='0xdeadbeef' width=5 height=5></img></a>" - " <input style='position:absolute; left:1; top:30' size='10'></input>" - " <div style='position:absolute; left:1; top:50; width:30; height:30; overflow:scroll'> </div>" - " <video style='position:absolute; left:1; top:100' width='300' height='300' controls='controls' preload='none'><source src='movie.ogg' type='video/ogg' /></video>" - "</body></html>"; - - test->loadHtml(linksHoveredHTML, "file:///"); - test->waitUntilLoadFinished(); - - // Move over link. - WebKitHitTestResult* hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 1); - g_assert(webkit_hit_test_result_context_is_link(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_image(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); - g_assert_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/"); - g_assert_cmpstr(webkit_hit_test_result_get_link_title(hitTestResult), ==, "WebKitGTK+ Title"); - g_assert_cmpstr(webkit_hit_test_result_get_link_label(hitTestResult), ==, "WebKitGTK+ Website"); - g_assert(!test->m_mouseTargetModifiers); - - // Move out of the link. - hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(0, 0); - g_assert(!webkit_hit_test_result_context_is_link(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_image(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); - g_assert(!test->m_mouseTargetModifiers); - - // Move over image with GDK_CONTROL_MASK. - hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 10, GDK_CONTROL_MASK); - g_assert(!webkit_hit_test_result_context_is_link(hitTestResult)); - g_assert(webkit_hit_test_result_context_is_image(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult)); - g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef"); - g_assert(test->m_mouseTargetModifiers & GDK_CONTROL_MASK); - - // Move over image link. - hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 20); - g_assert(webkit_hit_test_result_context_is_link(hitTestResult)); - g_assert(webkit_hit_test_result_context_is_image(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult)); - g_assert_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/logo"); - g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef"); - g_assert_cmpstr(webkit_hit_test_result_get_link_title(hitTestResult), ==, "WebKitGTK+ Logo"); - g_assert(!webkit_hit_test_result_get_link_label(hitTestResult)); - g_assert(!test->m_mouseTargetModifiers); - - // Move over media. - hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 100); - g_assert(!webkit_hit_test_result_context_is_link(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_image(hitTestResult)); - g_assert(webkit_hit_test_result_context_is_media(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult)); - g_assert_cmpstr(webkit_hit_test_result_get_media_uri(hitTestResult), ==, "file:///movie.ogg"); - g_assert(!test->m_mouseTargetModifiers); - - // Mover over input. - hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(5, 35); - g_assert(!webkit_hit_test_result_context_is_link(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_image(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult)); - g_assert(webkit_hit_test_result_context_is_editable(hitTestResult)); - g_assert(!test->m_mouseTargetModifiers); - - // Move over scrollbar. - hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(5, 75); - g_assert(!webkit_hit_test_result_context_is_link(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_image(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); - g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); - g_assert(webkit_hit_test_result_context_is_scrollbar(hitTestResult)); - g_assert(!test->m_mouseTargetModifiers); -} - -static void testWebViewPermissionRequests(UIClientTest* test, gconstpointer) -{ - // Some versions of geoclue give a runtime warning because it tries - // to register the error quark twice. See https://bugs.webkit.org/show_bug.cgi?id=89858. - // Make warnings non-fatal for this test to make it pass. - test->removeLogFatalFlag(G_LOG_LEVEL_WARNING); - test->showInWindowAndWaitUntilMapped(); - static const char* geolocationRequestHTML = - "<html>" - " <script>" - " function runTest()" - " {" - " navigator.geolocation.getCurrentPosition(function(p) { document.title = \"OK\" }," - " function(e) { document.title = e.code });" - " }" - " </script>" - " <body onload='runTest();'></body>" - "</html>"; - - // Test denying a permission request. - test->m_allowPermissionRequests = false; - test->loadHtml(geolocationRequestHTML, 0); - test->waitUntilTitleChanged(); - - // According to the Geolocation API specification, '1' is the - // error code returned for the PERMISSION_DENIED error. - // http://dev.w3.org/geo/api/spec-source.html#position_error_interface - const gchar* result = webkit_web_view_get_title(test->m_webView); - g_assert_cmpstr(result, ==, "1"); - - // Test allowing a permission request. - test->m_allowPermissionRequests = true; - test->loadHtml(geolocationRequestHTML, 0); - test->waitUntilTitleChanged(); - - // Check that we did not get the PERMISSION_DENIED error now. - result = webkit_web_view_get_title(test->m_webView); - g_assert_cmpstr(result, !=, "1"); - test->addLogFatalFlag(G_LOG_LEVEL_WARNING); -} - -static void testWebViewZoomLevel(WebViewTest* test, gconstpointer) -{ - g_assert_cmpfloat(webkit_web_view_get_zoom_level(test->m_webView), ==, 1); - webkit_web_view_set_zoom_level(test->m_webView, 2.5); - g_assert_cmpfloat(webkit_web_view_get_zoom_level(test->m_webView), ==, 2.5); - - webkit_settings_set_zoom_text_only(webkit_web_view_get_settings(test->m_webView), TRUE); - // The zoom level shouldn't change when zoom-text-only setting changes. - g_assert_cmpfloat(webkit_web_view_get_zoom_level(test->m_webView), ==, 2.5); -} - -static void testWebViewRunJavaScript(WebViewTest* test, gconstpointer) -{ - static const char* html = "<html><body><a id='WebKitLink' href='http://www.webkitgtk.org/' title='WebKitGTK+ Title'>WebKitGTK+ Website</a></body></html>"; - test->loadHtml(html, 0); - test->waitUntilLoadFinished(); - - GOwnPtr<GError> error; - WebKitJavascriptResult* javascriptResult = test->runJavaScriptAndWaitUntilFinished("window.document.getElementById('WebKitLink').title;", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - GOwnPtr<char> valueString(WebViewTest::javascriptResultToCString(javascriptResult)); - g_assert_cmpstr(valueString.get(), ==, "WebKitGTK+ Title"); - - javascriptResult = test->runJavaScriptAndWaitUntilFinished("window.document.getElementById('WebKitLink').href;", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - valueString.set(WebViewTest::javascriptResultToCString(javascriptResult)); - g_assert_cmpstr(valueString.get(), ==, "http://www.webkitgtk.org/"); - - javascriptResult = test->runJavaScriptAndWaitUntilFinished("window.document.getElementById('WebKitLink').textContent", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - valueString.set(WebViewTest::javascriptResultToCString(javascriptResult)); - g_assert_cmpstr(valueString.get(), ==, "WebKitGTK+ Website"); - - javascriptResult = test->runJavaScriptAndWaitUntilFinished("a = 25;", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - g_assert_cmpfloat(WebViewTest::javascriptResultToNumber(javascriptResult), ==, 25); - - javascriptResult = test->runJavaScriptAndWaitUntilFinished("a = 2.5;", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - g_assert_cmpfloat(WebViewTest::javascriptResultToNumber(javascriptResult), ==, 2.5); - - javascriptResult = test->runJavaScriptAndWaitUntilFinished("a = true", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - g_assert(WebViewTest::javascriptResultToBoolean(javascriptResult)); - - javascriptResult = test->runJavaScriptAndWaitUntilFinished("a = false", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - g_assert(!WebViewTest::javascriptResultToBoolean(javascriptResult)); - - javascriptResult = test->runJavaScriptAndWaitUntilFinished("a = null", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - g_assert(WebViewTest::javascriptResultIsNull(javascriptResult)); - - javascriptResult = test->runJavaScriptAndWaitUntilFinished("function Foo() { a = 25; } Foo();", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - g_assert(WebViewTest::javascriptResultIsUndefined(javascriptResult)); - - javascriptResult = test->runJavaScriptFromGResourceAndWaitUntilFinished("/org/webkit/webkit2gtk/tests/link-title.js", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - valueString.set(WebViewTest::javascriptResultToCString(javascriptResult)); - g_assert_cmpstr(valueString.get(), ==, "WebKitGTK+ Title"); - - javascriptResult = test->runJavaScriptFromGResourceAndWaitUntilFinished("/wrong/path/to/resource.js", &error.outPtr()); - g_assert(!javascriptResult); - g_assert_error(error.get(), G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND); - error.clear(); - - javascriptResult = test->runJavaScriptAndWaitUntilFinished("foo();", &error.outPtr()); - g_assert(!javascriptResult); - g_assert_error(error.get(), WEBKIT_JAVASCRIPT_ERROR, WEBKIT_JAVASCRIPT_ERROR_SCRIPT_FAILED); -} - -class FileChooserTest: public UIClientTest { -public: - MAKE_GLIB_TEST_FIXTURE(FileChooserTest); - - FileChooserTest() - { - g_signal_connect(m_webView, "run-file-chooser", G_CALLBACK(runFileChooserCallback), this); - } - - static gboolean runFileChooserCallback(WebKitWebView*, WebKitFileChooserRequest* request, FileChooserTest* test) - { - test->runFileChooser(request); - return TRUE; - } - - void runFileChooser(WebKitFileChooserRequest* request) - { - assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request)); - m_fileChooserRequest = request; - g_main_loop_quit(m_mainLoop); - } - - WebKitFileChooserRequest* clickMouseButtonAndWaitForFileChooserRequest(int x, int y) - { - clickMouseButton(x, y); - g_main_loop_run(m_mainLoop); - return m_fileChooserRequest.get(); - } - -private: - GRefPtr<WebKitFileChooserRequest> m_fileChooserRequest; -}; - -static void testWebViewFileChooserRequest(FileChooserTest* test, gconstpointer) -{ - test->showInWindowAndWaitUntilMapped(); - static const char* fileChooserHTMLFormat = "<html><body><input style='position:absolute;left:0;top:0;margin:0;padding:0' type='file' %s/></body></html>"; - - // Multiple selections not allowed, no MIME filtering. - GOwnPtr<char> simpleFileUploadHTML(g_strdup_printf(fileChooserHTMLFormat, "")); - test->loadHtml(simpleFileUploadHTML.get(), 0); - test->waitUntilLoadFinished(); - WebKitFileChooserRequest* fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5); - g_assert(!webkit_file_chooser_request_get_select_multiple(fileChooserRequest)); - - const gchar* const* mimeTypes = webkit_file_chooser_request_get_mime_types(fileChooserRequest); - g_assert(!mimeTypes); - GtkFileFilter* filter = webkit_file_chooser_request_get_mime_types_filter(fileChooserRequest); - g_assert(!filter); - const gchar* const* selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest); - g_assert(!selectedFiles); - webkit_file_chooser_request_cancel(fileChooserRequest); - - // Multiple selections allowed, no MIME filtering, some pre-selected files. - GOwnPtr<char> multipleSelectionFileUploadHTML(g_strdup_printf(fileChooserHTMLFormat, "multiple")); - test->loadHtml(multipleSelectionFileUploadHTML.get(), 0); - test->waitUntilLoadFinished(); - fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5); - g_assert(webkit_file_chooser_request_get_select_multiple(fileChooserRequest)); - - mimeTypes = webkit_file_chooser_request_get_mime_types(fileChooserRequest); - g_assert(!mimeTypes); - filter = webkit_file_chooser_request_get_mime_types_filter(fileChooserRequest); - g_assert(!filter); - selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest); - g_assert(!selectedFiles); - - // Select some files. - const gchar* filesToSelect[4] = { "/foo", "/foo/bar", "/foo/bar/baz", 0 }; - webkit_file_chooser_request_select_files(fileChooserRequest, filesToSelect); - - // Check the files that have been just selected. - selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest); - g_assert(selectedFiles); - g_assert_cmpstr(selectedFiles[0], ==, "/foo"); - g_assert_cmpstr(selectedFiles[1], ==, "/foo/bar"); - g_assert_cmpstr(selectedFiles[2], ==, "/foo/bar/baz"); - g_assert(!selectedFiles[3]); - - // Perform another request to check if the list of files selected - // in the previous step appears now as part of the new request. - fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5); - selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest); - g_assert(selectedFiles); - g_assert_cmpstr(selectedFiles[0], ==, "/foo"); - g_assert_cmpstr(selectedFiles[1], ==, "/foo/bar"); - g_assert_cmpstr(selectedFiles[2], ==, "/foo/bar/baz"); - g_assert(!selectedFiles[3]); - webkit_file_chooser_request_cancel(fileChooserRequest); - - // Multiple selections not allowed, only accept images, audio and video files.. - GOwnPtr<char> mimeFilteredFileUploadHTML(g_strdup_printf(fileChooserHTMLFormat, "accept='audio/*,video/*,image/*'")); - test->loadHtml(mimeFilteredFileUploadHTML.get(), 0); - test->waitUntilLoadFinished(); - fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5); - g_assert(!webkit_file_chooser_request_get_select_multiple(fileChooserRequest)); - - mimeTypes = webkit_file_chooser_request_get_mime_types(fileChooserRequest); - g_assert(mimeTypes); - g_assert_cmpstr(mimeTypes[0], ==, "audio/*"); - g_assert_cmpstr(mimeTypes[1], ==, "video/*"); - g_assert_cmpstr(mimeTypes[2], ==, "image/*"); - g_assert(!mimeTypes[3]); - - filter = webkit_file_chooser_request_get_mime_types_filter(fileChooserRequest); - g_assert(GTK_IS_FILE_FILTER(filter)); - g_assert(checkMimeTypeForFilter(filter, "audio/*")); - g_assert(checkMimeTypeForFilter(filter, "video/*")); - g_assert(checkMimeTypeForFilter(filter, "image/*")); - - selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest); - g_assert(!selectedFiles); - webkit_file_chooser_request_cancel(fileChooserRequest); -} - -class FullScreenClientTest: public WebViewTest { -public: - MAKE_GLIB_TEST_FIXTURE(FullScreenClientTest); - - enum FullScreenEvent { - None, - Enter, - Leave - }; - - static gboolean viewEnterFullScreenCallback(WebKitWebView*, FullScreenClientTest* test) - { - test->m_event = Enter; - g_main_loop_quit(test->m_mainLoop); - return FALSE; - } - - static gboolean viewLeaveFullScreenCallback(WebKitWebView*, FullScreenClientTest* test) - { - test->m_event = Leave; - g_main_loop_quit(test->m_mainLoop); - return FALSE; - } - - FullScreenClientTest() - : m_event(None) - { - webkit_settings_set_enable_fullscreen(webkit_web_view_get_settings(m_webView), TRUE); - g_signal_connect(m_webView, "enter-fullscreen", G_CALLBACK(viewEnterFullScreenCallback), this); - g_signal_connect(m_webView, "leave-fullscreen", G_CALLBACK(viewLeaveFullScreenCallback), this); - } - - ~FullScreenClientTest() - { - g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); - } - - void requestFullScreenAndWaitUntilEnteredFullScreen() - { - m_event = None; - webkit_web_view_run_javascript(m_webView, "document.documentElement.webkitRequestFullScreen();", 0, 0, 0); - g_main_loop_run(m_mainLoop); - } - - static gboolean leaveFullScreenIdle(FullScreenClientTest* test) - { - test->keyStroke(GDK_KEY_Escape); - return FALSE; - } - - void leaveFullScreenAndWaitUntilLeftFullScreen() - { - m_event = None; - g_idle_add(reinterpret_cast<GSourceFunc>(leaveFullScreenIdle), this); - g_main_loop_run(m_mainLoop); - } - - FullScreenEvent m_event; -}; - -static void testWebViewFullScreen(FullScreenClientTest* test, gconstpointer) -{ - test->showInWindowAndWaitUntilMapped(); - test->loadHtml("<html><body>FullScreen test</body></html>", 0); - test->waitUntilLoadFinished(); - test->requestFullScreenAndWaitUntilEnteredFullScreen(); - g_assert_cmpint(test->m_event, ==, FullScreenClientTest::Enter); - test->leaveFullScreenAndWaitUntilLeftFullScreen(); - g_assert_cmpint(test->m_event, ==, FullScreenClientTest::Leave); -} - -static void testWebViewCanShowMIMEType(WebViewTest* test, gconstpointer) -{ - // Supported MIME types. - g_assert(webkit_web_view_can_show_mime_type(test->m_webView, "text/html")); - g_assert(webkit_web_view_can_show_mime_type(test->m_webView, "text/plain")); - g_assert(webkit_web_view_can_show_mime_type(test->m_webView, "image/jpeg")); - - // Unsupported MIME types. - g_assert(!webkit_web_view_can_show_mime_type(test->m_webView, "text/vcard")); - g_assert(!webkit_web_view_can_show_mime_type(test->m_webView, "application/pdf")); - g_assert(!webkit_web_view_can_show_mime_type(test->m_webView, "application/zip")); - g_assert(!webkit_web_view_can_show_mime_type(test->m_webView, "application/octet-stream")); - - // Plugins are only supported when enabled. - webkit_web_context_set_additional_plugins_directory(webkit_web_view_get_context(test->m_webView), WEBKIT_TEST_PLUGIN_DIR); - g_assert(webkit_web_view_can_show_mime_type(test->m_webView, "application/x-webkit-test-netscape")); - webkit_settings_set_enable_plugins(webkit_web_view_get_settings(test->m_webView), FALSE); - g_assert(!webkit_web_view_can_show_mime_type(test->m_webView, "application/x-webkit-test-netscape")); -} - -class FormClientTest: public WebViewTest { -public: - MAKE_GLIB_TEST_FIXTURE(FormClientTest); - - static void submitFormCallback(WebKitWebView*, WebKitFormSubmissionRequest* request, FormClientTest* test) - { - test->submitForm(request); - } - - FormClientTest() - : m_submitPositionX(0) - , m_submitPositionY(0) - { - g_signal_connect(m_webView, "submit-form", G_CALLBACK(submitFormCallback), this); - } - - ~FormClientTest() - { - g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); - } - - void submitForm(WebKitFormSubmissionRequest* request) - { - assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request)); - m_request = request; - webkit_form_submission_request_submit(request); - quitMainLoop(); - } - - GHashTable* waitUntilFormSubmittedAndGetTextFields() - { - g_main_loop_run(m_mainLoop); - return webkit_form_submission_request_get_text_fields(m_request.get()); - } - - static gboolean doClickIdleCallback(FormClientTest* test) - { - test->clickMouseButton(test->m_submitPositionX, test->m_submitPositionY, 1); - return FALSE; - } - - void submitFormAtPosition(int x, int y) - { - m_submitPositionX = x; - m_submitPositionY = y; - g_idle_add(reinterpret_cast<GSourceFunc>(doClickIdleCallback), this); - } - - int m_submitPositionX; - int m_submitPositionY; - GRefPtr<WebKitFormSubmissionRequest> m_request; -}; - -static void testWebViewSubmitForm(FormClientTest* test, gconstpointer) -{ - test->showInWindowAndWaitUntilMapped(); - - const char* formHTML = - "<html><body>" - " <form action='#'>" - " <input type='text' name='text1' value='value1'>" - " <input type='text' name='text2' value='value2'>" - " <input type='password' name='password' value='secret'>" - " <textarea cols='5' rows='5' name='textarea'>Text</textarea>" - " <input type='hidden' name='hidden1' value='hidden1'>" - " <input type='submit' value='Submit' style='position:absolute; left:1; top:1' size='10'>" - " </form>" - "</body></html>"; - - test->loadHtml(formHTML, "file:///"); - test->waitUntilLoadFinished(); - - test->submitFormAtPosition(5, 5); - GHashTable* values = test->waitUntilFormSubmittedAndGetTextFields(); - g_assert(values); - g_assert_cmpuint(g_hash_table_size(values), ==, 3); - g_assert_cmpstr(static_cast<char*>(g_hash_table_lookup(values, "text1")), ==, "value1"); - g_assert_cmpstr(static_cast<char*>(g_hash_table_lookup(values, "text2")), ==, "value2"); - g_assert_cmpstr(static_cast<char*>(g_hash_table_lookup(values, "password")), ==, "secret"); -} - -class SaveWebViewTest: public WebViewTest { -public: - MAKE_GLIB_TEST_FIXTURE(SaveWebViewTest); - - SaveWebViewTest() - : m_tempDirectory(g_dir_make_tmp("WebKit2SaveViewTest-XXXXXX", 0)) - { - } - - ~SaveWebViewTest() - { - if (G_IS_FILE(m_file.get())) - g_file_delete(m_file.get(), 0, 0); - - if (G_IS_INPUT_STREAM(m_inputStream.get())) - g_input_stream_close(m_inputStream.get(), 0, 0); - - if (m_tempDirectory) - g_rmdir(m_tempDirectory.get()); - } - - static void webViewSavedToStreamCallback(GObject* object, GAsyncResult* result, SaveWebViewTest* test) - { - GOwnPtr<GError> error; - test->m_inputStream = adoptGRef(webkit_web_view_save_finish(test->m_webView, result, &error.outPtr())); - g_assert(G_IS_INPUT_STREAM(test->m_inputStream.get())); - g_assert(!error); - - test->quitMainLoop(); - } - - static void webViewSavedToFileCallback(GObject* object, GAsyncResult* result, SaveWebViewTest* test) - { - GOwnPtr<GError> error; - g_assert(webkit_web_view_save_to_file_finish(test->m_webView, result, &error.outPtr())); - g_assert(!error); - - test->quitMainLoop(); - } - - void saveAndWaitForStream() - { - webkit_web_view_save(m_webView, WEBKIT_SAVE_MODE_MHTML, 0, reinterpret_cast<GAsyncReadyCallback>(webViewSavedToStreamCallback), this); - g_main_loop_run(m_mainLoop); - } - - void saveAndWaitForFile() - { - m_saveDestinationFilePath.set(g_build_filename(m_tempDirectory.get(), "testWebViewSaveResult.mht", NULL)); - m_file = adoptGRef(g_file_new_for_path(m_saveDestinationFilePath.get())); - webkit_web_view_save_to_file(m_webView, m_file.get(), WEBKIT_SAVE_MODE_MHTML, 0, reinterpret_cast<GAsyncReadyCallback>(webViewSavedToFileCallback), this); - g_main_loop_run(m_mainLoop); - } - - GOwnPtr<char> m_tempDirectory; - GOwnPtr<char> m_saveDestinationFilePath; - GRefPtr<GInputStream> m_inputStream; - GRefPtr<GFile> m_file; -}; - -static void testWebViewSave(SaveWebViewTest* test, gconstpointer) -{ - test->loadHtml("<html>" - "<body>" - " <p>A paragraph with plain text</p>" - " <p>" - " A red box: <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3AYWDTMVwnSZnwAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAFklEQVQI12P8z8DAwMDAxMDAwMDAAAANHQEDK+mmyAAAAABJRU5ErkJggg=='></br>" - " A blue box: <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3AYWDTMvBHhALQAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAFklEQVQI12Nk4PnPwMDAxMDAwMDAAAALrwEPPIs1pgAAAABJRU5ErkJggg=='>" - " </p>" - "</body>" - "</html>", 0); - test->waitUntilLoadFinished(); - - // Write to a file and to an input stream. - test->saveAndWaitForFile(); - test->saveAndWaitForStream(); - - // We should have exactly the same amount of bytes in the file - // than those coming from the GInputStream. We don't compare the - // strings read since the 'Date' field and the boundaries will be - // different on each case. MHTML functionality will be tested by - // Layout tests, so checking the amount of bytes is enough. - GOwnPtr<GError> error; - gchar buffer[512] = { 0 }; - gssize readBytes = 0; - gssize totalBytesFromStream = 0; - while (readBytes = g_input_stream_read(test->m_inputStream.get(), &buffer, 512, 0, &error.outPtr())) { - g_assert(!error); - totalBytesFromStream += readBytes; - } - - // Check that the file exists and that it contains the same amount of bytes. - GRefPtr<GFileInfo> fileInfo = adoptGRef(g_file_query_info(test->m_file.get(), G_FILE_ATTRIBUTE_STANDARD_SIZE, static_cast<GFileQueryInfoFlags>(0), 0, 0)); - g_assert_cmpint(g_file_info_get_size(fileInfo.get()), ==, totalBytesFromStream); -} - -static void testWebViewMode(WebViewTest* test, gconstpointer) -{ - static const char* indexHTML = "<html><body><p>Test Web View Mode</p></body></html>"; - - // Web mode. - g_assert_cmpuint(webkit_web_view_get_view_mode(test->m_webView), ==, WEBKIT_VIEW_MODE_WEB); - test->loadHtml(indexHTML, 0); - test->waitUntilLoadFinished(); - WebKitJavascriptResult* javascriptResult = test->runJavaScriptAndWaitUntilFinished("window.document.body.textContent;", 0); - GOwnPtr<char> valueString(WebViewTest::javascriptResultToCString(javascriptResult)); - g_assert_cmpstr(valueString.get(), ==, "Test Web View Mode"); - - // Source mode. - webkit_web_view_set_view_mode(test->m_webView, WEBKIT_VIEW_MODE_SOURCE); - test->loadHtml(indexHTML, 0); - test->waitUntilLoadFinished(); - javascriptResult = test->runJavaScriptAndWaitUntilFinished("window.document.body.textContent;", 0); - valueString.set(WebViewTest::javascriptResultToCString(javascriptResult)); - g_assert_cmpstr(valueString.get(), ==, indexHTML); -} - -// To test page visibility API. Currently only 'visible' and 'hidden' states are implemented fully in WebCore. -// See also http://www.w3.org/TR/2011/WD-page-visibility-20110602/ and https://developers.google.com/chrome/whitepapers/pagevisibility -static void testWebViewPageVisibility(WebViewTest* test, gconstpointer) -{ - test->loadHtml("<html><title></title>" - "<body><p>Test Web Page Visibility</p>" - "<script>" - "document.addEventListener(\"webkitvisibilitychange\", onVisibilityChange, false);" - "function onVisibilityChange() {" - " document.title = document.webkitVisibilityState;" - "}" - "</script>" - "</body></html>", - 0); - - // Wait untill the page is loaded. Initial visibility should be 'hidden'. - test->waitUntilLoadFinished(); - - GOwnPtr<GError> error; - WebKitJavascriptResult* javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.webkitVisibilityState;", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - GOwnPtr<char> valueString(WebViewTest::javascriptResultToCString(javascriptResult)); - g_assert_cmpstr(valueString.get(), ==, "hidden"); - - javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.webkitHidden;", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - g_assert(WebViewTest::javascriptResultToBoolean(javascriptResult)); - - // Show the page. The visibility should be updated to 'visible'. - test->showInWindow(); - test->waitUntilTitleChanged(); - - javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.webkitVisibilityState;", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - valueString.set(WebViewTest::javascriptResultToCString(javascriptResult)); - g_assert_cmpstr(valueString.get(), ==, "visible"); - - javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.webkitHidden;", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - g_assert(!WebViewTest::javascriptResultToBoolean(javascriptResult)); - - // Hide the page. The visibility should be updated to 'hidden'. - gtk_widget_hide(GTK_WIDGET(test->m_webView)); - test->waitUntilTitleChanged(); - - javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.webkitVisibilityState;", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - valueString.set(WebViewTest::javascriptResultToCString(javascriptResult)); - g_assert_cmpstr(valueString.get(), ==, "hidden"); - - javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.webkitHidden;", &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - g_assert(WebViewTest::javascriptResultToBoolean(javascriptResult)); -} - -class SnapshotWebViewTest: public WebViewTest { -public: - MAKE_GLIB_TEST_FIXTURE(SnapshotWebViewTest); - - static void onSnapshotCancelledReady(WebKitWebView* web_view, GAsyncResult* res, SnapshotWebViewTest* test) - { - GOwnPtr<GError> error; - test->m_surface = webkit_web_view_get_snapshot_finish(web_view, res, &error.outPtr()); - g_assert(!test->m_surface); - g_assert_error(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED); - test->quitMainLoop(); - } - - gboolean getSnapshotAndCancel() - { - if (m_surface) - cairo_surface_destroy(m_surface); - m_surface = 0; - GRefPtr<GCancellable> cancellable = adoptGRef(g_cancellable_new()); - webkit_web_view_get_snapshot(m_webView, WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE, cancellable.get(), reinterpret_cast<GAsyncReadyCallback>(onSnapshotCancelledReady), this); - g_cancellable_cancel(cancellable.get()); - g_main_loop_run(m_mainLoop); - - return true; - } - -}; - -static void testWebViewSnapshot(SnapshotWebViewTest* test, gconstpointer) -{ - test->loadHtml("<html><body><p>Whatever</p></body></html>", 0); - test->waitUntilLoadFinished(); - - // WebView not visible. - cairo_surface_t* surface1 = test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE); - g_assert(!surface1); - - // Show surface, resize to 50x50, try again. - test->showInWindowAndWaitUntilMapped(); - test->resizeView(50, 50); - surface1 = test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE); - g_assert(surface1); - - // obtained surface should be at the most 50x50. Store the size - // for comparison later. - int width = cairo_image_surface_get_width(surface1); - int height = cairo_image_surface_get_height(surface1); - g_assert_cmpint(width, <=, 50); - g_assert_cmpint(height, <=, 50); - - // Select all text in the WebView, request a snapshot ignoring selection. - test->selectAll(); - surface1 = cairo_surface_reference(test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE)); - g_assert(surface1); - g_assert_cmpint(cairo_image_surface_get_width(surface1), ==, width); - g_assert_cmpint(cairo_image_surface_get_height(surface1), ==, height); - - // Create identical surface. - cairo_surface_t* surface2 = test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE); - g_assert(surface2); - - // Compare these two, they should be identical. - g_assert(Test::cairoSurfacesEqual(surface1, surface2)); - - // Request a new snapshot, including the selection this time. The - // size should be the same but the result must be different to the - // one previously obtained. - surface2 = test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_INCLUDE_SELECTION_HIGHLIGHTING); - g_assert(surface2); - g_assert_cmpint(cairo_image_surface_get_width(surface2), ==, width); - g_assert_cmpint(cairo_image_surface_get_height(surface2), ==, height); - g_assert(!Test::cairoSurfacesEqual(surface1, surface2)); - - // Request a snapshot of the whole document in the WebView. The - // result should be different from the size obtained previously. - surface2 = test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT, WEBKIT_SNAPSHOT_OPTIONS_NONE); - g_assert(surface2); - g_assert_cmpint(cairo_image_surface_get_width(surface2), >, width); - g_assert_cmpint(cairo_image_surface_get_height(surface2), >, height); - g_assert(!Test::cairoSurfacesEqual(surface1, surface2)); - - cairo_surface_destroy(surface1); - - g_assert(test->getSnapshotAndCancel()); -} - -void beforeAll() -{ - WebViewTest::add("WebKitWebView", "default-context", testWebViewDefaultContext); - WebViewTest::add("WebKitWebView", "custom-charset", testWebViewCustomCharset); - WebViewTest::add("WebKitWebView", "settings", testWebViewSettings); - UIClientTest::add("WebKitWebView", "create-ready-close", testWebViewCreateReadyClose); - ModalDialogsTest::add("WebKitWebView", "allow-modal-dialogs", testWebViewAllowModalDialogs); - ModalDialogsTest::add("WebKitWebView", "disallow-modal-dialogs", testWebViewDisallowModalDialogs); - UIClientTest::add("WebKitWebView", "javascript-dialogs", testWebViewJavaScriptDialogs); - UIClientTest::add("WebKitWebView", "window-properties", testWebViewWindowProperties); - UIClientTest::add("WebKitWebView", "mouse-target", testWebViewMouseTarget); - UIClientTest::add("WebKitWebView", "permission-requests", testWebViewPermissionRequests); - WebViewTest::add("WebKitWebView", "zoom-level", testWebViewZoomLevel); - WebViewTest::add("WebKitWebView", "run-javascript", testWebViewRunJavaScript); - FileChooserTest::add("WebKitWebView", "file-chooser-request", testWebViewFileChooserRequest); - FullScreenClientTest::add("WebKitWebView", "fullscreen", testWebViewFullScreen); - WebViewTest::add("WebKitWebView", "can-show-mime-type", testWebViewCanShowMIMEType); - FormClientTest::add("WebKitWebView", "submit-form", testWebViewSubmitForm); - SaveWebViewTest::add("WebKitWebView", "save", testWebViewSave); - WebViewTest::add("WebKitWebView", "view-mode", testWebViewMode); - SnapshotWebViewTest::add("WebKitWebView", "snapshot", testWebViewSnapshot); - WebViewTest::add("WebKitWebView", "page-visibility", testWebViewPageVisibility); -} - -void afterAll() -{ -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebViewGroup.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebViewGroup.cpp deleted file mode 100644 index 026c5c5b9..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebViewGroup.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (C) 2013 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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 "WebKitTestServer.h" -#include "WebViewTest.h" -#include <cstdarg> -#include <gtk/gtk.h> -#include <webkit2/webkit2.h> -#include <wtf/gobject/GRefPtr.h> - -static WebKitTestServer* kServer; - -// These are all here so that they can be changed easily, if necessary. -static const char* kStyleSheetHTML = "<html><div id=\"styledElement\">Sweet stylez!</div></html>"; -static const char* kInjectedStyleSheet = "#styledElement { font-weight: bold; }"; -static const char* kStyleSheetTestScript = "getComputedStyle(document.getElementById('styledElement'))['font-weight']"; -static const char* kStyleSheetTestScriptResult = "bold"; - -static void testWebViewGroupDefault(Test* test, gconstpointer) -{ - // Default group is shared by all WebViews by default. - GRefPtr<WebKitWebView> webView1 = WEBKIT_WEB_VIEW(webkit_web_view_new()); - GRefPtr<WebKitWebView> webView2 = WEBKIT_WEB_VIEW(webkit_web_view_new()); - g_assert(webkit_web_view_get_group(webView1.get()) == webkit_web_view_get_group(webView2.get())); - - // Settings are shared by all web view in the same group. - g_assert(webkit_web_view_get_settings(webView1.get()) == webkit_web_view_get_settings(webView2.get())); - g_assert(webkit_web_view_get_settings(webView1.get()) == webkit_web_view_group_get_settings(webkit_web_view_get_group(webView2.get()))); -} - -static void testWebViewGroupNewGroup(Test* test, gconstpointer) -{ - // Passing 0 as group name generates the name automatically. - GRefPtr<WebKitWebViewGroup> viewGroup1 = adoptGRef(webkit_web_view_group_new(0)); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(viewGroup1.get())); - g_assert(webkit_web_view_group_get_name(viewGroup1.get())); - - // New group with a given name. - GRefPtr<WebKitWebViewGroup> viewGroup2 = adoptGRef(webkit_web_view_group_new("TestGroup2")); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(viewGroup2.get())); - g_assert_cmpstr(webkit_web_view_group_get_name(viewGroup2.get()), ==, "TestGroup2"); - g_assert_cmpstr(webkit_web_view_group_get_name(viewGroup2.get()), !=, webkit_web_view_group_get_name(viewGroup1.get())); - - // Every group has its own settings. - g_assert(webkit_web_view_group_get_settings(viewGroup1.get()) != webkit_web_view_group_get_settings(viewGroup2.get())); -} - -static void testWebViewNewWithGroup(Test* test, gconstpointer) -{ - GRefPtr<WebKitWebViewGroup> viewGroup1 = adoptGRef(webkit_web_view_group_new("TestGroup1")); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(viewGroup1.get())); - GRefPtr<WebKitWebView> webView1 = WEBKIT_WEB_VIEW(webkit_web_view_new_with_group(viewGroup1.get())); - g_assert(webkit_web_view_get_group(webView1.get()) == viewGroup1.get()); - - GRefPtr<WebKitWebView> webView2 = WEBKIT_WEB_VIEW(webkit_web_view_new()); - g_assert(webkit_web_view_get_group(webView2.get()) != viewGroup1.get()); - - // Settings should be different for views in different groups. - g_assert(webkit_web_view_get_settings(webView1.get()) != webkit_web_view_get_settings(webView2.get())); -} - -static void testWebViewGroupSettings(Test* test, gconstpointer) -{ - GRefPtr<WebKitWebViewGroup> viewGroup1 = adoptGRef(webkit_web_view_group_new("TestGroup1")); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(viewGroup1.get())); - GRefPtr<WebKitSettings> newSettings = adoptGRef(webkit_settings_new_with_settings("enable-javascript", FALSE, NULL)); - test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(newSettings.get())); - webkit_web_view_group_set_settings(viewGroup1.get(), newSettings.get()); - g_assert(webkit_web_view_group_get_settings(viewGroup1.get()) == newSettings.get()); - - GRefPtr<WebKitWebView> webView1 = WEBKIT_WEB_VIEW(webkit_web_view_new_with_group(viewGroup1.get())); - GRefPtr<WebKitWebView> webView2 = WEBKIT_WEB_VIEW(webkit_web_view_new()); - WebKitSettings* webView1Settings = webkit_web_view_get_settings(webView1.get()); - WebKitSettings* webView2Settings = webkit_web_view_get_settings(webView2.get()); - g_assert(webView1Settings != webView2Settings); - g_assert(webkit_settings_get_enable_javascript(webView1Settings) != webkit_settings_get_enable_javascript(webView2Settings)); - - webkit_web_view_set_settings(webView1.get(), webView2Settings); - g_assert(webkit_web_view_get_settings(webView1.get()) == webView2Settings); - g_assert(webkit_web_view_group_get_settings(webkit_web_view_get_group(webView1.get())) == webView2Settings); -} - -static bool isStyleSheetInjectedForURLAtPath(WebViewTest* test, const char* path) -{ - test->loadURI(kServer->getURIForPath(path).data()); - test->waitUntilLoadFinished(); - - GOwnPtr<GError> error; - WebKitJavascriptResult* javascriptResult = test->runJavaScriptAndWaitUntilFinished(kStyleSheetTestScript, &error.outPtr()); - g_assert(javascriptResult); - g_assert(!error.get()); - - GOwnPtr<char> resultString(WebViewTest::javascriptResultToCString(javascriptResult)); - return !g_strcmp0(resultString.get(), kStyleSheetTestScriptResult); -} - -static void fillURLListFromPaths(char** list, const char* path, ...) -{ - va_list argumentList; - va_start(argumentList, path); - - int i = 0; - while (path) { - // FIXME: We must use a wildcard for the host here until http://wkbug.com/112476 is fixed. - // Until that time patterns with port numbers in them will not properly match URLs with port numbers. - list[i++] = g_strdup_printf("http://*/%s*", path); - path = va_arg(argumentList, const char*); - } -} - -static void removeOldInjectedStyleSheetsAndResetLists(WebKitWebViewGroup* group, char** whitelist, char** blacklist) -{ - webkit_web_view_group_remove_all_user_style_sheets(group); - - while (*whitelist) { - g_free(*whitelist); - *whitelist = 0; - whitelist++; - } - - while (*blacklist) { - g_free(*blacklist); - *blacklist = 0; - blacklist++; - } -} - -static void testWebViewGroupInjectedStyleSheet(WebViewTest* test, gconstpointer) -{ - WebKitWebViewGroup* group = webkit_web_view_get_group(test->m_webView); - char* whitelist[3] = { 0, 0, 0 }; - char* blacklist[3] = { 0, 0, 0 }; - - removeOldInjectedStyleSheetsAndResetLists(group, whitelist, blacklist); - - // Without a whitelist or a blacklist all URLs should have the injected style sheet. - static const char* randomPath = "somerandompath"; - g_assert(!isStyleSheetInjectedForURLAtPath(test, randomPath)); - webkit_web_view_group_add_user_style_sheet(group, kInjectedStyleSheet, 0, 0, 0, WEBKIT_INJECTED_CONTENT_FRAMES_ALL); - g_assert(isStyleSheetInjectedForURLAtPath(test, randomPath)); - - removeOldInjectedStyleSheetsAndResetLists(group, whitelist, blacklist); - - fillURLListFromPaths(blacklist, randomPath, 0); - webkit_web_view_group_add_user_style_sheet(group, kInjectedStyleSheet, 0, 0, blacklist, WEBKIT_INJECTED_CONTENT_FRAMES_ALL); - g_assert(!isStyleSheetInjectedForURLAtPath(test, randomPath)); - g_assert(isStyleSheetInjectedForURLAtPath(test, "someotherrandompath")); - - removeOldInjectedStyleSheetsAndResetLists(group, whitelist, blacklist); - - static const char* inTheWhiteList = "inthewhitelist"; - static const char* notInWhitelist = "notinthewhitelist"; - static const char* inTheWhiteListAndBlackList = "inthewhitelistandblacklist"; - - fillURLListFromPaths(whitelist, inTheWhiteList, inTheWhiteListAndBlackList, 0); - fillURLListFromPaths(blacklist, inTheWhiteListAndBlackList, 0); - webkit_web_view_group_add_user_style_sheet(group, kInjectedStyleSheet, 0, whitelist, blacklist, WEBKIT_INJECTED_CONTENT_FRAMES_ALL); - g_assert(isStyleSheetInjectedForURLAtPath(test, inTheWhiteList)); - g_assert(!isStyleSheetInjectedForURLAtPath(test, inTheWhiteListAndBlackList)); - g_assert(!isStyleSheetInjectedForURLAtPath(test, notInWhitelist)); - - // It's important to clean up the environment before other tests. - removeOldInjectedStyleSheetsAndResetLists(group, whitelist, blacklist); -} - -static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer) -{ - soup_message_set_status(message, SOUP_STATUS_OK); - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, kStyleSheetHTML, strlen(kStyleSheetHTML)); - soup_message_body_complete(message->response_body); -} - -void beforeAll() -{ - kServer = new WebKitTestServer(); - kServer->run(serverCallback); - - Test::add("WebKitWebViewGroup", "default-group", testWebViewGroupDefault); - Test::add("WebKitWebViewGroup", "new-group", testWebViewGroupNewGroup); - Test::add("WebKitWebView", "new-with-group", testWebViewNewWithGroup); - Test::add("WebKitWebViewGroup", "settings", testWebViewGroupSettings); - WebViewTest::add("WebKitWebViewGroup", "injected-style-sheet", testWebViewGroupInjectedStyleSheet); -} - -void afterAll() -{ - delete kServer; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebViewEditor.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebViewEditor.cpp deleted file mode 100644 index 93315db68..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebViewEditor.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2,1 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 "WebViewTest.h" -#include <wtf/gobject/GRefPtr.h> - -class EditorTest: public WebViewTest { -public: - MAKE_GLIB_TEST_FIXTURE(EditorTest); - - static const unsigned int kClipboardWaitTimeout = 50; - static const unsigned int kClipboardWaitMaxTries = 2; - - EditorTest() - : m_clipboard(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD)) - , m_canExecuteEditingCommand(false) - , m_triesCount(0) - { - gtk_clipboard_clear(m_clipboard); - } - - static void canExecuteEditingCommandReadyCallback(GObject*, GAsyncResult* result, EditorTest* test) - { - GOwnPtr<GError> error; - test->m_canExecuteEditingCommand = webkit_web_view_can_execute_editing_command_finish(test->m_webView, result, &error.outPtr()); - g_assert(!error.get()); - g_main_loop_quit(test->m_mainLoop); - } - - bool canExecuteEditingCommand(const char* command) - { - m_canExecuteEditingCommand = false; - webkit_web_view_can_execute_editing_command(m_webView, command, 0, reinterpret_cast<GAsyncReadyCallback>(canExecuteEditingCommandReadyCallback), this); - g_main_loop_run(m_mainLoop); - return m_canExecuteEditingCommand; - } - - static gboolean waitForClipboardText(EditorTest* test) - { - test->m_triesCount++; - if (gtk_clipboard_wait_is_text_available(test->m_clipboard) || test->m_triesCount > kClipboardWaitMaxTries) { - g_main_loop_quit(test->m_mainLoop); - return FALSE; - } - - return TRUE; - } - - void copyClipboard() - { - webkit_web_view_execute_editing_command(m_webView, WEBKIT_EDITING_COMMAND_COPY); - // There's no way to know when the selection has been copied to - // the clipboard, so use a timeout source to query the clipboard. - m_triesCount = 0; - g_timeout_add(kClipboardWaitTimeout, reinterpret_cast<GSourceFunc>(waitForClipboardText), this); - g_main_loop_run(m_mainLoop); - } - - GtkClipboard* m_clipboard; - bool m_canExecuteEditingCommand; - size_t m_triesCount; -}; - -static void testWebViewEditorCutCopyPasteNonEditable(EditorTest* test, gconstpointer) -{ - static const char* selectedSpanHTML = "<html><body contentEditable=\"false\">" - "<span id=\"mainspan\">All work and no play <span id=\"subspan\">make Jack a dull</span> boy.</span>" - "<script>document.getSelection().collapse();\n" - "document.getSelection().selectAllChildren(document.getElementById('subspan'));\n" - "</script></body></html>"; - - // Nothing loaded yet. - g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT)); - g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_COPY)); - g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE)); - - test->loadHtml(selectedSpanHTML, 0); - test->waitUntilLoadFinished(); - - g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_COPY)); - // It's not possible to cut and paste when content is not editable - // even if there's a selection. - g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT)); - g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE)); - - test->copyClipboard(); - GOwnPtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard)); - g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull"); -} - -static void testWebViewEditorCutCopyPasteEditable(EditorTest* test, gconstpointer) -{ - static const char* selectedSpanHTML = "<html><body contentEditable=\"true\">" - "<span id=\"mainspan\">All work and no play <span>make Jack a dull</span> boy.</span>" - "<script>document.getSelection().collapse();\n" - "document.getSelection().selectAllChildren(document.getElementById('mainspan'));\n" - "</script></body></html>"; - - // Nothing loaded yet. - g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT)); - g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_COPY)); - g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE)); - - test->loadHtml(selectedSpanHTML, 0); - test->waitUntilLoadFinished(); - - // There's a selection. - g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT)); - g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_COPY)); - g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE)); - - test->copyClipboard(); - GOwnPtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard)); - g_assert_cmpstr(clipboardText.get(), ==, "All work and no play make Jack a dull boy."); -} - -static void testWebViewEditorSelectAllNonEditable(EditorTest* test, gconstpointer) -{ - static const char* selectedSpanHTML = "<html><body contentEditable=\"false\">" - "<span id=\"mainspan\">All work and no play <span id=\"subspan\">make Jack a dull</span> boy.</span>" - "<script>document.getSelection().collapse();\n" - "document.getSelection().selectAllChildren(document.getElementById('subspan'));\n" - "</script></body></html>"; - - g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL)); - - test->loadHtml(selectedSpanHTML, 0); - test->waitUntilLoadFinished(); - - g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL)); - - test->copyClipboard(); - GOwnPtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard)); - - // Initially only the subspan is selected. - g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull"); - - webkit_web_view_execute_editing_command(test->m_webView, WEBKIT_EDITING_COMMAND_SELECT_ALL); - test->copyClipboard(); - clipboardText.set(gtk_clipboard_wait_for_text(test->m_clipboard)); - - // The mainspan should be selected after calling SELECT_ALL. - g_assert_cmpstr(clipboardText.get(), ==, "All work and no play make Jack a dull boy."); -} - -static void testWebViewEditorSelectAllEditable(EditorTest* test, gconstpointer) -{ - static const char* selectedSpanHTML = "<html><body contentEditable=\"true\">" - "<span id=\"mainspan\">All work and no play <span id=\"subspan\">make Jack a dull</span> boy.</span>" - "<script>document.getSelection().collapse();\n" - "document.getSelection().selectAllChildren(document.getElementById('subspan'));\n" - "</script></body></html>"; - - g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL)); - - test->loadHtml(selectedSpanHTML, 0); - test->waitUntilLoadFinished(); - - g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL)); - - test->copyClipboard(); - GOwnPtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard)); - - // Initially only the subspan is selected. - g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull"); - - webkit_web_view_execute_editing_command(test->m_webView, WEBKIT_EDITING_COMMAND_SELECT_ALL); - test->copyClipboard(); - clipboardText.set(gtk_clipboard_wait_for_text(test->m_clipboard)); - - // The mainspan should be selected after calling SELECT_ALL. - g_assert_cmpstr(clipboardText.get(), ==, "All work and no play make Jack a dull boy."); -} - -void beforeAll() -{ - EditorTest::add("WebKitWebView", "cut-copy-paste/non-editable", testWebViewEditorCutCopyPasteNonEditable); - EditorTest::add("WebKitWebView", "cut-copy-paste/editable", testWebViewEditorCutCopyPasteEditable); - EditorTest::add("WebKitWebView", "select-all/non-editable", testWebViewEditorSelectAllNonEditable); - EditorTest::add("WebKitWebView", "select-all/editable", testWebViewEditorSelectAllEditable); -} - -void afterAll() -{ -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebExtensionTest.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/WebExtensionTest.cpp deleted file mode 100644 index 692663e33..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/WebExtensionTest.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 <gio/gio.h> -#include <stdlib.h> -#include <string.h> - -#include <webkit2/webkit-web-extension.h> -#include <wtf/gobject/GOwnPtr.h> - -static const char introspectionXML[] = - "<node>" - " <interface name='org.webkit.gtk.WebExtensionTest'>" - " <method name='GetTitle'>" - " <arg type='t' name='pageID' direction='in'/>" - " <arg type='s' name='title' direction='out'/>" - " </method>" - " <method name='AbortProcess'>" - " </method>" - " <signal name='DocumentLoaded'/>" - " <signal name='URIChanged'>" - " <arg type='s' name='uri' direction='out'/>" - " </signal>" - " </interface>" - "</node>"; - -static void documentLoadedCallback(WebKitWebPage*, gpointer userData) -{ - bool ok = g_dbus_connection_emit_signal(G_DBUS_CONNECTION(userData), - 0, - "/org/webkit/gtk/WebExtensionTest", - "org.webkit.gtk.WebExtensionTest", - "DocumentLoaded", - 0, - 0); - g_assert(ok); -} - -static void uriChangedCallback(WebKitWebPage* webPage, GParamSpec* pspec, gpointer userData) -{ - bool ok = g_dbus_connection_emit_signal( - G_DBUS_CONNECTION(userData), - 0, - "/org/webkit/gtk/WebExtensionTest", - "org.webkit.gtk.WebExtensionTest", - "URIChanged", - g_variant_new("(s)", webkit_web_page_get_uri(webPage)), - 0); - g_assert(ok); -} - -static gboolean sendRequestCallback(WebKitWebPage*, WebKitURIRequest* request, WebKitURIResponse*, gpointer) -{ - const char* requestURI = webkit_uri_request_get_uri(request); - g_assert(requestURI); - - if (const char* suffix = g_strrstr(requestURI, "/remove-this/javascript.js")) { - GOwnPtr<char> prefix(g_strndup(requestURI, strlen(requestURI) - strlen(suffix))); - GOwnPtr<char> newURI(g_strdup_printf("%s/javascript.js", prefix.get())); - webkit_uri_request_set_uri(request, newURI.get()); - } else if (g_str_has_suffix(requestURI, "/add-do-not-track-header")) { - SoupMessageHeaders* headers = webkit_uri_request_get_http_headers(request); - g_assert(headers); - soup_message_headers_append(headers, "DNT", "1"); - } else if (g_str_has_suffix(requestURI, "/cancel-this.js")) - return TRUE; - - return FALSE; -} - -static void pageCreatedCallback(WebKitWebExtension*, WebKitWebPage* webPage, gpointer userData) -{ - g_signal_connect(webPage, "document-loaded", G_CALLBACK(documentLoadedCallback), userData); - g_signal_connect(webPage, "notify::uri", G_CALLBACK(uriChangedCallback), userData); - g_signal_connect(webPage, "send-request", G_CALLBACK(sendRequestCallback), 0); -} - -static void methodCallCallback(GDBusConnection* connection, const char* sender, const char* objectPath, const char* interfaceName, const char* methodName, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer userData) -{ - if (g_strcmp0(interfaceName, "org.webkit.gtk.WebExtensionTest")) - return; - - if (!g_strcmp0(methodName, "GetTitle")) { - uint64_t pageID; - g_variant_get(parameters, "(t)", &pageID); - - WebKitWebExtension* extension = WEBKIT_WEB_EXTENSION(userData); - WebKitWebPage* page = webkit_web_extension_get_page(extension, pageID); - if (!page) { - g_dbus_method_invocation_return_error( - invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, - "Invalid page ID: %" G_GUINT64_FORMAT, pageID); - return; - } - g_assert_cmpuint(webkit_web_page_get_id(page), ==, pageID); - - WebKitDOMDocument* document = webkit_web_page_get_dom_document(page); - GOwnPtr<char> title(webkit_dom_document_get_title(document)); - g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", title.get())); - } else if (!g_strcmp0(methodName, "AbortProcess")) { - abort(); - } -} - -static const GDBusInterfaceVTable interfaceVirtualTable = { - methodCallCallback, 0, 0, { 0, } -}; - -static void busAcquiredCallback(GDBusConnection* connection, const char* name, gpointer userData) -{ - static GDBusNodeInfo *introspectionData = 0; - if (!introspectionData) - introspectionData = g_dbus_node_info_new_for_xml(introspectionXML, 0); - - GOwnPtr<GError> error; - unsigned registrationID = g_dbus_connection_register_object( - connection, - "/org/webkit/gtk/WebExtensionTest", - introspectionData->interfaces[0], - &interfaceVirtualTable, - g_object_ref(userData), - static_cast<GDestroyNotify>(g_object_unref), - &error.outPtr()); - if (!registrationID) - g_warning("Failed to register object: %s\n", error->message); - - g_signal_connect(WEBKIT_WEB_EXTENSION(userData), "page-created", G_CALLBACK(pageCreatedCallback), connection); -} - -extern "C" void webkit_web_extension_initialize(WebKitWebExtension* extension) -{ - g_bus_own_name( - G_BUS_TYPE_SESSION, - "org.webkit.gtk.WebExtensionTest", - G_BUS_NAME_OWNER_FLAGS_NONE, - busAcquiredCallback, - 0, 0, - g_object_ref(extension), - static_cast<GDestroyNotify>(g_object_unref)); -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.cpp deleted file mode 100644 index 8c2d3f638..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 "WebKitTestBus.h" - -#include <wtf/gobject/GOwnPtr.h> -#include <wtf/text/WTFString.h> - -WebKitTestBus::WebKitTestBus() - : m_pid(-1) -{ -} - -bool WebKitTestBus::run() -{ - // FIXME: Use GTestDBus when we bump glib to 2.34. - GOwnPtr<char> dbusLaunch(g_find_program_in_path("dbus-launch")); - if (!dbusLaunch) { - g_warning("Error starting DBUS daemon: dbus-launch not found in path"); - return false; - } - - GOwnPtr<char> output; - GOwnPtr<GError> error; - if (!g_spawn_command_line_sync(dbusLaunch.get(), &output.outPtr(), 0, 0, &error.outPtr())) { - g_warning("Error starting DBUS daemon: %s", error->message); - return false; - } - - String outputString = String::fromUTF8(output.get()); - Vector<String> lines; - outputString.split(UChar('\n'), /* allowEmptyEntries */ false, lines); - for (size_t i = 0; i < lines.size(); ++i) { - char** keyValue = g_strsplit(lines[i].utf8().data(), "=", 2); - g_assert_cmpuint(g_strv_length(keyValue), ==, 2); - if (!g_strcmp0(keyValue[0], "DBUS_SESSION_BUS_ADDRESS")) { - m_address = keyValue[1]; - g_setenv("DBUS_SESSION_BUS_ADDRESS", keyValue[1], TRUE); - } else if (!g_strcmp0(keyValue[0], "DBUS_SESSION_BUS_PID")) - m_pid = g_ascii_strtoll(keyValue[1], 0, 10); - g_strfreev(keyValue); - } - - return m_pid > 0; -} - -WebKitTestBus::~WebKitTestBus() -{ - g_unsetenv("DBUS_SESSION_BUS_ADDRESS"); - - if (m_pid != -1) - kill(m_pid, SIGTERM); -} - -GDBusConnection* WebKitTestBus::getOrCreateConnection() -{ - if (m_connection) - return m_connection.get(); - - g_assert(!m_address.isNull()); - m_connection = adoptGRef(g_dbus_connection_new_for_address_sync(m_address.data(), - static_cast<GDBusConnectionFlags>(G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION), - 0, 0, 0)); - return m_connection.get(); -} - -static void onNameAppeared(GDBusConnection*, const char*, const char*, gpointer userData) -{ - g_main_loop_quit(static_cast<GMainLoop*>(userData)); -} - -GDBusProxy* WebKitTestBus::createProxy(const char* serviceName, const char* objectPath, const char* interfaceName, GMainLoop* mainLoop) -{ - unsigned watcherID = g_bus_watch_name_on_connection(getOrCreateConnection(), serviceName, G_BUS_NAME_WATCHER_FLAGS_NONE, onNameAppeared, 0, mainLoop, 0); - g_main_loop_run(mainLoop); - g_bus_unwatch_name(watcherID); - - GDBusProxy* proxy = g_dbus_proxy_new_sync( - connection(), - G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, - 0, // GDBusInterfaceInfo - serviceName, - objectPath, - interfaceName, - 0, // GCancellable - 0); - g_assert(proxy); - return proxy; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.h b/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.h deleted file mode 100644 index b9f856b27..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2012 Igalia S.L. - * - * 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 WebKitTestBus_h -#define WebKitTestBus_h - -#include <gio/gio.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -class WebKitTestBus { -public: - WebKitTestBus(); - virtual ~WebKitTestBus(); - - bool run(); - GDBusProxy* createProxy(const char* serviceName, const char* objectPath, const char* interfaceName, GMainLoop*); - GDBusConnection* connection() const { return m_connection.get(); } - -private: - GDBusConnection* getOrCreateConnection(); - - pid_t m_pid; - CString m_address; - GRefPtr<GDBusConnection> m_connection; -}; - -#endif // WebKitTestBus_h diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.cpp deleted file mode 100644 index 98b4a9a2b..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 "WebKitTestServer.h" - -#include "TestMain.h" -#include <wtf/gobject/GOwnPtr.h> - -WebKitTestServer::WebKitTestServer(ServerType type) -{ - GOwnPtr<char> sslCertificateFile; - GOwnPtr<char> sslKeyFile; - if (type == ServerHTTPS) { - CString resourcesDir = Test::getResourcesDir(); - sslCertificateFile.set(g_build_filename(resourcesDir.data(), "test-cert.pem", NULL)); - sslKeyFile.set(g_build_filename(resourcesDir.data(), "test-key.pem", NULL)); - } - - GRefPtr<SoupAddress> address = adoptGRef(soup_address_new("127.0.0.1", SOUP_ADDRESS_ANY_PORT)); - soup_address_resolve_sync(address.get(), 0); - - m_soupServer = adoptGRef(soup_server_new(SOUP_SERVER_INTERFACE, address.get(), - SOUP_SERVER_SSL_CERT_FILE, sslCertificateFile.get(), - SOUP_SERVER_SSL_KEY_FILE, sslKeyFile.get(), NULL)); - m_baseURI = type == ServerHTTPS ? soup_uri_new("https://127.0.0.1/") : soup_uri_new("http://127.0.0.1/"); - soup_uri_set_port(m_baseURI, soup_server_get_port(m_soupServer.get())); -} - -WebKitTestServer::~WebKitTestServer() -{ - soup_uri_free(m_baseURI); -} - -void WebKitTestServer::run(SoupServerCallback serverCallback) -{ - soup_server_run_async(m_soupServer.get()); - soup_server_add_handler(m_soupServer.get(), 0, serverCallback, 0, 0); -} - -CString WebKitTestServer::getURIForPath(const char* path) -{ - SoupURI* uri = soup_uri_new_with_base(m_baseURI, path); - GOwnPtr<gchar> uriString(soup_uri_to_string(uri, FALSE)); - soup_uri_free(uri); - return uriString.get(); -} - diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.h b/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.h deleted file mode 100644 index d4626f6b1..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * - * 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 WebKitTestServer_h -#define WebKitTestServer_h - -#include <libsoup/soup.h> -#include <webkit2/webkit2.h> -#include <wtf/gobject/GRefPtr.h> -#include <wtf/text/CString.h> - -class WebKitTestServer { -public: - - enum ServerType { - ServerHTTP, - ServerHTTPS - }; - - WebKitTestServer(ServerType type = ServerHTTP); - virtual ~WebKitTestServer(); - - SoupURI* baseURI() { return m_baseURI; } - - CString getURIForPath(const char* path); - void run(SoupServerCallback); - -private: - GRefPtr<SoupServer> m_soupServer; - SoupURI* m_baseURI; -}; - -#endif // WebKitTestServer_h diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp deleted file mode 100644 index e6c843456..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp +++ /dev/null @@ -1,444 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * Portions Copyright (c) 2011 Motorola Mobility, 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 "config.h" -#include "WebViewTest.h" - -#include <JavaScriptCore/JSRetainPtr.h> -#include <WebCore/GOwnPtrGtk.h> - -WebViewTest::WebViewTest() - : m_webView(WEBKIT_WEB_VIEW(g_object_ref_sink(webkit_web_view_new()))) - , m_mainLoop(g_main_loop_new(0, TRUE)) - , m_parentWindow(0) - , m_javascriptResult(0) - , m_resourceDataSize(0) - , m_surface(0) -{ - assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_webView)); -} - -WebViewTest::~WebViewTest() -{ - if (m_parentWindow) - gtk_widget_destroy(m_parentWindow); - if (m_javascriptResult) - webkit_javascript_result_unref(m_javascriptResult); - if (m_surface) - cairo_surface_destroy(m_surface); - g_object_unref(m_webView); - g_main_loop_unref(m_mainLoop); -} - -void WebViewTest::loadURI(const char* uri) -{ - m_activeURI = uri; - webkit_web_view_load_uri(m_webView, uri); -} - -void WebViewTest::loadHtml(const char* html, const char* baseURI) -{ - if (!baseURI) - m_activeURI = "about:blank"; - else - m_activeURI = baseURI; - webkit_web_view_load_html(m_webView, html, baseURI); -} - -void WebViewTest::loadPlainText(const char* plainText) -{ - m_activeURI = "about:blank"; - webkit_web_view_load_plain_text(m_webView, plainText); -} - -void WebViewTest::loadRequest(WebKitURIRequest* request) -{ - m_activeURI = webkit_uri_request_get_uri(request); - webkit_web_view_load_request(m_webView, request); -} - -void WebViewTest::loadAlternateHTML(const char* html, const char* contentURI, const char* baseURI) -{ - m_activeURI = contentURI; - webkit_web_view_load_alternate_html(m_webView, html, contentURI, baseURI); -} - -void WebViewTest::goBack() -{ - if (webkit_web_view_can_go_back(m_webView)) { - WebKitBackForwardList* list = webkit_web_view_get_back_forward_list(m_webView); - WebKitBackForwardListItem* item = webkit_back_forward_list_get_nth_item(list, -1); - m_activeURI = webkit_back_forward_list_item_get_original_uri(item); - } - - // Call go_back even when can_go_back returns FALSE to check nothing happens. - webkit_web_view_go_back(m_webView); -} - -void WebViewTest::goForward() -{ - if (webkit_web_view_can_go_forward(m_webView)) { - WebKitBackForwardList* list = webkit_web_view_get_back_forward_list(m_webView); - WebKitBackForwardListItem* item = webkit_back_forward_list_get_nth_item(list, 1); - m_activeURI = webkit_back_forward_list_item_get_original_uri(item); - } - - // Call go_forward even when can_go_forward returns FALSE to check nothing happens. - webkit_web_view_go_forward(m_webView); -} - -void WebViewTest::goToBackForwardListItem(WebKitBackForwardListItem* item) -{ - m_activeURI = webkit_back_forward_list_item_get_original_uri(item); - webkit_web_view_go_to_back_forward_list_item(m_webView, item); -} - -void WebViewTest::quitMainLoop() -{ - g_main_loop_quit(m_mainLoop); -} - -void WebViewTest::quitMainLoopAfterProcessingPendingEvents() -{ - while (gtk_events_pending()) - gtk_main_iteration(); - quitMainLoop(); -} - -static gboolean quitMainLoopIdleCallback(WebViewTest* test) -{ - test->quitMainLoop(); - return FALSE; -} - -void WebViewTest::wait(double seconds) -{ - g_timeout_add_seconds(seconds, reinterpret_cast<GSourceFunc>(quitMainLoopIdleCallback), this); - g_main_loop_run(m_mainLoop); -} - -static void loadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent, WebViewTest* test) -{ - if (loadEvent != WEBKIT_LOAD_FINISHED) - return; - g_signal_handlers_disconnect_by_func(webView, reinterpret_cast<void*>(loadChanged), test); - g_main_loop_quit(test->m_mainLoop); -} - -void WebViewTest::waitUntilLoadFinished() -{ - g_signal_connect(m_webView, "load-changed", G_CALLBACK(loadChanged), this); - g_main_loop_run(m_mainLoop); -} - -static void titleChanged(WebKitWebView* webView, GParamSpec*, WebViewTest* test) -{ - if (!test->m_expectedTitle.isNull() && test->m_expectedTitle != webkit_web_view_get_title(webView)) - return; - - g_signal_handlers_disconnect_by_func(webView, reinterpret_cast<void*>(titleChanged), test); - g_main_loop_quit(test->m_mainLoop); -} - -void WebViewTest::waitUntilTitleChangedTo(const char* expectedTitle) -{ - m_expectedTitle = expectedTitle; - g_signal_connect(m_webView, "notify::title", G_CALLBACK(titleChanged), this); - g_main_loop_run(m_mainLoop); - m_expectedTitle = CString(); -} - -void WebViewTest::waitUntilTitleChanged() -{ - waitUntilTitleChangedTo(0); -} - -static gboolean parentWindowMapped(GtkWidget* widget, GdkEvent*, WebViewTest* test) -{ - g_signal_handlers_disconnect_by_func(widget, reinterpret_cast<void*>(parentWindowMapped), test); - g_main_loop_quit(test->m_mainLoop); - - return FALSE; -} - -void WebViewTest::showInWindow(GtkWindowType windowType) -{ - g_assert(!m_parentWindow); - m_parentWindow = gtk_window_new(windowType); - gtk_container_add(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView)); - gtk_widget_show(GTK_WIDGET(m_webView)); - gtk_widget_show(m_parentWindow); -} - -void WebViewTest::showInWindowAndWaitUntilMapped(GtkWindowType windowType) -{ - g_assert(!m_parentWindow); - m_parentWindow = gtk_window_new(windowType); - gtk_container_add(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView)); - gtk_widget_show(GTK_WIDGET(m_webView)); - - g_signal_connect(m_parentWindow, "map-event", G_CALLBACK(parentWindowMapped), this); - gtk_widget_show(m_parentWindow); - g_main_loop_run(m_mainLoop); -} - -void WebViewTest::resizeView(int width, int height) -{ - GtkAllocation allocation; - gtk_widget_get_allocation(GTK_WIDGET(m_webView), &allocation); - if (width != -1) - allocation.width = width; - if (height != -1) - allocation.height = height; - gtk_widget_size_allocate(GTK_WIDGET(m_webView), &allocation); -} - -void WebViewTest::selectAll() -{ - webkit_web_view_execute_editing_command(m_webView, "SelectAll"); -} - -static void resourceGetDataCallback(GObject* object, GAsyncResult* result, gpointer userData) -{ - size_t dataSize; - GOwnPtr<GError> error; - unsigned char* data = webkit_web_resource_get_data_finish(WEBKIT_WEB_RESOURCE(object), result, &dataSize, &error.outPtr()); - g_assert(data); - - WebViewTest* test = static_cast<WebViewTest*>(userData); - test->m_resourceData.set(reinterpret_cast<char*>(data)); - test->m_resourceDataSize = dataSize; - g_main_loop_quit(test->m_mainLoop); -} - -const char* WebViewTest::mainResourceData(size_t& mainResourceDataSize) -{ - m_resourceDataSize = 0; - m_resourceData.clear(); - WebKitWebResource* resource = webkit_web_view_get_main_resource(m_webView); - g_assert(resource); - - webkit_web_resource_get_data(resource, 0, resourceGetDataCallback, this); - g_main_loop_run(m_mainLoop); - - mainResourceDataSize = m_resourceDataSize; - return m_resourceData.get(); -} - -void WebViewTest::mouseMoveTo(int x, int y, unsigned int mouseModifiers) -{ - g_assert(m_parentWindow); - GtkWidget* viewWidget = GTK_WIDGET(m_webView); - g_assert(gtk_widget_get_realized(viewWidget)); - - GOwnPtr<GdkEvent> event(gdk_event_new(GDK_MOTION_NOTIFY)); - event->motion.x = x; - event->motion.y = y; - - event->motion.time = GDK_CURRENT_TIME; - event->motion.window = gtk_widget_get_window(viewWidget); - g_object_ref(event->motion.window); - event->motion.device = gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(gtk_widget_get_display(viewWidget))); - event->motion.state = mouseModifiers; - event->motion.axes = 0; - - int xRoot, yRoot; - gdk_window_get_root_coords(gtk_widget_get_window(viewWidget), x, y, &xRoot, &yRoot); - event->motion.x_root = xRoot; - event->motion.y_root = yRoot; - gtk_main_do_event(event.get()); -} - -void WebViewTest::clickMouseButton(int x, int y, unsigned int button, unsigned int mouseModifiers) -{ - doMouseButtonEvent(GDK_BUTTON_PRESS, x, y, button, mouseModifiers); - doMouseButtonEvent(GDK_BUTTON_RELEASE, x, y, button, mouseModifiers); -} - -void WebViewTest::keyStroke(unsigned int keyVal, unsigned int keyModifiers) -{ - g_assert(m_parentWindow); - GtkWidget* viewWidget = GTK_WIDGET(m_webView); - g_assert(gtk_widget_get_realized(viewWidget)); - - GOwnPtr<GdkEvent> event(gdk_event_new(GDK_KEY_PRESS)); - event->key.keyval = keyVal; - - event->key.time = GDK_CURRENT_TIME; - event->key.window = gtk_widget_get_window(viewWidget); - g_object_ref(event->key.window); - gdk_event_set_device(event.get(), gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(gtk_widget_get_display(viewWidget)))); - event->key.state = keyModifiers; - - // When synthesizing an event, an invalid hardware_keycode value can cause it to be badly processed by GTK+. - GOwnPtr<GdkKeymapKey> keys; - int keysCount; - if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(), keyVal, &keys.outPtr(), &keysCount)) - event->key.hardware_keycode = keys.get()[0].keycode; - - gtk_main_do_event(event.get()); - event->key.type = GDK_KEY_RELEASE; - gtk_main_do_event(event.get()); -} - -void WebViewTest::doMouseButtonEvent(GdkEventType eventType, int x, int y, unsigned int button, unsigned int mouseModifiers) -{ - g_assert(m_parentWindow); - GtkWidget* viewWidget = GTK_WIDGET(m_webView); - g_assert(gtk_widget_get_realized(viewWidget)); - - GOwnPtr<GdkEvent> event(gdk_event_new(eventType)); - event->button.window = gtk_widget_get_window(viewWidget); - g_object_ref(event->button.window); - - event->button.time = GDK_CURRENT_TIME; - event->button.x = x; - event->button.y = y; - event->button.axes = 0; - event->button.state = mouseModifiers; - event->button.button = button; - - event->button.device = gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(gtk_widget_get_display(viewWidget))); - - int xRoot, yRoot; - gdk_window_get_root_coords(gtk_widget_get_window(viewWidget), x, y, &xRoot, &yRoot); - event->button.x_root = xRoot; - event->button.y_root = yRoot; - gtk_main_do_event(event.get()); -} - -static void runJavaScriptReadyCallback(GObject*, GAsyncResult* result, WebViewTest* test) -{ - test->m_javascriptResult = webkit_web_view_run_javascript_finish(test->m_webView, result, test->m_javascriptError); - g_main_loop_quit(test->m_mainLoop); -} - -static void runJavaScriptFromGResourceReadyCallback(GObject*, GAsyncResult* result, WebViewTest* test) -{ - test->m_javascriptResult = webkit_web_view_run_javascript_from_gresource_finish(test->m_webView, result, test->m_javascriptError); - g_main_loop_quit(test->m_mainLoop); -} - -WebKitJavascriptResult* WebViewTest::runJavaScriptAndWaitUntilFinished(const char* javascript, GError** error) -{ - if (m_javascriptResult) - webkit_javascript_result_unref(m_javascriptResult); - m_javascriptResult = 0; - m_javascriptError = error; - webkit_web_view_run_javascript(m_webView, javascript, 0, reinterpret_cast<GAsyncReadyCallback>(runJavaScriptReadyCallback), this); - g_main_loop_run(m_mainLoop); - - return m_javascriptResult; -} - -WebKitJavascriptResult* WebViewTest::runJavaScriptFromGResourceAndWaitUntilFinished(const char* resource, GError** error) -{ - if (m_javascriptResult) - webkit_javascript_result_unref(m_javascriptResult); - m_javascriptResult = 0; - m_javascriptError = error; - webkit_web_view_run_javascript_from_gresource(m_webView, resource, 0, reinterpret_cast<GAsyncReadyCallback>(runJavaScriptFromGResourceReadyCallback), this); - g_main_loop_run(m_mainLoop); - - return m_javascriptResult; -} - -static char* jsValueToCString(JSGlobalContextRef context, JSValueRef value) -{ - g_assert(value); - g_assert(JSValueIsString(context, value)); - - JSRetainPtr<JSStringRef> stringValue(Adopt, JSValueToStringCopy(context, value, 0)); - g_assert(stringValue); - - size_t cStringLength = JSStringGetMaximumUTF8CStringSize(stringValue.get()); - char* cString = static_cast<char*>(g_malloc(cStringLength)); - JSStringGetUTF8CString(stringValue.get(), cString, cStringLength); - return cString; -} - -char* WebViewTest::javascriptResultToCString(WebKitJavascriptResult* javascriptResult) -{ - JSGlobalContextRef context = webkit_javascript_result_get_global_context(javascriptResult); - g_assert(context); - return jsValueToCString(context, webkit_javascript_result_get_value(javascriptResult)); -} - -double WebViewTest::javascriptResultToNumber(WebKitJavascriptResult* javascriptResult) -{ - JSGlobalContextRef context = webkit_javascript_result_get_global_context(javascriptResult); - g_assert(context); - JSValueRef value = webkit_javascript_result_get_value(javascriptResult); - g_assert(value); - g_assert(JSValueIsNumber(context, value)); - - return JSValueToNumber(context, value, 0); -} - -bool WebViewTest::javascriptResultToBoolean(WebKitJavascriptResult* javascriptResult) -{ - JSGlobalContextRef context = webkit_javascript_result_get_global_context(javascriptResult); - g_assert(context); - JSValueRef value = webkit_javascript_result_get_value(javascriptResult); - g_assert(value); - g_assert(JSValueIsBoolean(context, value)); - - return JSValueToBoolean(context, value); -} - -bool WebViewTest::javascriptResultIsNull(WebKitJavascriptResult* javascriptResult) -{ - JSGlobalContextRef context = webkit_javascript_result_get_global_context(javascriptResult); - g_assert(context); - JSValueRef value = webkit_javascript_result_get_value(javascriptResult); - g_assert(value); - - return JSValueIsNull(context, value); -} - -bool WebViewTest::javascriptResultIsUndefined(WebKitJavascriptResult* javascriptResult) -{ - JSGlobalContextRef context = webkit_javascript_result_get_global_context(javascriptResult); - g_assert(context); - JSValueRef value = webkit_javascript_result_get_value(javascriptResult); - g_assert(value); - - return JSValueIsUndefined(context, value); -} - -static void onSnapshotReady(WebKitWebView* web_view, GAsyncResult* res, WebViewTest* test) -{ - GOwnPtr<GError> error; - test->m_surface = webkit_web_view_get_snapshot_finish(web_view, res, &error.outPtr()); - g_assert(!test->m_surface || !error.get()); - if (error) - g_assert_error(error.get(), WEBKIT_SNAPSHOT_ERROR, WEBKIT_SNAPSHOT_ERROR_FAILED_TO_CREATE); - test->quitMainLoop(); -} - -cairo_surface_t* WebViewTest::getSnapshotAndWaitUntilReady(WebKitSnapshotRegion region, WebKitSnapshotOptions options) -{ - if (m_surface) - cairo_surface_destroy(m_surface); - m_surface = 0; - webkit_web_view_get_snapshot(m_webView, region, options, 0, reinterpret_cast<GAsyncReadyCallback>(onSnapshotReady), this); - g_main_loop_run(m_mainLoop); - return m_surface; -} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h deleted file mode 100644 index a460e22b4..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * Portions Copyright (c) 2011 Motorola Mobility, 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 WebViewTest_h -#define WebViewTest_h - -#include "TestMain.h" -#include <webkit2/webkit2.h> -#include <wtf/text/CString.h> - -class WebViewTest: public Test { -public: - MAKE_GLIB_TEST_FIXTURE(WebViewTest); - WebViewTest(); - virtual ~WebViewTest(); - - virtual void loadURI(const char* uri); - virtual void loadHtml(const char* html, const char* baseURI); - virtual void loadPlainText(const char* plainText); - virtual void loadRequest(WebKitURIRequest*); - void loadAlternateHTML(const char* html, const char* contentURI, const char* baseURI); - void goBack(); - void goForward(); - void goToBackForwardListItem(WebKitBackForwardListItem*); - - void quitMainLoop(); - void quitMainLoopAfterProcessingPendingEvents(); - void wait(double seconds); - void waitUntilLoadFinished(); - void waitUntilTitleChangedTo(const char* expectedTitle); - void waitUntilTitleChanged(); - void showInWindow(GtkWindowType = GTK_WINDOW_POPUP); - void showInWindowAndWaitUntilMapped(GtkWindowType = GTK_WINDOW_POPUP); - void resizeView(int width, int height); - void selectAll(); - const char* mainResourceData(size_t& mainResourceDataSize); - - void mouseMoveTo(int x, int y, unsigned int mouseModifiers = 0); - void clickMouseButton(int x, int y, unsigned int button = 1, unsigned int mouseModifiers = 0); - void keyStroke(unsigned int keyVal, unsigned int keyModifiers = 0); - - WebKitJavascriptResult* runJavaScriptAndWaitUntilFinished(const char* javascript, GError**); - WebKitJavascriptResult* runJavaScriptFromGResourceAndWaitUntilFinished(const char* resource, GError**); - - // Javascript result helpers. - static char* javascriptResultToCString(WebKitJavascriptResult*); - static double javascriptResultToNumber(WebKitJavascriptResult*); - static bool javascriptResultToBoolean(WebKitJavascriptResult*); - static bool javascriptResultIsNull(WebKitJavascriptResult*); - static bool javascriptResultIsUndefined(WebKitJavascriptResult*); - - cairo_surface_t* getSnapshotAndWaitUntilReady(WebKitSnapshotRegion, WebKitSnapshotOptions); - - WebKitWebView* m_webView; - GMainLoop* m_mainLoop; - CString m_activeURI; - GtkWidget* m_parentWindow; - CString m_expectedTitle; - WebKitJavascriptResult* m_javascriptResult; - GError** m_javascriptError; - GOwnPtr<char> m_resourceData; - size_t m_resourceDataSize; - cairo_surface_t* m_surface; - -private: - void doMouseButtonEvent(GdkEventType, int, int, unsigned int, unsigned int); -}; - -#endif // WebViewTest_h diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/resources/link-title.js b/Source/WebKit2/UIProcess/API/gtk/tests/resources/link-title.js deleted file mode 100644 index 2c824da38..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/resources/link-title.js +++ /dev/null @@ -1 +0,0 @@ -window.document.getElementById('WebKitLink').title; diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/resources/test-cert.pem b/Source/WebKit2/UIProcess/API/gtk/tests/resources/test-cert.pem deleted file mode 100644 index b34301f25..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/resources/test-cert.pem +++ /dev/null @@ -1,13 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIB9jCCAV+gAwIBAgIJALeuXBo+vwz9MA0GCSqGSIb3DQEBBQUAMBQxEjAQBgNV -BAMMCTEyNy4wLjAuMTAeFw0xMjA3MTIxMjQ4MjRaFw0yMjA3MTAxMjQ4MjRaMBQx -EjAQBgNVBAMMCTEyNy4wLjAuMTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA -0TUzOQxHBIKDD2mkuq+tU92mQvDZg73B0G+Nhr2T2G6MbcLqIwjg1QYtBZWJ83tZ -xMMEfiweHLF85Z9ohavAgxJlKG7YmvZO79KkFpmjV2W5CVRm0eYMPnzmxNCoaYqo -DLl0zsH6KZOLPKu/fX4eDX9XpAP1f83hWB1UFBmHKN8CAwEAAaNQME4wHQYDVR0O -BBYEFDHv5ZQ1BdmhzTsDUEoY55EXyUdKMB8GA1UdIwQYMBaAFDHv5ZQ1BdmhzTsD -UEoY55EXyUdKMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAh3qMBx7v -jSodMf3OyTqTLE7deLnmnCeBVpgzxRZEoizcGqYcjiqO27i5N5Z6KVQsnITnLiyC -mUtuR5KnF69uTKUw4m/ugZe5whjig5Mq2l410KVK6EeG4tdLlfXR+wi4U5K4KjP6 -p4nchQUXLa2zcbJn+VBexJn6/9wdhr+DUGY= ------END CERTIFICATE----- diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/resources/test-key.pem b/Source/WebKit2/UIProcess/API/gtk/tests/resources/test-key.pem deleted file mode 100644 index 9036222ce..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/resources/test-key.pem +++ /dev/null @@ -1,16 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANE1MzkMRwSCgw9p -pLqvrVPdpkLw2YO9wdBvjYa9k9hujG3C6iMI4NUGLQWVifN7WcTDBH4sHhyxfOWf -aIWrwIMSZShu2Jr2Tu/SpBaZo1dluQlUZtHmDD585sTQqGmKqAy5dM7B+imTizyr -v31+Hg1/V6QD9X/N4VgdVBQZhyjfAgMBAAECgYB2QwOUsRsIMprRwJ9tJNfvO7G7 -z5i1/zOrlxPC4jHMPBnIBlICwgcOhLI4oOLdr5H8R12n0VqoT7DRwP396iwlJipF -iO1heDMn/8z8LPGwkCK/+ck04rMDksxWIdMwYKBXt9ahnJ/xRLzQ1/3AJiAGnoe5 -/QLXQweofd4mmfsjKQJBAO2CwT7uMP6nMjXgtVMJq5QP8UbeCS1sEOPJJbHuDxJB -/HePQHBjq4kzG6CL4oO7T+5fDv4g+fIIHzuXerZ0imsCQQDhfmiTIc9OucEIfg6/ -ms0JiKSmWc+qoiOCtrILuQvFoNwJRciQANqeJs6wpaDvevSUvBLGfG/7b3HvaE5X -iqBdAkBEQIvp2qcHtuJN60oQF7pPrRknxUyb2e8sljQX4pJAK+gyL19ULMAxiBdL -Vod8VYqNtJFpY+6Pp9fZ1xjzb6ALAkEA4JzrDAw0lQXA+3WduUw4ixOadr2ldyG0 -36KebcDwsfZO18m0Q4UmPz0Gy7zgN0wxzuochaw0W6+iPUiYKOlEXQJBAMWQrPlu -rrinoZS2f8doJ9BNNUa+RNpMug6UXc55qoUJlyiXEh+tu4AaMOtxuGIyC0sAcuw6 -XdAPVPXKd7Mne70= ------END PRIVATE KEY----- diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/resources/webkit2gtk-tests.gresource.xml b/Source/WebKit2/UIProcess/API/gtk/tests/resources/webkit2gtk-tests.gresource.xml deleted file mode 100644 index 4f1e5a654..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/tests/resources/webkit2gtk-tests.gresource.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<gresources> - <gresource prefix="/org/webkit/webkit2gtk/tests/"> - <file alias="link-title.js">Source/WebKit2/UIProcess/API/gtk/tests/resources/link-title.js</file> - </gresource> -</gresources> diff --git a/Source/WebKit2/UIProcess/API/gtk/webkit2.h b/Source/WebKit2/UIProcess/API/gtk/webkit2.h deleted file mode 100644 index d18431528..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/webkit2.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2011 Igalia S.L. - * Portions Copyright (c) 2011 Motorola Mobility, 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 __WEBKIT2_H__ -#define __WEBKIT2_H__ - -#define __WEBKIT2_H_INSIDE__ - -#include <webkit2/WebKitBackForwardList.h> -#include <webkit2/WebKitBackForwardListItem.h> -#include <webkit2/WebKitContextMenu.h> -#include <webkit2/WebKitContextMenuActions.h> -#include <webkit2/WebKitContextMenuItem.h> -#include <webkit2/WebKitCookieManager.h> -#include <webkit2/WebKitDefines.h> -#include <webkit2/WebKitDownload.h> -#include <webkit2/WebKitEditingCommands.h> -#include <webkit2/WebKitEnumTypes.h> -#include <webkit2/WebKitError.h> -#include <webkit2/WebKitFaviconDatabase.h> -#include <webkit2/WebKitFileChooserRequest.h> -#include <webkit2/WebKitFindController.h> -#include <webkit2/WebKitFormSubmissionRequest.h> -#include <webkit2/WebKitGeolocationPermissionRequest.h> -#include <webkit2/WebKitHitTestResult.h> -#include <webkit2/WebKitJavascriptResult.h> -#include <webkit2/WebKitMimeInfo.h> -#include <webkit2/WebKitNavigationPolicyDecision.h> -#include <webkit2/WebKitPermissionRequest.h> -#include <webkit2/WebKitPlugin.h> -#include <webkit2/WebKitPrintOperation.h> -#include <webkit2/WebKitResponsePolicyDecision.h> -#include <webkit2/WebKitScriptDialog.h> -#include <webkit2/WebKitSecurityManager.h> -#include <webkit2/WebKitSettings.h> -#include <webkit2/WebKitURIRequest.h> -#include <webkit2/WebKitURIResponse.h> -#include <webkit2/WebKitURISchemeRequest.h> -#include <webkit2/WebKitVersion.h> -#include <webkit2/WebKitWebContext.h> -#include <webkit2/WebKitWebInspector.h> -#include <webkit2/WebKitWebResource.h> -#include <webkit2/WebKitWebView.h> -#include <webkit2/WebKitWebViewBase.h> -#include <webkit2/WebKitWebViewGroup.h> -#include <webkit2/WebKitWindowProperties.h> - -#undef __WEBKIT2_H_INSIDE__ - -#endif /* __WEBKIT2_H__ */ diff --git a/Source/WebKit2/UIProcess/API/gtk/webkit2marshal.list b/Source/WebKit2/UIProcess/API/gtk/webkit2marshal.list deleted file mode 100644 index 420766ea7..000000000 --- a/Source/WebKit2/UIProcess/API/gtk/webkit2marshal.list +++ /dev/null @@ -1,15 +0,0 @@ -BOOLEAN:BOXED -BOOLEAN:ENUM,STRING,POINTER -BOOLEAN:OBJECT -BOOLEAN:OBJECT,BOXED,OBJECT -BOOLEAN:OBJECT,ENUM -BOOLEAN:OBJECT,OBJECT -BOOLEAN:STRING -BOOLEAN:VOID -OBJECT:VOID -VOID:OBJECT,UINT -VOID:OBJECT,OBJECT -VOID:OBJECT,POINTER -VOID:STRING,STRING -VOID:UINT64 - |