View | Details | Raw Unified | Return to bug 16562 | Differences between
and this patch

Collapse All | Expand All

(-)a/ChangeLog (+12 lines)
Lines 1-3 Link Here
1
2008-05-22  Marco Barisione  <marco.barisione@collabora.co.uk>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        http://bugs.webkit.org/show_bug.cgi?id=16562
6
        [gtk] Implement WebPolicyDelegate methods
7
8
        * GNUmakefile.am: Add WebKit/gtk/webkit/webkitwebpolicydecision.h,
9
        WebKit/gtk/webkit/webkitwebpolicydecision.cpp,
10
        WebKit/gtk/webkit/webkitwebnavigationaction.h and
11
        WebKit/gtk/webkit/webkitwebnavigationaction.cpp.
12
1
2008-05-20  Jan Michael Alonzo  <jmalonzo@webkit.org>
13
2008-05-20  Jan Michael Alonzo  <jmalonzo@webkit.org>
2
14
3
        Reviewed by Alp Toker.
15
        Reviewed by Alp Toker.
(-)a/GNUmakefile.am (+4 lines)
Lines 299-304 webkitgtk_h_api += \ Link Here
299
	WebKit/gtk/webkit/webkitwebbackforwardlist.h \
299
	WebKit/gtk/webkit/webkitwebbackforwardlist.h \
300
	WebKit/gtk/webkit/webkitwebframe.h \
300
	WebKit/gtk/webkit/webkitwebframe.h \
301
	WebKit/gtk/webkit/webkitwebhistoryitem.h \
301
	WebKit/gtk/webkit/webkitwebhistoryitem.h \
302
	WebKit/gtk/webkit/webkitwebnavigationaction.h \
303
	WebKit/gtk/webkit/webkitwebpolicydecision.h \
302
	WebKit/gtk/webkit/webkitwebsettings.h \
304
	WebKit/gtk/webkit/webkitwebsettings.h \
303
	WebKit/gtk/webkit/webkitwebview.h
305
	WebKit/gtk/webkit/webkitwebview.h
304
306
Lines 324-329 webkitgtk_sources += \ Link Here
324
	WebKit/gtk/webkit/webkitwebbackforwardlist.cpp \
326
	WebKit/gtk/webkit/webkitwebbackforwardlist.cpp \
325
	WebKit/gtk/webkit/webkitwebframe.cpp \
327
	WebKit/gtk/webkit/webkitwebframe.cpp \
326
	WebKit/gtk/webkit/webkitwebhistoryitem.cpp \
328
	WebKit/gtk/webkit/webkitwebhistoryitem.cpp \
329
	WebKit/gtk/webkit/webkitwebnavigationaction.cpp \
330
	WebKit/gtk/webkit/webkitwebpolicydecision.cpp \
327
	WebKit/gtk/webkit/webkitwebsettings.cpp \
331
	WebKit/gtk/webkit/webkitwebsettings.cpp \
328
	WebKit/gtk/webkit/webkitwebview.cpp \
332
	WebKit/gtk/webkit/webkitwebview.cpp \
329
	WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp \
333
	WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp \
(-)a/WebKit/gtk/ChangeLog (+64 lines)
Lines 1-3 Link Here
1
2008-05-22  Marco Barisione <marco.barisione@collabora.co.uk>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        http://bugs.webkit.org/show_bug.cgi?id=16562
6
        [gtk] Implement WebPolicyDelegate methods
7
8
        Original work by Pierre-Luc Beaudoin.
9
10
        This implements the delegates methods of WebPolicyDelegate.
11
        Since Gtk+/C doesn't have delegate methods, I replaced them with
12
        signals. Also, since WebPolicyDelegate only has 3 delegate, I added
13
        them to the WebView instead of creating new GObject with only 3
14
        signals.
15
16
        A new object WebKitWebPolicyDecision allow the browser to delay its
17
        response in certain cases.  As commented in WebCore, redirection
18
        navigation requests are one case where a response is required to be
19
        sync (ie. decision must be sent before the end of signal).  If a
20
        decision come in late, assertions could happen.
21
        Only one policy decision should be pending with this implementation.
22
        Again this seems to be a limitation in WebCore.
23
24
        I copied the default behaviours described in WebPolicyDelegate on the
25
        Mac port.
26
27
        * WebCoreSupport/FrameLoaderClientGtk.cpp:
28
        (WebKit::FrameLoaderClient::FrameLoaderClient):
29
        (WebKit::FrameLoaderClient::dispatchDecidePolicyForMIMEType):
30
        (WebKit::FrameLoaderClient::dispatchDecidePolicyForNavigationAction):
31
        (WebKit::FrameLoaderClient::cancelPolicyCheck):
32
        (WebKit::FrameLoaderClient::canShowMIMEType):
33
        * WebCoreSupport/FrameLoaderClientGtk.h:
34
        * webkit/webkit-marshal.list:
35
        * webkit/webkit.h:
36
        * webkit/webkitdefines.h:
37
        * webkit/webkitprivate.cpp:
38
        (WebKit::kit):
39
        (WebKit::core):
40
        * webkit/webkitprivate.h:
41
        * webkit/webkitwebnavigationaction.cpp: Added.
42
        (_WebKitWebNavigationActionPrivate::):
43
        (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_get_property):
44
        (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_set_property):
45
        (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_init):
46
        (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_finalize):
47
        (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_class_init):
48
        (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_get_reason):
49
        (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_set_reason):
50
        (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_get_original_uri):
51
        (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_set_original_uri):
52
        * webkit/webkitwebnavigationaction.h: Added.
53
        * webkit/webkitwebpolicydecision.cpp: Added.
54
        (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_class_init):
55
        (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_init):
56
        (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_new):
57
        (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_use):
58
        (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_ignore):
59
        (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_download):
60
        (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_cancel):
61
        * webkit/webkitwebpolicydecision.h: Added.
62
        * webkit/webkitwebview.cpp:
63
        * webkit/webkitwebview.h:
64
1
2008-05-19  Alp Toker  <alp@nuanti.com>
65
2008-05-19  Alp Toker  <alp@nuanti.com>
2
66
3
        Reviewed by Anders and Beth.
67
        Reviewed by Anders and Beth.
