After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 570735 - Need download support for WebKit
Need download support for WebKit
Status: RESOLVED FIXED
Product: epiphany
Classification: Core
Component: Backend
git master
Other All
: Normal normal
: ---
Assigned To: Gustavo Noronha (kov)
Epiphany Maintainers
: 554215 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-02-05 23:51 UTC by Gustavo Noronha (kov)
Modified: 2009-03-05 00:01 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
initial work (12.26 KB, patch)
2009-02-05 23:52 UTC, Gustavo Noronha (kov)
none Details | Review
download implementation for WebKit (24.12 KB, patch)
2009-02-12 20:37 UTC, Gustavo Noronha (kov)
none Details | Review

Description Gustavo Noronha (kov) 2009-02-05 23:51:57 UTC
Currently trunk has no download support because webkit has no support for it yet.
Comment 1 Gustavo Noronha (kov) 2009-02-05 23:52:56 UTC
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
Comment 2 Xan Lopez 2009-02-06 09:46:54 UTC
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?
Comment 3 Gustavo Noronha (kov) 2009-02-12 20:37:33 UTC
Created attachment 128585 [details] [review]
download implementation for WebKit

updated patch with the updated patch for WebKit/GTK+ and implemented changes requested by xan
Comment 4 Xan Lopez 2009-02-18 18:27:29 UTC
*** Bug 554215 has been marked as a duplicate of this bug. ***
Comment 5 Xan Lopez 2009-03-03 18:14:38 UTC
	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 :)
Comment 6 Gustavo Noronha (kov) 2009-03-05 00:01:15 UTC
I have landed this in trunk as r8848, with Xan's comments addressed and a crash fixed.