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

Unified Diff: ios/chrome/browser/ui/web_contents/web_contents_view_controller.mm

Issue 2580333003: Upstream Chrome on iOS source code [10/11]. (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/web_contents/web_contents_view_controller.mm
diff --git a/ios/chrome/browser/ui/web_contents/web_contents_view_controller.mm b/ios/chrome/browser/ui/web_contents/web_contents_view_controller.mm
new file mode 100644
index 0000000000000000000000000000000000000000..89c1d5d9180f375efe10bb935f62b4ddf1791dee
--- /dev/null
+++ b/ios/chrome/browser/ui/web_contents/web_contents_view_controller.mm
@@ -0,0 +1,56 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// ====== New Architecture =====
+// = This code is only used in the new iOS Chrome architecture. =
+// ============================================================================
+
+#import "ios/chrome/browser/ui/web_contents/web_contents_view_controller.h"
+
+#import "ios/web/public/navigation_manager.h"
+#include "ios/web/public/web_state/web_state.h"
+#include "ui/base/page_transition_types.h"
+#include "url/gurl.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+@implementation WebContentsViewController
+
+@synthesize webState = _webState;
+
+- (instancetype)initWithWebState:(web::WebState*)webState {
+ if ((self = [super initWithNibName:nil bundle:nil])) {
+ DCHECK(webState);
+ _webState = webState;
+ }
+ return self;
+}
+
+- (void)viewDidLoad {
+ self.view.backgroundColor = [UIColor colorWithWhite:0.75 alpha:1.0];
+
+ UIView* webContentsView = self.webState->GetView();
+ webContentsView.translatesAutoresizingMaskIntoConstraints = NO;
+ [self.view addSubview:webContentsView];
+ [NSLayoutConstraint activateConstraints:@[
+ [webContentsView.topAnchor constraintEqualToAnchor:self.view.topAnchor],
+ [webContentsView.bottomAnchor
+ constraintEqualToAnchor:self.view.bottomAnchor],
+ [webContentsView.leadingAnchor
+ constraintEqualToAnchor:self.view.leadingAnchor],
+ [webContentsView.trailingAnchor
+ constraintEqualToAnchor:self.view.trailingAnchor],
+ ]];
+
+ if (!self.webState->GetNavigationManager()->GetItemCount()) {
+ web::NavigationManager::WebLoadParams params(
+ GURL("https://dev.chromium.org/"));
+ params.transition_type = ui::PAGE_TRANSITION_TYPED;
+ _webState->GetNavigationManager()->LoadURLWithParams(params);
+ }
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698