(-)a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp (-13 / +48 lines)
Lines 44-49 Link Here
44
#include "kjs_proxy.h"
44
#include "kjs_proxy.h"
45
#include "webkitwebview.h"
45
#include "webkitwebview.h"
46
#include "webkitwebframe.h"
46
#include "webkitwebframe.h"
47
#include "webkitwebnavigationaction.h"
48
#include "webkitwebpolicydecision.h"
47
#include "webkitprivate.h"
49
#include "webkitprivate.h"
48
50
49
#include <JavaScriptCore/APICast.h>
51
#include <JavaScriptCore/APICast.h>
Lines 60-65 FrameLoaderClient::FrameLoaderClient(WebKitWebFrame* frame) Link Here
60
    : m_frame(frame)
62
    : m_frame(frame)
61
    , m_pluginView(0)
63
    , m_pluginView(0)
62
    , m_userAgent("")
64
    , m_userAgent("")
65
    , m_policyDecision(NULL)
63
{
66
{
64
    ASSERT(m_frame);
67
    ASSERT(m_frame);
65
}
68
}
Lines 242-257 void FrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader*, unsigned lon Link Here
242
    m_response = response;
245
    m_response = response;
243
}
246
}
244
247
245
void FrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction policyFunction, const String&, const ResourceRequest&)
248
void FrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction policyFunction, const String& mimeType, const ResourceRequest& resourceRequest)
246
{
249
{
247
    // FIXME: we need to call directly here (comment copied from Qt version)
248
    ASSERT(policyFunction);
250
    ASSERT(policyFunction);
249
    if (!policyFunction)
251
    if (!policyFunction)
250
        return;
252
        return;
251
    (core(m_frame)->loader()->*policyFunction)(PolicyUse);
253
254
    WebKitWebView* page = getViewFromFrame(m_frame);
255
    WebKitNetworkRequest* request = webkit_network_request_new(resourceRequest.url().string().utf8().data());
256
    WebKitWebPolicyDecision* policyDecision = webkit_web_policy_decision_new(m_frame, policyFunction);
257
    m_policyDecision = policyDecision;
258
259
    gboolean isHandled = false;
260
    g_signal_emit_by_name(page, "mime-type-policy-decision-requested", m_frame, request, mimeType.utf8().data(), policyDecision, &isHandled);
261
262
    g_object_unref(request);
263
264
    if (isHandled)
265
        return;
266
267
    PolicyAction policyResult;
268
269
    if (resourceRequest.url().isLocalFile())
270
        policyResult = PolicyUse;
271
    else if (canShowMIMEType(mimeType))
272
        policyResult = PolicyUse;
273
    else
274
        policyResult = PolicyIgnore;
275
276
    (core(m_frame)->loader()->*policyFunction)(policyResult);
252
}
277
}
253
278
254
void FrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction policyFunction, const NavigationAction&, const ResourceRequest&, const String&)
279
void FrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction policyFunction, const NavigationAction& action, const ResourceRequest& resourceRequest, const String& s)
255
{
280
{
256
    ASSERT(policyFunction);
281
    ASSERT(policyFunction);
257
    if (!policyFunction)
282
    if (!policyFunction)
Lines 269-285 void FrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunct Link Here
269
294
270
    WebKitWebView* webView = getViewFromFrame(m_frame);
295
    WebKitWebView* webView = getViewFromFrame(m_frame);
271
    WebKitNetworkRequest* request = webkit_network_request_new(resourceRequest.url().string().utf8().data());
296
    WebKitNetworkRequest* request = webkit_network_request_new(resourceRequest.url().string().utf8().data());
272
    WebKitNavigationResponse response;
297
    WebKitWebPolicyDecision* policyDecision = webkit_web_policy_decision_new(m_frame, policyFunction);
298
    m_policyDecision = policyDecision;
299
300
    // TODO: use action.event().
301
    gpointer navigationAction = g_object_new(WEBKIT_TYPE_WEB_NAVIGATION_ACTION,
302
                                             "reason", kit(action.type()),
303
                                             "original-uri", action.url().string().utf8().data(),
304
                                             NULL);
273
305
274
    g_signal_emit_by_name(webView, "navigation-requested", m_frame, request, &response);
306
    gboolean isHandled = false;
307
    g_signal_emit_by_name(webView, "navigation-requested", m_frame, request, navigationAction, policyDecision, &isHandled);
275
308
309
    g_object_unref(navigationAction);
276
    g_object_unref(request);
310
    g_object_unref(request);
277
311
278
    if (response == WEBKIT_NAVIGATION_RESPONSE_IGNORE) {
312
    if (isHandled)
279
        (core(m_frame)->loader()->*policyFunction)(PolicyIgnore);
280
        return;
313
        return;
281
    }
282
314
315
    // FIXME Implement default behavior when we can query the backend what protocols it supports
283
    (core(m_frame)->loader()->*policyFunction)(PolicyUse);
316
    (core(m_frame)->loader()->*policyFunction)(PolicyUse);
284
}
317
}
285
318
Lines 564-570 void FrameLoaderClient::dispatchShow() Link Here
564
597
565
void FrameLoaderClient::cancelPolicyCheck()
598
void FrameLoaderClient::cancelPolicyCheck()
566
{
599
{
567
    notImplemented();
600
    //FIXME Add support for more than one policy decision at once
601
    if (m_policyDecision)
602
        webkit_web_policy_decision_cancel(m_policyDecision);
568
}
603
}
569
604
570
void FrameLoaderClient::dispatchDidLoadMainResource(DocumentLoader*)
605
void FrameLoaderClient::dispatchDidLoadMainResource(DocumentLoader*)
Lines 593-602 bool FrameLoaderClient::canHandleRequest(const ResourceRequest&) const Link Here
593
    return true;
628
    return true;
