add adblocking with userContent.css to pref panel.
This commit is contained in:
Родитель
19a65df600
Коммит
7374d205ed
|
@ -1742,6 +1742,7 @@
|
|||
3F22CC1303DF42A200026DCE,
|
||||
F56610A1039474CB01A9666E,
|
||||
3003B8AB044514E300B85BF3,
|
||||
3FFE23520847CB0D00D6CAFC,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = Resources;
|
||||
|
@ -3095,6 +3096,7 @@
|
|||
0FFE0A83079B147F00966027,
|
||||
3FFFEBDA081C2CC500843C07,
|
||||
3FBDC8E00827C44B00D7F8E0,
|
||||
3FFE23530847CB0D00D6CAFC,
|
||||
);
|
||||
isa = PBXResourcesBuildPhase;
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -6959,6 +6961,7 @@
|
|||
3FBDC86108253C8C00D7F8E0,
|
||||
3FBDC86208253C8C00D7F8E0,
|
||||
3FBDC8E10827C44B00D7F8E0,
|
||||
3FFE23540847CB0D00D6CAFC,
|
||||
);
|
||||
isa = PBXResourcesBuildPhase;
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -10828,6 +10831,27 @@
|
|||
settings = {
|
||||
};
|
||||
};
|
||||
3FFE23520847CB0D00D6CAFC = {
|
||||
fileEncoding = 30;
|
||||
isa = PBXFileReference;
|
||||
lastKnownFileType = text;
|
||||
name = ad_blocking.css;
|
||||
path = resources/application/ad_blocking.css;
|
||||
refType = 2;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
3FFE23530847CB0D00D6CAFC = {
|
||||
fileRef = 3FFE23520847CB0D00D6CAFC;
|
||||
isa = PBXBuildFile;
|
||||
settings = {
|
||||
};
|
||||
};
|
||||
3FFE23540847CB0D00D6CAFC = {
|
||||
fileRef = 3FFE23520847CB0D00D6CAFC;
|
||||
isa = PBXBuildFile;
|
||||
settings = {
|
||||
};
|
||||
};
|
||||
3FFFEBD9081C2CC500843C07 = {
|
||||
isa = PBXFileReference;
|
||||
lastKnownFileType = image.tiff;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
{
|
||||
ACTIONS = {
|
||||
addWhitelistSite = id;
|
||||
clickEnableAdBlocking = id;
|
||||
clickEnableAnnoyanceBlocker = id;
|
||||
clickEnableImageResizing = id;
|
||||
clickEnableJS = id;
|
||||
|
@ -31,6 +32,7 @@
|
|||
mAddButton = NSButton;
|
||||
mAddField = NSTextField;
|
||||
mEditWhitelist = NSButton;
|
||||
mEnableAdBlocking = NSButton;
|
||||
mEnableAnnoyanceBlocker = NSButton;
|
||||
mEnableJS = NSButton;
|
||||
mEnableJava = NSButton;
|
||||
|
|
|
@ -3,12 +3,16 @@
|
|||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IBDocumentLocation</key>
|
||||
<string>67 152 356 240 0 0 1600 1002 </string>
|
||||
<string>50 118 356 240 0 0 1280 832 </string>
|
||||
<key>IBFramework Version</key>
|
||||
<string>364.0</string>
|
||||
<string>437.0</string>
|
||||
<key>IBOldestOS</key>
|
||||
<integer>2</integer>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>5</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>7S215</string>
|
||||
<string>8A428</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
Двоичные данные
camino/PreferencePanes/WebFeatures/English.lproj/WebFeatures.nib/keyedobjects.nib
сгенерированный
Двоичные данные
camino/PreferencePanes/WebFeatures/English.lproj/WebFeatures.nib/keyedobjects.nib
сгенерированный
Двоичный файл не отображается.
|
@ -53,6 +53,7 @@ class nsISupportsArray;
|
|||
IBOutlet NSButton* mEnableJava;
|
||||
|
||||
IBOutlet NSButton *mEnablePopupBlocking;
|
||||
IBOutlet NSButton *mEnableAdBlocking;
|
||||
IBOutlet NSButton *mImageResize;
|
||||
IBOutlet NSButton *mEditWhitelist;
|
||||
|
||||
|
@ -71,6 +72,7 @@ class nsISupportsArray;
|
|||
-(IBAction) clickEnableJava:(id)sender;
|
||||
|
||||
-(IBAction) clickEnablePopupBlocking:(id)sender;
|
||||
-(IBAction) clickEnableAdBlocking:(id)sender;
|
||||
-(IBAction) clickEnableImageResizing:(id)sender;
|
||||
-(IBAction) editWhitelist:(id)sender;
|
||||
|
||||
|
|
|
@ -48,12 +48,18 @@
|
|||
#include "nsISupportsArray.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
// we should really get this from "CHBrowserService.h",
|
||||
// but that requires linkage and extra search paths.
|
||||
static NSString* XPCOMShutDownNotificationName = @"XPCOMShutDown";
|
||||
|
||||
@interface OrgMozillaChimeraPreferenceWebFeatures(PRIVATE)
|
||||
-(NSString*)profilePath;
|
||||
@end
|
||||
|
||||
@implementation OrgMozillaChimeraPreferenceWebFeatures
|
||||
|
||||
- (void) dealloc
|
||||
|
@ -106,7 +112,14 @@ static NSString* XPCOMShutDownNotificationName = @"XPCOMShutDown";
|
|||
// set initial value on image-resizing
|
||||
BOOL enableImageResize = [self getBooleanPref:"browser.enable_automatic_image_resizing" withSuccess:&gotPref];
|
||||
[mImageResize setState:enableImageResize];
|
||||
|
||||
|
||||
// check if userContent.css is in the profile. Yes, this will give false positives if the
|
||||
// user has made their own, but that's their problem.
|
||||
NSString* adBlockFile = [[[self profilePath] stringByAppendingPathComponent:@"chrome"]
|
||||
stringByAppendingPathComponent:@"userContent.css"];
|
||||
BOOL enableAdBlock = [[NSFileManager defaultManager] fileExistsAtPath:adBlockFile];
|
||||
[mEnableAdBlocking setState:enableAdBlock];
|
||||
|
||||
// store permission manager service and cache the enumerator.
|
||||
nsCOMPtr<nsIPermissionManager> pm ( do_GetService(NS_PERMISSIONMANAGER_CONTRACTID) );
|
||||
mManager = pm.get();
|
||||
|
@ -134,6 +147,26 @@ static NSString* XPCOMShutDownNotificationName = @"XPCOMShutDown";
|
|||
[self setPref:"security.enable_java" toBoolean:[sender state] == NSOnState];
|
||||
}
|
||||
|
||||
//
|
||||
// -clickEnableAdBlocking:
|
||||
//
|
||||
// Enable and disable ad blocking via a userContent.css file that we provide in our
|
||||
// package, copied into the user's profile.
|
||||
//
|
||||
- (IBAction)clickEnableAdBlocking:(id)sender
|
||||
{
|
||||
NSString* adBlockFileInProfile = [[[self profilePath] stringByAppendingPathComponent:@"chrome"]
|
||||
stringByAppendingPathComponent:@"userContent.css"];
|
||||
if ([sender state]) {
|
||||
NSString* sourcePath = [[NSBundle mainBundle] pathForResource:@"ad_blocking" ofType:@"css"];
|
||||
[[NSFileManager defaultManager] removeFileAtPath:adBlockFileInProfile handler:nil];
|
||||
[[NSFileManager defaultManager] copyPath:sourcePath toPath:adBlockFileInProfile handler:nil];
|
||||
}
|
||||
else {
|
||||
[[NSFileManager defaultManager] removeFileAtPath:adBlockFileInProfile handler:nil];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// clickEnablePopupBlocking
|
||||
//
|
||||
|
@ -346,4 +379,25 @@ static NSString* XPCOMShutDownNotificationName = @"XPCOMShutDown";
|
|||
[self setPref:"dom.disable_window_status_change" toBoolean:inValue];
|
||||
[self setPref:"dom.disable_window_flip" toBoolean:inValue];
|
||||
}
|
||||
|
||||
//
|
||||
// -profilePath
|
||||
//
|
||||
// Returns the path for our post 0.8 profiles stored in Application Support/Camino.
|
||||
// Copied from the pref manager which we can't use w/out compiling it into our bundle.
|
||||
//
|
||||
- (NSString*) profilePath
|
||||
{
|
||||
nsCOMPtr<nsIFile> appSupportDir;
|
||||
nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILES_ROOT_DIR,
|
||||
getter_AddRefs(appSupportDir));
|
||||
if (NS_FAILED(rv))
|
||||
return nil;
|
||||
nsCAutoString nativePath;
|
||||
rv = appSupportDir->GetNativePath(nativePath);
|
||||
if (NS_FAILED(rv))
|
||||
return nil;
|
||||
return [NSString stringWithUTF8String:nativePath.get()];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
Загрузка…
Ссылка в новой задаче