GNOME Bugzilla – Bug 570735
Need download support for WebKit
Last modified: 2009-03-05 00:01:46 UTC
Currently trunk has no download support because webkit has no support for it yet.
Created attachment 128063 [details] [review] initial work This patch depends on WebKit having the patch in: https://bugs.webkit.org/show_bug.cgi?id=16826
I was thinking that we should get rid of the EphyDownload abstraction and just use the WebKit object in DownloaderView. Could you modify the patch to do that?
Created attachment 128585 [details] [review] download implementation for WebKit updated patch with the updated patch for WebKit/GTK+ and implemented changes requested by xan
*** Bug 554215 has been marked as a duplicate of this bug. ***
gint64 total, cur; + gdouble elapsed_time; + gdouble remaining_time; + + total = webkit_download_get_total_size (download); + cur = webkit_download_get_current_size (download); + elapsed_time = webkit_download_get_elapsed_time (download); + + if (cur > 0) + { + gdouble per_byte_time; + + per_byte_time = elapsed_time / cur; + remaining_time = per_byte_time * (total - cur); + } + + return remaining_time; This looks a bit wrong. If cur <= 0 you'll return garbage (I think there must have been a warning), and you are doing too much work before knowing if you need it. I'd just get cur, check it, then do the rest, otherwise return some default value. static gboolean +download_requested_cb (WebKitWebView *web_view, + WebKitDownload *download, + WebKitEmbed *embed) +{ + EphyFileChooser *dialog; + EphyEmbedPersist *persist; + + GtkWindow *window; + const char *title; + const char *key; + + gint dialog_result; + gboolean should_continue = FALSE; A better name for 'should_continue' is 'handled' IMHO. + persist = EPHY_EMBED_PERSIST (ephy_embed_factory_new_object (EPHY_TYPE_EMBED_PERSIST)); + + title = ephy_embed_persist_get_fc_title (persist); + window = ephy_embed_persist_get_fc_parent (persist); + key = ephy_embed_persist_get_persist_key (persist); + + dialog = ephy_file_chooser_new (title ? title: _("Save"), + GTK_WIDGET (window), + GTK_FILE_CHOOSER_ACTION_SAVE, + key ? key : CONF_STATE_SAVE_DIR, + EPHY_FILE_FILTER_ALL_SUPPORTED); How can this work if you have just created the EphyEmbedPersist? EphyEmbedPersist is an abstract interface on top of the download stuff of the browsers, we have to get rid of it and use WebKitDownload everywhere. The point is to create an EphyEmbedPersist, set those properties, and then start a download. If i FileChooser is needed it will be launched with them. Here you just want to use the default values you set (for window get the toplevel of the view). As a follow-up to this it would be great to port all the remaining uses of EphyEmbedPersist and then get rid of it :)
I have landed this in trunk as r8848, with Xan's comments addressed and a crash fixed.