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/criwv.h" |
8 #import "ios/web_view/public/criwv_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 // CRIWV view which renders the web page. |
23 @property(nonatomic, strong) CRIWVWebView* 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 |
33 | 33 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // Do not update the URL if the text field is currently being edited. | 167 // Do not update the URL if the text field is currently being edited. |
168 if ([_field isFirstResponder]) { | 168 if ([_field isFirstResponder]) { |
169 return; | 169 return; |
170 } | 170 } |
171 | 171 |
172 [_field setText:[[_webView visibleURL] absoluteString]]; | 172 [_field setText:[[_webView visibleURL] absoluteString]]; |
173 } | 173 } |
174 | 174 |
175 #pragma mark CRIWVWebViewDelegate methods | 175 #pragma mark CRIWVWebViewDelegate methods |
176 | 176 |
177 - (void)webView:(CRIWVWebView*)webView | 177 - (void)webView:(CWVWebView*)webView |
178 didFinishLoadingWithURL:(NSURL*)url | 178 didFinishLoadingWithURL:(NSURL*)url |
179 loadSuccess:(BOOL)loadSuccess { | 179 loadSuccess:(BOOL)loadSuccess { |
180 // TODO(crbug.com/679895): Add some visual indication that the page load has | 180 // TODO(crbug.com/679895): Add some visual indication that the page load has |
181 // finished. | 181 // finished. |
182 [self updateToolbar]; | 182 [self updateToolbar]; |
183 } | 183 } |
184 | 184 |
185 - (void)webView:(CRIWVWebView*)webView | 185 - (void)webView:(CWVWebView*)webView |
186 didUpdateWithChanges:(CRIWVWebViewUpdateType)changes { | 186 didUpdateWithChanges:(CRIWVWebViewUpdateType)changes { |
187 if (changes & CRIWVWebViewUpdateTypeProgress) { | 187 if (changes & CRIWVWebViewUpdateTypeProgress) { |
188 // TODO(crbug.com/679895): Add a progress indicator. | 188 // TODO(crbug.com/679895): Add a progress indicator. |
189 } | 189 } |
190 | 190 |
191 if (changes & CRIWVWebViewUpdateTypeTitle) { | 191 if (changes & CRIWVWebViewUpdateTypeTitle) { |
192 // TODO(crbug.com/679895): Add a title display. | 192 // TODO(crbug.com/679895): Add a title display. |
193 } | 193 } |
194 | 194 |
195 if (changes & CRIWVWebViewUpdateTypeURL) { | 195 if (changes & CRIWVWebViewUpdateTypeURL) { |
196 [self updateToolbar]; | 196 [self updateToolbar]; |
197 } | 197 } |
198 } | 198 } |
199 | 199 |
200 - (id<CRIWVTranslateDelegate>)translateDelegate { | 200 - (id<CRIWVTranslateDelegate>)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 |