594
}
629
}
595
630
596
bool FrameLoaderClient::canShowMIMEType(const String&) const
631
bool FrameLoaderClient::canShowMIMEType(const String& type) const
597
{
632
{
598
    notImplemented();
633
    return MIMETypeRegistry::isSupportedImageMIMEType(type) || MIMETypeRegistry::isSupportedNonImageMIMEType(type) ||
599
    return true;
634
        PluginDatabase::installedPlugins()->isMIMETypeRegistered(type);
600
}
635
}
601
636
602
bool FrameLoaderClient::representationExistsForURLScheme(const String&) const
637
bool FrameLoaderClient::representationExistsForURLScheme(const String&) const
(-)a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h (+2 lines)
Lines 33-38 Link Here
33
#include "FrameLoaderClient.h"
33
#include "FrameLoaderClient.h"
34
#include "ResourceResponse.h"
34
#include "ResourceResponse.h"
35
#include "PluginView.h"
35
#include "PluginView.h"
36
#include "webkitwebpolicydecision.h"
36
37
37
typedef struct _WebKitWebFrame WebKitWebFrame;
38
typedef struct _WebKitWebFrame WebKitWebFrame;
38
39
Lines 172-177 namespace WebKit { Link Here
172
        WebKitWebFrame* m_frame;
173
        WebKitWebFrame* m_frame;
173
        WebCore::ResourceResponse m_response;
174
        WebCore::ResourceResponse m_response;
174
        WebCore::String m_userAgent;
175
        WebCore::String m_userAgent;
176
        WebKitWebPolicyDecision* m_policyDecision;
175
177
176
        // Plugin view to redirect data to
178
        // Plugin view to redirect data to
177
        WebCore::PluginView* m_pluginView;
179
        WebCore::PluginView* m_pluginView;
(-)a/WebKit/gtk/webkit/webkit-marshal.list (-1 / +2 lines)
Lines 9-12 BOOLEAN:STRING,INT,STRING Link Here
9
BOOLEAN:OBJECT,STRING
9
BOOLEAN:OBJECT,STRING
10
BOOLEAN:OBJECT,STRING,BOOLEAN
10
BOOLEAN:OBJECT,STRING,BOOLEAN
11
BOOLEAN:OBJECT,STRING,STRING,STRING
11
BOOLEAN:OBJECT,STRING,STRING,STRING
12
INT:OBJECT,OBJECT
12
BOOLEAN:OBJECT,OBJECT,STRING,OBJECT
13
BOOLEAN:OBJECT,OBJECT,OBJECT,OBJECT
(-)a/WebKit/gtk/webkit/webkit.h (+3 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
2
 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
3
 * Copyright (C) 2008 Collabora Ltd.
3
 *
4
 *
4
 * This library is free software; you can redistribute it and/or
5
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * modify it under the terms of the GNU Library General Public
Lines 27-32 Link Here
27
#include <webkit/webkitwebview.h>
28
#include <webkit/webkitwebview.h>
28
#include <webkit/webkitwebbackforwardlist.h>
29
#include <webkit/webkitwebbackforwardlist.h>
29
#include <webkit/webkitwebhistoryitem.h>
30
#include <webkit/webkitwebhistoryitem.h>
31
#include <webkit/webkitwebpolicydecision.h>
32
#include <webkit/webkitwebnavigationaction.h>
30
#include <webkit/webkit-enum-types.h>
33
#include <webkit/webkit-enum-types.h>
31
34
32
#endif /* __WEBKIT_H__ */
35
#endif /* __WEBKIT_H__ */
(-)a/WebKit/gtk/webkit/webkitdefines.h (+4 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * Copyright (C) 2007 Holger Hans Peter Freyther
2
 * Copyright (C) 2007 Holger Hans Peter Freyther
3
 * Copyright (C) 2008 Collabora Ltd.
3
 *
4
 *
4
 * This library is free software; you can redistribute it and/or
5
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * modify it under the terms of the GNU Library General Public
Lines 52-57 typedef struct _WebKitWebHistoryItemClass WebKitWebHistoryItemClass; Link Here
52
typedef struct _WebKitWebFrame WebKitWebFrame;
53
typedef struct _WebKitWebFrame WebKitWebFrame;
53
typedef struct _WebKitWebFrameClass WebKitWebFrameClass;
54
typedef struct _WebKitWebFrameClass WebKitWebFrameClass;
54
55
56
typedef struct _WebKitWebPolicyDecision WebKitWebPolicyDecision;
57
typedef struct _WebKitWebPolicyDecisionClass WebKitWebPolicyDecisionClass;
58
55
typedef struct _WebKitWebSettings WebKitWebSettings;
59
typedef struct _WebKitWebSettings WebKitWebSettings;
56
typedef struct _WebKitWebSettingsClass WebKitWebSettingsClass;
60
typedef struct _WebKitWebSettingsClass WebKitWebSettingsClass;
57
61
(-)a/WebKit/gtk/webkit/webkitprivate.cpp (+11 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * Copyright (C) 2007 Holger Hans Peter Freyther
2
 * Copyright (C) 2007 Holger Hans Peter Freyther
3
 * Copyright (C) 2008 Collabora Ltd.
3
 *
4
 *
4
 * This library is free software; you can redistribute it and/or
5
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * modify it under the terms of the GNU Library General Public
Lines 83-88 WebKitWebView* kit(WebCore::Page* corePage) Link Here
83
    return client ? client->webView() : 0;
84
    return client ? client->webView() : 0;
84
}
85
}
85
86
87
WebKitWebNavigationReason kit(WebCore::NavigationType type)
88
{
89
    return (WebKitWebNavigationReason)type;
90
}
91
 
92
WebCore::NavigationType core(WebKitWebNavigationReason type)
93
{
94
    return (WebCore::NavigationType)type;
95
}
96
86
} /** end namespace WebCore */
97
} /** end namespace WebCore */
87
98
88
void webkit_init()
99
void webkit_init()
(-)a/WebKit/gtk/webkit/webkitprivate.h (+10 lines)
Lines 1-6 Link Here
1
/*
1
/*
2
 * Copyright (C) 2007, 2008 Holger Hans Peter Freyther
2
 * Copyright (C) 2007, 2008 Holger Hans Peter Freyther
3
 * Copyright (C) 2008 Jan Michael C. Alonzo
3
 * Copyright (C) 2008 Jan Michael C. Alonzo
4
 * Copyright (C) 2008 Collabora Ltd.
4
 *
5
 *
5
 * This library is free software; you can redistribute it and/or
6
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Library General Public
7
 * modify it under the terms of the GNU Library General Public
Lines 29-34 Link Here
29
#include <webkit/webkitdefines.h>
30
#include <webkit/webkitdefines.h>
30
#include <webkit/webkitwebview.h>
31
#include <webkit/webkitwebview.h>
31
#include <webkit/webkitwebframe.h>
32
#include <webkit/webkitwebframe.h>
33
#include <webkit/webkitwebpolicydecision.h>
34
#include <webkit/webkitwebnavigationaction.h>
32
#include <webkit/webkitwebsettings.h>
35
#include <webkit/webkitwebsettings.h>
33
#include <webkit/webkitwebbackforwardlist.h>
36
#include <webkit/webkitwebbackforwardlist.h>
34
37
Lines 54-59 namespace WebKit { Link Here
54
    WebKitWebHistoryItem* kit(WebCore::HistoryItem*);
57
    WebKitWebHistoryItem* kit(WebCore::HistoryItem*);
55
58
56
    WebCore::BackForwardList* core(WebKitWebBackForwardList*);
59
    WebCore::BackForwardList* core(WebKitWebBackForwardList*);
60
61
    WebKitWebNavigationReason kit(WebCore::NavigationType type);
62
    WebCore::NavigationType core(WebKitWebNavigationReason reason);
57
}
63
}
58
64
59
extern "C" {
65
extern "C" {
Lines 108-113 extern "C" { Link Here
108
    WebKitWebHistoryItem*
114
    WebKitWebHistoryItem*
109
    webkit_web_history_item_new_with_core_item(WebCore::HistoryItem*);
115
    webkit_web_history_item_new_with_core_item(WebCore::HistoryItem*);
110
116
117
    WebKitWebPolicyDecision* webkit_web_policy_decision_new (WebKitWebFrame*, WebCore::FramePolicyFunction);
118
119
    void webkit_web_policy_decision_cancel (WebKitWebPolicyDecision* decision);
120
111
    // FIXME: Move these to webkitwebframe.h once their API has been discussed.
121
    // FIXME: Move these to webkitwebframe.h once their API has been discussed.
112
122
113
    WEBKIT_API GSList*
123
    WEBKIT_API GSList*
(-)a/WebKit/gtk/webkit/webkitwebnavigationaction.cpp (+195 lines)
Line 0 Link Here
1
/*
2
 * Copyright (C) 2008 Collabora Ltd.
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Library General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Library General Public License
15
 * along with this library; see the file COPYING.LIB.  If not, write to
16
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
 * Boston, MA 02110-1301, USA.
18
 */
