OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ios/web_view/shell/shell_view_controller.h" | 5 #import "ios/web_view/shell/shell_view_controller.h" |
6 | 6 |
7 #import "ios/web_view/public/criwv.h" | 7 #import "ios/web_view/public/cwv.h" |
8 #import "ios/web_view/public/cwv_web_view.h" | 8 #import "ios/web_view/public/cwv_web_view.h" |
9 #import "ios/web_view/shell/translate_controller.h" | 9 #import "ios/web_view/shell/translate_controller.h" |
10 | 10 |
11 #if !defined(__has_feature) || !__has_feature(objc_arc) | 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
12 #error "This file requires ARC support." | 12 #error "This file requires ARC support." |
13 #endif | 13 #endif |
14 | 14 |
15 @interface ShellViewController () | 15 @interface ShellViewController () |
16 // Container for |webView|. | 16 // Container for |webView|. |
17 @property(nonatomic, strong) UIView* containerView; | 17 @property(nonatomic, strong) UIView* containerView; |
18 // Text field used for navigating to URLs. | 18 // Text field used for navigating to URLs. |
19 @property(nonatomic, strong) UITextField* field; | 19 @property(nonatomic, strong) UITextField* field; |
20 // Toolbar containing navigation buttons and |field|. | 20 // Toolbar containing navigation buttons and |field|. |
21 @property(nonatomic, strong) UIToolbar* toolbar; | 21 @property(nonatomic, strong) UIToolbar* toolbar; |
22 // CRIWV view which renders the web page. | 22 // CWV view which renders the web page. |
23 @property(nonatomic, strong) CWVWebView* webView; | 23 @property(nonatomic, strong) CWVWebView* webView; |
24 // Handles the translation of the content displayed in |webView|. | 24 // Handles the translation of the content displayed in |webView|. |
25 @property(nonatomic, strong) TranslateController* translateController; | 25 @property(nonatomic, strong) TranslateController* translateController; |
26 | 26 |
27 - (void)back; | 27 - (void)back; |
28 - (void)forward; | 28 - (void)forward; |
29 - (void)stopLoading; | 29 - (void)stopLoading; |
30 @end | 30 @end |
31 | 31 |
32 @implementation ShellViewController | 32 @implementation ShellViewController |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 [stop setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin]; | 113 [stop setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin]; |
114 [stop addTarget:self | 114 [stop addTarget:self |
115 action:@selector(stopLoading) | 115 action:@selector(stopLoading) |
116 forControlEvents:UIControlEventTouchUpInside]; | 116 forControlEvents:UIControlEventTouchUpInside]; |
117 | 117 |
118 [_toolbar addSubview:back]; | 118 [_toolbar addSubview:back]; |
119 [_toolbar addSubview:forward]; | 119 [_toolbar addSubview:forward]; |
120 [_toolbar addSubview:stop]; | 120 [_toolbar addSubview:stop]; |
121 [_toolbar addSubview:_field]; | 121 [_toolbar addSubview:_field]; |
122 | 122 |
123 self.webView = [CRIWV webViewWithFrame:[_containerView bounds]]; | 123 self.webView = [CWV webViewWithFrame:[_containerView bounds]]; |
124 [_webView setDelegate:self]; | 124 [_webView setDelegate:self]; |
125 [_webView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | | 125 [_webView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | |
126 UIViewAutoresizingFlexibleHeight]; | 126 UIViewAutoresizingFlexibleHeight]; |
127 [_containerView addSubview:_webView]; | 127 [_containerView addSubview:_webView]; |
128 | 128 |
129 NSURLRequest* request = [NSURLRequest | 129 NSURLRequest* request = [NSURLRequest |
130 requestWithURL:[NSURL URLWithString:@"https://www.google.com/"]]; | 130 requestWithURL:[NSURL URLWithString:@"https://www.google.com/"]]; |
131 [_webView loadRequest:request]; | 131 [_webView loadRequest:request]; |
132 } | 132 } |
133 | 133 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 197 } |
198 } | 198 } |
199 | 199 |
200 - (id<CWVTranslateDelegate>)translateDelegate { | 200 - (id<CWVTranslateDelegate>)translateDelegate { |
201 if (!_translateController) | 201 if (!_translateController) |
202 self.translateController = [[TranslateController alloc] init]; | 202 self.translateController = [[TranslateController alloc] init]; |
203 return _translateController; | 203 return _translateController; |
204 } | 204 } |
205 | 205 |
206 @end | 206 @end |
OLD | NEW |