OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.h" |
| 6 |
| 7 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_consumer.h" |
| 8 #import "ios/web/public/navigation_manager.h" |
| 9 #include "ios/web/public/web_state/web_state.h" |
| 10 #include "ui/base/page_transition_types.h" |
| 11 #include "url/gurl.h" |
| 12 |
| 13 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 14 #error "This file requires ARC support." |
| 15 #endif |
| 16 |
| 17 @implementation WebContentsMediator |
| 18 @synthesize webState = _webState; |
| 19 @synthesize consumer = _consumer; |
| 20 |
| 21 - (void)setWebState:(web::WebState*)webState { |
| 22 if (_webState) |
| 23 _webState->SetWebUsageEnabled(false); |
| 24 |
| 25 _webState = webState; |
| 26 if (!self.webState) |
| 27 return; |
| 28 |
| 29 self.webState->SetWebUsageEnabled(true); |
| 30 if (!self.webState->GetNavigationManager()->GetItemCount()) { |
| 31 web::NavigationManager::WebLoadParams params( |
| 32 GURL("https://dev.chromium.org/")); |
| 33 params.transition_type = ui::PAGE_TRANSITION_TYPED; |
| 34 self.webState->GetNavigationManager()->LoadURLWithParams(params); |
| 35 } |
| 36 [self.consumer contentViewDidChange:self.webState->GetView()]; |
| 37 } |
| 38 |
| 39 - (void)setConsumer:(id<WebContentsConsumer>)consumer { |
| 40 _consumer = consumer; |
| 41 if (self.webState) |
| 42 [self.consumer contentViewDidChange:self.webState->GetView()]; |
| 43 } |
| 44 |
| 45 @end |
OLD | NEW |