19
20
#include "config.h"
21
22
#include "webkitwebnavigationaction.h"
23
#include "webkitprivate.h"
24
#include "webkit-enum-types.h"
25
26
#include <string.h>
27
28
extern "C" {
29
30
struct _WebKitWebNavigationActionPrivate {
31
    WebKitWebNavigationReason reason;
32
    gchar* originalUri;
33
};
34
35
#define WEBKIT_WEB_NAVIGATION_ACTION_GET_PRIVATE(obj)(G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_NAVIGATION_ACTION, WebKitWebNavigationActionPrivate))
36
37
enum  {
38
    PROP_0,
39
40
    PROP_REASON,
41
    PROP_ORIGINAL_URI
42
};
43
44
G_DEFINE_TYPE(WebKitWebNavigationAction, webkit_web_navigation_action, G_TYPE_OBJECT)
45
46
47
static void webkit_web_navigation_action_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec)
48
{
49
    WebKitWebNavigationAction* navigationAction = WEBKIT_WEB_NAVIGATION_ACTION(object);
50
51
    switch(propertyId) {
52
    case PROP_REASON:
53
        g_value_set_enum(value, webkit_web_navigation_action_get_reason(navigationAction));
54
        break;
55
    case PROP_ORIGINAL_URI:
56
        g_value_set_string(value, webkit_web_navigation_action_get_original_uri(navigationAction));
57
        break;
58
    default:
59
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
60
        break;
61
    }
62
}
63
64
static void webkit_web_navigation_action_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec)
65
{
66
    WebKitWebNavigationAction* navigationAction = WEBKIT_WEB_NAVIGATION_ACTION(object);
67
68
    switch(propertyId) {
69
    case PROP_REASON:
70
        webkit_web_navigation_action_set_reason(navigationAction, (WebKitWebNavigationReason)g_value_get_enum(value));
71
        break;
72
    case PROP_ORIGINAL_URI:
73
        webkit_web_navigation_action_set_original_uri(navigationAction, g_value_get_string(value));
74
        break;
75
    default:
76
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
77
        break;
78
    }
79
}
80
81
static void webkit_web_navigation_action_init(WebKitWebNavigationAction* navigationAction)
82
{
83
    navigationAction->priv = WEBKIT_WEB_NAVIGATION_ACTION_GET_PRIVATE(navigationAction);
84
85
    WebKitWebNavigationActionPrivate* priv = navigationAction->priv;
86
    priv->originalUri = g_strdup("");
87
}
88
89
static void webkit_web_navigation_action_finalize(GObject* obj)
90
{
91
    WebKitWebNavigationAction* navigationAction = WEBKIT_WEB_NAVIGATION_ACTION(obj);
92
    WebKitWebNavigationActionPrivate* priv = navigationAction->priv;
93
94
    g_free(priv->originalUri);
95
96
    G_OBJECT_CLASS(webkit_web_navigation_action_parent_class)->finalize(obj);
97
}
98
99
static void webkit_web_navigation_action_class_init(WebKitWebNavigationActionClass* requestClass)
100
{
101
    GObjectClass* objectClass = G_OBJECT_CLASS(requestClass);
102
103
    objectClass->get_property = webkit_web_navigation_action_get_property;
104
    objectClass->set_property = webkit_web_navigation_action_set_property;
105
    objectClass->dispose = webkit_web_navigation_action_finalize;
106
107
    g_object_class_install_property(objectClass, PROP_REASON,
108
                                    g_param_spec_enum("reason",
109
                                                      "Reason",
110
                                                      "The reason why this navigation is occurring",
111
                                                      WEBKIT_TYPE_WEB_NAVIGATION_REASON,
112
                                                      WEBKIT_WEB_NAVIGATION_REASON_OTHER,
113
                                                      (GParamFlags)(WEBKIT_PARAM_READWRITE)));
114
115
    g_object_class_install_property(objectClass, PROP_ORIGINAL_URI,
116
                                    g_param_spec_string("original-uri",
117
                                                        "Original URI",
118
                                                        "The URI that was requested as the target for the navigation",
119
                                                        "",
120
                                                        WEBKIT_PARAM_READWRITE));
121
122
    g_type_class_add_private(requestClass, sizeof(WebKitWebNavigationActionPrivate));
123
}
124
125
/**
126
 * webkit_web_navigation_action_get_reason:
127
 * @navigationAction: a #WebKitWebNavigationAction
128
 *
129
 * Returns the reason why WebKit is requesting a navigation.
130
 *
131
 * Return value: a #WebKitWebNavigationReason
132
 */
