Chromium Code Reviews| 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..f3da446fa15e0fdba43efc5294b0f825c46f53fa |
| --- /dev/null |
| +++ b/ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.mm |
| @@ -0,0 +1,46 @@ |
| +// 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) |
|
edchin
2017/02/02 22:17:52
Can we be consistent in the use of property vs. in
marq (ping after 24h)
2017/02/03 09:48:10
I think I have been. Note that this is the setter
edchin
2017/02/03 15:33:38
You're right. I should have seen that this is a pr
|
| + 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; |
| + _webState->GetNavigationManager()->LoadURLWithParams(params); |
|
edchin
2017/02/03 15:33:38
Perhaps this one should actually be a property acc
marq (ping after 24h)
2017/02/07 14:33:10
Yes! Bad copy/paste from me.
|
| + } |
| + [self.consumer contentViewDidChange:self.webState->GetView()]; |
| +} |
| + |
| +- (void)setConsumer:(id<WebContentsConsumer>)consumer { |
| + _consumer = consumer; |
| + if (self.webState) { |
| + [self.consumer contentViewDidChange:self.webState->GetView()]; |
| + } |
| +} |
| + |
| +@end |