mozilla-kde.patch
branchfirefox118
changeset 1196 954851a35787
parent 1191 37e065158be7
child 1199 4c520ebe1ad7
equal deleted inserted replaced
1195:78bbadb03249 1196:954851a35787
     1 # HG changeset patch
     1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
     2 # User msirringhaus@suse.de
     2 From: Wolfgang Rosenauer <wolfgang@rosenauer.org>
     3 # Date 1559294891 -7200
     3 Date: Tue, 8 Aug 2023 16:13:48 +0300
     4 #      Fri May 31 11:28:11 2019 +0200
     4 Subject: [PATCH] Add KDE integration to Firefox (toolkit parts)
     5 # Node ID c2aa7198fb925e7fde96abf65b6f68b9b755f112
     5 MIME-Version: 1.0
     6 # Parent  eaadcfc5cb5ee0eed248051a657a69646334aad7
     6 Content-Type: text/plain; charset=UTF-8
     7 Description: Add KDE integration to Firefox (toolkit parts)
     7 Content-Transfer-Encoding: 8bit
     8 Author: Wolfgang Rosenauer <wolfgang@rosenauer.org>
     8 
     9 Author: Lubos Lunak <lunak@suse.com>
       
    10 Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=140751
     9 Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=140751
    11      https://bugzilla.novell.com/show_bug.cgi?id=170055
    10 Bug: https://bugzilla.suse.com/show_bug.cgi?id=170055
       
    11 
       
    12 EDIT: Björn Bidar: Removed handling for obsolete special files
       
    13 
       
    14 Co-authored-by: Wolfgang Rosenauer <wolfgang@rosenauer.org>
       
    15 Co-authored-by: Lubos Lunak <lunak@suse.com>
       
    16 Co-authored-by: Björn Bidar <bjorn.bidar@thaodan.de>
       
    17 ---
       
    18  modules/libpref/Preferences.cpp               |   1 +
       
    19  modules/libpref/moz.build                     |   4 +
       
    20  python/mozbuild/mozpack/chrome/flags.py       |   1 +
       
    21  python/mozbuild/mozpack/chrome/manifest.py    |   1 +
       
    22  toolkit/components/downloads/moz.build        |   4 +
       
    23  .../mozapps/downloads/HelperAppDlg.sys.mjs    |  70 +++--
       
    24  .../unixproxy/nsUnixSystemProxySettings.cpp   |  29 ++
       
    25  toolkit/xre/moz.build                         |   2 +
       
    26  toolkit/xre/nsKDEUtils.cpp                    | 286 ++++++++++++++++++
       
    27  toolkit/xre/nsKDEUtils.h                      |  53 ++++
       
    28  uriloader/exthandler/HandlerServiceParent.cpp |   6 +-
       
    29  uriloader/exthandler/moz.build                |   3 +
       
    30  .../exthandler/unix/nsCommonRegistry.cpp      |  42 +++
       
    31  uriloader/exthandler/unix/nsCommonRegistry.h  |  28 ++
       
    32  uriloader/exthandler/unix/nsKDERegistry.cpp   |  75 +++++
       
    33  uriloader/exthandler/unix/nsKDERegistry.h     |  35 +++
       
    34  uriloader/exthandler/unix/nsMIMEInfoUnix.cpp  |  28 +-
       
    35  .../exthandler/unix/nsOSHelperAppService.cpp  |  10 +-
       
    36  widget/gtk/moz.build                          |   1 +
       
    37  widget/gtk/nsFilePicker.cpp                   | 230 +++++++++++++-
       
    38  widget/gtk/nsFilePicker.h                     |   6 +
       
    39  xpcom/components/ManifestParser.cpp           |  10 +
       
    40  xpcom/components/moz.build                    |   1 +
       
    41  xpcom/io/nsLocalFileUnix.cpp                  |  20 +-
       
    42  24 files changed, 910 insertions(+), 36 deletions(-)
       
    43  create mode 100644 toolkit/xre/nsKDEUtils.cpp
       
    44  create mode 100644 toolkit/xre/nsKDEUtils.h
       
    45  create mode 100644 uriloader/exthandler/unix/nsCommonRegistry.cpp
       
    46  create mode 100644 uriloader/exthandler/unix/nsCommonRegistry.h
       
    47  create mode 100644 uriloader/exthandler/unix/nsKDERegistry.cpp
       
    48  create mode 100644 uriloader/exthandler/unix/nsKDERegistry.h
    12 
    49 
    13 diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp
    50 diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp
       
    51 index 94a5aa0f3f169563d570e18fc1a525994293ad99..c1cf316d05b742502f7b07da1b7f25024b09f4e8 100644
    14 --- a/modules/libpref/Preferences.cpp
    52 --- a/modules/libpref/Preferences.cpp
    15 +++ b/modules/libpref/Preferences.cpp
    53 +++ b/modules/libpref/Preferences.cpp
    16 @@ -90,16 +90,17 @@
    54 @@ -95,6 +95,7 @@
    17  #include "PLDHashTable.h"
       
    18  #include "prdtoa.h"
       
    19  #include "prlink.h"
       
    20  #include "xpcpublic.h"
       
    21  #include "js/RootingAPI.h"
       
    22  #ifdef MOZ_BACKGROUNDTASKS
    55  #ifdef MOZ_BACKGROUNDTASKS
    23  #  include "mozilla/BackgroundTasks.h"
    56  #  include "mozilla/BackgroundTasks.h"
    24  #endif
    57  #endif
    25 +#include "nsKDEUtils.h"
    58 +#include "nsKDEUtils.h"
    26  
    59  
    27  #ifdef DEBUG
    60  #ifdef DEBUG
    28  #  include <map>
    61  #  include <map>
    29  #endif
       
    30  
       
    31  #ifdef MOZ_MEMORY
       
    32  #  include "mozmemory.h"
       
    33  #endif
       
    34 @@ -4901,16 +4902,26 @@ nsresult Preferences::InitInitialObjects
       
    35      "unix.js"
       
    36  #  if defined(_AIX)
       
    37      ,
       
    38      "aix.js"
       
    39  #  endif
       
    40  #endif
       
    41    };
       
    42  
       
    43 +  if (nsKDEUtils::kdeSession()) {  // TODO what if some setup actually requires
       
    44 +                                   // the helper?
       
    45 +    for (int i = 0; i < MOZ_ARRAY_LENGTH(specialFiles); ++i) {
       
    46 +      if (*specialFiles[i] == '\0') {
       
    47 +        specialFiles[i] = "kde.js";
       
    48 +        break;
       
    49 +      }
       
    50 +    }
       
    51 +  }
       
    52 +
       
    53    rv = pref_LoadPrefsInDir(defaultPrefDir, specialFiles,
       
    54                             ArrayLength(specialFiles));
       
    55    if (NS_FAILED(rv)) {
       
    56      NS_WARNING("Error parsing application default preferences.");
       
    57    }
       
    58  
       
    59    // Load jar:$app/omni.jar!/defaults/preferences/*.js
       
    60    // or jar:$gre/omni.jar!/defaults/preferences/*.js.
       
    61 @@ -4975,17 +4986,17 @@ nsresult Preferences::InitInitialObjects
       
    62        }
       
    63  
       
    64        nsCOMPtr<nsIFile> path = do_QueryInterface(elem);
       
    65        if (!path) {
       
    66          continue;
       
    67        }
       
    68  
       
    69        // Do we care if a file provided by this process fails to load?
       
    70 -      pref_LoadPrefsInDir(path, nullptr, 0);
       
    71 +      pref_LoadPrefsInDir(path, specialFiles, ArrayLength(specialFiles));
       
    72      }
       
    73    }
       
    74  
       
    75  #if defined(MOZ_WIDGET_GTK)
       
    76    // To ensure the system-wide preferences are not overwritten by
       
    77    // firefox/browser/defauts/preferences/*.js we need to load
       
    78    // the /etc/firefox/defaults/pref/*.js settings as last.
       
    79    // Under Flatpak, the NS_OS_SYSTEM_CONFIG_DIR points to /app/etc/firefox
       
    80 diff --git a/modules/libpref/moz.build b/modules/libpref/moz.build
    62 diff --git a/modules/libpref/moz.build b/modules/libpref/moz.build
       
    63 index e8f8b97170d32c1d3ac342dd93da7265bf707c8f..831001cee4b1eb33171d83d524ee9e453a800257 100644
    81 --- a/modules/libpref/moz.build
    64 --- a/modules/libpref/moz.build
    82 +++ b/modules/libpref/moz.build
    65 +++ b/modules/libpref/moz.build
    83 @@ -121,16 +121,20 @@ EXPORTS.mozilla += [
    66 @@ -126,6 +126,10 @@ UNIFIED_SOURCES += [
    84  ]
       
    85  EXPORTS.mozilla += sorted(["!" + g for g in gen_h])
       
    86  
       
    87  UNIFIED_SOURCES += [
       
    88      "Preferences.cpp",
       
    89      "SharedPrefMap.cpp",
    67      "SharedPrefMap.cpp",
    90  ]
    68  ]
    91  
    69  
    92 +LOCAL_INCLUDES += [
    70 +LOCAL_INCLUDES += [
    93 +    '/toolkit/xre'
    71 +    '/toolkit/xre'
    94 +]
    72 +]
    95 +
    73 +
    96  gen_all_tuple = tuple(gen_h + gen_cpp + gen_rs)
    74  gen_all_tuple = tuple(gen_h + gen_cpp + gen_rs)
    97  
    75  
    98  GeneratedFile(
    76  GeneratedFile(
    99      *gen_all_tuple,
       
   100      script="init/generate_static_pref_list.py",
       
   101      entry_point="emit_code",
       
   102      inputs=["init/StaticPrefList.yaml"]
       
   103  )
       
   104 diff --git a/python/mozbuild/mozpack/chrome/flags.py b/python/mozbuild/mozpack/chrome/flags.py
    77 diff --git a/python/mozbuild/mozpack/chrome/flags.py b/python/mozbuild/mozpack/chrome/flags.py
       
    78 index 6b096c862aaac5e02d9d7dacda42d9321d5e89cc..2b46d9294b93fda17117e9c84b240c52f96c9b74 100644
   105 --- a/python/mozbuild/mozpack/chrome/flags.py
    79 --- a/python/mozbuild/mozpack/chrome/flags.py
   106 +++ b/python/mozbuild/mozpack/chrome/flags.py
    80 +++ b/python/mozbuild/mozpack/chrome/flags.py
   107 @@ -229,16 +229,17 @@ class Flags(OrderedDict):
    81 @@ -234,6 +234,7 @@ class Flags(OrderedDict):
   108          "os": StringFlag,
       
   109          "osversion": VersionFlag,
       
   110          "abi": StringFlag,
       
   111          "platform": Flag,
       
   112          "xpcnativewrappers": Flag,
       
   113          "tablet": Flag,
    82          "tablet": Flag,
   114          "process": StringFlag,
    83          "process": StringFlag,
   115          "backgroundtask": StringFlag,
    84          "backgroundtask": StringFlag,
   116 +        "desktop": StringFlag,
    85 +        "desktop": StringFlag,
   117      }
    86      }
   118      RE = re.compile(r"([!<>=]+)")
    87      RE = re.compile(r"([!<>=]+)")
   119  
    88  
   120      def __init__(self, *flags):
       
   121          """
       
   122          Initialize a set of flags given in string form.
       
   123             flags = Flags('contentaccessible=yes', 'appversion>=3.5')
       
   124          """
       
   125 diff --git a/python/mozbuild/mozpack/chrome/manifest.py b/python/mozbuild/mozpack/chrome/manifest.py
    89 diff --git a/python/mozbuild/mozpack/chrome/manifest.py b/python/mozbuild/mozpack/chrome/manifest.py
       
    90 index 14c11d4c1daa8cbb03abf3cd2e1a7b60a981abc8..41b9969e7277fa2400f299863c83145342cd7b43 100644
   126 --- a/python/mozbuild/mozpack/chrome/manifest.py
    91 --- a/python/mozbuild/mozpack/chrome/manifest.py
   127 +++ b/python/mozbuild/mozpack/chrome/manifest.py
    92 +++ b/python/mozbuild/mozpack/chrome/manifest.py
   128 @@ -38,16 +38,17 @@ class ManifestEntry(object):
    93 @@ -43,6 +43,7 @@ class ManifestEntry(object):
   129          "os",
       
   130          "osversion",
       
   131          "abi",
       
   132          "xpcnativewrappers",
       
   133          "tablet",
       
   134          "process",
    94          "process",
   135          "contentaccessible",
    95          "contentaccessible",
   136          "backgroundtask",
    96          "backgroundtask",
   137 +        "desktop",
    97 +        "desktop",
   138      ]
    98      ]
   139  
    99  
   140      def __init__(self, base, *flags):
   100      def __init__(self, base, *flags):
   141          """
       
   142          Initialize a manifest entry with the given base path and flags.
       
   143          """
       
   144          self.base = base
       
   145          self.flags = Flags(*flags)
       
   146 diff --git a/toolkit/components/downloads/moz.build b/toolkit/components/downloads/moz.build
   101 diff --git a/toolkit/components/downloads/moz.build b/toolkit/components/downloads/moz.build
       
   102 index 3818e8c0db1ed3cfc068d89b18b1fe2f1bf750a9..b70986db811191952919531cfb79e04b801491a2 100644
   147 --- a/toolkit/components/downloads/moz.build
   103 --- a/toolkit/components/downloads/moz.build
   148 +++ b/toolkit/components/downloads/moz.build
   104 +++ b/toolkit/components/downloads/moz.build
   149 @@ -46,10 +46,14 @@ XPCOM_MANIFESTS += [
   105 @@ -51,5 +51,9 @@ if CONFIG["MOZ_PLACES"]:
   150  
       
   151  if CONFIG["MOZ_PLACES"]:
       
   152      EXTRA_JS_MODULES += [
       
   153          "DownloadHistory.sys.mjs",
       
   154      ]
       
   155  
   106  
   156  FINAL_LIBRARY = "xul"
   107  FINAL_LIBRARY = "xul"
   157  
   108  
   158 +LOCAL_INCLUDES += [
   109 +LOCAL_INCLUDES += [
   159 +    '/toolkit/xre'
   110 +    '/toolkit/xre'
   160 +]
   111 +]
   161 +
   112 +
   162  with Files("**"):
   113  with Files("**"):
   163      BUG_COMPONENT = ("Toolkit", "Downloads API")
   114      BUG_COMPONENT = ("Toolkit", "Downloads API")
   164 diff --git a/toolkit/mozapps/downloads/HelperAppDlg.sys.mjs b/toolkit/mozapps/downloads/HelperAppDlg.sys.mjs
   115 diff --git a/toolkit/mozapps/downloads/HelperAppDlg.sys.mjs b/toolkit/mozapps/downloads/HelperAppDlg.sys.mjs
       
   116 index 66f77d38e4ed7b3802303194e8df675a5db81272..f8839c446683620d6df6c6eb2ea0a0ca3549af95 100644
   165 --- a/toolkit/mozapps/downloads/HelperAppDlg.sys.mjs
   117 --- a/toolkit/mozapps/downloads/HelperAppDlg.sys.mjs
   166 +++ b/toolkit/mozapps/downloads/HelperAppDlg.sys.mjs
   118 +++ b/toolkit/mozapps/downloads/HelperAppDlg.sys.mjs
   167 @@ -1241,36 +1241,66 @@ nsUnknownContentTypeDialog.prototype = {
   119 @@ -1246,26 +1246,56 @@ nsUnknownContentTypeDialog.prototype = {
   168          params.handlerApp &&
       
   169          params.handlerApp.executable &&
       
   170          params.handlerApp.executable.isFile()
       
   171        ) {
       
   172          // Remember the file they chose to run.
       
   173          this.chosenApp = params.handlerApp;
   120          this.chosenApp = params.handlerApp;
   174        }
   121        }
   175      } else if ("@mozilla.org/applicationchooser;1" in Cc) {
   122      } else if ("@mozilla.org/applicationchooser;1" in Cc) {
   176 -      var nsIApplicationChooser = Ci.nsIApplicationChooser;
   123 -      var nsIApplicationChooser = Ci.nsIApplicationChooser;
   177 -      var appChooser = Cc["@mozilla.org/applicationchooser;1"].createInstance(
   124 -      var appChooser = Cc["@mozilla.org/applicationchooser;1"].createInstance(
   244 +        return;
   191 +        return;
   245 +      }
   192 +      }
   246      } else {
   193      } else {
   247        var nsIFilePicker = Ci.nsIFilePicker;
   194        var nsIFilePicker = Ci.nsIFilePicker;
   248        var fp = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
   195        var fp = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
   249        fp.init(
       
   250          this.mDialog,
       
   251          this.dialogElement("strings").getString("chooseAppFilePickerTitle"),
       
   252          nsIFilePicker.modeOpen
       
   253        );
       
   254 diff --git a/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp b/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
   196 diff --git a/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp b/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
       
   197 index 185dc1e22a903cec95b212d1713dddf764b9b198..bdb4ed6f9f86583d02dd80278f858d064584f82a 100644
   255 --- a/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
   198 --- a/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
   256 +++ b/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
   199 +++ b/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
   257 @@ -11,16 +11,18 @@
   200 @@ -16,6 +16,8 @@
   258  #include "prenv.h"
       
   259  #include "nsInterfaceHashtable.h"
       
   260  #include "nsHashtablesFwd.h"
       
   261  #include "nsHashKeys.h"
       
   262  #include "nsNetUtil.h"
       
   263  #include "nsISupportsPrimitives.h"
   201  #include "nsISupportsPrimitives.h"
   264  #include "nsIGSettingsService.h"
   202  #include "nsIGSettingsService.h"
   265  #include "nsReadableUtils.h"
   203  #include "nsReadableUtils.h"
   266 +#include "nsPrintfCString.h"
   204 +#include "nsPrintfCString.h"
   267 +#include "nsKDEUtils.h"
   205 +#include "nsKDEUtils.h"
   268  
   206  
   269  using namespace mozilla;
   207  using namespace mozilla;
   270  
   208  
   271  class nsUnixSystemProxySettings final : public nsISystemProxySettings {
   209 @@ -39,6 +41,8 @@ class nsUnixSystemProxySettings final : public nsISystemProxySettings {
   272   public:
       
   273    NS_DECL_ISUPPORTS
       
   274    NS_DECL_NSISYSTEMPROXYSETTINGS
       
   275  
       
   276 @@ -34,16 +36,18 @@ class nsUnixSystemProxySettings final : 
       
   277    nsCOMPtr<nsIGSettingsCollection> mProxySettings;
       
   278    nsInterfaceHashtable<nsCStringHashKey, nsIGSettingsCollection>
       
   279        mSchemeProxySettings;
       
   280    nsresult GetProxyFromGSettings(const nsACString& aScheme,
       
   281                                   const nsACString& aHost, int32_t aPort,
       
   282                                   nsACString& aResult);
   210                                   nsACString& aResult);
   283    nsresult SetProxyResultFromGSettings(const char* aKeyBase, const char* aType,
   211    nsresult SetProxyResultFromGSettings(const char* aKeyBase, const char* aType,
   284                                         nsACString& aResult);
   212                                         nsACString& aResult);
   285 +  nsresult GetProxyFromKDE(const nsACString& aScheme, const nsACString& aHost,
   213 +  nsresult GetProxyFromKDE(const nsACString& aScheme, const nsACString& aHost,
   286 +                           PRInt32 aPort, nsACString& aResult);
   214 +                           PRInt32 aPort, nsACString& aResult);
   287  };
   215  };
   288  
   216  
   289  NS_IMPL_ISUPPORTS(nsUnixSystemProxySettings, nsISystemProxySettings)
   217  NS_IMPL_ISUPPORTS(nsUnixSystemProxySettings, nsISystemProxySettings)
   290  
   218 @@ -397,6 +401,9 @@ nsresult nsUnixSystemProxySettings::GetProxyForURI(const nsACString& aSpec,
   291  NS_IMETHODIMP
       
   292  nsUnixSystemProxySettings::GetMainThreadOnly(bool* aMainThreadOnly) {
       
   293    // dbus prevents us from being threadsafe, but this routine should not block
       
   294    // anyhow
       
   295 @@ -391,21 +395,46 @@ nsresult nsUnixSystemProxySettings::GetP
       
   296    return NS_OK;
       
   297  }
       
   298  
       
   299  nsresult nsUnixSystemProxySettings::GetProxyForURI(const nsACString& aSpec,
       
   300                                                     const nsACString& aScheme,
       
   301                                                     const nsACString& aHost,
   219                                                     const nsACString& aHost,
   302                                                     const int32_t aPort,
   220                                                     const int32_t aPort,
   303                                                     nsACString& aResult) {
   221                                                     nsACString& aResult) {
   304 +  if (nsKDEUtils::kdeSupport())
   222 +  if (nsKDEUtils::kdeSupport())
   305 +    return GetProxyFromKDE(aScheme, aHost, aPort, aResult);
   223 +    return GetProxyFromKDE(aScheme, aHost, aPort, aResult);
   306 +
   224 +
   307    if (mProxySettings) {
   225    if (mProxySettings) {
   308      nsresult rv = GetProxyFromGSettings(aScheme, aHost, aPort, aResult);
   226      nsresult rv = GetProxyFromGSettings(aScheme, aHost, aPort, aResult);
   309      if (NS_SUCCEEDED(rv)) return rv;
   227      if (NS_SUCCEEDED(rv)) return rv;
   310    }
   228 @@ -405,6 +412,28 @@ nsresult nsUnixSystemProxySettings::GetProxyForURI(const nsACString& aSpec,
   311  
       
   312    return GetProxyFromEnvironment(aScheme, aHost, aPort, aResult);
   229    return GetProxyFromEnvironment(aScheme, aHost, aPort, aResult);
   313  }
   230  }
   314  
   231  
   315 +nsresult nsUnixSystemProxySettings::GetProxyFromKDE(const nsACString& aScheme,
   232 +nsresult nsUnixSystemProxySettings::GetProxyFromKDE(const nsACString& aScheme,
   316 +                                                    const nsACString& aHost,
   233 +                                                    const nsACString& aHost,
   335 +}
   252 +}
   336 +
   253 +
   337  NS_IMPL_COMPONENT_FACTORY(nsUnixSystemProxySettings) {
   254  NS_IMPL_COMPONENT_FACTORY(nsUnixSystemProxySettings) {
   338    auto result = MakeRefPtr<nsUnixSystemProxySettings>();
   255    auto result = MakeRefPtr<nsUnixSystemProxySettings>();
   339    result->Init();
   256    result->Init();
   340    return result.forget().downcast<nsISupports>();
       
   341  }
       
   342 diff --git a/toolkit/xre/moz.build b/toolkit/xre/moz.build
   257 diff --git a/toolkit/xre/moz.build b/toolkit/xre/moz.build
       
   258 index de05e0cc29752855138b4d189ce6a13c2121d715..c89faad7bfca4ab1d60390766b2e7befd9e3831d 100644
   343 --- a/toolkit/xre/moz.build
   259 --- a/toolkit/xre/moz.build
   344 +++ b/toolkit/xre/moz.build
   260 +++ b/toolkit/xre/moz.build
   345 @@ -91,17 +91,19 @@ elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "co
   261 @@ -96,7 +96,9 @@ elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "uikit":
   346          "../components/printingui",
       
   347      ]
       
   348  elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "uikit":
       
   349      UNIFIED_SOURCES += [
       
   350          "nsNativeAppSupportDefault.cpp",
       
   351          "UIKitDirProvider.mm",
   262          "UIKitDirProvider.mm",
   352      ]
   263      ]
   353  elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
   264  elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
   354 +    EXPORTS += ['nsKDEUtils.h']
   265 +    EXPORTS += ['nsKDEUtils.h']
   355      UNIFIED_SOURCES += [
   266      UNIFIED_SOURCES += [
   356 +        "nsKDEUtils.cpp",
   267 +        "nsKDEUtils.cpp",
   357          "nsNativeAppSupportUnix.cpp",
   268          "nsNativeAppSupportUnix.cpp",
   358      ]
   269      ]
   359      CXXFLAGS += CONFIG["MOZ_X11_SM_CFLAGS"]
   270      CXXFLAGS += CONFIG["MOZ_X11_SM_CFLAGS"]
   360  else:
       
   361      UNIFIED_SOURCES += [
       
   362          "nsNativeAppSupportDefault.cpp",
       
   363      ]
       
   364  
       
   365 diff --git a/toolkit/xre/nsKDEUtils.cpp b/toolkit/xre/nsKDEUtils.cpp
   271 diff --git a/toolkit/xre/nsKDEUtils.cpp b/toolkit/xre/nsKDEUtils.cpp
   366 new file mode 100644
   272 new file mode 100644
       
   273 index 0000000000000000000000000000000000000000..e282de40618e0be06a4247891d9ab1a26cba2126
   367 --- /dev/null
   274 --- /dev/null
   368 +++ b/toolkit/xre/nsKDEUtils.cpp
   275 +++ b/toolkit/xre/nsKDEUtils.cpp
   369 @@ -0,0 +1,286 @@
   276 @@ -0,0 +1,286 @@
   370 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
   277 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
   371 +/* This Source Code Form is subject to the terms of the Mozilla Public
   278 +/* This Source Code Form is subject to the terms of the Mozilla Public
   653 +        commandFile);  // done as \E, so it cannot happen in normal data
   560 +        commandFile);  // done as \E, so it cannot happen in normal data
   654 +  fflush(commandFile);
   561 +  fflush(commandFile);
   655 +}
   562 +}
   656 diff --git a/toolkit/xre/nsKDEUtils.h b/toolkit/xre/nsKDEUtils.h
   563 diff --git a/toolkit/xre/nsKDEUtils.h b/toolkit/xre/nsKDEUtils.h
   657 new file mode 100644
   564 new file mode 100644
       
   565 index 0000000000000000000000000000000000000000..7fa6eb8e83b32c8e2c62a0035d253e06e135e3d2
   658 --- /dev/null
   566 --- /dev/null
   659 +++ b/toolkit/xre/nsKDEUtils.h
   567 +++ b/toolkit/xre/nsKDEUtils.h
   660 @@ -0,0 +1,53 @@
   568 @@ -0,0 +1,53 @@
   661 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
   569 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
   662 +/* This Source Code Form is subject to the terms of the Mozilla Public
   570 +/* This Source Code Form is subject to the terms of the Mozilla Public
   710 +  FILE* replyFile;
   618 +  FILE* replyFile;
   711 +};
   619 +};
   712 +
   620 +
   713 +#endif  // nsKDEUtils
   621 +#endif  // nsKDEUtils
   714 diff --git a/uriloader/exthandler/HandlerServiceParent.cpp b/uriloader/exthandler/HandlerServiceParent.cpp
   622 diff --git a/uriloader/exthandler/HandlerServiceParent.cpp b/uriloader/exthandler/HandlerServiceParent.cpp
       
   623 index ab77657dd5f378af0955c43ef958a8abea620134..18b4d85560699bbc3c69b82ee91dfb5cbe700e7b 100644
   715 --- a/uriloader/exthandler/HandlerServiceParent.cpp
   624 --- a/uriloader/exthandler/HandlerServiceParent.cpp
   716 +++ b/uriloader/exthandler/HandlerServiceParent.cpp
   625 +++ b/uriloader/exthandler/HandlerServiceParent.cpp
   717 @@ -13,17 +13,17 @@
   626 @@ -18,7 +18,7 @@
   718  #include "ContentHandlerService.h"
       
   719  #include "nsIExternalProtocolService.h"
       
   720  #include "nsStringEnumerator.h"
       
   721  #include "nsIMutableArray.h"
       
   722  #include "nsCExternalHandlerService.h"
       
   723  #include "nsComponentManagerUtils.h"
   627  #include "nsComponentManagerUtils.h"
   724  #include "nsServiceManagerUtils.h"
   628  #include "nsServiceManagerUtils.h"
   725  #ifdef MOZ_WIDGET_GTK
   629  #ifdef MOZ_WIDGET_GTK
   726 -#  include "unix/nsGNOMERegistry.h"
   630 -#  include "unix/nsGNOMERegistry.h"
   727 +#  include "unix/nsCommonRegistry.h"
   631 +#  include "unix/nsCommonRegistry.h"
   728  #endif
   632  #endif
   729  
   633  
   730  using mozilla::dom::ContentHandlerService;
   634  using mozilla::dom::ContentHandlerService;
   731  using mozilla::dom::HandlerApp;
   635 @@ -310,8 +310,8 @@ mozilla::ipc::IPCResult HandlerServiceParent::RecvExistsForProtocolOS(
   732  using mozilla::dom::HandlerInfo;
       
   733  using mozilla::dom::RemoteHandlerApp;
       
   734  
       
   735  namespace {
       
   736 @@ -305,18 +305,18 @@ mozilla::ipc::IPCResult HandlerServicePa
       
   737  mozilla::ipc::IPCResult HandlerServiceParent::RecvExistsForProtocolOS(
       
   738      const nsACString& aProtocolScheme, bool* aHandlerExists) {
       
   739    if (aProtocolScheme.Length() > MAX_SCHEME_LENGTH) {
       
   740      *aHandlerExists = false;
       
   741      return IPC_OK();
       
   742    }
   636    }
   743  #ifdef MOZ_WIDGET_GTK
   637  #ifdef MOZ_WIDGET_GTK
   744    // Check the GNOME registry for a protocol handler
   638    // Check the GNOME registry for a protocol handler
   745 -  *aHandlerExists =
   639 -  *aHandlerExists =
   746 -      nsGNOMERegistry::HandlerExists(PromiseFlatCString(aProtocolScheme).get());
   640 -      nsGNOMERegistry::HandlerExists(PromiseFlatCString(aProtocolScheme).get());
   747 +  *aHandlerExists = nsCommonRegistry::HandlerExists(
   641 +  *aHandlerExists = nsCommonRegistry::HandlerExists(
   748 +      PromiseFlatCString(aProtocolScheme).get());
   642 +      PromiseFlatCString(aProtocolScheme).get());
   749  #else
   643  #else
   750    *aHandlerExists = false;
   644    *aHandlerExists = false;
   751  #endif
   645  #endif
   752    return IPC_OK();
       
   753  }
       
   754  
       
   755  /*
       
   756   * Check if a handler exists for the provided protocol. Check the datastore
       
   757 diff --git a/uriloader/exthandler/moz.build b/uriloader/exthandler/moz.build
   646 diff --git a/uriloader/exthandler/moz.build b/uriloader/exthandler/moz.build
       
   647 index 0fb126a7f3f7a45d53e6fb81aef74147c711cb77..8cc0006f3045e14e83fd51926ac7856eacbe7357 100644
   758 --- a/uriloader/exthandler/moz.build
   648 --- a/uriloader/exthandler/moz.build
   759 +++ b/uriloader/exthandler/moz.build
   649 +++ b/uriloader/exthandler/moz.build
   760 @@ -81,17 +81,19 @@ elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "ui
   650 @@ -86,7 +86,9 @@ else:
   761  else:
       
   762      # These files can't be built in unified mode because they redefine LOG.
       
   763      SOURCES += [
       
   764          osdir + "/nsOSHelperAppService.cpp",
       
   765      ]
       
   766  
   651  
   767  if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
   652  if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
   768      UNIFIED_SOURCES += [
   653      UNIFIED_SOURCES += [
   769 +        "unix/nsCommonRegistry.cpp",
   654 +        "unix/nsCommonRegistry.cpp",
   770          "unix/nsGNOMERegistry.cpp",
   655          "unix/nsGNOMERegistry.cpp",
   771 +        "unix/nsKDERegistry.cpp",
   656 +        "unix/nsKDERegistry.cpp",
   772          "unix/nsMIMEInfoUnix.cpp",
   657          "unix/nsMIMEInfoUnix.cpp",
   773      ]
   658      ]
   774  elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "android":
   659  elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "android":
   775      UNIFIED_SOURCES += [
   660 @@ -134,6 +136,7 @@ LOCAL_INCLUDES += [
   776          "android/nsMIMEInfoAndroid.cpp",
       
   777      ]
       
   778  elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows":
       
   779      UNIFIED_SOURCES += [
       
   780 @@ -129,16 +131,17 @@ include("/ipc/chromium/chromium-config.m
       
   781  FINAL_LIBRARY = "xul"
       
   782  
       
   783  LOCAL_INCLUDES += [
       
   784      "/docshell/base",
       
   785      "/dom/base",
       
   786      "/dom/ipc",
   661      "/dom/ipc",
   787      "/netwerk/base",
   662      "/netwerk/base",
   788      "/netwerk/protocol/http",
   663      "/netwerk/protocol/http",
   789 +    "/toolkit/xre",
   664 +    "/toolkit/xre",
   790  ]
   665  ]
   791  
   666  
   792  if CONFIG["MOZ_ENABLE_DBUS"]:
   667  if CONFIG["MOZ_ENABLE_DBUS"]:
   793      CXXFLAGS += CONFIG["MOZ_DBUS_CFLAGS"]
       
   794  
       
   795  if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
       
   796      CXXFLAGS += CONFIG["MOZ_GTK3_CFLAGS"]
       
   797      CXXFLAGS += CONFIG["MOZ_DBUS_GLIB_CFLAGS"]
       
   798 diff --git a/uriloader/exthandler/unix/nsCommonRegistry.cpp b/uriloader/exthandler/unix/nsCommonRegistry.cpp
   668 diff --git a/uriloader/exthandler/unix/nsCommonRegistry.cpp b/uriloader/exthandler/unix/nsCommonRegistry.cpp
   799 new file mode 100644
   669 new file mode 100644
       
   670 index 0000000000000000000000000000000000000000..3371a756e2c240bfe5fe31ef0ee9c393368dab60
   800 --- /dev/null
   671 --- /dev/null
   801 +++ b/uriloader/exthandler/unix/nsCommonRegistry.cpp
   672 +++ b/uriloader/exthandler/unix/nsCommonRegistry.cpp
   802 @@ -0,0 +1,42 @@
   673 @@ -0,0 +1,42 @@
   803 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
   674 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
   804 +/* This Source Code Form is subject to the terms of the Mozilla Public
   675 +/* This Source Code Form is subject to the terms of the Mozilla Public
   842 +  if (nsKDEUtils::kdeSupport()) return nsKDERegistry::GetFromType(aMIMEType);
   713 +  if (nsKDEUtils::kdeSupport()) return nsKDERegistry::GetFromType(aMIMEType);
   843 +  return nsGNOMERegistry::GetFromType(aMIMEType);
   714 +  return nsGNOMERegistry::GetFromType(aMIMEType);
   844 +}
   715 +}
   845 diff --git a/uriloader/exthandler/unix/nsCommonRegistry.h b/uriloader/exthandler/unix/nsCommonRegistry.h
   716 diff --git a/uriloader/exthandler/unix/nsCommonRegistry.h b/uriloader/exthandler/unix/nsCommonRegistry.h
   846 new file mode 100644
   717 new file mode 100644
       
   718 index 0000000000000000000000000000000000000000..075413e2fbb165862956c7753a750bfdfb5d389b
   847 --- /dev/null
   719 --- /dev/null
   848 +++ b/uriloader/exthandler/unix/nsCommonRegistry.h
   720 +++ b/uriloader/exthandler/unix/nsCommonRegistry.h
   849 @@ -0,0 +1,28 @@
   721 @@ -0,0 +1,28 @@
   850 +/* This Source Code Form is subject to the terms of the Mozilla Public
   722 +/* This Source Code Form is subject to the terms of the Mozilla Public
   851 + * License, v. 2.0. If a copy of the MPL was not distributed with this
   723 + * License, v. 2.0. If a copy of the MPL was not distributed with this
   875 +};
   747 +};
   876 +
   748 +
   877 +#endif
   749 +#endif
   878 diff --git a/uriloader/exthandler/unix/nsKDERegistry.cpp b/uriloader/exthandler/unix/nsKDERegistry.cpp
   750 diff --git a/uriloader/exthandler/unix/nsKDERegistry.cpp b/uriloader/exthandler/unix/nsKDERegistry.cpp
   879 new file mode 100644
   751 new file mode 100644
       
   752 index 0000000000000000000000000000000000000000..082035566f0b82c14f866c2fbed34c0884f27d34
   880 --- /dev/null
   753 --- /dev/null
   881 +++ b/uriloader/exthandler/unix/nsKDERegistry.cpp
   754 +++ b/uriloader/exthandler/unix/nsKDERegistry.cpp
   882 @@ -0,0 +1,75 @@
   755 @@ -0,0 +1,75 @@
   883 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
   756 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
   884 +/* This Source Code Form is subject to the terms of the Mozilla Public
   757 +/* This Source Code Form is subject to the terms of the Mozilla Public
   955 +  }
   828 +  }
   956 +  return nullptr;
   829 +  return nullptr;
   957 +}
   830 +}
   958 diff --git a/uriloader/exthandler/unix/nsKDERegistry.h b/uriloader/exthandler/unix/nsKDERegistry.h
   831 diff --git a/uriloader/exthandler/unix/nsKDERegistry.h b/uriloader/exthandler/unix/nsKDERegistry.h
   959 new file mode 100644
   832 new file mode 100644
       
   833 index 0000000000000000000000000000000000000000..c6a41b331b2b5ead6142171f08d8b8a7872ca516
   960 --- /dev/null
   834 --- /dev/null
   961 +++ b/uriloader/exthandler/unix/nsKDERegistry.h
   835 +++ b/uriloader/exthandler/unix/nsKDERegistry.h
   962 @@ -0,0 +1,35 @@
   836 @@ -0,0 +1,35 @@
   963 +/* This Source Code Form is subject to the terms of the Mozilla Public
   837 +/* This Source Code Form is subject to the terms of the Mozilla Public
   964 + * License, v. 2.0. If a copy of the MPL was not distributed with this
   838 + * License, v. 2.0. If a copy of the MPL was not distributed with this
   994 +      const nsTArray<nsCString>& command);
   868 +      const nsTArray<nsCString>& command);
   995 +};
   869 +};
   996 +
   870 +
   997 +#endif  // nsKDERegistry_h__
   871 +#endif  // nsKDERegistry_h__
   998 diff --git a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
   872 diff --git a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
       
   873 index 330c4411597f1a19105601e256a2c3bc71c61780..c96c1f3ca5a05c3b6bce321d7a975aa040865fa8 100644
   999 --- a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
   874 --- a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
  1000 +++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
   875 +++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
  1001 @@ -1,48 +1,51 @@
   876 @@ -5,16 +5,19 @@
  1002  /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       
  1003   *
       
  1004   * This Source Code Form is subject to the terms of the Mozilla Public
       
  1005   * License, v. 2.0. If a copy of the MPL was not distributed with this
       
  1006   * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
   877   * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  1007  
   878  
  1008  #include "nsMIMEInfoUnix.h"
   879  #include "nsMIMEInfoUnix.h"
  1009 -#include "nsGNOMERegistry.h"
   880 -#include "nsGNOMERegistry.h"
  1010 +#include "nsCommonRegistry.h"
   881 +#include "nsCommonRegistry.h"
  1022 -  return nsGNOMERegistry::LoadURL(aURI);
   893 -  return nsGNOMERegistry::LoadURL(aURI);
  1023 +  return nsCommonRegistry::LoadURL(aURI);
   894 +  return nsCommonRegistry::LoadURL(aURI);
  1024  }
   895  }
  1025  
   896  
  1026  NS_IMETHODIMP
   897  NS_IMETHODIMP
  1027  nsMIMEInfoUnix::GetHasDefaultHandler(bool* _retval) {
   898 @@ -29,15 +32,15 @@ nsMIMEInfoUnix::GetHasDefaultHandler(bool* _retval) {
  1028    // if a default app is set, it means the application has been set from
       
  1029    // either /etc/mailcap or ${HOME}/.mailcap, in which case we don't want to
       
  1030    // give the GNOME answer.
       
  1031    if (GetDefaultApplication()) {
       
  1032      return nsMIMEInfoImpl::GetHasDefaultHandler(_retval);
       
  1033    }
       
  1034  
       
  1035    *_retval = false;
   899    *_retval = false;
  1036  
   900  
  1037    if (mClass == eProtocolInfo) {
   901    if (mClass == eProtocolInfo) {
  1038 -    *_retval = nsGNOMERegistry::HandlerExists(mSchemeOrType.get());
   902 -    *_retval = nsGNOMERegistry::HandlerExists(mSchemeOrType.get());
  1039 +    *_retval = nsCommonRegistry::HandlerExists(mSchemeOrType.get());
   903 +    *_retval = nsCommonRegistry::HandlerExists(mSchemeOrType.get());
  1048 -        mimeInfo = nsGNOMERegistry::GetFromExtension(ext);
   912 -        mimeInfo = nsGNOMERegistry::GetFromExtension(ext);
  1049 +        mimeInfo = nsCommonRegistry::GetFromExtension(ext);
   913 +        mimeInfo = nsCommonRegistry::GetFromExtension(ext);
  1050        }
   914        }
  1051      }
   915      }
  1052      if (mimeInfo) *_retval = true;
   916      if (mimeInfo) *_retval = true;
  1053    }
   917 @@ -59,6 +62,21 @@ nsresult nsMIMEInfoUnix::LaunchDefaultWithFile(nsIFile* aFile) {
  1054  
       
  1055    if (*_retval) return NS_OK;
       
  1056  
       
  1057    return NS_OK;
       
  1058 @@ -54,16 +57,31 @@ nsresult nsMIMEInfoUnix::LaunchDefaultWi
       
  1059    // give the GNOME answer.
       
  1060    if (GetDefaultApplication()) {
       
  1061      return nsMIMEInfoImpl::LaunchDefaultWithFile(aFile);
       
  1062    }
       
  1063  
       
  1064    nsAutoCString nativePath;
   918    nsAutoCString nativePath;
  1065    aFile->GetNativePath(nativePath);
   919    aFile->GetNativePath(nativePath);
  1066  
   920  
  1067 +  if (nsKDEUtils::kdeSupport()) {
   921 +  if (nsKDEUtils::kdeSupport()) {
  1068 +    bool supports;
   922 +    bool supports;
  1080 +  }
   934 +  }
  1081 +
   935 +
  1082    nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
   936    nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
  1083    if (!giovfs) {
   937    if (!giovfs) {
  1084      return NS_ERROR_FAILURE;
   938      return NS_ERROR_FAILURE;
  1085    }
       
  1086  
       
  1087    // nsGIOMimeApp->Launch wants a URI string instead of local file
       
  1088    nsresult rv;
       
  1089    nsCOMPtr<nsIIOService> ioservice =
       
  1090 diff --git a/uriloader/exthandler/unix/nsOSHelperAppService.cpp b/uriloader/exthandler/unix/nsOSHelperAppService.cpp
   939 diff --git a/uriloader/exthandler/unix/nsOSHelperAppService.cpp b/uriloader/exthandler/unix/nsOSHelperAppService.cpp
       
   940 index 7f6eaa46f2ee0d5155b83bfb07d8040584935772..f7627e790c47e1ae007b072b4bb47b18de1ae417 100644
  1091 --- a/uriloader/exthandler/unix/nsOSHelperAppService.cpp
   941 --- a/uriloader/exthandler/unix/nsOSHelperAppService.cpp
  1092 +++ b/uriloader/exthandler/unix/nsOSHelperAppService.cpp
   942 +++ b/uriloader/exthandler/unix/nsOSHelperAppService.cpp
  1093 @@ -5,17 +5,17 @@
   943 @@ -10,7 +10,7 @@
  1094   * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       
  1095  
       
  1096  #include <sys/types.h>
       
  1097  #include <sys/stat.h>
       
  1098  
       
  1099  #include "nsOSHelperAppService.h"
   944  #include "nsOSHelperAppService.h"
  1100  #include "nsMIMEInfoUnix.h"
   945  #include "nsMIMEInfoUnix.h"
  1101  #ifdef MOZ_WIDGET_GTK
   946  #ifdef MOZ_WIDGET_GTK
  1102 -#  include "nsGNOMERegistry.h"
   947 -#  include "nsGNOMERegistry.h"
  1103 +#  include "nsCommonRegistry.h"
   948 +#  include "nsCommonRegistry.h"
  1104  #  ifdef MOZ_BUILD_APP_IS_BROWSER
   949  #  ifdef MOZ_BUILD_APP_IS_BROWSER
  1105  #    include "nsIToolkitShellService.h"
   950  #    include "nsIToolkitShellService.h"
  1106  #    include "nsIGNOMEShellService.h"
   951  #    include "nsIGNOMEShellService.h"
  1107  #  endif
   952 @@ -1106,7 +1106,7 @@ nsresult nsOSHelperAppService::OSProtocolHandlerExists(
  1108  #endif
       
  1109  #include "nsISupports.h"
       
  1110  #include "nsString.h"
       
  1111  #include "nsReadableUtils.h"
       
  1112 @@ -1101,17 +1101,17 @@ nsresult nsOSHelperAppService::GetHandle
       
  1113  
       
  1114  nsresult nsOSHelperAppService::OSProtocolHandlerExists(
       
  1115      const char* aProtocolScheme, bool* aHandlerExists) {
       
  1116    nsresult rv = NS_OK;
       
  1117  
       
  1118    if (!XRE_IsContentProcess()) {
   953    if (!XRE_IsContentProcess()) {
  1119  #ifdef MOZ_WIDGET_GTK
   954  #ifdef MOZ_WIDGET_GTK
  1120      // Check the GNOME registry for a protocol handler
   955      // Check the GNOME registry for a protocol handler
  1121 -    *aHandlerExists = nsGNOMERegistry::HandlerExists(aProtocolScheme);
   956 -    *aHandlerExists = nsGNOMERegistry::HandlerExists(aProtocolScheme);
  1122 +    *aHandlerExists = nsCommonRegistry::HandlerExists(aProtocolScheme);
   957 +    *aHandlerExists = nsCommonRegistry::HandlerExists(aProtocolScheme);
  1123  #else
   958  #else
  1124      *aHandlerExists = false;
   959      *aHandlerExists = false;
  1125  #endif
   960  #endif
  1126    } else {
   961 @@ -1126,7 +1126,7 @@ nsresult nsOSHelperAppService::OSProtocolHandlerExists(
  1127      *aHandlerExists = false;
       
  1128      nsCOMPtr<nsIHandlerService> handlerSvc =
       
  1129          do_GetService(NS_HANDLERSERVICE_CONTRACTID, &rv);
       
  1130      if (NS_SUCCEEDED(rv) && handlerSvc) {
       
  1131 @@ -1121,17 +1121,17 @@ nsresult nsOSHelperAppService::OSProtoco
       
  1132    }
       
  1133  
       
  1134    return rv;
       
  1135  }
       
  1136  
       
  1137  NS_IMETHODIMP nsOSHelperAppService::GetApplicationDescription(
   962  NS_IMETHODIMP nsOSHelperAppService::GetApplicationDescription(
  1138      const nsACString& aScheme, nsAString& _retval) {
   963      const nsACString& aScheme, nsAString& _retval) {
  1139  #ifdef MOZ_WIDGET_GTK
   964  #ifdef MOZ_WIDGET_GTK
  1140 -  nsGNOMERegistry::GetAppDescForScheme(aScheme, _retval);
   965 -  nsGNOMERegistry::GetAppDescForScheme(aScheme, _retval);
  1141 +  nsCommonRegistry::GetAppDescForScheme(aScheme, _retval);
   966 +  nsCommonRegistry::GetAppDescForScheme(aScheme, _retval);
  1142    return _retval.IsEmpty() ? NS_ERROR_NOT_AVAILABLE : NS_OK;
   967    return _retval.IsEmpty() ? NS_ERROR_NOT_AVAILABLE : NS_OK;
  1143  #else
   968  #else
  1144    return NS_ERROR_NOT_AVAILABLE;
   969    return NS_ERROR_NOT_AVAILABLE;
  1145  #endif
   970 @@ -1231,7 +1231,7 @@ already_AddRefed<nsMIMEInfoBase> nsOSHelperAppService::GetFromExtension(
  1146  }
       
  1147  
       
  1148  NS_IMETHODIMP nsOSHelperAppService::IsCurrentAppOSDefaultForProtocol(
       
  1149      const nsACString& aScheme, bool* _retval) {
       
  1150 @@ -1226,17 +1226,17 @@ already_AddRefed<nsMIMEInfoBase> nsOSHel
       
  1151    nsresult rv =
       
  1152        LookUpTypeAndDescription(NS_ConvertUTF8toUTF16(aFileExt), majorType,
       
  1153                                 minorType, mime_types_description, true);
       
  1154  
       
  1155    if (NS_FAILED(rv) || majorType.IsEmpty()) {
       
  1156  #ifdef MOZ_WIDGET_GTK
   971  #ifdef MOZ_WIDGET_GTK
  1157      LOG("Looking in GNOME registry\n");
   972      LOG("Looking in GNOME registry\n");
  1158      RefPtr<nsMIMEInfoBase> gnomeInfo =
   973      RefPtr<nsMIMEInfoBase> gnomeInfo =
  1159 -        nsGNOMERegistry::GetFromExtension(aFileExt);
   974 -        nsGNOMERegistry::GetFromExtension(aFileExt);
  1160 +        nsCommonRegistry::GetFromExtension(aFileExt);
   975 +        nsCommonRegistry::GetFromExtension(aFileExt);
  1161      if (gnomeInfo) {
   976      if (gnomeInfo) {
  1162        LOG("Got MIMEInfo from GNOME registry\n");
   977        LOG("Got MIMEInfo from GNOME registry\n");
  1163        return gnomeInfo.forget();
   978        return gnomeInfo.forget();
  1164      }
   979 @@ -1344,7 +1344,7 @@ already_AddRefed<nsMIMEInfoBase> nsOSHelperAppService::GetFromType(
  1165  #endif
       
  1166  
       
  1167      rv = LookUpTypeAndDescription(NS_ConvertUTF8toUTF16(aFileExt), majorType,
       
  1168                                    minorType, mime_types_description, false);
       
  1169 @@ -1339,17 +1339,17 @@ already_AddRefed<nsMIMEInfoBase> nsOSHel
       
  1170  
       
  1171    // Now look up our extensions
       
  1172    nsAutoString extensions, mime_types_description;
       
  1173    LookUpExtensionsAndDescription(majorType, minorType, extensions,
       
  1174                                   mime_types_description);
       
  1175  
   980  
  1176  #ifdef MOZ_WIDGET_GTK
   981  #ifdef MOZ_WIDGET_GTK
  1177    if (handler.IsEmpty()) {
   982    if (handler.IsEmpty()) {
  1178 -    RefPtr<nsMIMEInfoBase> gnomeInfo = nsGNOMERegistry::GetFromType(aMIMEType);
   983 -    RefPtr<nsMIMEInfoBase> gnomeInfo = nsGNOMERegistry::GetFromType(aMIMEType);
  1179 +    RefPtr<nsMIMEInfoBase> gnomeInfo = nsCommonRegistry::GetFromType(aMIMEType);
   984 +    RefPtr<nsMIMEInfoBase> gnomeInfo = nsCommonRegistry::GetFromType(aMIMEType);
  1180      if (gnomeInfo) {
   985      if (gnomeInfo) {
  1181        LOG("Got MIMEInfo from GNOME registry without extensions; setting them "
   986        LOG("Got MIMEInfo from GNOME registry without extensions; setting them "
  1182            "to %s\n",
   987            "to %s\n",
  1183            NS_LossyConvertUTF16toASCII(extensions).get());
       
  1184  
       
  1185        NS_ASSERTION(!gnomeInfo->HasExtensions(), "How'd that happen?");
       
  1186        gnomeInfo->SetFileExtensions(NS_ConvertUTF16toUTF8(extensions));
       
  1187        return gnomeInfo.forget();
       
  1188 diff --git a/widget/gtk/moz.build b/widget/gtk/moz.build
   988 diff --git a/widget/gtk/moz.build b/widget/gtk/moz.build
       
   989 index c6a765df9e5a4c95f77e9ee1b4ebbf9913a81e15..6e9028169ac594a24f90a4f58dc493c8332c6bf8 100644
  1189 --- a/widget/gtk/moz.build
   990 --- a/widget/gtk/moz.build
  1190 +++ b/widget/gtk/moz.build
   991 +++ b/widget/gtk/moz.build
  1191 @@ -146,16 +146,17 @@ FINAL_LIBRARY = "xul"
   992 @@ -161,6 +161,7 @@ LOCAL_INCLUDES += [
  1192  
       
  1193  LOCAL_INCLUDES += [
       
  1194      "/layout/base",
       
  1195      "/layout/forms",
       
  1196      "/layout/generic",
       
  1197      "/layout/xul",
   993      "/layout/xul",
  1198      "/other-licenses/atk-1.0",
   994      "/other-licenses/atk-1.0",
  1199      "/third_party/cups/include",
   995      "/third_party/cups/include",
  1200 +    "/toolkit/xre",
   996 +    "/toolkit/xre",
  1201      "/widget",
   997      "/widget",
  1202      "/widget/headless",
   998      "/widget/headless",
  1203      "/widget/x11",
   999      "/widget/x11",
  1204  ]
       
  1205  
       
  1206  DEFINES["CAIRO_GFX"] = True
       
  1207  
       
  1208  DEFINES["MOZ_APP_NAME"] = '"%s"' % CONFIG["MOZ_APP_NAME"]
       
  1209 diff --git a/widget/gtk/nsFilePicker.cpp b/widget/gtk/nsFilePicker.cpp
  1000 diff --git a/widget/gtk/nsFilePicker.cpp b/widget/gtk/nsFilePicker.cpp
       
  1001 index 22d0f46b9563734c7afb4292417124f3cd171a12..b2a68711eb344d5ac41a7133751b2c19d574f532 100644
  1210 --- a/widget/gtk/nsFilePicker.cpp
  1002 --- a/widget/gtk/nsFilePicker.cpp
  1211 +++ b/widget/gtk/nsFilePicker.cpp
  1003 +++ b/widget/gtk/nsFilePicker.cpp
  1212 @@ -1,15 +1,16 @@
  1004 @@ -5,6 +5,7 @@
  1213  /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       
  1214  /* This Source Code Form is subject to the terms of the Mozilla Public
       
  1215   * License, v. 2.0. If a copy of the MPL was not distributed with this
       
  1216   * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       
  1217  
  1005  
  1218  #include <dlfcn.h>
  1006  #include <dlfcn.h>
  1219  #include <gtk/gtk.h>
  1007  #include <gtk/gtk.h>
  1220 +#include <gdk/gdkx.h>
  1008 +#include <gdk/gdkx.h>
  1221  #include <sys/types.h>
  1009  #include <sys/types.h>
  1222  #include <sys/stat.h>
  1010  #include <sys/stat.h>
  1223  #include <unistd.h>
  1011  #include <unistd.h>
  1224  
  1012 @@ -28,6 +29,8 @@
  1225  #include "mozilla/Types.h"
       
  1226  #include "nsGtkUtils.h"
       
  1227  #include "nsIFileURL.h"
       
  1228  #include "nsIGIOService.h"
       
  1229 @@ -23,16 +24,18 @@
       
  1230  #include "nsArrayEnumerator.h"
       
  1231  #include "nsEnumeratorUtils.h"
       
  1232  #include "nsNetUtil.h"
       
  1233  #include "nsReadableUtils.h"
       
  1234  #include "MozContainer.h"
       
  1235  #include "WidgetUtilsGtk.h"
  1013  #include "WidgetUtilsGtk.h"
  1236  
  1014  
  1237  #include "nsFilePicker.h"
  1015  #include "nsFilePicker.h"
  1238 +#include "nsKDEUtils.h"
  1016 +#include "nsKDEUtils.h"
  1239 +#include "nsURLHelper.h"
  1017 +#include "nsURLHelper.h"
  1240  
  1018  
  1241  #undef LOG
  1019  #undef LOG
  1242  #ifdef MOZ_LOGGING
  1020  #ifdef MOZ_LOGGING
  1243  #  include "mozilla/Logging.h"
  1021 @@ -242,7 +245,8 @@ NS_IMETHODIMP
  1244  #  include "nsTArray.h"
       
  1245  #  include "Units.h"
       
  1246  extern mozilla::LazyLogModule gWidgetLog;
       
  1247  #  define LOG(args) MOZ_LOG(gWidgetLog, mozilla::LogLevel::Debug, args)
       
  1248 @@ -237,17 +240,18 @@ nsFilePicker::AppendFilters(int32_t aFil
       
  1249    mAllowURLs = !!(aFilterMask & filterAllowURLs);
       
  1250    return nsBaseFilePicker::AppendFilters(aFilterMask);
       
  1251  }
       
  1252  
       
  1253  NS_IMETHODIMP
       
  1254  nsFilePicker::AppendFilter(const nsAString& aTitle, const nsAString& aFilter) {
  1022  nsFilePicker::AppendFilter(const nsAString& aTitle, const nsAString& aFilter) {
  1255    if (aFilter.EqualsLiteral("..apps")) {
  1023    if (aFilter.EqualsLiteral("..apps")) {
  1256      // No platform specific thing we can do here, really....
  1024      // No platform specific thing we can do here, really....
  1257 -    return NS_OK;
  1025 -    return NS_OK;
  1258 +    // Unless it's KDE.
  1026 +    // Unless it's KDE.
  1259 +    if (mMode != modeOpen || !nsKDEUtils::kdeSupport()) return NS_OK;
  1027 +    if (mMode != modeOpen || !nsKDEUtils::kdeSupport()) return NS_OK;
  1260    }
  1028    }
  1261  
  1029  
  1262    nsAutoCString filter, name;
  1030    nsAutoCString filter, name;
  1263    CopyUTF16toUTF8(aFilter, filter);
  1031 @@ -352,6 +356,31 @@ nsFilePicker::Open(nsIFilePickerShownCallback* aCallback) {
  1264    CopyUTF16toUTF8(aTitle, name);
       
  1265  
       
  1266    mFilters.AppendElement(filter);
       
  1267    mFilterNames.AppendElement(name);
       
  1268 @@ -347,16 +351,41 @@ nsresult nsFilePicker::Show(nsIFilePicke
       
  1269    return NS_OK;
       
  1270  }
       
  1271  
       
  1272  NS_IMETHODIMP
       
  1273  nsFilePicker::Open(nsIFilePickerShownCallback* aCallback) {
       
  1274    // Can't show two dialogs concurrently with the same filepicker
  1032    // Can't show two dialogs concurrently with the same filepicker
  1275    if (mRunning) return NS_ERROR_NOT_AVAILABLE;
  1033    if (mRunning) return NS_ERROR_NOT_AVAILABLE;
  1276  
  1034  
  1277 +  // KDE file picker is not handled via callback
  1035 +  // KDE file picker is not handled via callback
  1278 +  if (nsKDEUtils::kdeSupport()) {
  1036 +  if (nsKDEUtils::kdeSupport()) {
  1300 +  }
  1058 +  }
  1301 +
  1059 +
  1302    NS_ConvertUTF16toUTF8 title(mTitle);
  1060    NS_ConvertUTF16toUTF8 title(mTitle);
  1303  
  1061  
  1304    GtkWindow* parent_widget =
  1062    GtkWindow* parent_widget =
  1305        GTK_WINDOW(mParentWidget->GetNativeData(NS_NATIVE_SHELLWIDGET));
  1063 @@ -633,6 +662,205 @@ void nsFilePicker::Done(void* file_chooser, gint response) {
  1306  
       
  1307    GtkFileChooserAction action = GetGtkFileChooserAction(mMode);
       
  1308  
       
  1309    const gchar* accept_button;
       
  1310 @@ -628,16 +657,215 @@ void nsFilePicker::Done(void* file_choos
       
  1311      mCallback->Done(result);
       
  1312      mCallback = nullptr;
       
  1313    } else {
       
  1314      mResult = result;
       
  1315    }
       
  1316    NS_RELEASE_THIS();
  1064    NS_RELEASE_THIS();
  1317  }
  1065  }
  1318  
  1066  
  1319 +nsCString nsFilePicker::kdeMakeFilter(int index) {
  1067 +nsCString nsFilePicker::kdeMakeFilter(int index) {
  1320 +  nsCString buf = mFilters[index];
  1068 +  nsCString buf = mFilters[index];
  1516 +}
  1264 +}
  1517 +
  1265 +
  1518  // All below functions available as of GTK 3.20+
  1266  // All below functions available as of GTK 3.20+
  1519  void* nsFilePicker::GtkFileChooserNew(const gchar* title, GtkWindow* parent,
  1267  void* nsFilePicker::GtkFileChooserNew(const gchar* title, GtkWindow* parent,
  1520                                        GtkFileChooserAction action,
  1268                                        GtkFileChooserAction action,
  1521                                        const gchar* accept_label) {
       
  1522    static auto sGtkFileChooserNativeNewPtr =
       
  1523        (void* (*)(const gchar*, GtkWindow*, GtkFileChooserAction, const gchar*,
       
  1524                   const gchar*))dlsym(RTLD_DEFAULT,
       
  1525                                       "gtk_file_chooser_native_new");
       
  1526 diff --git a/widget/gtk/nsFilePicker.h b/widget/gtk/nsFilePicker.h
  1269 diff --git a/widget/gtk/nsFilePicker.h b/widget/gtk/nsFilePicker.h
       
  1270 index 496df4937277d96485376176296ee836aa261ec7..a4c1862ec042f4465d53bc95f138afb87260ba07 100644
  1527 --- a/widget/gtk/nsFilePicker.h
  1271 --- a/widget/gtk/nsFilePicker.h
  1528 +++ b/widget/gtk/nsFilePicker.h
  1272 +++ b/widget/gtk/nsFilePicker.h
  1529 @@ -69,16 +69,22 @@ class nsFilePicker : public nsBaseFilePi
  1273 @@ -74,6 +74,12 @@ class nsFilePicker : public nsBaseFilePicker {
  1530    nsString mDefaultExtension;
       
  1531  
       
  1532    nsTArray<nsCString> mFilters;
       
  1533    nsTArray<nsCString> mFilterNames;
       
  1534  
       
  1535   private:
  1274   private:
  1536    static nsIFile* mPrevDisplayDirectory;
  1275    static nsIFile* mPrevDisplayDirectory;
  1537  
  1276  
  1538 +  bool kdeRunning();
  1277 +  bool kdeRunning();
  1539 +  bool getKdeRunning();
  1278 +  bool getKdeRunning();
  1542 +  nsCString kdeMakeFilter(int index);
  1281 +  nsCString kdeMakeFilter(int index);
  1543 +
  1282 +
  1544    void* GtkFileChooserNew(const gchar* title, GtkWindow* parent,
  1283    void* GtkFileChooserNew(const gchar* title, GtkWindow* parent,
  1545                            GtkFileChooserAction action,
  1284                            GtkFileChooserAction action,
  1546                            const gchar* accept_label);
  1285                            const gchar* accept_label);
  1547    void GtkFileChooserShow(void* file_chooser);
       
  1548    void GtkFileChooserDestroy(void* file_chooser);
       
  1549    void GtkFileChooserSetModal(void* file_chooser, GtkWindow* parent_widget,
       
  1550                                gboolean modal);
       
  1551  
       
  1552 diff --git a/xpcom/components/ManifestParser.cpp b/xpcom/components/ManifestParser.cpp
  1286 diff --git a/xpcom/components/ManifestParser.cpp b/xpcom/components/ManifestParser.cpp
       
  1287 index 88ee06d78db60a84343fd3d23c16e163aead37c3..834d6a2d353cc1bd11916de8a28f5d05a86d9031 100644
  1553 --- a/xpcom/components/ManifestParser.cpp
  1288 --- a/xpcom/components/ManifestParser.cpp
  1554 +++ b/xpcom/components/ManifestParser.cpp
  1289 +++ b/xpcom/components/ManifestParser.cpp
  1555 @@ -38,16 +38,17 @@
  1290 @@ -43,6 +43,7 @@
  1556  #include "nsTextFormatter.h"
       
  1557  #include "nsVersionComparator.h"
       
  1558  #include "nsXPCOMCIDInternal.h"
       
  1559  
       
  1560  #include "nsIConsoleService.h"
       
  1561  #include "nsIScriptError.h"
  1291  #include "nsIScriptError.h"
  1562  #include "nsIXULAppInfo.h"
  1292  #include "nsIXULAppInfo.h"
  1563  #include "nsIXULRuntime.h"
  1293  #include "nsIXULRuntime.h"
  1564 +#include "nsKDEUtils.h"
  1294 +#include "nsKDEUtils.h"
  1565  
  1295  
  1566  using namespace mozilla;
  1296  using namespace mozilla;
  1567  
  1297  
  1568  struct ManifestDirective {
  1298 @@ -394,6 +395,7 @@ void ParseManifest(NSLocationType aType, FileLocation& aFile, char* aBuf,
  1569    const char* directive;
       
  1570    int argc;
       
  1571  
       
  1572    bool ischrome;
       
  1573 @@ -389,16 +390,17 @@ void ParseManifest(NSLocationType aType,
       
  1574    constexpr auto kRemoteEnabled = u"remoteenabled"_ns;
       
  1575    constexpr auto kRemoteRequired = u"remoterequired"_ns;
       
  1576    constexpr auto kApplication = u"application"_ns;
       
  1577    constexpr auto kAppVersion = u"appversion"_ns;
       
  1578    constexpr auto kGeckoVersion = u"platformversion"_ns;
       
  1579    constexpr auto kOs = u"os"_ns;
  1299    constexpr auto kOs = u"os"_ns;
  1580    constexpr auto kOsVersion = u"osversion"_ns;
  1300    constexpr auto kOsVersion = u"osversion"_ns;
  1581    constexpr auto kABI = u"abi"_ns;
  1301    constexpr auto kABI = u"abi"_ns;
  1582 +  constexpr auto kDesktop = u"desktop"_ns;
  1302 +  constexpr auto kDesktop = u"desktop"_ns;
  1583    constexpr auto kProcess = u"process"_ns;
  1303    constexpr auto kProcess = u"process"_ns;
  1584  #if defined(MOZ_WIDGET_ANDROID)
  1304  #if defined(MOZ_WIDGET_ANDROID)
  1585    constexpr auto kTablet = u"tablet"_ns;
  1305    constexpr auto kTablet = u"tablet"_ns;
  1586  #endif
  1306 @@ -453,6 +455,7 @@ void ParseManifest(NSLocationType aType, FileLocation& aFile, char* aBuf,
  1587    // You might expect this to be guarded by MOZ_BACKGROUNDTASKS, but it's not
       
  1588    // possible to have conditional manifest contents, so we need to recognize and
       
  1589    // discard these tokens even when MOZ_BACKGROUNDTASKS is not set.
       
  1590    constexpr auto kBackgroundTask = u"backgroundtask"_ns;
       
  1591 @@ -448,39 +450,44 @@ void ParseManifest(NSLocationType aType,
       
  1592          CopyUTF8toUTF16(s, abi);
       
  1593          abi.Insert(char16_t('_'), 0);
       
  1594          abi.Insert(osTarget, 0);
       
  1595        }
       
  1596      }
       
  1597    }
  1307    }
  1598  
  1308  
  1599    nsAutoString osVersion;
  1309    nsAutoString osVersion;
  1600 +  nsAutoString desktop;
  1310 +  nsAutoString desktop;
  1601  #if defined(XP_WIN)
  1311  #if defined(XP_WIN)
  1602  #  pragma warning(push)
  1312  #  pragma warning(push)
  1603  #  pragma warning(disable : 4996)  // VC12+ deprecates GetVersionEx
  1313  #  pragma warning(disable : 4996)  // VC12+ deprecates GetVersionEx
  1604    OSVERSIONINFO info = {sizeof(OSVERSIONINFO)};
  1314 @@ -461,14 +464,17 @@ void ParseManifest(NSLocationType aType, FileLocation& aFile, char* aBuf,
  1605    if (GetVersionEx(&info)) {
       
  1606      nsTextFormatter::ssprintf(osVersion, u"%ld.%ld", info.dwMajorVersion,
  1315      nsTextFormatter::ssprintf(osVersion, u"%ld.%ld", info.dwMajorVersion,
  1607                                info.dwMinorVersion);
  1316                                info.dwMinorVersion);
  1608    }
  1317    }
  1609 +  desktop = u"win"_ns;
  1318 +  desktop = u"win"_ns;
  1610  #  pragma warning(pop)
  1319  #  pragma warning(pop)
  1618                              gtk_minor_version);
  1327                              gtk_minor_version);
  1619 +  desktop = nsKDEUtils::kdeSession() ? u"kde"_ns : u"gnome"_ns;
  1328 +  desktop = nsKDEUtils::kdeSession() ? u"kde"_ns : u"gnome"_ns;
  1620  #elif defined(MOZ_WIDGET_ANDROID)
  1329  #elif defined(MOZ_WIDGET_ANDROID)
  1621    bool isTablet = false;
  1330    bool isTablet = false;
  1622    if (jni::IsAvailable()) {
  1331    if (jni::IsAvailable()) {
  1623      jni::String::LocalRef release = java::sdk::Build::VERSION::RELEASE();
  1332 @@ -476,6 +482,7 @@ void ParseManifest(NSLocationType aType, FileLocation& aFile, char* aBuf,
  1624      osVersion.Assign(release->ToString());
  1333      osVersion.Assign(release->ToString());
  1625      isTablet = java::GeckoAppShell::IsTablet();
  1334      isTablet = java::GeckoAppShell::IsTablet();
  1626    }
  1335    }
  1627 +  desktop = u"android"_ns;
  1336 +  desktop = u"android"_ns;
  1628  #endif
  1337  #endif
  1629  
  1338  
  1630    if (XRE_IsContentProcess()) {
  1339    if (XRE_IsContentProcess()) {
  1631      process = kContent;
  1340 @@ -576,6 +583,7 @@ void ParseManifest(NSLocationType aType, FileLocation& aFile, char* aBuf,
  1632    } else {
       
  1633      process = kMain;
       
  1634    }
       
  1635  
       
  1636 @@ -571,25 +578,27 @@ void ParseManifest(NSLocationType aType,
       
  1637      // When in background task mode, default to not registering
       
  1638      // category directivies unless backgroundtask=1 is specified.
       
  1639      TriState stBackgroundTask = (BackgroundTasks::IsBackgroundTaskMode() &&
       
  1640                                   strcmp("category", directive->directive) == 0)
       
  1641                                      ? eBad
       
  1642                                      : eUnspecified;
  1341                                      : eUnspecified;
  1643  #endif
  1342  #endif
  1644      int flags = 0;
  1343      int flags = 0;
  1645 +    TriState stDesktop = eUnspecified;
  1344 +    TriState stDesktop = eUnspecified;
  1646  
  1345  
  1647      while ((token = nsCRT::strtok(whitespace, kWhitespace, &whitespace)) &&
  1346      while ((token = nsCRT::strtok(whitespace, kWhitespace, &whitespace)) &&
  1648             ok) {
  1347             ok) {
  1649        ToLowerCase(token);
  1348 @@ -585,6 +593,7 @@ void ParseManifest(NSLocationType aType, FileLocation& aFile, char* aBuf,
  1650        NS_ConvertASCIItoUTF16 wtoken(token);
       
  1651  
       
  1652        if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
  1349        if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
  1653            CheckOsFlag(kOs, wtoken, osTarget, stOs) ||
  1350            CheckOsFlag(kOs, wtoken, osTarget, stOs) ||
  1654            CheckStringFlag(kABI, wtoken, abi, stABI) ||
  1351            CheckStringFlag(kABI, wtoken, abi, stABI) ||
  1655 +          CheckStringFlag(kDesktop, wtoken, desktop, stDesktop) ||
  1352 +          CheckStringFlag(kDesktop, wtoken, desktop, stDesktop) ||
  1656            CheckStringFlag(kProcess, wtoken, process, stProcess) ||
  1353            CheckStringFlag(kProcess, wtoken, process, stProcess) ||
  1657            CheckVersionFlag(kOsVersion, wtoken, osVersion, stOsVersion) ||
  1354            CheckVersionFlag(kOsVersion, wtoken, osVersion, stOsVersion) ||
  1658            CheckVersionFlag(kAppVersion, wtoken, appVersion, stAppVersion) ||
  1355            CheckVersionFlag(kAppVersion, wtoken, appVersion, stAppVersion) ||
  1659            CheckVersionFlag(kGeckoVersion, wtoken, geckoVersion,
  1356 @@ -644,6 +653,7 @@ void ParseManifest(NSLocationType aType, FileLocation& aFile, char* aBuf,
  1660                             stGeckoVersion)) {
       
  1661          continue;
       
  1662        }
       
  1663  
       
  1664 @@ -639,16 +648,17 @@ void ParseManifest(NSLocationType aType,
       
  1665  
       
  1666        LogMessageWithContext(
       
  1667            aFile, line, "Unrecognized chrome manifest modifier '%s'.", token);
       
  1668        ok = false;
       
  1669      }
       
  1670  
  1357  
  1671      if (!ok || stApp == eBad || stAppVersion == eBad ||
  1358      if (!ok || stApp == eBad || stAppVersion == eBad ||
  1672          stGeckoVersion == eBad || stOs == eBad || stOsVersion == eBad ||
  1359          stGeckoVersion == eBad || stOs == eBad || stOsVersion == eBad ||
  1673 +        stDesktop == eBad ||
  1360 +        stDesktop == eBad ||
  1674  #ifdef MOZ_WIDGET_ANDROID
  1361  #ifdef MOZ_WIDGET_ANDROID
  1675          stTablet == eBad ||
  1362          stTablet == eBad ||
  1676  #endif
  1363  #endif
  1677  #ifdef MOZ_BACKGROUNDTASKS
       
  1678          stBackgroundTask == eBad ||
       
  1679  #endif
       
  1680          stABI == eBad || stProcess == eBad) {
       
  1681        continue;
       
  1682 diff --git a/xpcom/components/moz.build b/xpcom/components/moz.build
  1364 diff --git a/xpcom/components/moz.build b/xpcom/components/moz.build
       
  1365 index 95ee64e985ac34dd6a3191f1948afa6d05adcb73..9af8f80497b7390b7ca434b6ee3b86b2baf47489 100644
  1683 --- a/xpcom/components/moz.build
  1366 --- a/xpcom/components/moz.build
  1684 +++ b/xpcom/components/moz.build
  1367 +++ b/xpcom/components/moz.build
  1685 @@ -66,16 +66,17 @@ LOCAL_INCLUDES += [
  1368 @@ -71,6 +71,7 @@ LOCAL_INCLUDES += [
  1686      "!..",
       
  1687      "../base",
       
  1688      "../build",
       
  1689      "../ds",
       
  1690      "/chrome",
       
  1691      "/js/xpconnect/loader",
  1369      "/js/xpconnect/loader",
  1692      "/layout/build",
  1370      "/layout/build",
  1693      "/modules/libjar",
  1371      "/modules/libjar",
  1694 +    "/toolkit/xre",
  1372 +    "/toolkit/xre",
  1695  ]
  1373  ]
  1696  
  1374  
  1697  if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
  1375  if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
  1698      CXXFLAGS += CONFIG["MOZ_GTK3_CFLAGS"]
       
  1699      if CONFIG["MOZ_ENABLE_DBUS"]:
       
  1700          CXXFLAGS += CONFIG["MOZ_DBUS_GLIB_CFLAGS"]
       
  1701  
       
  1702  include("/ipc/chromium/chromium-config.mozbuild")
       
  1703 diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp
  1376 diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp
       
  1377 index 08c77360de6fdbf3dc579ea49243dbdc18f37ebc..eedd5bcf86bde3ecd795bbbcbf94799f19135323 100644
  1704 --- a/xpcom/io/nsLocalFileUnix.cpp
  1378 --- a/xpcom/io/nsLocalFileUnix.cpp
  1705 +++ b/xpcom/io/nsLocalFileUnix.cpp
  1379 +++ b/xpcom/io/nsLocalFileUnix.cpp
  1706 @@ -46,16 +46,17 @@
  1380 @@ -51,6 +51,7 @@
  1707  #include "nsString.h"
       
  1708  #include "nsIDirectoryEnumerator.h"
       
  1709  #include "nsSimpleEnumerator.h"
       
  1710  #include "private/pprio.h"
       
  1711  #include "prlink.h"
       
  1712  
  1381  
  1713  #ifdef MOZ_WIDGET_GTK
  1382  #ifdef MOZ_WIDGET_GTK
  1714  #  include "nsIGIOService.h"
  1383  #  include "nsIGIOService.h"
  1715 +#  include "nsKDEUtils.h"
  1384 +#  include "nsKDEUtils.h"
  1716  #endif
  1385  #endif
  1717  
  1386  
  1718  #ifdef MOZ_WIDGET_COCOA
  1387  #ifdef MOZ_WIDGET_COCOA
  1719  #  include <Carbon/Carbon.h>
  1388 @@ -2172,10 +2173,18 @@ nsLocalFile::Reveal() {
  1720  #  include "CocoaFileUtils.h"
       
  1721  #  include "prmem.h"
       
  1722  #  include "plbase64.h"
       
  1723  
       
  1724 @@ -2167,20 +2168,28 @@ nsLocalFile::SetPersistentDescriptor(con
       
  1725  
       
  1726  NS_IMETHODIMP
       
  1727  nsLocalFile::Reveal() {
       
  1728    if (!FilePreferences::IsAllowedPath(mPath)) {
       
  1729      return NS_ERROR_FILE_ACCESS_DENIED;
       
  1730    }
  1389    }
  1731  
  1390  
  1732  #ifdef MOZ_WIDGET_GTK
  1391  #ifdef MOZ_WIDGET_GTK
  1733 +  nsAutoCString url;
  1392 +  nsAutoCString url;
  1734    nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
  1393    nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
  1745 +  if (!giovfs) return NS_ERROR_FAILURE;
  1404 +  if (!giovfs) return NS_ERROR_FAILURE;
  1746 +
  1405 +
  1747    return giovfs->RevealFile(this);
  1406    return giovfs->RevealFile(this);
  1748  #elif defined(MOZ_WIDGET_COCOA)
  1407  #elif defined(MOZ_WIDGET_COCOA)
  1749    CFURLRef url;
  1408    CFURLRef url;
  1750    if (NS_SUCCEEDED(GetCFURL(&url))) {
  1409 @@ -2197,6 +2206,13 @@ nsLocalFile::Launch() {
  1751      nsresult rv = CocoaFileUtils::RevealFileInFinder(url);
       
  1752      ::CFRelease(url);
       
  1753      return rv;
       
  1754    }
       
  1755 @@ -2192,16 +2201,23 @@ nsLocalFile::Reveal() {
       
  1756  
       
  1757  NS_IMETHODIMP
       
  1758  nsLocalFile::Launch() {
       
  1759    if (!FilePreferences::IsAllowedPath(mPath)) {
       
  1760      return NS_ERROR_FILE_ACCESS_DENIED;
       
  1761    }
  1410    }
  1762  
  1411  
  1763  #ifdef MOZ_WIDGET_GTK
  1412  #ifdef MOZ_WIDGET_GTK
  1764 +  if (nsKDEUtils::kdeSupport()) {
  1413 +  if (nsKDEUtils::kdeSupport()) {
  1765 +    nsTArray<nsCString> command;
  1414 +    nsTArray<nsCString> command;
  1769 +  }
  1418 +  }
  1770 +
  1419 +
  1771    nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
  1420    nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
  1772    if (!giovfs) {
  1421    if (!giovfs) {
  1773      return NS_ERROR_FAILURE;
  1422      return NS_ERROR_FAILURE;
  1774    }
       
  1775  
       
  1776    return giovfs->LaunchFile(mPath);
       
  1777  #elif defined(MOZ_WIDGET_ANDROID)
       
  1778    // Not supported on GeckoView