133
WebKitWebNavigationReason webkit_web_navigation_action_get_reason(WebKitWebNavigationAction* navigationAction)
134
{
135
    g_return_val_if_fail(WEBKIT_IS_WEB_NAVIGATION_ACTION(navigationAction), WEBKIT_WEB_NAVIGATION_REASON_OTHER);
136
137
    return navigationAction->priv->reason;
138
}
139
140
/**
141
 * webkit_web_navigation_action_set_reason:
142
 * @navigationAction: a #WebKitWebNavigationAction
143
 * @reason: a #WebKitWebNavigationReason
144
 *
145
 * Sets the reason why WebKit is requesting a navigation.
146
 */
147
void webkit_web_navigation_action_set_reason(WebKitWebNavigationAction* navigationAction, WebKitWebNavigationReason reason)
148
{
149
    g_return_if_fail(WEBKIT_IS_WEB_NAVIGATION_ACTION(navigationAction));
150
151
    if (navigationAction->priv->reason == reason)
152
        return;
153
154
    navigationAction->priv->reason = reason;
155
    g_object_notify(G_OBJECT(navigationAction), "reason");
156
}
157
158
/**
159
 * webkit_web_navigation_action_get_original_uri:
160
 * @navigationAction: a #WebKitWebNavigationAction
161
 *
162
 * Returns the URI that was originally requested. This may differ from the
163
 * navigation target, for instance because of a redirect.
164
 *
165
 * Return value: the originally requested URI
166
 */
167
const gchar* webkit_web_navigation_action_get_original_uri(WebKitWebNavigationAction* navigationAction)
168
{
169
    g_return_val_if_fail(WEBKIT_IS_WEB_NAVIGATION_ACTION(navigationAction), NULL);
170
171
    return navigationAction->priv->originalUri;
172
}
173
174
/**
175
 * webkit_web_navigation_action_set_original_uri:
176
 * @navigationAction: a #WebKitWebNavigationAction
177
 * @originalUri: a URI
178
 *
179
 * Sets the URI that was originally requested. This may differ from the
180
 * navigation target, for instance because of a redirect.
181
 */
182
void webkit_web_navigation_action_set_original_uri(WebKitWebNavigationAction* navigationAction, const gchar* originalUri)
183
{
184
    g_return_if_fail(WEBKIT_IS_WEB_NAVIGATION_ACTION(navigationAction));
185
    g_return_if_fail(originalUri);
186
187
    if (!strcmp(navigationAction->priv->originalUri, originalUri))
188
        return;
189
190
    g_free(navigationAction->priv->originalUri);
191
    navigationAction->priv->originalUri = g_strdup(originalUri);
192
    g_object_notify(G_OBJECT(navigationAction), "original-uri");
193
}
194
195
}
(-)a/WebKit/gtk/webkit/webkitwebnavigationaction.h (+77 lines)
Line 0 Link Here
1
/*
2
 * Copyright (C) 2008 Collabora Ltd.
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Library General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Library General Public License
15
 * along with this library; see the file COPYING.LIB.  If not, write to
16
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
 * Boston, MA 02110-1301, USA.
18
 */
19
20
#ifndef WEBKIT_WEB_NAVIGATION_ACTION_H
21
#define WEBKIT_WEB_NAVIGATION_ACTION_H
22
23
#include <glib-object.h>
24
25
#include <webkit/webkitdefines.h>
26
27
G_BEGIN_DECLS
28
29
// The order of this enum must be the same as NavigationType in FrameLoaderTypes.h
30
typedef enum {
31
    WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED,
32
    WEBKIT_WEB_NAVIGATION_REASON_FORM_SUBMITTED,
33
    WEBKIT_WEB_NAVIGATION_REASON_BACK_FORWARD,
34
    WEBKIT_WEB_NAVIGATION_REASON_RELOAD,
35
    WEBKIT_WEB_NAVIGATION_REASON_FORM_RESUBMITTED,
36
    WEBKIT_WEB_NAVIGATION_REASON_OTHER,    
37
    WEBKIT_WEB_NAVIGATION_REASON_PLUG_IN_REQUEST
38
} WebKitWebNavigationReason;
39
40
#define WEBKIT_TYPE_WEB_NAVIGATION_ACTION            (webkit_web_navigation_action_get_type())
41
#define WEBKIT_WEB_NAVIGATION_ACTION(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_NAVIGATION_ACTION, WebKitWebNavigationAction))
42
#define WEBKIT_WEB_NAVIGATION_ACTION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_NAVIGATION_ACTION, WebKitWebNavigationActionClass))
43
#define WEBKIT_IS_WEB_NAVIGATION_ACTION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_NAVIGATION_ACTION))
44
#define WEBKIT_IS_WEB_NAVIGATION_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_NAVIGATION_ACTION))
45
#define WEBKIT_WEB_NAVIGATION_ACTION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_NAVIGATION_ACTION, WebKitWebNavigationActionClass))
46
47
typedef struct _WebKitWebNavigationAction WebKitWebNavigationAction;
48
typedef struct _WebKitWebNavigationActionClass WebKitWebNavigationActionClass;
49
typedef struct _WebKitWebNavigationActionPrivate WebKitWebNavigationActionPrivate;
50
51
struct _WebKitWebNavigationAction {
52
    GObject parent_instance;
53
    WebKitWebNavigationActionPrivate* priv;
54
};
55
56
struct _WebKitWebNavigationActionClass {
57
    GObjectClass parent_class;
58
};
59
60
WEBKIT_API GType
61
webkit_web_navigation_action_get_type(void);
62
63
WEBKIT_API WebKitWebNavigationReason
64
webkit_web_navigation_action_get_reason(WebKitWebNavigationAction* navigationAction);
65
66
WEBKIT_API void
67
webkit_web_navigation_action_set_reason(WebKitWebNavigationAction* navigationAction, WebKitWebNavigationReason reason);
68
69
WEBKIT_API const gchar*
70
webkit_web_navigation_action_get_original_uri(WebKitWebNavigationAction* navigationAction);
71
72
WEBKIT_API void
73
webkit_web_navigation_action_set_original_uri(WebKitWebNavigationAction* navigationAction, const gchar* originalUri);
74
75
G_END_DECLS
76
77
#endif
(-)a/WebKit/gtk/webkit/webkitwebpolicydecision.cpp (+123 lines)
Line 0 Link Here
1
/*
2
 * Copyright (C) 2008 Collabora Ltd.
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Library General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Library General Public License
15
 * along with this library; see the file COPYING.LIB.  If not, write to
16
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
 * Boston, MA 02110-1301, USA.
18
 */
