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

Unified Diff: ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.mm

Issue 2675763002: [ios clean] Consumer interface for WebContents (Closed)
Patch Set: Feedback. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.mm
diff --git a/ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.mm b/ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.mm
new file mode 100644
index 0000000000000000000000000000000000000000..2a5529bc5f8dd067bc843f649c472665d58b8d77
--- /dev/null
+++ b/ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.mm
@@ -0,0 +1,45 @@
+// Copyright 2017 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.
+
+#import "ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.h"
+
+#import "ios/clean/chrome/browser/ui/web_contents/web_contents_consumer.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 WebContentsMediator
+@synthesize webState = _webState;
+@synthesize consumer = _consumer;
+
+- (void)setWebState:(web::WebState*)webState {
+ if (_webState)
+ _webState->SetWebUsageEnabled(false);
+
+ _webState = webState;
+ if (!self.webState)
+ return;
+
+ self.webState->SetWebUsageEnabled(true);
+ if (!self.webState->GetNavigationManager()->GetItemCount()) {
+ web::NavigationManager::WebLoadParams params(
+ GURL("https://dev.chromium.org/"));
+ params.transition_type = ui::PAGE_TRANSITION_TYPED;
+ self.webState->GetNavigationManager()->LoadURLWithParams(params);
+ }
+ [self.consumer contentViewDidChange:self.webState->GetView()];
+}
+
+- (void)setConsumer:(id<WebContentsConsumer>)consumer {
+ _consumer = consumer;
+ if (self.webState)
+ [self.consumer contentViewDidChange:self.webState->GetView()];
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698