iOS web browser with a focus on security and privacy
at master 141 lines 3.6 kB view raw
1/* 2 * Endless 3 * Copyright (c) 2014-2018 joshua stein <jcs@jcs.org> 4 * 5 * See LICENSE file for redistribution terms. 6 */ 7 8#import <Foundation/Foundation.h> 9#import <UIKit/UIKit.h> 10 11#import "SSLCertificate.h" 12 13#define ZOOM_OUT_SCALE 0.8 14#define ZOOM_OUT_SCALE_ROTATED 0.7 15 16#define HISTORY_SIZE 40 17 18#define UNIVERSAL_LINKS_WORKAROUND_KEY @"yayprivacy" 19 20typedef NS_ENUM(NSInteger, WebViewTabSecureMode) { 21 WebViewTabSecureModeInsecure, 22 WebViewTabSecureModeMixed, 23 WebViewTabSecureModeSecure, 24 WebViewTabSecureModeSecureEV, 25}; 26 27static const struct keyboard_map_entry { 28 char *input; 29 int keycode; 30 int keypress_keycode; 31 int shift_keycode; 32 int shift_keypress_keycode; 33} keyboard_map[] = { 34 { "UIKeyInputEscape", 27, 0, 0 }, 35 36 { "`", 192, '`', '~' }, 37 { "1", '1', '1', '!' }, 38 { "2", '2', '2', '@' }, 39 { "3", '3', '3', '#' }, 40 { "4", '4', '4', '$' }, 41 { "5", '5', '5', '%' }, 42 { "6", '6', '6', '^' }, 43 { "7", '7', '7', '&' }, 44 { "8", '8', '8', '*' }, 45 { "9", '9', '9', '(' }, 46 { "0", '0', '0', ')' }, 47 { "-", 189, '-', '_' }, 48 { "=", 187, '=', '+' }, 49 { "\b", 8, 0, 0 }, 50 51 { "\t", 9, 0, 0 }, 52 { "q", 'Q', 'q', 'Q' }, 53 { "w", 'W', 'w', 'W' }, 54 { "e", 'E', 'e', 'E' }, 55 { "r", 'R', 'r', 'R' }, 56 { "t", 'T', 't', 'T' }, 57 { "y", 'Y', 'y', 'Y' }, 58 { "u", 'U', 'u', 'U' }, 59 { "i", 'I', 'i', 'I' }, 60 { "o", 'O', 'o', 'O' }, 61 { "p", 'P', 'p', 'P' }, 62 { "[", 219, '[', '{' }, 63 { "]", 221, ']', '}' }, 64 { "\\", 220, '\\', '|' }, 65 66 { "a", 'A', 'a', 'A' }, 67 { "s", 'S', 's', 'S' }, 68 { "d", 'D', 'd', 'D' }, 69 { "f", 'F', 'f', 'F' }, 70 { "g", 'G', 'g', 'G' }, 71 { "h", 'H', 'h', 'H' }, 72 { "j", 'J', 'j', 'J' }, 73 { "k", 'K', 'k', 'K' }, 74 { "l", 'L', 'l', 'L' }, 75 { ";", 186, ';', ':' }, 76 { "'", 222, '\'', '"' }, 77 { "\r", 13, 0, 0 }, 78 79 { "z", 'Z', 'z', 'Z' }, 80 { "x", 'X', 'x', 'X' }, 81 { "c", 'C', 'c', 'C' }, 82 { "v", 'V', 'v', 'V' }, 83 { "b", 'B', 'b', 'B' }, 84 { "n", 'N', 'n', 'N' }, 85 { "m", 'M', 'm', 'M' }, 86 { ",", 188, ',', '<' }, 87 { ".", 190, '.', '>' }, 88 { "/", 191, '/', '/' }, 89 90 { " ", ' ', ' ', ' ' }, 91 { "UIKeyInputLeftArrow", 37, 0, 0 }, 92 { "UIKeyInputUpArrow", 38, 0, 0 }, 93 { "UIKeyInputRightArrow", 39, 0, 0 }, 94 { "UIKeyInputDownArrow", 40, 0, 0 }, 95 96 { NULL } 97}; 98 99@interface WebViewTab : NSObject <UIWebViewDelegate, UIGestureRecognizerDelegate, UIActivityItemSource> 100 101@property (strong, atomic) UIView *viewHolder; 102@property (strong, atomic) UIWebView *webView; 103@property (strong, atomic) UIRefreshControl *refresher; 104@property (strong, atomic) NSURL *url; 105@property BOOL needsRefresh; 106@property (strong, atomic) NSNumber *tabIndex; 107@property (strong, atomic) UIView *titleHolder; 108@property (strong, atomic) UILabel *title; 109@property (strong, atomic) UILabel *closer; 110@property (strong, nonatomic) NSNumber *progress; 111@property BOOL forcingRefresh; 112 113@property WebViewTabSecureMode secureMode; 114@property (strong, nonatomic) SSLCertificate *SSLCertificate; 115@property NSMutableDictionary *applicableHTTPSEverywhereRules; 116@property NSMutableDictionary *applicableURLBlockerTargets; 117 118/* for javascript IPC */ 119@property (strong, atomic) NSString *randID; 120@property (strong, atomic) NSNumber *openedByTabHash; 121 122@property (strong, atomic) NSMutableArray *history; 123 124+ (WebViewTab *)openedWebViewTabByRandID:(NSString *)randID; 125 126- (id)initWithFrame:(CGRect)frame; 127- (id)initWithFrame:(CGRect)frame withRestorationIdentifier:(NSString *)rid; 128- (void)updateFrame:(CGRect)frame; 129- (void)loadURL:(NSURL *)u; 130- (void)searchFor:(NSString *)query; 131- (BOOL)canGoBack; 132- (BOOL)canGoForward; 133- (void)goBack; 134- (void)goForward; 135- (void)refresh; 136- (void)forceRefresh; 137- (void)zoomOut; 138- (void)zoomNormal; 139- (void)handleKeyCommand:(UIKeyCommand *)keyCommand; 140 141@end