[epiphany] download: Remove EPHY_DOWNLOAD_ACTION_AUTO



commit d0ad9976396265f166546ff5e4d483002881b3b7
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Sat Mar 5 13:16:33 2016 -0600

    download: Remove EPHY_DOWNLOAD_ACTION_AUTO
    
    Let's always take the same action when auto-opening a file as when
    opening manually, instead of allowing ephy_download_do_download_action()
    to confusingly invoke itself recursively.
    
    At first, I thought it would be good to treat automatic downloads
    differently, and perform MIME type safety checking on them, but not on
    downloads opened manually. But I'm not so sure anymore, since it is easy
    for a server to give the file a deceptive file extension but report an
    accurate MIME type, which could trick the user into opening a harmful
    file (e.g. a script) if we were to stop performing MIME type safety
    checks on manually-opened files. So let's continue to perform that check
    in both cases. But now that EPHY_DOWNLOAD_ACTION_OPEN browses to the
    file if opening fails, there's no need to have special behavior for
    EPHY_DOWNLOAD_ACTION_AUTO anymore. The only difference that currently
    implies is that we check the safety of the MIME type once for the
    server's reported MIME type, fall back to browsing to the file if it's
    unsafe, then sniff the MIME type ourselves, check safety again, and
    decide to browse to. There's no point in checking the safety of the
    server's reported type, since we're just going to sniff it ourselves.
    
    So just get rid of it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=610586

 embed/ephy-download.c |   38 ++------------------------------------
 embed/ephy-download.h |    1 -
 2 files changed, 2 insertions(+), 37 deletions(-)
---
diff --git a/embed/ephy-download.c b/embed/ephy-download.c
index 1d56dec..0f28a26 100644
--- a/embed/ephy-download.c
+++ b/embed/ephy-download.c
@@ -143,35 +143,6 @@ ephy_download_get_content_type (EphyDownload *download)
   return download->content_type;
 }
 
-/* Helper function to decide what EphyDownloadActionType should be the
- * default for the download. This implies that you want something to
- * happen, this function will never return EPHY_DOWNLOAD_ACTION_NONE.
- */
-static EphyDownloadActionType
-decide_action_from_mime (EphyDownload *ephy_download)
-{
-  const char *content_type;
-  GAppInfo *helper_app = NULL;
-  EphyDownloadActionType action;
-
-  content_type = ephy_download_get_content_type (ephy_download);
-  if (content_type) {
-    helper_app = g_app_info_get_default_for_type (content_type, FALSE);
-    if (helper_app)
-      action = EPHY_DOWNLOAD_ACTION_OPEN;
-  }
-
-  /* Downloads that have no content_type, or no helper_app, are
-   * considered unsafe/unable to open. Default them to BROWSE_TO.
-   */
-  if (helper_app == NULL)
-    action = EPHY_DOWNLOAD_ACTION_BROWSE_TO;
-  else
-    g_object_unref (helper_app);
-
-  return action;
-}
-
 /* From the old embed/mozilla/MozDownload.cpp */
 static const char *
 file_is_compressed (const char *filename)
@@ -446,8 +417,7 @@ ephy_download_failed (EphyDownload *download,
  * @action: one of #EphyDownloadActionType
  *
  * Executes the given @action for @download, this can be any of
- * #EphyDownloadActionType, including #EPHY_DOWNLOAD_ACTION_AUTO which decides
- * the default action from the mime type of @download.
+ * #EphyDownloadActionType.
  *
  * Returns: %TRUE if the action was executed succesfully.
  *
@@ -464,10 +434,6 @@ ephy_download_do_download_action (EphyDownload          *download,
   destination = g_file_new_for_uri (destination_uri);
 
   switch ((action ? action : download->action)) {
-    case EPHY_DOWNLOAD_ACTION_AUTO:
-      LOG ("ephy_download_do_download_action: auto");
-      ret = ephy_download_do_download_action (download, decide_action_from_mime (download));
-      break;
     case EPHY_DOWNLOAD_ACTION_BROWSE_TO:
       LOG ("ephy_download_do_download_action: browse_to");
       ret = ephy_file_browse_to (destination, download->start_time);
@@ -727,7 +693,7 @@ download_finished_cb (WebKitDownload *wk_download,
 
   if (g_settings_get_boolean (EPHY_SETTINGS_MAIN, EPHY_PREFS_AUTO_DOWNLOADS) &&
       download->action == EPHY_DOWNLOAD_ACTION_NONE)
-    ephy_download_do_download_action (download, EPHY_DOWNLOAD_ACTION_AUTO);
+    ephy_download_do_download_action (download, EPHY_DOWNLOAD_ACTION_OPEN);
   else
     ephy_download_do_download_action (download, download->action);
 }
diff --git a/embed/ephy-download.h b/embed/ephy-download.h
index 0843ea4..e0b8afb 100644
--- a/embed/ephy-download.h
+++ b/embed/ephy-download.h
@@ -35,7 +35,6 @@ G_DECLARE_FINAL_TYPE (EphyDownload, ephy_download, EPHY, DOWNLOAD, GObject)
 typedef enum
 {
   EPHY_DOWNLOAD_ACTION_NONE,
-  EPHY_DOWNLOAD_ACTION_AUTO,
   EPHY_DOWNLOAD_ACTION_BROWSE_TO,
   EPHY_DOWNLOAD_ACTION_OPEN
 } EphyDownloadActionType;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]