Permalink
Browse files

Script evaluation in Linux, register url scheme as local for Linux, h…

…andle new window navigation for Linux
  • Loading branch information...
1 parent 6af2f8a commit 46086bdba8491be8c0059c99518a280907c3261f martin robinson committed Feb 19, 2009
@@ -252,14 +252,28 @@ void FrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction poli
(core(m_frame)->loader()->*policyFunction)(PolicyUse);
}
-void FrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction policyFunction, const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>, const String&)
+void FrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction policyFunction, const NavigationAction&, const ResourceRequest& resourceRequest, PassRefPtr<FormState>, const String& frameName)
{
ASSERT(policyFunction);
if (!policyFunction)
return;
- // FIXME: I think Qt version marshals this to another thread so when we
- // have multi-threaded download, we might need to do the same
- (core(m_frame)->loader()->*policyFunction)(PolicyUse);
+
+ WebKitWebView* webView = getViewFromFrame(m_frame);
+ WebKitNetworkRequest* request = webkit_network_request_new(strdup(resourceRequest.url().string().utf8().data()));
+ WebKitNavigationResponse response;
+ gchar* frame_name = strdup(frameName.utf8().data());
+
+ printf("in-args: %x %x %x\n", (int) m_frame, (int) request, (int) frame_name);
+ g_signal_emit_by_name(webView, "new-window-navigation-requested", m_frame, request, frame_name, &response);
+
+ free(frame_name);
+ g_object_unref(request);
+
+ if (response == WEBKIT_NAVIGATION_RESPONSE_IGNORE) {
+ (core(m_frame)->loader()->*policyFunction)(PolicyIgnore);
+ } else {
+ (core(m_frame)->loader()->*policyFunction)(PolicyUse);
+ }
}
void FrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunction policyFunction, const NavigationAction& action, const ResourceRequest& resourceRequest, PassRefPtr<FormState>)
@@ -272,6 +286,7 @@ void FrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunct
WebKitNetworkRequest* request = webkit_network_request_new(resourceRequest.url().string().utf8().data());
WebKitNavigationResponse response;
+ printf("str: %s\n", webkit_network_request_get_uri(request));
g_signal_emit_by_name(webView, "navigation-requested", m_frame, request, &response);
g_object_unref(request);
@@ -16,11 +16,12 @@ EvaluatorAdapter::EvaluatorAdapter(WebKitWebScriptEvaluator *evaluator)
bool EvaluatorAdapter::matchesMimeType(const WebCore::String &mimeType) {
return evaluator->matchesMimeType(mimeType.utf8().data());
+
}
void EvaluatorAdapter::evaluate(const WebCore::String &mimeType, const WebCore::ScriptSourceCode& sourceCode, void *context)
{
- evaluator->evaluate(mimeType.utf8().data(), sourceCode.jsSourceCode().toString().ascii());
+ evaluator->evaluate(mimeType.utf8().data(), sourceCode.jsSourceCode().toString().ascii(), context);
}
WEBKIT_API void addScriptEvaluator(WebKitWebScriptEvaluator *evaluator) {
@@ -5,7 +5,7 @@ class WebKitWebScriptEvaluator
{
public:
virtual bool matchesMimeType(const gchar * mimeType) = 0;
- virtual void evaluate(const gchar *mimeType, const gchar *sourceCode) = 0;
+ virtual void evaluate(const gchar *mimeType, const gchar *sourceCode, void*) = 0;
};
#endif
@@ -75,6 +75,7 @@ extern "C" {
enum {
/* normal signals */
NAVIGATION_REQUESTED,
+ NEW_WINDOW_NAVIGATION_REQUESTED,
CREATE_WEB_VIEW,
WEB_VIEW_READY,
WINDOW_OBJECT_CLEARED,
@@ -637,6 +638,12 @@ static WebKitNavigationResponse webkit_web_view_real_navigation_requested(WebKit
return WEBKIT_NAVIGATION_RESPONSE_ACCEPT;
}
+static WebKitNavigationResponse webkit_web_view_real_new_window_navigation_requested(WebKitWebView*, WebKitWebFrame* frame, WebKitNetworkRequest*, gchar*)
+{
+ notImplemented();
+ return WEBKIT_NAVIGATION_RESPONSE_ACCEPT;
+}
+
static void webkit_web_view_real_window_object_cleared(WebKitWebView*, WebKitWebFrame*, JSGlobalContextRef context, JSObjectRef window_object)
{
notImplemented();
@@ -820,6 +827,17 @@ static gboolean webkit_navigation_request_handled(GSignalInvocationHint* ihint,
return TRUE;
}
+static gboolean webkit_new_window_navigation_request_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy)
+{
+ int signalHandled = g_value_get_int(handlerReturn);
+ g_value_set_int(returnAccu, signalHandled);
+
+ if (signalHandled != WEBKIT_NAVIGATION_RESPONSE_ACCEPT)
+ return FALSE;
+
+ return TRUE;
+}
+
static AtkObject* webkit_web_view_get_accessible(GtkWidget* widget)
{
WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
@@ -918,6 +936,18 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
G_TYPE_OBJECT,
G_TYPE_OBJECT);
+ webkit_web_view_signals[NEW_WINDOW_NAVIGATION_REQUESTED] = g_signal_new("new-window-navigation-requested",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ G_STRUCT_OFFSET (WebKitWebViewClass, new_window_navigation_requested),
+ webkit_navigation_request_handled,
+ NULL,
+ webkit_marshal_INT__OBJECT_OBJECT_STRING,
+ G_TYPE_INT, 3,
+ G_TYPE_OBJECT,
+ G_TYPE_OBJECT,
+ G_TYPE_STRING);
+
/**
* WebKitWebView::window-object-cleared:
* @web_view: the object on which the signal is emitted
@@ -1244,6 +1274,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
webViewClass->create_web_view = webkit_web_view_real_create_web_view;
webViewClass->web_view_ready = webkit_web_view_real_web_view_ready;
webViewClass->navigation_requested = webkit_web_view_real_navigation_requested;
+ webViewClass->new_window_navigation_requested = webkit_web_view_real_new_window_navigation_requested;
webViewClass->window_object_cleared = webkit_web_view_real_window_object_cleared;
webViewClass->choose_file = webkit_web_view_real_choose_file;
webViewClass->script_alert = webkit_web_view_real_script_alert;
@@ -2496,4 +2527,9 @@ void webkit_web_view_set_full_content_zoom(WebKitWebView* webView, gboolean zoom
g_object_notify(G_OBJECT(webView), "full-content-zoom");
}
+void webkit_web_view_register_url_scheme_as_local(const gchar* scheme)
+{
+ FrameLoader::registerURLSchemeAsLocal(String(scheme, strlen(scheme)));
+}
+
}
@@ -77,6 +77,10 @@ struct _WebKitWebViewClass {
WebKitNavigationResponse (* navigation_requested) (WebKitWebView *web_view,
WebKitWebFrame *frame,
WebKitNetworkRequest *request);
+ WebKitNavigationResponse (* new_window_navigation_requested) (WebKitWebView *web_view,
+ WebKitWebFrame *frame,
+ WebKitNetworkRequest *request,
+ gchar *frame_name);
void (* window_object_cleared) (WebKitWebView *web_view,
WebKitWebFrame *frame,
JSGlobalContextRef context,
@@ -282,6 +286,8 @@ WEBKIT_API void
webkit_web_view_set_full_content_zoom (WebKitWebView *web_view,
gboolean full_content_zoom);
+WEBKIT_API void webkit_web_view_register_url_scheme_as_local(const gchar* scheme);
+
G_END_DECLS
#endif

0 comments on commit 46086bd

Please sign in to comment.