File gecko-lockdown.patch of Package MozillaFirefox (Revision 7c458b0c944a0d81b4eb8bad6bbf0c7d)
Currently displaying revision 7c458b0c944a0d81b4eb8bad6bbf0c7d, show latest
x
1
Index: extensions/cookie/nsCookiePermission.cpp
2
================================================================================
3
--- extensions/cookie/nsCookiePermission.cpp
4
+++ extensions/cookie/nsCookiePermission.cpp
5
6
// obsolete pref names for migration
7
static const char kCookiesLifetimeEnabled[] = "network.cookie.lifetime.enabled";
8
static const char kCookiesLifetimeBehavior[] = "network.cookie.lifetime.behavior";
9
+static const char kCookiesHonorExceptions[] = "network.cookie.honorExceptions";
10
static const char kCookiesAskPermission[] = "network.cookie.warnAboutCookies";
11
12
static const char kPermissionType[] = "cookie";
13
14
prefBranch->AddObserver(kCookiesLifetimePolicy, this, PR_FALSE);
15
prefBranch->AddObserver(kCookiesLifetimeDays, this, PR_FALSE);
16
prefBranch->AddObserver(kCookiesAlwaysAcceptSession, this, PR_FALSE);
17
+ prefBranch->AddObserver(kCookiesHonorExceptions, this, PR_FALSE);
18
#ifdef MOZ_MAIL_NEWS
19
prefBranch->AddObserver(kCookiesDisabledForMailNews, this, PR_FALSE);
20
#endif
21
22
if (PREF_CHANGED(kCookiesAlwaysAcceptSession) &&
23
NS_SUCCEEDED(aPrefBranch->GetBoolPref(kCookiesAlwaysAcceptSession, &val)))
24
mCookiesAlwaysAcceptSession = val;
25
+
26
+ if (PREF_CHANGED(kCookiesHonorExceptions) &&
27
+ NS_SUCCEEDED(aPrefBranch->GetBoolPref(kCookiesHonorExceptions, &val)))
28
+ mCookiesHonorExceptions = val;
29
30
#ifdef MOZ_MAIL_NEWS
31
if (PREF_CHANGED(kCookiesDisabledForMailNews) &&
32
33
#endif // MOZ_MAIL_NEWS
34
35
// finally, check with permission manager...
36
+ if (!mCookiesHonorExceptions) {
37
+ *aResult = ACCESS_DEFAULT;
38
+ return NS_OK;
39
+ }
40
+
41
nsresult rv = mPermMgr->TestPermission(aURI, kPermissionType, (PRUint32 *) aResult);
42
if (NS_SUCCEEDED(rv)) {
43
switch (*aResult) {
44
--- extensions/cookie/nsCookiePermission.h
45
+++ extensions/cookie/nsCookiePermission.h
46
47
nsCookiePermission()
48
: mCookiesLifetimeSec(LL_MAXINT)
49
, mCookiesLifetimePolicy(0) // ACCEPT_NORMALLY
50
- , mCookiesAlwaysAcceptSession(PR_FALSE)
51
+ , mCookiesAlwaysAcceptSession(PR_FALSE),
52
#ifdef MOZ_MAIL_NEWS
53
- , mCookiesDisabledForMailNews(PR_TRUE)
54
+ , mCookiesDisabledForMailNews(PR_TRUE),
55
#endif
56
+ mCookiesHonorExceptions(PR_TRUE)
57
{}
58
virtual ~nsCookiePermission() {}
59
60
61
#ifdef MOZ_MAIL_NEWS
62
PRPackedBool mCookiesDisabledForMailNews;
63
#endif
64
-
65
+ PRPackedBool mCookiesHonorExceptions;
66
};
67
68
// {CE002B28-92B7-4701-8621-CC925866FB87}
69
--- extensions/permissions/nsContentBlocker.cpp
70
+++ extensions/permissions/nsContentBlocker.cpp
71
72
nsContentBlocker::nsContentBlocker()
73
{
74
memset(mBehaviorPref, BEHAVIOR_ACCEPT, NUMBER_OF_TYPES);
75
+ memset(mHonorExceptions, PR_TRUE, NUMBER_OF_TYPES);
76
}
77
78
nsresult
79
80
rv = prefService->GetBranch("permissions.default.", getter_AddRefs(prefBranch));
81
NS_ENSURE_SUCCESS(rv, rv);
82
83
+ nsCOMPtr<nsIPrefBranch> honorExceptionsPrefBranch;
84
+ rv = prefService->GetBranch("permissions.honorExceptions.",
85
+ getter_AddRefs(honorExceptionsPrefBranch));
86
+ NS_ENSURE_SUCCESS(rv, rv);
87
+
88
// Migrate old image blocker pref
89
nsCOMPtr<nsIPrefBranch> oldPrefBranch;
90
oldPrefBranch = do_QueryInterface(prefService);
91
92
mPrefBranchInternal = do_QueryInterface(prefBranch, &rv);
93
NS_ENSURE_SUCCESS(rv, rv);
94
95
+ mHonorExceptionsPrefBranchInternal =
96
+ do_QueryInterface(honorExceptionsPrefBranch, &rv);
97
+ NS_ENSURE_SUCCESS(rv, rv);
98
+
99
rv = mPrefBranchInternal->AddObserver("", this, PR_TRUE);
100
- PrefChanged(prefBranch, nsnull);
101
+ NS_ENSURE_SUCCESS(rv, rv);
102
+
103
+ rv = mHonorExceptionsPrefBranchInternal->AddObserver("", this, PR_TRUE);
104
+ PrefChanged(nsnull);
105
106
return rv;
107
}
108
109
#define LIMIT(x, low, high, default) ((x) >= (low) && (x) <= (high) ? (x) : (default))
110
111
void
112
-nsContentBlocker::PrefChanged(nsIPrefBranch *aPrefBranch,
113
- const char *aPref)
114
+nsContentBlocker::PrefChanged(const char *aPref)
115
{
116
- PRInt32 val;
117
-
118
-#define PREF_CHANGED(_P) (!aPref || !strcmp(aPref, _P))
119
-
120
- for(PRUint32 i = 0; i < NUMBER_OF_TYPES; ++i) {
121
- if (PREF_CHANGED(kTypeString[i]) &&
122
- NS_SUCCEEDED(aPrefBranch->GetIntPref(kTypeString[i], &val)))
123
- mBehaviorPref[i] = LIMIT(val, 1, 3, 1);
124
+ for (PRUint32 i = 0; i < NUMBER_OF_TYPES; ++i) {
125
+ if (!aPref || !strcmp(kTypeString[i], aPref)) {
126
+ PRInt32 val;
127
+ PRBool b;
128
+ if (mPrefBranchInternal &&
129
+ NS_SUCCEEDED(mPrefBranchInternal->GetIntPref(kTypeString[i], &val))) {
130
+ mBehaviorPref[i] = LIMIT(val, 1, 3, 1);
131
+ }
132
+ if (mHonorExceptionsPrefBranchInternal &&
133
+ NS_SUCCEEDED(mHonorExceptionsPrefBranchInternal->GetBoolPref(kTypeString[i], &b))) {
134
+ mHonorExceptions[i] = b;
135
+ }
136
+ }
137
}
138
-
139
}
140
141
// nsIContentPolicy Implementation
142
143
// default prefs.
144
// Don't forget the aContentType ranges from 1..8, while the
145
// array is indexed 0..7
146
- PRUint32 permission;
147
- nsresult rv = mPermissionManager->TestPermission(aCurrentURI,
148
- kTypeString[aContentType - 1],
149
- &permission);
150
- NS_ENSURE_SUCCESS(rv, rv);
151
+ PRUint32 permission = 0;
152
+ if (mHonorExceptions[aContentType - 1]) {
153
+ nsresult rv = mPermissionManager->TestPermission(aCurrentURI,
154
+ kTypeString[aContentType - 1],
155
+ &permission);
156
+ NS_ENSURE_SUCCESS(rv, rv);
157
+ }
158
159
// If there is nothing on the list, use the default.
160
if (!permission) {
161
162
return NS_OK;
163
164
PRBool trustedSource = PR_FALSE;
165
- rv = aFirstURI->SchemeIs("chrome", &trustedSource);
166
+ nsresult rv = aFirstURI->SchemeIs("chrome", &trustedSource);
167
NS_ENSURE_SUCCESS(rv,rv);
168
if (!trustedSource) {
169
rv = aFirstURI->SchemeIs("resource", &trustedSource);
170
171
{
172
NS_ASSERTION(!strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic),
173
"unexpected topic - we only deal with pref changes!");
174
-
175
- if (mPrefBranchInternal)
176
- PrefChanged(mPrefBranchInternal, NS_LossyConvertUTF16toASCII(aData).get());
177
+ PrefChanged(NS_LossyConvertUTF16toASCII(aData).get());
178
return NS_OK;
179
}
180
--- extensions/permissions/nsContentBlocker.h
181
+++ extensions/permissions/nsContentBlocker.h
182
183
private:
184
~nsContentBlocker() {}
185
186
- void PrefChanged(nsIPrefBranch *, const char *);
187
+ void PrefChanged(const char *);
188
nsresult TestPermission(nsIURI *aCurrentURI,
189
nsIURI *aFirstURI,
190
PRInt32 aContentType,
191
192
193
nsCOMPtr<nsIPermissionManager> mPermissionManager;
194
nsCOMPtr<nsIPrefBranch2> mPrefBranchInternal;
195
+ nsCOMPtr<nsIPrefBranch2> mHonorExceptionsPrefBranchInternal;
196
PRUint8 mBehaviorPref[NUMBER_OF_TYPES];
197
+ PRPackedBool mHonorExceptions[NUMBER_OF_TYPES];
198
};
199
200
#define NS_CONTENTBLOCKER_CID \
201
--- modules/libpref/src/init/all.js
202
+++ modules/libpref/src/init/all.js
203
204
pref("network.hosts.nntp_server", "news.mozilla.org");
205
206
pref("permissions.default.image", 1); // 1-Accept, 2-Deny, 3-dontAcceptForeign
207
+pref("permissions.honorExceptions.image", true);
208
pref("network.image.warnAboutImages", false);
209
pref("network.proxy.type", 0);
210
pref("network.proxy.ftp", "");
211
212
pref("network.proxy.failover_timeout", 1800); // 30 minutes
213
pref("network.online", true); //online/offline
214
pref("network.cookie.cookieBehavior", 0); // 0-Accept, 1-dontAcceptForeign, 2-dontUse, 3-p3p
215
+pref("network.cookie.honorExceptions", true);
216
pref("network.cookie.disableCookieForMailNews", true); // disable all cookies for mail
217
pref("network.cookie.lifetimePolicy", 0); // accept normally, 1-askBeforeAccepting, 2-acceptForSession,3-acceptForNDays
218
pref("network.cookie.alwaysAcceptSessionCookies", false);
219
--- netwerk/base/src/nsIOService.cpp
220
+++ netwerk/base/src/nsIOService.cpp
221
222
nsCOMPtr<nsIPrefBranch2> prefBranch;
223
GetPrefBranch(getter_AddRefs(prefBranch));
224
if (prefBranch) {
225
+ nsCAutoString protocolBlockedPref("network.protocol-handler.blocked.");
226
+ protocolBlockedPref += scheme;
227
+ PRBool blockedProtocol = PR_FALSE;
228
+ rv = prefBranch->GetBoolPref(protocolBlockedPref.get(), &blockedProtocol);
229
+ if (NS_FAILED(rv)) {
230
+ rv = prefBranch->GetBoolPref("network.protocol-handler.blocked-default", &blockedProtocol);
231
+ }
232
+ if (NS_SUCCEEDED(rv) && blockedProtocol)
233
+ return NS_ERROR_UNKNOWN_PROTOCOL;
234
+
235
nsCAutoString externalProtocolPref("network.protocol-handler.external.");
236
externalProtocolPref += scheme;
237
rv = prefBranch->GetBoolPref(externalProtocolPref.get(), &externalProtocol);
238
--- widget/src/gtk2/nsWindow.cpp
239
+++ widget/src/gtk2/nsWindow.cpp
240
241
#include "nsIPrefBranch.h"
242
#include "nsIServiceManager.h"
243
#include "nsGfxCIID.h"
244
+#include "nsIPrefService.h"
245
246
#ifdef ACCESSIBILITY
247
#include "nsPIAccessNode.h"
248
249
#include "stdlib.h"
250
static PRBool sAccessibilityChecked = PR_FALSE;
251
static PRBool sAccessibilityEnabled = PR_FALSE;
252
-static const char sSysPrefService [] = "@mozilla.org/system-preference-service;1";
253
static const char sAccEnv [] = "GNOME_ACCESSIBILITY";
254
static const char sAccessibilityKey [] = "config.use_system_prefs.accessibility";
255
#endif
256
257
sAccessibilityEnabled = atoi(envValue);
258
LOG(("Accessibility Env %s=%s\n", sAccEnv, envValue));
259
}
260
- //check gconf-2 setting
261
+ //check preference setting
262
else {
263
- nsCOMPtr<nsIPrefBranch> sysPrefService =
264
- do_GetService(sSysPrefService, &rv);
265
- if (NS_SUCCEEDED(rv) && sysPrefService) {
266
-
267
- // do the work to get gconf setting.
268
- // will be done soon later.
269
- sysPrefService->GetBoolPref(sAccessibilityKey,
270
+ nsCOMPtr<nsIPrefService> prefService =
271
+ do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
272
+ if (NS_SUCCEEDED(rv) && prefService) {
273
+ nsCOMPtr<nsIPrefBranch> prefBranch;
274
+ rv = prefService->GetBranch(nsnull, getter_AddRefs(prefBranch));
275
+ if (NS_SUCCEEDED(rv) && prefBranch) {
276
+ prefBranch->GetBoolPref(sAccessibilityKey,
277
&sAccessibilityEnabled);
278
+ }
279
}
280
-
281
}
282
}
283
if (sAccessibilityEnabled) {
284
--- xpinstall/src/nsXPInstallManager.cpp
285
+++ xpinstall/src/nsXPInstallManager.cpp
286
287
//-----------------------------------------------------
288
// Get permission to install
289
//-----------------------------------------------------
290
+ nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID));
291
292
#ifdef ENABLE_SKIN_SIMPLE_INSTALLATION_UI
293
if ( mChromeType == CHROME_SKIN )
294
295
296
// skins get a simpler/friendlier dialog
297
// XXX currently not embeddable
298
- OKtoInstall = ConfirmChromeInstall( mParentWindow, packageList );
299
+ PRBool themesDisabled = PR_FALSE;
300
+ if (pref)
301
+ pref->GetBoolPref("config.lockdown.disable_themes", &themesDisabled);
302
+ OKtoInstall = !themesDisabled &&
303
+ ConfirmChromeInstall( mParentWindow, packageList );
304
}
305
else
306
{
307
308
else
309
{
310
#endif
311
- rv = dlgSvc->ConfirmInstall( mParentWindow,
312
- packageList,
313
- numStrings,
314
- &OKtoInstall );
315
- if (NS_FAILED(rv))
316
- OKtoInstall = PR_FALSE;
317
+ PRBool extensionsDisabled = PR_FALSE;
318
+ if (pref)
319
+ pref->GetBoolPref("config.lockdown.disable_extensions", &extensionsDisabled);
320
+ if (!extensionsDisabled) {
321
+ rv = dlgSvc->ConfirmInstall( mParentWindow,
322
+ packageList,
323
+ numStrings,
324
+ &OKtoInstall );
325
+ if (NS_FAILED(rv))
326
+ OKtoInstall = PR_FALSE;
327
+ }
328
#ifdef ENABLE_SKIN_SIMPLE_INSTALLATION_UI
329
}
330
#endif
331