Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/clean/chrome/browser/ui/web_contents/web_coordinator.h" | 5 #import "ios/clean/chrome/browser/ui/web_contents/web_coordinator.h" |
| 6 | 6 |
| 7 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.h" | 7 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.h" |
| 8 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_view_controller.h " | 8 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_view_controller.h " |
| 9 #import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h" | 9 #import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h" |
| 10 #import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal. h" | 10 #import "ios/shared/chrome/browser/tabs/web_state_list.h" |
| 11 #import "ios/shared/chrome/browser/ui/browser_list/browser.h" | |
| 11 #include "ios/web/public/web_state/web_state.h" | 12 #include "ios/web/public/web_state/web_state.h" |
| 12 | 13 |
| 13 #if !defined(__has_feature) || !__has_feature(objc_arc) | 14 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 14 #error "This file requires ARC support." | 15 #error "This file requires ARC support." |
| 15 #endif | 16 #endif |
| 16 | 17 |
| 17 @interface WebCoordinator () | 18 @interface WebCoordinator () |
| 18 @property(nonatomic, strong) WebContentsViewController* viewController; | 19 @property(nonatomic, strong) WebContentsViewController* viewController; |
| 19 @property(nonatomic, strong) WebContentsMediator* mediator; | 20 @property(nonatomic, strong) WebContentsMediator* mediator; |
| 20 @end | 21 @end |
| 21 | 22 |
| 22 @implementation WebCoordinator | 23 @implementation WebCoordinator |
| 23 @synthesize webState = _webState; | |
| 24 @synthesize viewController = _viewController; | 24 @synthesize viewController = _viewController; |
| 25 @synthesize mediator = _mediator; | 25 @synthesize mediator = _mediator; |
| 26 | 26 |
| 27 - (instancetype)init { | |
| 28 if ((self = [super init])) { | |
| 29 _mediator = [[WebContentsMediator alloc] init]; | |
| 30 } | |
| 31 return self; | |
| 32 } | |
| 33 | |
| 34 - (void)setWebState:(web::WebState*)webState { | |
| 35 _webState = webState; | |
| 36 self.mediator.webState = self.webState; | |
| 37 } | |
| 38 | |
| 39 - (void)start { | 27 - (void)start { |
| 40 self.viewController = [[WebContentsViewController alloc] init]; | 28 self.viewController = [[WebContentsViewController alloc] init]; |
| 29 self.mediator = [[WebContentsMediator alloc] init]; | |
| 30 self.mediator.webStateList = &self.browser->web_state_list(); | |
| 41 self.mediator.consumer = self.viewController; | 31 self.mediator.consumer = self.viewController; |
| 42 | 32 |
| 43 // Reminder: this is a no-op if |baseViewController| is nil, for example | 33 // Reminder: this is a no-op if |baseViewController| is nil, for example |
| 44 // when this coordinator's view controller will be contained instead of | 34 // when this coordinator's view controller will be contained instead of |
| 45 // presented. | 35 // presented. |
| 46 [self.context.baseViewController presentViewController:self.viewController | 36 [self.context.baseViewController presentViewController:self.viewController |
| 47 animated:self.context.animated | 37 animated:self.context.animated |
| 48 completion:nil]; | 38 completion:nil]; |
| 49 [super start]; | 39 [super start]; |
| 50 } | 40 } |
| 51 | 41 |
| 52 - (void)stop { | 42 - (void)stop { |
| 53 [super stop]; | 43 [super stop]; |
| 54 // PLACEHOLDER: This is how the webUsageEnabled is set to false. Find a | 44 web::WebState* webState = self.browser->web_state_list().GetActiveWebState(); |
|
lpromero
2017/04/03 09:48:36
I'd move this to the WebContentsMediator and here
edchin
2017/04/04 19:50:12
I added a -disconnect method. PTAL.
| |
| 55 // better way in the future. | 45 if (webState) { |
| 56 self.mediator.webState = nullptr; | 46 webState->SetWebUsageEnabled(false); |
| 47 } | |
| 57 } | 48 } |
| 58 | 49 |
| 59 @end | 50 @end |
| OLD | NEW |