1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
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____
|