OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // ====== New Architecture ===== | |
6 // = This code is only used in the new iOS Chrome architecture. = | |
7 // ============================================================================ | |
8 | |
9 #import "ios/chrome/browser/ui/web_contents/web_contents_view_controller.h" | |
10 | |
11 #import "ios/web/public/navigation_manager.h" | |
12 #include "ios/web/public/web_state/web_state.h" | |
13 #include "ui/base/page_transition_types.h" | |
14 #include "url/gurl.h" | |
15 | |
16 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
17 #error "This file requires ARC support." | |
18 #endif | |
19 | |
20 @implementation WebContentsViewController | |
21 | |
22 @synthesize webState = _webState; | |
23 | |
24 - (instancetype)initWithWebState:(web::WebState*)webState { | |
25 if ((self = [super initWithNibName:nil bundle:nil])) { | |
26 DCHECK(webState); | |
27 _webState = webState; | |
28 } | |
29 return self; | |
30 } | |
31 | |
32 - (void)viewDidLoad { | |
33 self.view.backgroundColor = [UIColor colorWithWhite:0.75 alpha:1.0]; | |
34 | |
35 UIView* webContentsView = self.webState->GetView(); | |
36 webContentsView.translatesAutoresizingMaskIntoConstraints = NO; | |
37 [self.view addSubview:webContentsView]; | |
38 [NSLayoutConstraint activateConstraints:@[ | |
39 [webContentsView.topAnchor constraintEqualToAnchor:self.view.topAnchor], | |
40 [webContentsView.bottomAnchor | |
41 constraintEqualToAnchor:self.view.bottomAnchor], | |
42 [webContentsView.leadingAnchor | |
43 constraintEqualToAnchor:self.view.leadingAnchor], | |
44 [webContentsView.trailingAnchor | |
45 constraintEqualToAnchor:self.view.trailingAnchor], | |
46 ]]; | |
47 | |
48 if (!self.webState->GetNavigationManager()->GetItemCount()) { | |
49 web::NavigationManager::WebLoadParams params( | |
50 GURL("https://dev.chromium.org/")); | |
51 params.transition_type = ui::PAGE_TRANSITION_TYPED; | |
52 _webState->GetNavigationManager()->LoadURLWithParams(params); | |
53 } | |
54 } | |
55 | |
56 @end | |
OLD | NEW |