summaryrefslogtreecommitdiffstats
path: root/firefox-4.0-moz-app-launcher.patch
diff options
context:
space:
mode:
Diffstat (limited to 'firefox-4.0-moz-app-launcher.patch')
-rw-r--r--firefox-4.0-moz-app-launcher.patch137
1 files changed, 137 insertions, 0 deletions
diff --git a/firefox-4.0-moz-app-launcher.patch b/firefox-4.0-moz-app-launcher.patch
new file mode 100644
index 0000000..d87b64a
--- /dev/null
+++ b/firefox-4.0-moz-app-launcher.patch
@@ -0,0 +1,137 @@
+From https://bugzilla.mozilla.org/show_bug.cgi?id=611953
+Patch 1 - Use MOZ_APP_LAUNCHER for default browser executable (v3, un-bitrotted)
+
+
+diff --git a/browser/components/shell/src/nsGNOMEShellService.cpp b/browser/components/shell/src/nsGNOMEShellService.cpp
+--- a/browser/components/shell/src/nsGNOMEShellService.cpp
++++ b/browser/components/shell/src/nsGNOMEShellService.cpp
+@@ -115,16 +115,19 @@ nsGNOMEShellService::Init()
+
+ if (!gconf)
+ return NS_ERROR_NOT_AVAILABLE;
+
+ // Check G_BROKEN_FILENAMES. If it's set, then filenames in glib use
+ // the locale encoding. If it's not set, they use UTF-8.
+ mUseLocaleFilenames = PR_GetEnv("G_BROKEN_FILENAMES") != nsnull;
+
++ if (GetAppPathFromLauncher())
++ return NS_OK;
++
+ nsCOMPtr<nsIProperties> dirSvc
+ (do_GetService("@mozilla.org/file/directory_service;1"));
+ NS_ENSURE_TRUE(dirSvc, NS_ERROR_NOT_AVAILABLE);
+
+ nsCOMPtr<nsILocalFile> appPath;
+ rv = dirSvc->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsILocalFile),
+ getter_AddRefs(appPath));
+ NS_ENSURE_SUCCESS(rv, rv);
+@@ -133,16 +136,44 @@ nsGNOMEShellService::Init()
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ return appPath->GetNativePath(mAppPath);
+ }
+
+ NS_IMPL_ISUPPORTS1(nsGNOMEShellService, nsIShellService)
+
+ PRBool
++nsGNOMEShellService::GetAppPathFromLauncher()
++{
++ gchar *tmp;
++
++ const char *launcher = PR_GetEnv("MOZ_APP_LAUNCHER");
++ if (!launcher)
++ return PR_FALSE;
++
++ if (g_path_is_absolute(launcher)) {
++ mAppPath = launcher;
++ tmp = g_path_get_basename(launcher);
++ gchar *fullpath = g_find_program_in_path(tmp);
++ if (fullpath && mAppPath.Equals(fullpath))
++ mAppIsInPath = PR_TRUE;
++ g_free(fullpath);
++ } else {
++ tmp = g_find_program_in_path(launcher);
++ if (!tmp)
++ return PR_FALSE;
++ mAppPath = tmp;
++ mAppIsInPath = PR_TRUE;
++ }
++
++ g_free(tmp);
++ return PR_TRUE;
++}
++
++PRBool
+ nsGNOMEShellService::KeyMatchesAppName(const char *aKeyValue) const
+ {
+
+ gchar *commandPath;
+ if (mUseLocaleFilenames) {
+ gchar *nativePath = g_filename_from_utf8(aKeyValue, -1, NULL, NULL, NULL);
+ if (!nativePath) {
+ NS_ERROR("Error converting path to filesystem encoding");
+@@ -210,18 +241,28 @@ nsGNOMEShellService::SetDefaultBrowser(P
+ {
+ #ifdef DEBUG
+ if (aForAllUsers)
+ NS_WARNING("Setting the default browser for all users is not yet supported");
+ #endif
+
+ nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
+ if (gconf) {
+- nsCAutoString appKeyValue(mAppPath);
+- appKeyValue.Append(" \"%s\"");
++ nsCAutoString appKeyValue;
++ if(mAppIsInPath) {
++ // mAppPath is in the users path, so use only the basename as the launcher
++ gchar *tmp = g_path_get_basename(mAppPath.get());
++ appKeyValue = tmp;
++ g_free(tmp);
++ } else {
++ appKeyValue = mAppPath;
++ }
++
++ appKeyValue.AppendLiteral(" %s");
++
+ for (unsigned int i = 0; i < NS_ARRAY_LENGTH(appProtocols); ++i) {
+ if (appProtocols[i].essential || aClaimAllTypes) {
+ gconf->SetAppForProtocol(nsDependentCString(appProtocols[i].name),
+ appKeyValue);
+ }
+ }
+ }
+
+diff --git a/browser/components/shell/src/nsGNOMEShellService.h b/browser/components/shell/src/nsGNOMEShellService.h
+--- a/browser/components/shell/src/nsGNOMEShellService.h
++++ b/browser/components/shell/src/nsGNOMEShellService.h
+@@ -38,26 +38,28 @@
+ #define nsgnomeshellservice_h____
+
+ #include "nsIShellService.h"
+ #include "nsStringAPI.h"
+
+ class nsGNOMEShellService : public nsIShellService
+ {
+ public:
+- nsGNOMEShellService() : mCheckedThisSession(PR_FALSE) { }
++ nsGNOMEShellService() : mCheckedThisSession(PR_FALSE), mAppIsInPath(PR_FALSE) { }
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSISHELLSERVICE
+
+ nsresult Init() NS_HIDDEN;
+
+ private:
+ ~nsGNOMEShellService() {}
+
+ NS_HIDDEN_(PRBool) KeyMatchesAppName(const char *aKeyValue) const;
+
++ NS_HIDDEN_(PRBool) GetAppPathFromLauncher();
+ PRPackedBool mCheckedThisSession;
+ PRPackedBool mUseLocaleFilenames;
+ nsCString mAppPath;
++ PRPackedBool mAppIsInPath;
+ };
+
+ #endif // nsgnomeshellservice_h____
+