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

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

Issue 2626823006: [ios] Removed network stack related code from ios_web_shell's VC. (Closed)
Patch Set: Created 3 years, 11 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 | « no previous file | 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/shell/view_controller.h" 5 #import "ios/web/shell/view_controller.h"
6 6
7 #import <MobileCoreServices/MobileCoreServices.h> 7 #import <MobileCoreServices/MobileCoreServices.h>
8 8
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <utility> 12 #include <utility>
13 13
14 #import "base/mac/scoped_nsobject.h" 14 #import "base/mac/scoped_nsobject.h"
15 #include "base/strings/sys_string_conversions.h" 15 #include "base/strings/sys_string_conversions.h"
16 #import "ios/net/crn_http_protocol_handler.h"
17 #import "ios/net/empty_nsurlcache.h"
18 #import "ios/net/request_tracker.h"
19 #import "ios/web/public/navigation_manager.h" 16 #import "ios/web/public/navigation_manager.h"
20 #include "ios/web/public/referrer.h" 17 #include "ios/web/public/referrer.h"
21 #import "ios/web/public/web_state/context_menu_params.h" 18 #import "ios/web/public/web_state/context_menu_params.h"
22 #import "ios/web/public/web_state/web_state.h" 19 #import "ios/web/public/web_state/web_state.h"
23 #import "ios/web/public/web_state/web_state_delegate_bridge.h" 20 #import "ios/web/public/web_state/web_state_delegate_bridge.h"
24 #import "ios/web/public/web_state/web_state_observer_bridge.h" 21 #import "ios/web/public/web_state/web_state_observer_bridge.h"
25 #import "net/base/mac/url_conversions.h" 22 #import "net/base/mac/url_conversions.h"
26 #include "ui/base/page_transition_types.h" 23 #include "ui/base/page_transition_types.h"
27 24
28 #if !defined(__has_feature) || !__has_feature(objc_arc) 25 #if !defined(__has_feature) || !__has_feature(objc_arc)
(...skipping 26 matching lines...) Expand all
55 @synthesize toolbarView = _toolbarView; 52 @synthesize toolbarView = _toolbarView;
56 53
57 - (instancetype)initWithBrowserState:(web::BrowserState*)browserState { 54 - (instancetype)initWithBrowserState:(web::BrowserState*)browserState {
58 self = [super initWithNibName:nil bundle:nil]; 55 self = [super initWithNibName:nil bundle:nil];
59 if (self) { 56 if (self) {
60 _browserState = browserState; 57 _browserState = browserState;
61 } 58 }
62 return self; 59 return self;
63 } 60 }
64 61
65 - (void)dealloc {
66 net::HTTPProtocolHandlerDelegate::SetInstance(nullptr);
67 net::RequestTracker::SetRequestTrackerFactory(nullptr);
68 }
69
70 - (void)viewDidLoad { 62 - (void)viewDidLoad {
71 [super viewDidLoad]; 63 [super viewDidLoad];
72 64
73 CGRect bounds = self.view.bounds; 65 CGRect bounds = self.view.bounds;
74 66
75 // Set up the toolbar. 67 // Set up the toolbar.
76 _toolbarView = [[UIToolbar alloc] init]; 68 _toolbarView = [[UIToolbar alloc] init];
77 _toolbarView.barTintColor = 69 _toolbarView.barTintColor =
78 [UIColor colorWithRed:0.337 green:0.467 blue:0.988 alpha:1.0]; 70 [UIColor colorWithRed:0.337 green:0.467 blue:0.988 alpha:1.0];
79 _toolbarView.frame = CGRectMake(0, 20, CGRectGetWidth(bounds), 44); 71 _toolbarView.frame = CGRectMake(0, 20, CGRectGetWidth(bounds), 44);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 [field setKeyboardType:UIKeyboardTypeWebSearch]; 117 [field setKeyboardType:UIKeyboardTypeWebSearch];
126 [field setAutocorrectionType:UITextAutocorrectionTypeNo]; 118 [field setAutocorrectionType:UITextAutocorrectionTypeNo];
127 [field setAccessibilityLabel:kWebShellAddressFieldAccessibilityLabel]; 119 [field setAccessibilityLabel:kWebShellAddressFieldAccessibilityLabel];
128 [field setClearButtonMode:UITextFieldViewModeWhileEditing]; 120 [field setClearButtonMode:UITextFieldViewModeWhileEditing];
129 self.field = field; 121 self.field = field;
130 122
131 [_toolbarView addSubview:back]; 123 [_toolbarView addSubview:back];
132 [_toolbarView addSubview:forward]; 124 [_toolbarView addSubview:forward];
133 [_toolbarView addSubview:field]; 125 [_toolbarView addSubview:field];
134 126
135 // Set up the network stack before creating the WebState.
136 [self setUpNetworkStack];
137
138 web::WebState::CreateParams webStateCreateParams(_browserState); 127 web::WebState::CreateParams webStateCreateParams(_browserState);
139 _webState = web::WebState::Create(webStateCreateParams); 128 _webState = web::WebState::Create(webStateCreateParams);
140 _webState->SetWebUsageEnabled(true); 129 _webState->SetWebUsageEnabled(true);
141 130
142 _webStateObserver.reset( 131 _webStateObserver.reset(
143 new web::WebStateObserverBridge(_webState.get(), self)); 132 new web::WebStateObserverBridge(_webState.get(), self));
144 _webStateDelegate.reset(new web::WebStateDelegateBridge(self)); 133 _webStateDelegate.reset(new web::WebStateDelegateBridge(self));
145 _webState->SetDelegate(_webStateDelegate.get()); 134 _webState->SetDelegate(_webStateDelegate.get());
146 135
147 UIView* view = _webState->GetView(); 136 UIView* view = _webState->GetView();
148 [view setFrame:[_containerView bounds]]; 137 [view setFrame:[_containerView bounds]];
149 [_containerView addSubview:view]; 138 [_containerView addSubview:view];
150 139
151 NavigationManager::WebLoadParams params(GURL("https://dev.chromium.org/")); 140 NavigationManager::WebLoadParams params(GURL("https://dev.chromium.org/"));
152 params.transition_type = ui::PAGE_TRANSITION_TYPED; 141 params.transition_type = ui::PAGE_TRANSITION_TYPED;
153 self.navigationManager->LoadURLWithParams(params); 142 self.navigationManager->LoadURLWithParams(params);
154 } 143 }
155 144
156 - (NavigationManager*)navigationManager { 145 - (NavigationManager*)navigationManager {
157 return _webState->GetNavigationManager(); 146 return _webState->GetNavigationManager();
158 } 147 }
159 148
160 - (web::WebState*)webState { 149 - (web::WebState*)webState {
161 return _webState.get(); 150 return _webState.get();
162 } 151 }
163 152
164 - (void)setUpNetworkStack {
165 // Disable the default cache.
166 [NSURLCache setSharedURLCache:[EmptyNSURLCache emptyNSURLCache]];
167 }
168
169 - (void)didReceiveMemoryWarning { 153 - (void)didReceiveMemoryWarning {
170 [super didReceiveMemoryWarning]; 154 [super didReceiveMemoryWarning];
171 } 155 }
172 156
173 - (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar { 157 - (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar {
174 if (bar == _toolbarView) { 158 if (bar == _toolbarView) {
175 return UIBarPositionTopAttached; 159 return UIBarPositionTopAttached;
176 } 160 }
177 return UIBarPositionAny; 161 return UIBarPositionAny;
178 } 162 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 [alert addAction:[UIAlertAction actionWithTitle:@"Cancel" 302 [alert addAction:[UIAlertAction actionWithTitle:@"Cancel"
319 style:UIAlertActionStyleCancel 303 style:UIAlertActionStyleCancel
320 handler:nil]]; 304 handler:nil]];
321 305
322 [self presentViewController:alert animated:YES completion:nil]; 306 [self presentViewController:alert animated:YES completion:nil];
323 307
324 return YES; 308 return YES;
325 } 309 }
326 310
327 @end 311 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698