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 // ====== New Architecture ===== | 5 // ====== New Architecture ===== |
6 // = This code is only used in the new iOS Chrome architecture. = | 6 // = This code is only used in the new iOS Chrome architecture. = |
7 // ============================================================================ | 7 // ============================================================================ |
8 | 8 |
9 #import "ios/clean/chrome/browser/ui/web_contents/web_coordinator.h" | 9 #import "ios/clean/chrome/browser/ui/web_contents/web_coordinator.h" |
10 | 10 |
11 #import "ios/clean/chrome/browser/browser_coordinator+internal.h" | 11 #import "ios/clean/chrome/browser/browser_coordinator+internal.h" |
12 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.h" | |
12 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_view_controller.h " | 13 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_view_controller.h " |
13 #import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h" | 14 #import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h" |
14 #include "ios/web/public/web_state/web_state.h" | 15 #include "ios/web/public/web_state/web_state.h" |
15 | 16 |
16 #if !defined(__has_feature) || !__has_feature(objc_arc) | 17 #if !defined(__has_feature) || !__has_feature(objc_arc) |
17 #error "This file requires ARC support." | 18 #error "This file requires ARC support." |
18 #endif | 19 #endif |
19 | 20 |
20 @interface WebCoordinator () | 21 @interface WebCoordinator () |
21 | |
22 @property(nonatomic, strong) WebContentsViewController* viewController; | 22 @property(nonatomic, strong) WebContentsViewController* viewController; |
23 | 23 @property(nonatomic, strong) WebContentsMediator* mediator; |
24 @end | 24 @end |
25 | 25 |
26 @implementation WebCoordinator | 26 @implementation WebCoordinator |
27 @synthesize webState = _webState; | 27 @synthesize webState = _webState; |
28 @synthesize viewController = _viewController; | 28 @synthesize viewController = _viewController; |
29 @synthesize mediator = _mediator; | |
30 | |
31 - (instancetype)init { | |
32 if ((self = [super init])) { | |
33 _mediator = [[WebContentsMediator alloc] init]; | |
34 } | |
35 return self; | |
36 } | |
37 | |
38 - (void)setWebState:(web::WebState*)webState { | |
39 _webState = webState; | |
edchin
2017/02/02 22:17:53
Consistent use of property accessor.
marq (ping after 24h)
2017/02/03 09:48:10
Again, this is the setter method; I have to use th
edchin
2017/02/03 15:33:38
You're right. I should have seen that this is the
| |
40 self.mediator.webState = self.webState; | |
41 } | |
29 | 42 |
30 - (void)start { | 43 - (void)start { |
31 self.webState->SetWebUsageEnabled(true); | 44 self.viewController = [[WebContentsViewController alloc] init]; |
32 self.viewController = | 45 self.mediator.consumer = self.viewController; |
33 [[WebContentsViewController alloc] initWithWebState:self.webState]; | |
34 | 46 |
35 // Reminder: this is a no-op if |baseViewController| is nil, for example | 47 // Reminder: this is a no-op if |baseViewController| is nil, for example |
36 // when this coordinator's view controller will be contained instead of | 48 // when this coordinator's view controller will be contained instead of |
37 // presented. | 49 // presented. |
38 [self.context.baseViewController presentViewController:self.viewController | 50 [self.context.baseViewController presentViewController:self.viewController |
39 animated:self.context.animated | 51 animated:self.context.animated |
40 completion:nil]; | 52 completion:nil]; |
41 } | 53 } |
42 | 54 |
43 - (void)stop { | 55 - (void)stop { |
44 self.webState->SetWebUsageEnabled(false); | 56 // PLACEHOLDER: This is how the webUsageEnabled is set to false. Find a |
57 // better way in the future. | |
edchin
2017/02/02 22:17:53
It is not clear to me why we should set webUsageEn
marq (ping after 24h)
2017/02/03 09:48:10
webUsageEnabled means that the WebState is attache
edchin
2017/02/03 15:33:38
Acknowledged.
| |
58 self.mediator.webState = nullptr; | |
45 } | 59 } |
46 | 60 |
47 @end | 61 @end |
OLD | NEW |