Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Side by Side Diff: ios/web_view/shell/shell_view_controller.m

Issue 2675633002: Let CRIWVWebView inherit UIView instead of NSObject. (Closed)
Patch Set: Fix format. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/web_view/public/criwv_web_view_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/criwv_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) id<CRIWVWebView> webView; 23 @property(nonatomic, strong) CRIWVWebView* 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 webView]; 123 self.webView = [CRIWV webViewWithFrame:[_containerView bounds]];
124 [_webView setDelegate:self]; 124 [_webView setDelegate:self];
125 UIView* view = [_webView view]; 125 [_webView setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
126 [_containerView addSubview:view]; 126 UIViewAutoresizingFlexibleHeight];
127 [view setFrame:[_containerView bounds]]; 127 [_containerView addSubview:_webView];
128 [view setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
129 UIViewAutoresizingFlexibleHeight];
130 128
131 [_webView loadURL:[NSURL URLWithString:@"https://www.google.com/"]]; 129 [_webView loadURL:[NSURL URLWithString:@"https://www.google.com/"]];
132 } 130 }
133 131
134 - (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar { 132 - (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar {
135 if (bar == _toolbar) { 133 if (bar == _toolbar) {
136 return UIBarPositionTopAttached; 134 return UIBarPositionTopAttached;
137 } 135 }
138 return UIBarPositionAny; 136 return UIBarPositionAny;
139 } 137 }
(...skipping 25 matching lines...) Expand all
165 // Do not update the URL if the text field is currently being edited. 163 // Do not update the URL if the text field is currently being edited.
166 if ([_field isFirstResponder]) { 164 if ([_field isFirstResponder]) {
167 return; 165 return;
168 } 166 }
169 167
170 [_field setText:[[_webView visibleURL] absoluteString]]; 168 [_field setText:[[_webView visibleURL] absoluteString]];
171 } 169 }
172 170
173 #pragma mark CRIWVWebViewDelegate methods 171 #pragma mark CRIWVWebViewDelegate methods
174 172
175 - (void)webView:(id<CRIWVWebView>)webView 173 - (void)webView:(CRIWVWebView*)webView
176 didFinishLoadingWithURL:(NSURL*)url 174 didFinishLoadingWithURL:(NSURL*)url
177 loadSuccess:(BOOL)loadSuccess { 175 loadSuccess:(BOOL)loadSuccess {
178 // TODO(crbug.com/679895): Add some visual indication that the page load has 176 // TODO(crbug.com/679895): Add some visual indication that the page load has
179 // finished. 177 // finished.
180 [self updateToolbar]; 178 [self updateToolbar];
181 } 179 }
182 180
183 - (void)webView:(id<CRIWVWebView>)webView 181 - (void)webView:(CRIWVWebView*)webView
184 didUpdateWithChanges:(CRIWVWebViewUpdateType)changes { 182 didUpdateWithChanges:(CRIWVWebViewUpdateType)changes {
185 if (changes & CRIWVWebViewUpdateTypeProgress) { 183 if (changes & CRIWVWebViewUpdateTypeProgress) {
186 // TODO(crbug.com/679895): Add a progress indicator. 184 // TODO(crbug.com/679895): Add a progress indicator.
187 } 185 }
188 186
189 if (changes & CRIWVWebViewUpdateTypeTitle) { 187 if (changes & CRIWVWebViewUpdateTypeTitle) {
190 // TODO(crbug.com/679895): Add a title display. 188 // TODO(crbug.com/679895): Add a title display.
191 } 189 }
192 190
193 if (changes & CRIWVWebViewUpdateTypeURL) { 191 if (changes & CRIWVWebViewUpdateTypeURL) {
194 [self updateToolbar]; 192 [self updateToolbar];
195 } 193 }
196 } 194 }
197 195
198 - (id<CRIWVTranslateDelegate>)translateDelegate { 196 - (id<CRIWVTranslateDelegate>)translateDelegate {
199 if (!_translateController) 197 if (!_translateController)
200 self.translateController = [[TranslateController alloc] init]; 198 self.translateController = [[TranslateController alloc] init];
201 return _translateController; 199 return _translateController;
202 } 200 }
203 201
204 @end 202 @end
OLDNEW
« no previous file with comments | « ios/web_view/public/criwv_web_view_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698