[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.17-1283-gcf603cf
christian at webkit.org
christian at webkit.org
Tue Jan 5 23:52:27 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 6fd8964e3069c180922cf6ffa81ed12176f978c0
Author: christian at webkit.org <christian at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Dec 17 19:14:33 2009 +0000
2009-12-17 Christian Dywan <christian at twotoasts.de>
Reviewed by Gustavo Noronha Silva.
[GTK] Don't assume downloads are always synchronous
http://bugs.webkit.org/show_bug.cgi?id=32359
* tests/testdownload.c:
(download_requested_cb):
(set_filename):
(test_webkit_download_perform):
(test_webkit_download_synch):
(test_webkit_download_asynch):
(main): Test downloads synchronously and asynchronously.
* webkit/webkitwebview.cpp:
(webkit_web_view_class_init):
(webkit_web_view_request_download): Only try to start a requested
download if the destination URI is set and clarify the documentation.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52267 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
index 30862dc..bfbf2c8 100644
--- a/WebKit/gtk/ChangeLog
+++ b/WebKit/gtk/ChangeLog
@@ -1,5 +1,24 @@
2009-12-17 Christian Dywan <christian at twotoasts.de>
+ Reviewed by Gustavo Noronha Silva.
+
+ [GTK] Don't assume downloads are always synchronous
+ http://bugs.webkit.org/show_bug.cgi?id=32359
+
+ * tests/testdownload.c:
+ (download_requested_cb):
+ (set_filename):
+ (test_webkit_download_perform):
+ (test_webkit_download_synch):
+ (test_webkit_download_asynch):
+ (main): Test downloads synchronously and asynchronously.
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_class_init):
+ (webkit_web_view_request_download): Only try to start a requested
+ download if the destination URI is set and clarify the documentation.
+
+2009-12-17 Christian Dywan <christian at twotoasts.de>
+
Reviewed by Xan Lopez.
Deprecate the title-changed signal of WebKitWebFrame.
diff --git a/WebKit/gtk/tests/testdownload.c b/WebKit/gtk/tests/testdownload.c
index 0d964ed..05c3a8d 100644
--- a/WebKit/gtk/tests/testdownload.c
+++ b/WebKit/gtk/tests/testdownload.c
@@ -26,6 +26,7 @@
GMainLoop* loop;
char* temporaryFilename = NULL;
+WebKitDownload* theDownload = NULL;
static void
test_webkit_download_create(void)
@@ -87,6 +88,7 @@ download_requested_cb(WebKitWebView* web_view,
WebKitDownload* download,
gboolean* beenThere)
{
+ theDownload = download;
*beenThere = TRUE;
if (temporaryFilename) {
gchar *uri = g_filename_to_uri(temporaryFilename, NULL, NULL);
@@ -101,8 +103,19 @@ download_requested_cb(WebKitWebView* web_view,
return TRUE;
}
+static gboolean
+set_filename(gchar* filename)
+{
+ gchar *uri = g_filename_to_uri(filename, NULL, NULL);
+ webkit_download_set_destination_uri(theDownload, uri);
+ g_free(uri);
+ temporaryFilename = filename;
+ webkit_download_start(theDownload);
+ return FALSE;
+}
+
static void
-test_webkit_download_perform(void)
+test_webkit_download_perform(gboolean asynch)
{
WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
@@ -121,16 +134,23 @@ test_webkit_download_perform(void)
* utilities file, because we have a very similar one in
* testwebframe.c */
GError *error = NULL;
- int fd = g_file_open_tmp ("webkit-testwebdownload-XXXXXX",
- &temporaryFilename, &error);
+ gchar* filename;
+ int fd = g_file_open_tmp("webkit-testwebdownload-XXXXXX", &filename, &error);
close(fd);
if (error)
g_critical("Failed to open a temporary file for writing: %s.", error->message);
- if (g_unlink(temporaryFilename) == -1)
+ if (g_unlink(filename) == -1)
g_critical("Failed to delete the temporary file: %s.", g_strerror(errno));
+ if (asynch)
+ g_idle_add((GSourceFunc)set_filename, filename);
+ else
+ temporaryFilename = filename;
+
+ theDownload = NULL;
+
loop = g_main_loop_new(NULL, TRUE);
webkit_web_view_load_uri(webView, "http://gnome.org/");
g_main_loop_run(loop);
@@ -145,6 +165,18 @@ test_webkit_download_perform(void)
g_object_unref(webView);
}
+static void
+test_webkit_download_synch(void)
+{
+ test_webkit_download_perform(FALSE);
+}
+
+static void
+test_webkit_download_asynch(void)
+{
+ test_webkit_download_perform(TRUE);
+}
+
int main(int argc, char** argv)
{
g_thread_init(NULL);
@@ -152,7 +184,8 @@ int main(int argc, char** argv)
g_test_bug_base("https://bugs.webkit.org/");
g_test_add_func("/webkit/download/create", test_webkit_download_create);
- g_test_add_func("/webkit/download/perform", test_webkit_download_perform);
+ g_test_add_func("/webkit/download/synch", test_webkit_download_synch);
+ g_test_add_func("/webkit/download/asynch", test_webkit_download_asynch);
return g_test_run ();
}
diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp
index f6296b9..b9c70c6 100644
--- a/WebKit/gtk/webkit/webkitwebview.cpp
+++ b/WebKit/gtk/webkit/webkitwebview.cpp
@@ -1541,9 +1541,10 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* @return: %TRUE if the download should be performed, %FALSE to cancel it.
*
* A new Download is being requested. By default, if the signal is
- * not handled, the download is cancelled. Notice that while
- * handling this signal you must set the target URI using
- * webkit_download_set_target_uri().
+ * not handled, the download is cancelled. If you handle the download
+ * and call webkit_download_set_destination_uri(), it will be
+ * started for you. If you need to set the destination asynchronously
+ * you are responsible for starting or cancelling it yourself.
*
* If you intend to handle downloads yourself rather than using
* the #WebKitDownload helper object you must handle this signal,
@@ -2695,7 +2696,10 @@ void webkit_web_view_request_download(WebKitWebView* webView, WebKitNetworkReque
return;
}
- webkit_download_start(download);
+ /* Start the download now if it has a destination URI, otherwise it
+ may be handled asynchronously by the application. */
+ if (webkit_download_get_destination_uri(download))
+ webkit_download_start(download);
}
bool webkit_web_view_use_primary_for_paste(WebKitWebView* webView)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list