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

Side by Side Diff: ios/clean/chrome/browser/ui/web_contents/web_coordinator.mm

Issue 2780423003: [ios] Use web_state_list in web_contents_mediator. (Closed)
Patch Set: Rebase. Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « ios/clean/chrome/browser/ui/web_contents/web_contents_mediator_unittest.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #import "ios/clean/chrome/browser/ui/context_menu/web_context_menu_coordinator.h " 8 #import "ios/clean/chrome/browser/ui/context_menu/web_context_menu_coordinator.h "
9 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.h" 9 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.h"
10 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_view_controller.h " 10 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_view_controller.h "
11 #import "ios/shared/chrome/browser/ui/browser_list/browser.h"
11 #import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal. h" 12 #import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal. h"
12 #include "ios/web/public/web_state/web_state.h" 13 #include "ios/web/public/web_state/web_state.h"
13 #import "ios/web/public/web_state/web_state_delegate_bridge.h" 14 #import "ios/web/public/web_state/web_state_delegate_bridge.h"
14 15
15 #if !defined(__has_feature) || !__has_feature(objc_arc) 16 #if !defined(__has_feature) || !__has_feature(objc_arc)
16 #error "This file requires ARC support." 17 #error "This file requires ARC support."
17 #endif 18 #endif
18 19
19 @interface WebCoordinator ()<CRWWebStateDelegate> { 20 @interface WebCoordinator ()<CRWWebStateDelegate> {
20 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate; 21 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate;
21 } 22 }
22 @property(nonatomic, strong) WebContentsViewController* viewController; 23 @property(nonatomic, strong) WebContentsViewController* viewController;
23 @property(nonatomic, strong) WebContentsMediator* mediator; 24 @property(nonatomic, strong) WebContentsMediator* mediator;
24 @end 25 @end
25 26
26 @implementation WebCoordinator 27 @implementation WebCoordinator
27 @synthesize webState = _webState; 28 @synthesize webState = _webState;
28 @synthesize viewController = _viewController; 29 @synthesize viewController = _viewController;
29 @synthesize mediator = _mediator; 30 @synthesize mediator = _mediator;
30 31
31 - (instancetype)init { 32 - (instancetype)init {
32 if ((self = [super init])) { 33 if ((self = [super init])) {
33 _mediator = [[WebContentsMediator alloc] init]; 34 _mediator = [[WebContentsMediator alloc] init];
34 _webStateDelegate = base::MakeUnique<web::WebStateDelegateBridge>(self); 35 _webStateDelegate = base::MakeUnique<web::WebStateDelegateBridge>(self);
35 } 36 }
36 return self; 37 return self;
37 } 38 }
38 39
39 - (void)setWebState:(web::WebState*)webState { 40 - (void)setWebState:(web::WebState*)webState {
41 // PLACEHOLDER: The web state delegate will be set by another object, and
42 // this coordinator will not need to know the active web state.
40 _webState = webState; 43 _webState = webState;
41 self.webState->SetDelegate(_webStateDelegate.get()); 44 self.webState->SetDelegate(_webStateDelegate.get());
42 self.mediator.webState = self.webState;
43 } 45 }
44 46
45 - (void)start { 47 - (void)start {
46 self.viewController = [[WebContentsViewController alloc] init]; 48 self.viewController = [[WebContentsViewController alloc] init];
47 self.mediator.consumer = self.viewController; 49 self.mediator.consumer = self.viewController;
50 self.mediator.webStateList = &self.browser->web_state_list();
48 [super start]; 51 [super start];
49 } 52 }
50 53
51 - (void)stop { 54 - (void)stop {
52 [super stop]; 55 [super stop];
53 // PLACEHOLDER: This is how the webUsageEnabled is set to false. Find a 56 [self.mediator disconnect];
54 // better way in the future.
55 self.mediator.webState = nullptr;
56 } 57 }
57 58
58 - (void)childCoordinatorDidStart:(BrowserCoordinator*)childCoordinator { 59 - (void)childCoordinatorDidStart:(BrowserCoordinator*)childCoordinator {
59 DCHECK([childCoordinator isKindOfClass:[WebContextMenuCoordinator class]]); 60 DCHECK([childCoordinator isKindOfClass:[WebContextMenuCoordinator class]]);
60 [self.viewController presentViewController:childCoordinator.viewController 61 [self.viewController presentViewController:childCoordinator.viewController
61 animated:YES 62 animated:YES
62 completion:nil]; 63 completion:nil];
63 } 64 }
64 65
65 #pragma mark - CRWWebStateDelegate 66 #pragma mark - CRWWebStateDelegate
66 67
67 - (BOOL)webState:(web::WebState*)webState 68 - (BOOL)webState:(web::WebState*)webState
68 handleContextMenu:(const web::ContextMenuParams&)params { 69 handleContextMenu:(const web::ContextMenuParams&)params {
69 WebContextMenuCoordinator* contextMenu = 70 WebContextMenuCoordinator* contextMenu =
70 [[WebContextMenuCoordinator alloc] init]; 71 [[WebContextMenuCoordinator alloc] init];
71 [self addChildCoordinator:contextMenu]; 72 [self addChildCoordinator:contextMenu];
72 [contextMenu start]; 73 [contextMenu start];
73 return YES; 74 return YES;
74 } 75 }
75 76
76 @end 77 @end
OLDNEW
« no previous file with comments | « ios/clean/chrome/browser/ui/web_contents/web_contents_mediator_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698