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

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

Issue 2080123003: Remove ios web shell MainView.xib. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/shell/view_controller.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/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
(...skipping 17 matching lines...) Expand all
28 #include "ui/base/page_transition_types.h" 28 #include "ui/base/page_transition_types.h"
29 29
30 NSString* const kWebShellBackButtonAccessibilityLabel = @"Back"; 30 NSString* const kWebShellBackButtonAccessibilityLabel = @"Back";
31 NSString* const kWebShellForwardButtonAccessibilityLabel = @"Forward"; 31 NSString* const kWebShellForwardButtonAccessibilityLabel = @"Forward";
32 NSString* const kWebShellAddressFieldAccessibilityLabel = @"Address field"; 32 NSString* const kWebShellAddressFieldAccessibilityLabel = @"Address field";
33 33
34 using web::NavigationManager; 34 using web::NavigationManager;
35 35
36 @interface ViewController ()<CRWWebStateDelegate, 36 @interface ViewController ()<CRWWebStateDelegate,
37 CRWWebStateObserver, 37 CRWWebStateObserver,
38 UITextFieldDelegate> { 38 UITextFieldDelegate,
39 UIToolbarDelegate> {
39 web::BrowserState* _browserState; 40 web::BrowserState* _browserState;
40 std::unique_ptr<web::WebState> _webState; 41 std::unique_ptr<web::WebState> _webState;
41 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver; 42 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver;
42 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate; 43 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate;
43 44
44 base::mac::ObjCPropertyReleaser _propertyReleaser_ViewController; 45 base::mac::ObjCPropertyReleaser _propertyReleaser_ViewController;
45 } 46 }
46 @property(nonatomic, assign, readonly) NavigationManager* navigationManager; 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 {
57 self = [super initWithNibName:@"MainView" bundle:nil]; 58 self = [super initWithNibName:nil bundle:nil];
58 if (self) { 59 if (self) {
59 _propertyReleaser_ViewController.Init(self, [ViewController class]); 60 _propertyReleaser_ViewController.Init(self, [ViewController class]);
60 _browserState = browserState; 61 _browserState = browserState;
61 } 62 }
62 return self; 63 return self;
63 } 64 }
64 65
65 - (void)dealloc { 66 - (void)dealloc {
66 net::HTTPProtocolHandlerDelegate::SetInstance(nullptr); 67 net::HTTPProtocolHandlerDelegate::SetInstance(nullptr);
67 net::RequestTracker::SetRequestTrackerFactory(nullptr); 68 net::RequestTracker::SetRequestTrackerFactory(nullptr);
68 [super dealloc]; 69 [super dealloc];
69 } 70 }
70 71
71 - (void)viewDidLoad { 72 - (void)viewDidLoad {
72 [super viewDidLoad]; 73 [super viewDidLoad];
73 74
75 CGRect bounds = self.view.bounds;
76
77 // Set up the toolbar.
78 _toolbarView = [[UIToolbar alloc] init];
79 _toolbarView.barTintColor =
80 [UIColor colorWithRed:0.337 green:0.467 blue:0.988 alpha:1.0];
81 _toolbarView.frame = CGRectMake(0, 20, CGRectGetWidth(bounds), 44);
82 _toolbarView.autoresizingMask =
83 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
84 _toolbarView.delegate = self;
85 [self.view addSubview:_toolbarView];
86
87 // Set up the container view.
88 _containerView = [[UIView alloc] init];
89 _containerView.frame =
90 CGRectMake(0, 64, CGRectGetWidth(bounds), CGRectGetHeight(bounds) - 64);
91 _containerView.backgroundColor = [UIColor lightGrayColor];
92 _containerView.autoresizingMask =
93 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
94 [self.view addSubview:_containerView];
95
74 // Set up the toolbar buttons. 96 // Set up the toolbar buttons.
75 UIButton* back = [UIButton buttonWithType:UIButtonTypeCustom]; 97 UIButton* back = [UIButton buttonWithType:UIButtonTypeCustom];
76 [back setImage:[UIImage imageNamed:@"toolbar_back"] 98 [back setImage:[UIImage imageNamed:@"toolbar_back"]
77 forState:UIControlStateNormal]; 99 forState:UIControlStateNormal];
78 [back setFrame:CGRectMake(0, 0, 44, 44)]; 100 [back setFrame:CGRectMake(0, 0, 44, 44)];
79 [back setImageEdgeInsets:UIEdgeInsetsMake(5, 5, 4, 4)]; 101 [back setImageEdgeInsets:UIEdgeInsetsMake(5, 5, 4, 4)];
80 [back setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin]; 102 [back setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin];
81 [back addTarget:self 103 [back addTarget:self
82 action:@selector(back) 104 action:@selector(back)
83 forControlEvents:UIControlEventTouchUpInside]; 105 forControlEvents:UIControlEventTouchUpInside];
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 [alert addAction:[UIAlertAction actionWithTitle:@"Cancel" 321 [alert addAction:[UIAlertAction actionWithTitle:@"Cancel"
300 style:UIAlertActionStyleCancel 322 style:UIAlertActionStyleCancel
301 handler:nil]]; 323 handler:nil]];
302 324
303 [self presentViewController:alert animated:YES completion:nil]; 325 [self presentViewController:alert animated:YES completion:nil];
304 326
305 return YES; 327 return YES;
306 } 328 }
307 329
308 @end 330 @end
OLDNEW
« no previous file with comments | « ios/web/shell/view_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698