iOS web browser with a focus on security and privacy
1/*
2 * Endless
3 * Copyright (c) 2014-2015 joshua stein <jcs@jcs.org>
4 *
5 * See LICENSE file for redistribution terms.
6 */
7
8#import "HTTPSEverywhereRuleController.h"
9#import "HTTPSEverywhere.h"
10#import "HTTPSEverywhereRule.h"
11
12@implementation HTTPSEverywhereRuleController
13
14- (id)initWithStyle:(UITableViewStyle)style
15{
16 self = [super initWithStyle:style];
17
18 self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self.navigationController action:@selector(dismissModalViewControllerAnimated:)];
19
20 self.sortedRuleNames = [[NSMutableArray alloc] initWithCapacity:[[HTTPSEverywhere rules] count]];
21
22 if ([[self.appDelegate webViewController] curWebViewTab] != nil) {
23 self.inUseRuleNames = [[NSMutableArray alloc] initWithArray:[[[[[self.appDelegate webViewController] curWebViewTab] applicableHTTPSEverywhereRules] allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]];
24 }
25 else {
26 self.inUseRuleNames = [[NSMutableArray alloc] init];
27 }
28
29 for (NSString *k in [[HTTPSEverywhere rules] allKeys]) {
30 if (![self.inUseRuleNames containsObject:k])
31 [self.sortedRuleNames addObject:k];
32 }
33
34 self.sortedRuleNames = [NSMutableArray arrayWithArray:[self.sortedRuleNames sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]];
35 self.searchResult = [NSMutableArray arrayWithCapacity:[self.sortedRuleNames count]];
36
37 self.title = @"HTTPS Everywhere Rules";
38
39 return self;
40}
41
42- (NSString *)ruleDisabledReason:(NSString *)rule
43{
44 return [[HTTPSEverywhere disabledRules] objectForKey:rule];
45}
46
47- (void)disableRuleByName:(NSString *)rule withReason:(NSString *)reason
48{
49 [HTTPSEverywhere disableRuleByName:rule withReason:reason];
50}
51
52- (void)enableRuleByName:(NSString *)rule
53{
54 [HTTPSEverywhere enableRuleByName:rule];
55}
56
57@end