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

Side by Side Diff: ios/web/shell/view_controller.mm

Issue 1838323003: [ios] Added NavigationManager::LoadURLWithParams public API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/public/navigation_manager.h ('k') | ios/web/web_state/web_state_impl.h » ('j') | 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/shell/view_controller.h" 5 #import "ios/web/shell/view_controller.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 26 matching lines...) Expand all
37 @interface ViewController ()<CRWWebStateObserver> { 37 @interface ViewController ()<CRWWebStateObserver> {
38 web::BrowserState* _browserState; 38 web::BrowserState* _browserState;
39 base::scoped_nsobject<CRWWebController> _webController; 39 base::scoped_nsobject<CRWWebController> _webController;
40 scoped_ptr<web::RequestTrackerFactoryImpl> _requestTrackerFactory; 40 scoped_ptr<web::RequestTrackerFactoryImpl> _requestTrackerFactory;
41 scoped_ptr<web::WebHTTPProtocolHandlerDelegate> _httpProtocolDelegate; 41 scoped_ptr<web::WebHTTPProtocolHandlerDelegate> _httpProtocolDelegate;
42 scoped_ptr<web::WebStateObserverBridge> _webStateObserver; 42 scoped_ptr<web::WebStateObserverBridge> _webStateObserver;
43 43
44 base::mac::ObjCPropertyReleaser _propertyReleaser_ViewController; 44 base::mac::ObjCPropertyReleaser _propertyReleaser_ViewController;
45 } 45 }
46 @property(nonatomic, assign, readonly) web::WebState* webState; 46 @property(nonatomic, assign, readonly) web::WebState* webState;
47 @property(nonatomic, assign, readonly) NavigationManager* navigationManager;
47 @property(nonatomic, readwrite, retain) UITextField* field; 48 @property(nonatomic, readwrite, retain) UITextField* field;
48 @end 49 @end
49 50
50 @implementation ViewController 51 @implementation ViewController
51 52
52 @synthesize field = _field; 53 @synthesize field = _field;
53 @synthesize containerView = _containerView; 54 @synthesize containerView = _containerView;
54 @synthesize toolbarView = _toolbarView; 55 @synthesize toolbarView = _toolbarView;
55 56
56 - (instancetype)initWithBrowserState:(web::BrowserState*)browserState { 57 - (instancetype)initWithBrowserState:(web::BrowserState*)browserState {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 [_webController setWebUsageEnabled:YES]; 123 [_webController setWebUsageEnabled:YES];
123 124
124 _webStateObserver.reset(new web::WebStateObserverBridge(self.webState, self)); 125 _webStateObserver.reset(new web::WebStateObserverBridge(self.webState, self));
125 126
126 UIView* view = self.webState->GetView(); 127 UIView* view = self.webState->GetView();
127 [view setFrame:[_containerView bounds]]; 128 [view setFrame:[_containerView bounds]];
128 [_containerView addSubview:view]; 129 [_containerView addSubview:view];
129 130
130 NavigationManager::WebLoadParams params(GURL("https://dev.chromium.org/")); 131 NavigationManager::WebLoadParams params(GURL("https://dev.chromium.org/"));
131 params.transition_type = ui::PAGE_TRANSITION_TYPED; 132 params.transition_type = ui::PAGE_TRANSITION_TYPED;
132 [_webController loadWithParams:params]; 133 self.navigationManager->LoadURLWithParams(params);
133 } 134 }
134 135
135 - (web::WebState*)webState { 136 - (web::WebState*)webState {
136 return [_webController webState]; 137 return [_webController webState];
137 } 138 }
138 139
140 - (NavigationManager*)navigationManager {
141 return self.webState->GetNavigationManager();
142 }
143
139 - (void)setUpNetworkStack { 144 - (void)setUpNetworkStack {
140 // Disable the default cache. 145 // Disable the default cache.
141 [NSURLCache setSharedURLCache:[EmptyNSURLCache emptyNSURLCache]]; 146 [NSURLCache setSharedURLCache:[EmptyNSURLCache emptyNSURLCache]];
142 147
143 _httpProtocolDelegate.reset(new web::WebHTTPProtocolHandlerDelegate( 148 _httpProtocolDelegate.reset(new web::WebHTTPProtocolHandlerDelegate(
144 _browserState->GetRequestContext())); 149 _browserState->GetRequestContext()));
145 net::HTTPProtocolHandlerDelegate::SetInstance(_httpProtocolDelegate.get()); 150 net::HTTPProtocolHandlerDelegate::SetInstance(_httpProtocolDelegate.get());
146 BOOL success = [NSURLProtocol registerClass:[CRNHTTPProtocolHandler class]]; 151 BOOL success = [NSURLProtocol registerClass:[CRNHTTPProtocolHandler class]];
147 DCHECK(success); 152 DCHECK(success);
148 // The CRWURLVerifyingProtocolHandler is used to verify URL in the 153 // The CRWURLVerifyingProtocolHandler is used to verify URL in the
(...skipping 13 matching lines...) Expand all
162 } 167 }
163 168
164 - (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar { 169 - (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar {
165 if (bar == _toolbarView) { 170 if (bar == _toolbarView) {
166 return UIBarPositionTopAttached; 171 return UIBarPositionTopAttached;
167 } 172 }
168 return UIBarPositionAny; 173 return UIBarPositionAny;
169 } 174 }
170 175
171 - (void)back { 176 - (void)back {
172 NavigationManager* navManager = self.webState->GetNavigationManager(); 177 if (self.navigationManager->CanGoBack()) {
173 if (navManager->CanGoBack()) { 178 self.navigationManager->GoBack();
174 navManager->GoBack();
175 } 179 }
176 } 180 }
177 181
178 - (void)forward { 182 - (void)forward {
179 NavigationManager* navManager = self.webState->GetNavigationManager(); 183 if (self.navigationManager->CanGoForward()) {
180 if (navManager->CanGoForward()) { 184 self.navigationManager->GoForward();
181 navManager->GoForward();
182 } 185 }
183 } 186 }
184 187
185 - (BOOL)textFieldShouldReturn:(UITextField*)field { 188 - (BOOL)textFieldShouldReturn:(UITextField*)field {
186 GURL URL = GURL(base::SysNSStringToUTF8([field text])); 189 GURL URL = GURL(base::SysNSStringToUTF8([field text]));
187 190
188 // Do not try to load invalid URLs. 191 // Do not try to load invalid URLs.
189 if (URL.is_valid()) { 192 if (URL.is_valid()) {
190 NavigationManager::WebLoadParams params(URL); 193 NavigationManager::WebLoadParams params(URL);
191 params.transition_type = ui::PAGE_TRANSITION_TYPED; 194 params.transition_type = ui::PAGE_TRANSITION_TYPED;
192 [_webController loadWithParams:params]; 195 self.navigationManager->LoadURLWithParams(params);
193 } 196 }
194 197
195 [field resignFirstResponder]; 198 [field resignFirstResponder];
196 [self updateToolbar]; 199 [self updateToolbar];
197 return YES; 200 return YES;
198 } 201 }
199 202
200 - (void)updateToolbar { 203 - (void)updateToolbar {
201 // Do not update the URL if the text field is currently being edited. 204 // Do not update the URL if the text field is currently being edited.
202 if ([_field isFirstResponder]) { 205 if ([_field isFirstResponder]) {
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry { 368 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry {
366 } 369 }
367 - (int)downloadImageAtUrl:(const GURL&)url 370 - (int)downloadImageAtUrl:(const GURL&)url
368 maxBitmapSize:(uint32_t)maxBitmapSize 371 maxBitmapSize:(uint32_t)maxBitmapSize
369 callback: 372 callback:
370 (const web::WebState::ImageDownloadCallback&)callback { 373 (const web::WebState::ImageDownloadCallback&)callback {
371 return -1; 374 return -1;
372 } 375 }
373 376
374 @end 377 @end
OLDNEW
« no previous file with comments | « ios/web/public/navigation_manager.h ('k') | ios/web/web_state/web_state_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698