19
20
#include "config.h"
21
22
#include "webkitwebpolicydecision.h"
23
24
#include "FrameLoaderTypes.h"
25
#include "webkitprivate.h"
26
27
using namespace WebKit;
28
using namespace WebCore;
29
30
extern "C" {
31
32
G_DEFINE_TYPE(WebKitWebPolicyDecision, webkit_web_policy_decision, G_TYPE_OBJECT);
33
34
struct _WebKitWebPolicyDecisionPrivate {
35
    WebKitWebFrame* frame;
36
    FramePolicyFunction framePolicyFunction;
37
    gboolean isCancelled;
38
};
39
40
#define WEBKIT_WEB_POLICY_DECISION_GET_PRIVATE(obj)    (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_POLICY_DECISION, WebKitWebPolicyDecisionPrivate))
41
42
static void webkit_web_policy_decision_class_init(WebKitWebPolicyDecisionClass* decisionClass)
43
{
44
    g_type_class_add_private(decisionClass, sizeof(WebKitWebPolicyDecisionPrivate));
45
}
46
47
static void webkit_web_policy_decision_init(WebKitWebPolicyDecision* decision)
48
{
49
    decision->priv = WEBKIT_WEB_POLICY_DECISION_GET_PRIVATE(decision);
50
}
51
52
WebKitWebPolicyDecision* webkit_web_policy_decision_new(WebKitWebFrame* frame, WebCore::FramePolicyFunction function)
53
{
54
    g_return_val_if_fail(frame, NULL);
55
56
    WebKitWebPolicyDecision* decision = WEBKIT_WEB_POLICY_DECISION(g_object_new(WEBKIT_TYPE_WEB_POLICY_DECISION, NULL));
57
    WebKitWebPolicyDecisionPrivate* priv = decision->priv;
58
59
    priv->frame = frame;
60
    priv->framePolicyFunction = function;
61
    priv->isCancelled = FALSE;
62
63
    return decision;
64
}
65
66
/**
67
 * webkit_web_policy_decision_use
68
 * @decision: a #WebKitWebPolicyDecision
69
 *
70
 * Will send the USE decision to the policy implementer.
71
 */
72
void webkit_web_policy_decision_use(WebKitWebPolicyDecision* decision)
73
{
74
    g_return_if_fail(WEBKIT_IS_WEB_POLICY_DECISION(decision));
75
76
    WebKitWebPolicyDecisionPrivate* priv = decision->priv;
77
78
    if (!priv->isCancelled)
79
        (core(priv->frame)->loader()->*(priv->framePolicyFunction))(WebCore::PolicyUse);
80
}
81
82
/**
83
 * webkit_web_policy_decision_ignore
84
 * @decision: a #WebKitWebPolicyDecision
85
 *
86
 * Will send the IGNORE decision to the policy implementer.
87
 */
88
void webkit_web_policy_decision_ignore(WebKitWebPolicyDecision* decision)
89
{
90
    g_return_if_fail(WEBKIT_IS_WEB_POLICY_DECISION(decision));
91
92
    WebKitWebPolicyDecisionPrivate* priv = decision->priv;
93
    
94
    if (!priv->isCancelled)
95
        (core(priv->frame)->loader()->*(priv->framePolicyFunction))(WebCore::PolicyIgnore);
96
}
97
98
/**
99
 * webkit_web_policy_decision_download
100
 * @decision: a #WebKitWebPolicyDecision
101
 *
102
 * Will send the DOWNLOAD decision to the policy implementer.
103
 */
104
void webkit_web_policy_decision_download(WebKitWebPolicyDecision* decision)
105
{
106
    g_return_if_fail(WEBKIT_IS_WEB_POLICY_DECISION(decision));
107
108
    WebKitWebPolicyDecisionPrivate* priv = decision->priv;
109
    
110
    if (!priv->isCancelled)
111
        (core(priv->frame)->loader()->*(priv->framePolicyFunction))(WebCore::PolicyDownload);
112
}
113
114
void webkit_web_policy_decision_cancel(WebKitWebPolicyDecision* decision)
115
{
116
    g_return_if_fail(WEBKIT_IS_WEB_POLICY_DECISION(decision));
117
118
    WebKitWebPolicyDecisionPrivate* priv = decision->priv;
119
    
120
    priv->isCancelled = TRUE;
121
}
122
123
}
(-)a/WebKit/gtk/webkit/webkitwebpolicydecision.h (+62 lines)
Line 0 Link Here
1
/*
2
 * Copyright (C) 2008 Collabora Ltd.
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Library General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Library General Public License
15
 * along with this library; see the file COPYING.LIB.  If not, write to
16
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
 * Boston, MA 02110-1301, USA.
18
 */
19
20
#ifndef WEBKIT_WEB_POLICY_DECISION_H
21
#define WEBKIT_WEB_POLICY_DECISION_H
22
23
#include <config.h>
24
25
#include <glib-object.h>
26
#include <stdint.h>
27
#include "webkitdefines.h"
28
29
G_BEGIN_DECLS
30
31
#define WEBKIT_TYPE_WEB_POLICY_DECISION            (webkit_web_policy_decision_get_type())
32
#define WEBKIT_WEB_POLICY_DECISION(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_POLICY_DECISION, WebKitWebPolicyDecision))
33
#define WEBKIT_WEB_POLICY_DECISION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_WEB_POLICY_DECISION, WebKitWebPolicyDecisionClass))
34
#define WEBKIT_IS_WEB_POLICY_DECISION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_POLICY_DECISION))
35
#define WEBKIT_IS_WEB_POLICY_DECISION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_WEB_POLICY_DECISION))
36
#define WEBKIT_WEB_POLICY_DECISION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_WEB_POLICY_DECISION, WebKitWebPolicyDecisionClass))
37
38
typedef struct _WebKitWebPolicyDecisionPrivate WebKitWebPolicyDecisionPrivate;
39
struct _WebKitWebPolicyDecision {
40
    GObject parent;
41
    WebKitWebPolicyDecisionPrivate* priv;
42
};
43
44
struct _WebKitWebPolicyDecisionClass {
45
    GObjectClass parent;
46
};
47
48
WEBKIT_API GType
49
webkit_web_policy_decision_get_type (void);
50
51
WEBKIT_API void
52
webkit_web_policy_decision_use (WebKitWebPolicyDecision* decision);
53
54
WEBKIT_API void
55
webkit_web_policy_decision_ignore (WebKitWebPolicyDecision* decision);
56
57
WEBKIT_API void
58
webkit_web_policy_decision_download (WebKitWebPolicyDecision* decision);
59
60
G_END_DECLS
61
62
#endif
(-)a/WebKit/gtk/webkit/webkitwebview.cpp (-25 / +73 lines)
Lines 5-10 Link Here
5
 *  Copyright (C) 2007 Alp Toker <alp@atoker.com>
