Use upstream's version of our patch to set the default browser
When setting the default browser, we want to set it to 'firefox %s' instead of '/usr/lib{,64}/firefox-4/firefox %s' firefox-default.patch did the job for us for a bit, but upstream now has a patch to do this which we can now use. The patch will check to see if MOZ_APP_LAUNCHER is passed, and if so, it will use only the basename when setting the default browser. We already set MOZ_APP_LAUNCHER, so just need to switch to using the patch. From https://bugzilla.mozilla.org/show_bug.cgi?id=611953 Patch 1 - Use MOZ_APP_LAUNCHER for default browser executable (v3, un-bitrotted)
This commit is contained in:
parent
905589a4fd
commit
4acbcb3302
137
firefox-4.0-moz-app-launcher.patch
Normal file
137
firefox-4.0-moz-app-launcher.patch
Normal file
@ -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____
|
||||
|
@ -1,34 +0,0 @@
|
||||
diff -up mozilla-central/browser/components/shell/src/nsGNOMEShellService.cpp.default mozilla-central/browser/components/shell/src/nsGNOMEShellService.cpp
|
||||
--- mozilla-central/browser/components/shell/src/nsGNOMEShellService.cpp.default 2011-02-07 14:53:16.883934747 -0800
|
||||
+++ mozilla-central/browser/components/shell/src/nsGNOMEShellService.cpp 2011-02-07 17:11:55.209941360 -0800
|
||||
@@ -104,8 +104,6 @@ static const char kDesktopColorKey[] = D
|
||||
nsresult
|
||||
nsGNOMEShellService::Init()
|
||||
{
|
||||
- nsresult rv;
|
||||
-
|
||||
// GConf _must_ be available, or we do not allow
|
||||
// CreateInstance to succeed.
|
||||
|
||||
@@ -120,19 +118,9 @@ nsGNOMEShellService::Init()
|
||||
// the locale encoding. If it's not set, they use UTF-8.
|
||||
mUseLocaleFilenames = PR_GetEnv("G_BROKEN_FILENAMES") != nsnull;
|
||||
|
||||
- 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);
|
||||
+ mAppPath.Assign(NS_LITERAL_CSTRING(MOZ_APP_NAME));
|
||||
|
||||
- rv = appPath->AppendNative(NS_LITERAL_CSTRING(MOZ_APP_NAME));
|
||||
- NS_ENSURE_SUCCESS(rv, rv);
|
||||
-
|
||||
- return appPath->GetNativePath(mAppPath);
|
||||
+ return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsGNOMEShellService, nsIShellService)
|
@ -65,9 +65,9 @@ Source23: firefox.1
|
||||
Patch0: firefox-version.patch
|
||||
|
||||
# Fedora patches
|
||||
Patch11: firefox-default.patch
|
||||
|
||||
# Upstream patches
|
||||
Patch30: firefox-4.0-moz-app-launcher.patch
|
||||
|
||||
%if %{official_branding}
|
||||
# Required by Mozilla Corporation
|
||||
@ -111,7 +111,9 @@ sed -e 's/__RPM_VERSION_INTERNAL__/%{firefox_dir_ver}/' %{P:%%PATCH0} \
|
||||
# For branding specific patches.
|
||||
|
||||
# Fedora patches
|
||||
%patch11 -p1 -b .default
|
||||
|
||||
# Upstream patches
|
||||
%patch30 -p1 -b .moz-app-launcher
|
||||
|
||||
%if %{official_branding}
|
||||
# Required by Mozilla Corporation
|
||||
|
Loading…
Reference in New Issue
Block a user