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/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 #include "base/mac/objc_property_releaser.h" | |
15 #import "base/mac/scoped_nsobject.h" | 14 #import "base/mac/scoped_nsobject.h" |
16 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
17 #include "ios/net/cookies/cookie_store_ios.h" | 16 #include "ios/net/cookies/cookie_store_ios.h" |
18 #import "ios/net/crn_http_protocol_handler.h" | 17 #import "ios/net/crn_http_protocol_handler.h" |
19 #import "ios/net/empty_nsurlcache.h" | 18 #import "ios/net/empty_nsurlcache.h" |
20 #import "ios/net/request_tracker.h" | 19 #import "ios/net/request_tracker.h" |
21 #import "ios/web/public/navigation_manager.h" | 20 #import "ios/web/public/navigation_manager.h" |
22 #include "ios/web/public/referrer.h" | 21 #include "ios/web/public/referrer.h" |
23 #import "ios/web/public/web_state/context_menu_params.h" | 22 #import "ios/web/public/web_state/context_menu_params.h" |
24 #include "ios/web/public/web_state/web_state.h" | 23 #include "ios/web/public/web_state/web_state.h" |
25 #import "ios/web/public/web_state/web_state_delegate_bridge.h" | 24 #import "ios/web/public/web_state/web_state_delegate_bridge.h" |
26 #import "ios/web/public/web_state/web_state_observer_bridge.h" | 25 #import "ios/web/public/web_state/web_state_observer_bridge.h" |
27 #import "net/base/mac/url_conversions.h" | 26 #import "net/base/mac/url_conversions.h" |
28 #include "ui/base/page_transition_types.h" | 27 #include "ui/base/page_transition_types.h" |
29 | 28 |
| 29 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 30 #error "This file requires ARC support." |
| 31 #endif |
| 32 |
30 NSString* const kWebShellBackButtonAccessibilityLabel = @"Back"; | 33 NSString* const kWebShellBackButtonAccessibilityLabel = @"Back"; |
31 NSString* const kWebShellForwardButtonAccessibilityLabel = @"Forward"; | 34 NSString* const kWebShellForwardButtonAccessibilityLabel = @"Forward"; |
32 NSString* const kWebShellAddressFieldAccessibilityLabel = @"Address field"; | 35 NSString* const kWebShellAddressFieldAccessibilityLabel = @"Address field"; |
33 | 36 |
34 using web::NavigationManager; | 37 using web::NavigationManager; |
35 | 38 |
36 @interface ViewController ()<CRWWebStateDelegate, | 39 @interface ViewController ()<CRWWebStateDelegate, |
37 CRWWebStateObserver, | 40 CRWWebStateObserver, |
38 UITextFieldDelegate> { | 41 UITextFieldDelegate> { |
39 web::BrowserState* _browserState; | 42 web::BrowserState* _browserState; |
40 std::unique_ptr<web::WebState> _webState; | 43 std::unique_ptr<web::WebState> _webState; |
41 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver; | 44 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver; |
42 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate; | 45 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate; |
43 | |
44 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, strong) 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:@"MainView" bundle:nil]; |
58 if (self) { | 59 if (self) { |
59 _propertyReleaser_ViewController.Init(self, [ViewController class]); | |
60 _browserState = browserState; | 60 _browserState = browserState; |
61 } | 61 } |
62 return self; | 62 return self; |
63 } | 63 } |
64 | 64 |
65 - (void)dealloc { | 65 - (void)dealloc { |
66 net::HTTPProtocolHandlerDelegate::SetInstance(nullptr); | 66 net::HTTPProtocolHandlerDelegate::SetInstance(nullptr); |
67 net::RequestTracker::SetRequestTrackerFactory(nullptr); | 67 net::RequestTracker::SetRequestTrackerFactory(nullptr); |
68 [super dealloc]; | |
69 } | 68 } |
70 | 69 |
71 - (void)viewDidLoad { | 70 - (void)viewDidLoad { |
72 [super viewDidLoad]; | 71 [super viewDidLoad]; |
73 | 72 |
74 // Set up the toolbar buttons. | 73 // Set up the toolbar buttons. |
75 UIButton* back = [UIButton buttonWithType:UIButtonTypeCustom]; | 74 UIButton* back = [UIButton buttonWithType:UIButtonTypeCustom]; |
76 [back setImage:[UIImage imageNamed:@"toolbar_back"] | 75 [back setImage:[UIImage imageNamed:@"toolbar_back"] |
77 forState:UIControlStateNormal]; | 76 forState:UIControlStateNormal]; |
78 [back setFrame:CGRectMake(0, 0, 44, 44)]; | 77 [back setFrame:CGRectMake(0, 0, 44, 44)]; |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 [alert addAction:[UIAlertAction actionWithTitle:@"Cancel" | 298 [alert addAction:[UIAlertAction actionWithTitle:@"Cancel" |
300 style:UIAlertActionStyleCancel | 299 style:UIAlertActionStyleCancel |
301 handler:nil]]; | 300 handler:nil]]; |
302 | 301 |
303 [self presentViewController:alert animated:YES completion:nil]; | 302 [self presentViewController:alert animated:YES completion:nil]; |
304 | 303 |
305 return YES; | 304 return YES; |
306 } | 305 } |
307 | 306 |
308 @end | 307 @end |
OLD | NEW |