5
 *  Copyright (C) 2007 Alp Toker <alp@atoker.com>
6
 *  Copyright (C) 2008 Jan Alonzo <jmalonzo@unpluggable.com>
6
 *  Copyright (C) 2008 Jan Alonzo <jmalonzo@unpluggable.com>
7
 *  Copyright (C) 2008 Nuanti Ltd.
7
 *  Copyright (C) 2008 Nuanti Ltd.
8
 *  Copyright (C) 2008 Collabora Ltd.
8
 *
9
 *
9
 *  This library is free software; you can redistribute it and/or
10
 *  This library is free software; you can redistribute it and/or
10
 *  modify it under the terms of the GNU Lesser General Public
11
 *  modify it under the terms of the GNU Lesser General Public
Lines 69-74 extern "C" { Link Here
69
enum {
70
enum {
70
    /* normal signals */
71
    /* normal signals */
71
    NAVIGATION_REQUESTED,
72
    NAVIGATION_REQUESTED,
73
    MIME_TYPE_POLICY_DECISION_REQUESTED,
72
    WINDOW_OBJECT_CLEARED,
74
    WINDOW_OBJECT_CLEARED,
73
    LOAD_STARTED,
75
    LOAD_STARTED,
74
    LOAD_COMMITTED,
76
    LOAD_COMMITTED,
Lines 539-550 static WebKitWebView* webkit_web_view_real_create_web_view(WebKitWebView*) Link Here
539
    return 0;
541
    return 0;
540
}
542
}
541
543
542
static WebKitNavigationResponse webkit_web_view_real_navigation_requested(WebKitWebView*, WebKitWebFrame* frame, WebKitNetworkRequest*)
543
{
544
    notImplemented();
545
    return WEBKIT_NAVIGATION_RESPONSE_ACCEPT;
546
}
547
548
static void webkit_web_view_real_window_object_cleared(WebKitWebView*, WebKitWebFrame*, JSGlobalContextRef context, JSObjectRef window_object)
544
static void webkit_web_view_real_window_object_cleared(WebKitWebView*, WebKitWebFrame*, JSGlobalContextRef context, JSObjectRef window_object)
549
{
545
{
550
    notImplemented();
546
    notImplemented();
Lines 705-722 static void webkit_web_view_finalize(GObject* object) Link Here
705
    G_OBJECT_CLASS(webkit_web_view_parent_class)->finalize(object);
701
    G_OBJECT_CLASS(webkit_web_view_parent_class)->finalize(object);
706
}
702
}
707
703
708
static gboolean webkit_navigation_request_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy)
709
{
710
  gboolean continueEmission = TRUE;
711
  int signalHandled = g_value_get_int(handlerReturn);
712
  g_value_set_int(returnAccu, signalHandled);
713
714
  if (signalHandled != WEBKIT_NAVIGATION_RESPONSE_ACCEPT)
715
      continueEmission = FALSE;
716
717
  return continueEmission;
718
}
719
720
static AtkObject* webkit_web_view_get_accessible(GtkWidget* widget)
704
static AtkObject* webkit_web_view_get_accessible(GtkWidget* widget)
721
{
705
{
722
    WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
706
    WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
Lines 747-762 static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) Link Here
747
     * Signals
731
     * Signals
748
     */
732
     */
749
733
734
    /**
735
     * WebKitWebView::navigation-requested:
736
     * @web_view: the object on which the signal is emitted
737
     * @frame: the #WebKitWebFrame that required the navigation
738
     * @request: a #WebKitNetworkRequest
739
     * @navigation_action: a #WebKitWebNavigation
740
     * @policy_decision: a #WebKitWebPolicyDecision
741
     * @return: TRUE if the signal will be handled, 
742
     *          FALSE to have the default behavior apply
743
     *
744
     * Emitted when @frame requests a navigation to another page.
745
     * If this signal is not handled, the default behavior is to allow the
746
     * navigation.
747
     */
750
    webkit_web_view_signals[NAVIGATION_REQUESTED] = g_signal_new("navigation-requested",
748
    webkit_web_view_signals[NAVIGATION_REQUESTED] = g_signal_new("navigation-requested",
751
            G_TYPE_FROM_CLASS(webViewClass),
749
            G_TYPE_FROM_CLASS(webViewClass),
752
            (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
750
            (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
753
            G_STRUCT_OFFSET (WebKitWebViewClass, navigation_requested),
751
            0,
754
            webkit_navigation_request_handled,
752
            g_signal_accumulator_true_handled,
755
            NULL,
753
            NULL,
756
            webkit_marshal_INT__OBJECT_OBJECT,
754
            webkit_marshal_BOOLEAN__OBJECT_OBJECT_OBJECT_OBJECT,
757
            G_TYPE_INT, 2,
755
            G_TYPE_BOOLEAN, 4,
758
            G_TYPE_OBJECT,
756
            WEBKIT_TYPE_WEB_FRAME,
759
            G_TYPE_OBJECT);
757
            WEBKIT_TYPE_NETWORK_REQUEST,
758
            WEBKIT_TYPE_WEB_NAVIGATION_ACTION,
759
            WEBKIT_TYPE_WEB_POLICY_DECISION);
760
761
    /**
762
     * WebKitWebView::mime-type-policy-decision-requested:
763
     * @web_view: the object on which the signal is emitted
764
     * @frame: the #WebKitWebFrame that required the policy decision
765
     * @request: a WebKitNetworkRequest
766
     * @mimetype: the MIME type attempted to load
767
     * @policy_decision: a #WebKitWebPolicyDecision
768
     * @return: TRUE if the signal will be handled, 
769
     *          FALSE to have the default behavior apply
770
     *
771
     * Decide whether or not to display of not the given MIME type.
772
     * If this signal is not handled, the default behavior is to show the
773
     * content of the requested URI if WebKit can show this MIME type,
774
     * else it will be ignored.
775
     */
776
    webkit_web_view_signals[MIME_TYPE_POLICY_DECISION_REQUESTED] = g_signal_new("mime-type-policy-decision-requested",
777
            G_TYPE_FROM_CLASS(webViewClass),
778
            (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
779
            0,
780
            g_signal_accumulator_true_handled,
781
            NULL,
782
            webkit_marshal_BOOLEAN__OBJECT_OBJECT_STRING_OBJECT,
783
            G_TYPE_BOOLEAN, 4,
784
            WEBKIT_TYPE_WEB_FRAME,
785
            WEBKIT_TYPE_NETWORK_REQUEST,
786
            G_TYPE_STRING,
787
            WEBKIT_TYPE_WEB_POLICY_DECISION);
760
788
761
    /**
789
    /**
762
     * WebKitWebView::window-object-cleared:
790
     * WebKitWebView::window-object-cleared:
Lines 1074-1080 static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) Link Here
1074
     * implementations of virtual methods
1102
     * implementations of virtual methods
1075
     */
1103
     */
1076
    webViewClass->create_web_view = webkit_web_view_real_create_web_view;
1104
    webViewClass->create_web_view = webkit_web_view_real_create_web_view;
1077
    webViewClass->navigation_requested = webkit_web_view_real_navigation_requested;
1078
    webViewClass->window_object_cleared = webkit_web_view_real_window_object_cleared;
1105
    webViewClass->window_object_cleared = webkit_web_view_real_window_object_cleared;
1079
    webViewClass->choose_file = webkit_web_view_real_choose_file;
1106
    webViewClass->choose_file = webkit_web_view_real_choose_file;
1080
    webViewClass->script_alert = webkit_web_view_real_script_alert;
1107
    webViewClass->script_alert = webkit_web_view_real_script_alert;
Lines 1993-1998 GtkTargetList* webkit_web_view_get_paste_target_list(WebKitWebView* webView) Link Here
1993
}
2020
}
1994
2021
1995
/**
2022
/**
2023
 * webkit_web_view_can_show_mime_type:
2024
 * @web_view: a #WebKitWebView
2025
 * @mime_type: a MIME type
2026
 *
2027
 * This functions returns whether or not a MIME type can be displayed using this view.
2028
 *
2029
 * Return value: a #gboolean indicating if the MIME type can be displayed
2030
 **/
2031
2032
gboolean webkit_web_view_can_show_mime_type (WebKitWebView* webView, const gchar* mimeType)
2033
{
2034
    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
2035
    
2036
    Frame* frame = core(webkit_web_view_get_main_frame(webView));
2037
    if (FrameLoader* loader = frame->loader())
2038
        return loader->canShowMIMEType(mimeType);
2039
    else
2040
        return FALSE;
2041
}
2042
2043
/**
1996
 * webkit_web_view_get_transparent:
2044
 * webkit_web_view_get_transparent:
1997
 * @web_view: a #WebKitWebView
2045
 * @web_view: a #WebKitWebView
1998
 *
2046
 *
(-)a/WebKit/gtk/webkit/webkitwebview.h (-11 / +4 lines)
Lines 1-6 Link Here
1
/*
1
/*
2
 * Copyright (C) 2007 Holger Hans Peter Freyther
2
 * Copyright (C) 2007 Holger Hans Peter Freyther
3
 * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
3
 * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
4
 * Copyright (C) 2008 Collabora Ltd.
4
 *
5
 *
5
 * This library is free software; you can redistribute it and/or
6
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Library General Public
7
 * modify it under the terms of the GNU Library General Public
Lines 40-51 G_BEGIN_DECLS Link Here
40
41
41
typedef struct _WebKitWebViewPrivate WebKitWebViewPrivate;
42
typedef struct _WebKitWebViewPrivate WebKitWebViewPrivate;
42
43
43
typedef enum {
44
    WEBKIT_NAVIGATION_RESPONSE_ACCEPT,
45
    WEBKIT_NAVIGATION_RESPONSE_IGNORE,
46
    WEBKIT_NAVIGATION_RESPONSE_DOWNLOAD
47
} WebKitNavigationResponse;
48
49
typedef enum
44
typedef enum
50
{
45
{
51
    WEBKIT_WEB_VIEW_TARGET_INFO_HTML = - 1,
46
    WEBKIT_WEB_VIEW_TARGET_INFO_HTML = - 1,
Lines 69-79 struct _WebKitWebViewClass { Link Here
69
     */
64
     */
70
    WebKitWebView*  (*create_web_view)  (WebKitWebView* web_view);
65
    WebKitWebView*  (*create_web_view)  (WebKitWebView* web_view);
71
66
72
    /*
73
     * TODO: FIXME: Create something like WebPolicyDecisionListener_Protocol instead
74
     */
75
    WebKitNavigationResponse (*navigation_requested) (WebKitWebView* web_view, WebKitWebFrame* frame, WebKitNetworkRequest* request);
76
77
    void (*window_object_cleared) (WebKitWebView* web_view, WebKitWebFrame* frame, JSGlobalContextRef context, JSObjectRef window_object);
67
    void (*window_object_cleared) (WebKitWebView* web_view, WebKitWebFrame* frame, JSGlobalContextRef context, JSObjectRef window_object);
78
    gchar*   (*choose_file) (WebKitWebView* web_view, WebKitWebFrame* frame, const gchar* old_file);
68
    gchar*   (*choose_file) (WebKitWebView* web_view, WebKitWebFrame* frame, const gchar* old_file);
79
    gboolean (*script_alert) (WebKitWebView* web_view, WebKitWebFrame* frame, const gchar* alert_message);
69
    gboolean (*script_alert) (WebKitWebView* web_view, WebKitWebFrame* frame, const gchar* alert_message);
Lines 212-217 WEBKIT_OBSOLETE_API void Link Here
212
webkit_web_view_go_backward (WebKitWebView* web_view);
202
webkit_web_view_go_backward (WebKitWebView* web_view);
213
203
214
WEBKIT_API gboolean
204
WEBKIT_API gboolean
205
webkit_web_view_can_show_mime_type (WebKitWebView* web_view, const gchar* mime_type);
206
207
WEBKIT_API gboolean
215
webkit_web_view_get_transparent (WebKitWebView* web_view);
208
webkit_web_view_get_transparent (WebKitWebView* web_view);
216
209
217
WEBKIT_API void
210
WEBKIT_API void

Return to bug 16562