Changeset 39421 in webkit
- Timestamp:
- Dec 19, 2008 7:18:31 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r39407 r39421 1 2008-12-19 Marco Barisione <marco.barisione@collabora.co.uk> 2 3 Reviewed by Holger Freyther. 4 5 http://bugs.webkit.org/show_bug.cgi?id=16562 6 [gtk] Implement WebPolicyDelegate methods 7 8 Original work by Pierre-Luc Beaudoin. Final touches by Gustavo 9 Noronha. 10 11 This implements the delegates methods of WebPolicyDelegate. 12 Since Gtk+/C doesn't have delegate methods, they are replaced with 13 signals. 14 15 A new object WebKitWebPolicyDecision allows the browser to delay its 16 response in certain cases. WebKitWebNavigationAction contains the 17 information about what caused a navigation request. 18 19 * GNUmakefile.am: Add new files 20 1 21 2008-12-19 Gustavo Noronha Silva <gns@gnome.org> 2 22 -
trunk/GNUmakefile.am
r39241 r39421 309 309 WebKit/gtk/webkit/webkitwebhistoryitem.h \ 310 310 WebKit/gtk/webkit/webkitwebinspector.h \ 311 WebKit/gtk/webkit/webkitwebnavigationaction.h \ 312 WebKit/gtk/webkit/webkitwebpolicydecision.h \ 311 313 WebKit/gtk/webkit/webkitwebsettings.h \ 312 314 WebKit/gtk/webkit/webkitwebwindowfeatures.h \ … … 342 344 WebKit/gtk/webkit/webkitwebhistoryitem.cpp \ 343 345 WebKit/gtk/webkit/webkitwebinspector.cpp \ 346 WebKit/gtk/webkit/webkitwebnavigationaction.cpp \ 347 WebKit/gtk/webkit/webkitwebpolicydecision.cpp \ 344 348 WebKit/gtk/webkit/webkitwebsettings.cpp \ 345 349 WebKit/gtk/webkit/webkitwebview.cpp \ -
trunk/WebKit/gtk/ChangeLog
r39393 r39421 1 2008-12-19 Marco Barisione <marco.barisione@collabora.co.uk> 2 3 Reviewed by Holger Freyther. 4 5 http://bugs.webkit.org/show_bug.cgi?id=16562 6 [gtk] Implement WebPolicyDelegate methods 7 8 Original work by Pierre-Luc Beaudoin. Final touches by Gustavo 9 Noronha. 10 11 This implements the delegates methods of WebPolicyDelegate. 12 Since Gtk+/C doesn't have delegate methods, they are replaced with 13 signals. 14 15 A new object WebKitWebPolicyDecision allows the browser to delay its 16 response in certain cases. WebKitWebNavigationAction contains the 17 information about what caused a navigation request. 18 19 * WebCoreSupport/FrameLoaderClientGtk.cpp: 20 (WebKit::FrameLoaderClient::FrameLoaderClient): 21 (WebKit::FrameLoaderClient::~FrameLoaderClient): 22 (WebKit::FrameLoaderClient::dispatchDecidePolicyForMIMEType): 23 (WebKit::FrameLoaderClient::dispatchDecidePolicyForNewWindowAction): 24 (WebKit::FrameLoaderClient::dispatchDecidePolicyForNavigationAction): 25 (WebKit::FrameLoaderClient::cancelPolicyCheck): 26 (WebKit::FrameLoaderClient::canShowMIMEType): 27 * WebCoreSupport/FrameLoaderClientGtk.h: 28 * webkit/webkit.h: 29 * webkit/webkitdefines.h: 30 * webkit/webkitprivate.cpp: 31 (WebKit::kit): 32 (WebKit::core): 33 * webkit/webkitprivate.h: 34 * webkit/webkitwebnavigationaction.cpp: Added. 35 (_WebKitWebNavigationActionPrivate::): 36 (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_get_property): 37 (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_set_property): 38 (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_init): 39 (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_finalize): 40 (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_class_init): 41 (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_get_reason): 42 (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_set_reason): 43 (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_get_original_uri): 44 (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_set_original_uri): 45 * webkit/webkitwebnavigationaction.h: Added. 46 * webkit/webkitwebpolicydecision.cpp: Added. 47 (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_class_init): 48 (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_init): 49 (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_new): 50 (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_use): 51 (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_ignore): 52 (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_download): 53 (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_cancel): 54 * webkit/webkitwebpolicydecision.h: Added. 55 * webkit/webkitwebview.cpp: 56 * webkit/webkitwebview.h: 57 1 58 2008-12-18 Dan Bernstein <mitz@apple.com> 2 59 -
trunk/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
r39393 r39421 47 47 #include "webkitnetworkrequest.h" 48 48 #include "webkitwebframe.h" 49 #include "webkitwebnavigationaction.h" 50 #include "webkitwebpolicydecision.h" 49 51 #include "webkitprivate.h" 50 52 … … 62 64 : m_frame(frame) 63 65 , m_userAgent("") 66 , m_policyDecision(0) 64 67 , m_pluginView(0) 65 68 , m_hasSentResponseToPlugin(false) 66 69 { 67 70 ASSERT(m_frame); 71 } 72 73 FrameLoaderClient::~FrameLoaderClient() 74 { 75 if (m_policyDecision) 76 g_object_unref(m_policyDecision); 68 77 } 69 78 … … 251 260 } 252 261 253 void FrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction policyFunction, const String&, const ResourceRequest&) 254 { 255 // FIXME: we need to call directly here (comment copied from Qt version) 262 void FrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction policyFunction, const String& mimeType, const ResourceRequest& resourceRequest) 263 { 256 264 ASSERT(policyFunction); 257 265 if (!policyFunction) 258 266 return; 259 (core(m_frame)->loader()->*policyFunction)(PolicyUse); 260 } 261 262 void FrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction policyFunction, const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>, const String&) 267 268 WebKitWebView* page = getViewFromFrame(m_frame); 269 WebKitNetworkRequest* request = webkit_network_request_new(resourceRequest.url().string().utf8().data()); 270 271 WebKitWebPolicyDecision* policyDecision = webkit_web_policy_decision_new(m_frame, policyFunction); 272 if (m_policyDecision) 273 g_object_unref(m_policyDecision); 274 m_policyDecision = policyDecision; 275 276 gboolean isHandled = false; 277 g_signal_emit_by_name(page, "mime-type-policy-decision-requested", m_frame, request, mimeType.utf8().data(), policyDecision, &isHandled); 278 279 g_object_unref(request); 280 281 if (isHandled) 282 return; 283 284 if (canShowMIMEType(mimeType)) 285 webkit_web_policy_decision_use (policyDecision); 286 else 287 webkit_web_policy_decision_download (policyDecision); 288 } 289 290 void FrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction policyFunction, const NavigationAction& action, const ResourceRequest& resourceRequest, PassRefPtr<FormState>, const String& s) 263 291 { 264 292 ASSERT(policyFunction); … … 279 307 WebKitNetworkRequest* request = webkit_network_request_new(resourceRequest.url().string().utf8().data()); 280 308 WebKitNavigationResponse response; 281 309 /* 310 * We still support the deprecated navigation-requested signal, if the 311 * application doesn't ignore the navigation then the new signal is 312 * emitted. 313 * navigation-policy-decision-requested must be emitted after 314 * navigation-requested as the policy decision can be async. 315 */ 282 316 g_signal_emit_by_name(webView, "navigation-requested", m_frame, request, &response); 283 284 g_object_unref(request);285 317 286 318 if (response == WEBKIT_NAVIGATION_RESPONSE_IGNORE) { 287 319 (core(m_frame)->loader()->*policyFunction)(PolicyIgnore); 320 g_object_unref(request); 288 321 return; 289 322 } 290 323 291 (core(m_frame)->loader()->*policyFunction)(PolicyUse); 324 WebKitWebPolicyDecision* policyDecision = webkit_web_policy_decision_new(m_frame, policyFunction); 325 if (m_policyDecision) 326 g_object_unref(m_policyDecision); 327 m_policyDecision = policyDecision; 328 329 // TODO: use action.event(). 330 GObject* navigationAction = G_OBJECT(g_object_new(WEBKIT_TYPE_WEB_NAVIGATION_ACTION, 331 "reason", kit(action.type()), 332 "original-uri", action.url().string().utf8().data(), 333 NULL)); 334 335 gboolean isHandled = false; 336 g_signal_emit_by_name(webView, "navigation-policy-decision-requested", m_frame, request, navigationAction, policyDecision, &isHandled); 337 338 g_object_unref(navigationAction); 339 g_object_unref(request); 340 341 // FIXME Implement default behavior when we can query the backend what protocols it supports 342 if (!isHandled) 343 webkit_web_policy_decision_use(m_policyDecision); 292 344 } 293 345 … … 563 615 void FrameLoaderClient::cancelPolicyCheck() 564 616 { 565 notImplemented(); 617 //FIXME Add support for more than one policy decision at once 618 if (m_policyDecision) 619 webkit_web_policy_decision_cancel(m_policyDecision); 566 620 } 567 621 … … 592 646 } 593 647 594 bool FrameLoaderClient::canShowMIMEType(const String& ) const595 { 596 notImplemented();597 return true;648 bool FrameLoaderClient::canShowMIMEType(const String& type) const 649 { 650 return MIMETypeRegistry::isSupportedImageMIMEType(type) || MIMETypeRegistry::isSupportedNonImageMIMEType(type) || 651 PluginDatabase::installedPlugins()->isMIMETypeRegistered(type); 598 652 } 599 653 -
trunk/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h
r39393 r39421 34 34 #include "ResourceResponse.h" 35 35 #include "PluginView.h" 36 #include "webkitwebpolicydecision.h" 36 37 37 38 typedef struct _WebKitWebFrame WebKitWebFrame; … … 42 43 public: 43 44 FrameLoaderClient(WebKitWebFrame*); 44 virtual ~FrameLoaderClient() { }45 virtual ~FrameLoaderClient(); 45 46 virtual void frameLoaderDestroyed(); 46 47 … … 173 174 WebCore::ResourceResponse m_response; 174 175 WebCore::String m_userAgent; 176 WebKitWebPolicyDecision* m_policyDecision; 175 177 176 178 // Plugin view to redirect data to -
trunk/WebKit/gtk/webkit/webkit.h
r38834 r39421 1 1 /* 2 2 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 3 * Copyright (C) 2008 Collabora Ltd. 3 4 * 4 5 * This library is free software; you can redistribute it and/or … … 31 32 #include <webkit/webkitwebbackforwardlist.h> 32 33 #include <webkit/webkitwebhistoryitem.h> 34 #include <webkit/webkitwebpolicydecision.h> 35 #include <webkit/webkitwebnavigationaction.h> 33 36 #include <webkit/webkitenumtypes.h> 34 37 -
trunk/WebKit/gtk/webkit/webkitdefines.h
r38834 r39421 1 1 /* 2 2 * Copyright (C) 2007 Holger Hans Peter Freyther 3 * Copyright (C) 2008 Collabora Ltd. 3 4 * 4 5 * This library is free software; you can redistribute it and/or … … 53 54 typedef struct _WebKitWebFrameClass WebKitWebFrameClass; 54 55 56 typedef struct _WebKitWebPolicyDecision WebKitWebPolicyDecision; 57 typedef struct _WebKitWebPolicyDecisionClass WebKitWebPolicyDecisionClass; 58 55 59 typedef struct _WebKitWebSettings WebKitWebSettings; 56 60 typedef struct _WebKitWebSettingsClass WebKitWebSettingsClass; -
trunk/WebKit/gtk/webkit/webkitprivate.cpp
r38087 r39421 1 1 /* 2 2 * Copyright (C) 2007 Holger Hans Peter Freyther 3 * Copyright (C) 2008 Collabora Ltd. 3 4 * 4 5 * This library is free software; you can redistribute it and/or … … 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 97 } /** end namespace WebKit */ 87 98 -
trunk/WebKit/gtk/webkit/webkitprivate.h
r39274 r39421 2 2 * Copyright (C) 2007, 2008 Holger Hans Peter Freyther 3 3 * Copyright (C) 2008 Jan Michael C. Alonzo 4 * Copyright (C) 2008 Collabora Ltd. 4 5 * 5 6 * This library is free software; you can redistribute it and/or … … 30 31 #include <webkit/webkitwebview.h> 31 32 #include <webkit/webkitwebframe.h> 33 #include <webkit/webkitwebpolicydecision.h> 34 #include <webkit/webkitwebnavigationaction.h> 32 35 #include <webkit/webkitwebsettings.h> 33 36 #include <webkit/webkitwebwindowfeatures.h> … … 58 61 59 62 WebCore::BackForwardList* core(WebKitWebBackForwardList*); 63 64 WebKitWebNavigationReason kit(WebCore::NavigationType type); 65 WebCore::NavigationType core(WebKitWebNavigationReason reason); 60 66 } 61 67 … … 131 137 webkit_web_view_notify_ready (WebKitWebView* web_view); 132 138 139 WebKitWebPolicyDecision* 140 webkit_web_policy_decision_new (WebKitWebFrame*, WebCore::FramePolicyFunction); 141 142 void 143 webkit_web_policy_decision_cancel (WebKitWebPolicyDecision* decision); 144 133 145 // FIXME: Move these to webkitwebframe.h once their API has been discussed. 134 146 -
trunk/WebKit/gtk/webkit/webkitwebview.cpp
r39223 r39421 27 27 28 28 #include "webkitwebview.h" 29 #include "webkitenumtypes.h" 29 30 #include "webkitmarshal.h" 30 31 #include "webkitprivate.h" … … 76 77 /* normal signals */ 77 78 NAVIGATION_REQUESTED, 79 NAVIGATION_POLICY_DECISION_REQUESTED, 80 MIME_TYPE_POLICY_DECISION_REQUESTED, 78 81 CREATE_WEB_VIEW, 79 82 WEB_VIEW_READY, … … 632 635 } 633 636 634 static WebKitNavigationResponse webkit_web_view_real_navigation_requested(WebKitWebView*, WebKitWebFrame* frame, WebKitNetworkRequest*) 635 { 636 notImplemented(); 637 static WebKitNavigationResponse webkit_web_view_real_navigation_requested(WebKitWebView*, WebKitWebFrame*, WebKitNetworkRequest*) 638 { 637 639 return WEBKIT_NAVIGATION_RESPONSE_ACCEPT; 638 640 } … … 812 814 static gboolean webkit_navigation_request_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy) 813 815 { 814 int signalHandled = g_value_get_int(handlerReturn);815 g_value_set_ int(returnAccu, signalHandled);816 817 if ( signalHandled!= WEBKIT_NAVIGATION_RESPONSE_ACCEPT)816 WebKitNavigationResponse navigationResponse = (WebKitNavigationResponse)g_value_get_enum(handlerReturn); 817 g_value_set_enum(returnAccu, navigationResponse); 818 819 if (navigationResponse != WEBKIT_NAVIGATION_RESPONSE_ACCEPT) 818 820 return FALSE; 819 821 … … 908 910 G_TYPE_BOOLEAN, 0); 909 911 912 /** 913 * WebKitWebView::navigation-requested: 914 * @web_view: the object on which the signal is emitted 915 * @frame: the #WebKitWebFrame that required the navigation 916 * @request: a #WebKitNetworkRequest 917 * @return: a WebKitNavigationResponse 918 * 919 * Emitted when @frame requests a navigation to another page. 920 * 921 * Deprecated: Use WebKitWebView::navigation-policy-decision-requested 922 * instead 923 */ 910 924 webkit_web_view_signals[NAVIGATION_REQUESTED] = g_signal_new("navigation-requested", 911 925 G_TYPE_FROM_CLASS(webViewClass), … … 914 928 webkit_navigation_request_handled, 915 929 NULL, 916 webkit_marshal_INT__OBJECT_OBJECT, 917 G_TYPE_INT, 2, 918 G_TYPE_OBJECT, 919 G_TYPE_OBJECT); 930 webkit_marshal_ENUM__OBJECT_OBJECT, 931 WEBKIT_TYPE_NAVIGATION_RESPONSE, 2, 932 WEBKIT_TYPE_WEB_FRAME, 933 WEBKIT_TYPE_NETWORK_REQUEST); 934 935 /** 936 * WebKitWebView::navigation-policy-decision-requested: 937 * @web_view: the object on which the signal is emitted 938 * @frame: the #WebKitWebFrame that required the navigation 939 * @request: a #WebKitNetworkRequest 940 * @navigation_action: a #WebKitWebNavigation 941 * @policy_decision: a #WebKitWebPolicyDecision 942 * @return: TRUE if the signal will be handled, FALSE to have the 943 * default behavior apply 944 * 945 * Emitted when @frame requests a navigation to another page. 946 * If this signal is not handled, the default behavior is to allow the 947 * navigation. 948 * 949 * Since: 1.0.3 950 */ 951 webkit_web_view_signals[NAVIGATION_POLICY_DECISION_REQUESTED] = g_signal_new("navigation-policy-decision-requested", 952 G_TYPE_FROM_CLASS(webViewClass), 953 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 954 0, 955 g_signal_accumulator_true_handled, 956 NULL, 957 webkit_marshal_BOOLEAN__OBJECT_OBJECT_OBJECT_OBJECT, 958 G_TYPE_BOOLEAN, 4, 959 WEBKIT_TYPE_WEB_FRAME, 960 WEBKIT_TYPE_NETWORK_REQUEST, 961 WEBKIT_TYPE_WEB_NAVIGATION_ACTION, 962 WEBKIT_TYPE_WEB_POLICY_DECISION); 963 964 /** 965 * WebKitWebView::mime-type-policy-decision-requested: 966 * @web_view: the object on which the signal is emitted 967 * @frame: the #WebKitWebFrame that required the policy decision 968 * @request: a WebKitNetworkRequest 969 * @mimetype: the MIME type attempted to load 970 * @policy_decision: a #WebKitWebPolicyDecision 971 * @return: TRUE if the signal will be handled, FALSE to have the 972 * default behavior apply 973 * 974 * Decide whether or not to display the given MIME type. If this 975 * signal is not handled, the default behavior is to show the 976 * content of the requested URI if WebKit can show this MIME 977 * type; if WebKit is not able to show the MIME type nothing 978 * happens. 979 * 980 * Since: 1.0.3 981 */ 982 webkit_web_view_signals[MIME_TYPE_POLICY_DECISION_REQUESTED] = g_signal_new("mime-type-policy-decision-requested", 983 G_TYPE_FROM_CLASS(webViewClass), 984 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 985 0, 986 g_signal_accumulator_true_handled, 987 NULL, 988 webkit_marshal_BOOLEAN__OBJECT_OBJECT_STRING_OBJECT, 989 G_TYPE_BOOLEAN, 4, 990 WEBKIT_TYPE_WEB_FRAME, 991 WEBKIT_TYPE_NETWORK_REQUEST, 992 G_TYPE_STRING, 993 WEBKIT_TYPE_WEB_POLICY_DECISION); 920 994 921 995 /** … … 2316 2390 2317 2391 /** 2392 * webkit_web_view_can_show_mime_type: 2393 * @web_view: a #WebKitWebView 2394 * @mime_type: a MIME type 2395 * 2396 * This functions returns whether or not a MIME type can be displayed using this view. 2397 * 2398 * Return value: a #gboolean indicating if the MIME type can be displayed 2399 * 2400 * Since: 1.0.3 2401 **/ 2402 2403 gboolean webkit_web_view_can_show_mime_type(WebKitWebView* webView, const gchar* mimeType) 2404 { 2405 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); 2406 2407 Frame* frame = core(webkit_web_view_get_main_frame(webView)); 2408 if (FrameLoader* loader = frame->loader()) 2409 return loader->canShowMIMEType(String::fromUTF8(mimeType)); 2410 else 2411 return FALSE; 2412 } 2413 2414 /** 2318 2415 * webkit_web_view_get_transparent: 2319 2416 * @web_view: a #WebKitWebView -
trunk/WebKit/gtk/webkit/webkitwebview.h
r39223 r39421 2 2 * Copyright (C) 2007 Holger Hans Peter Freyther 3 3 * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com> 4 * Copyright (C) 2008 Collabora Ltd. 4 5 * 5 6 * This library is free software; you can redistribute it and/or … … 72 73 gboolean (* web_view_ready) (WebKitWebView* web_view); 73 74 74 /*75 * TODO: FIXME: Create something like WebPolicyDecisionListener_Protocol instead76 */77 75 WebKitNavigationResponse (* navigation_requested) (WebKitWebView *web_view, 78 76 WebKitWebFrame *frame, … … 257 255 258 256 WEBKIT_API gboolean 257 webkit_web_view_can_show_mime_type (WebKitWebView *web_view, 258 const gchar *mime_type); 259 260 WEBKIT_API gboolean 259 261 webkit_web_view_get_transparent (WebKitWebView *web_view); 260 262
Note: See TracChangeset
for help on using the changeset viewer.