iOS web browser with a focus on security and privacy
1/*
2 * Endless
3 * Copyright (c) 2014-2017 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:NSLocalizedString(@"Done", nil) style:UIBarButtonItemStyleDone target:self.navigationController action:@selector(dismissModalViewControllerAnimated:)];
19
20 self.sortedRuleRows = [[NSMutableArray alloc] initWithCapacity:[[HTTPSEverywhere rules] count]];
21 self.inUseRuleRows = [[NSMutableArray alloc] init];
22
23 NSDictionary *inUse = nil;
24 if ([[self.appDelegate webViewController] curWebViewTab] != nil)
25 inUse = [[[self.appDelegate webViewController] curWebViewTab] applicableHTTPSEverywhereRules];
26
27 for (NSString *k in [[[HTTPSEverywhere rules] allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]) {
28 RuleEditorRow *row = [[RuleEditorRow alloc] init];
29 row.key = k;
30 row.textLabel = k;
31
32 if (inUse && [inUse objectForKey:k])
33 [self.inUseRuleRows addObject:row];
34 else
35 [self.sortedRuleRows addObject:row];
36 }
37
38 self.inUseRuleRows = [NSMutableArray arrayWithArray:self.inUseRuleRows];
39 self.sortedRuleRows = [NSMutableArray arrayWithArray:self.sortedRuleRows];
40
41 self.title = NSLocalizedString(@"HTTPS Everywhere Rules", nil);
42
43 return self;
44}
45
46- (NSString *)ruleDisabledReason:(RuleEditorRow *)row
47{
48 return [[HTTPSEverywhere disabledRules] objectForKey:[row key]];
49}
50
51- (void)disableRuleForRow:(RuleEditorRow *)row withReason:(NSString *)reason
52{
53 [HTTPSEverywhere disableRuleByName:[row key] withReason:reason];
54}
55
56- (void)enableRuleForRow:(RuleEditorRow *)row
57{
58 [HTTPSEverywhere enableRuleByName:[row key]];
59}
60
61@end