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 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #import "ios/clean/chrome/browser/ui/commands/context_menu_commands.h" | 9 #import "ios/clean/chrome/browser/ui/commands/context_menu_commands.h" |
10 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_context_impl.h" | 10 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_context_impl.h" |
11 #import "ios/clean/chrome/browser/ui/context_menu/web_context_menu_coordinator.h " | 11 #import "ios/clean/chrome/browser/ui/context_menu/web_context_menu_coordinator.h " |
12 #import "ios/clean/chrome/browser/ui/overlays/overlay_service.h" | |
13 #import "ios/clean/chrome/browser/ui/overlays/overlay_service_factory.h" | |
12 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.h" | 14 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.h" |
13 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_view_controller.h " | 15 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_view_controller.h " |
14 #import "ios/shared/chrome/browser/ui/browser_list/browser.h" | 16 #import "ios/shared/chrome/browser/ui/browser_list/browser.h" |
15 #import "ios/shared/chrome/browser/ui/commands/command_dispatcher.h" | 17 #import "ios/shared/chrome/browser/ui/commands/command_dispatcher.h" |
16 #import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal. h" | 18 #import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal. h" |
17 #include "ios/web/public/navigation_manager.h" | 19 #include "ios/web/public/navigation_manager.h" |
18 #include "ios/web/public/web_state/web_state.h" | 20 #include "ios/web/public/web_state/web_state.h" |
19 #import "ios/web/public/web_state/web_state_delegate_bridge.h" | 21 #import "ios/web/public/web_state/web_state_delegate_bridge.h" |
20 | 22 |
21 #if !defined(__has_feature) || !__has_feature(objc_arc) | 23 #if !defined(__has_feature) || !__has_feature(objc_arc) |
22 #error "This file requires ARC support." | 24 #error "This file requires ARC support." |
23 #endif | 25 #endif |
24 | 26 |
25 @interface WebCoordinator ()<ContextMenuCommands, CRWWebStateDelegate> { | 27 @interface WebCoordinator ()<ContextMenuCommands, CRWWebStateDelegate> { |
26 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate; | 28 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate; |
27 } | 29 } |
28 @property(nonatomic, strong) WebContentsViewController* viewController; | 30 @property(nonatomic, strong) WebContentsViewController* viewController; |
29 @property(nonatomic, strong) WebContentsMediator* mediator; | 31 @property(nonatomic, strong) WebContentsMediator* mediator; |
32 | |
30 @end | 33 @end |
31 | 34 |
32 @implementation WebCoordinator | 35 @implementation WebCoordinator |
33 @synthesize webState = _webState; | 36 @synthesize webState = _webState; |
34 @synthesize viewController = _viewController; | 37 @synthesize viewController = _viewController; |
35 @synthesize mediator = _mediator; | 38 @synthesize mediator = _mediator; |
36 | 39 |
37 - (instancetype)init { | 40 - (instancetype)init { |
38 if ((self = [super init])) { | 41 if ((self = [super init])) { |
39 _mediator = [[WebContentsMediator alloc] init]; | 42 _mediator = [[WebContentsMediator alloc] init]; |
40 _webStateDelegate = base::MakeUnique<web::WebStateDelegateBridge>(self); | 43 _webStateDelegate = base::MakeUnique<web::WebStateDelegateBridge>(self); |
41 } | 44 } |
42 return self; | 45 return self; |
43 } | 46 } |
44 | 47 |
45 - (void)setWebState:(web::WebState*)webState { | 48 - (void)setWebState:(web::WebState*)webState { |
46 // PLACEHOLDER: The web state delegate will be set by another object, and | 49 // PLACEHOLDER: The web state delegate will be set by another object, and |
47 // this coordinator will not need to know the active web state. | 50 // this coordinator will not need to know the active web state. |
48 _webState = webState; | 51 _webState = webState; |
49 self.webState->SetDelegate(_webStateDelegate.get()); | 52 self.webState->SetDelegate(_webStateDelegate.get()); |
50 } | 53 } |
51 | 54 |
52 - (void)start { | 55 - (void)start { |
56 // Create the view controller and start it. | |
53 self.viewController = [[WebContentsViewController alloc] init]; | 57 self.viewController = [[WebContentsViewController alloc] init]; |
54 self.mediator.consumer = self.viewController; | 58 self.mediator.consumer = self.viewController; |
55 self.mediator.webStateList = &self.browser->web_state_list(); | 59 self.mediator.webStateList = &self.browser->web_state_list(); |
56 [super start]; | 60 [super start]; |
61 // Notify the OverlayService that this coordinator is displaying |webState|. | |
62 OverlayServiceFactory::GetInstance() | |
63 ->GetForBrowserState(self.browser->browser_state()) | |
64 ->SetWebStateParentCoordinator(self, self.webState); | |
57 } | 65 } |
58 | 66 |
59 - (void)stop { | 67 - (void)stop { |
68 // Notify the OverlayService that this coordinator is no long displaying | |
marq (ping after 24h)
2017/06/21 09:41:54
no longer
kkhorimoto
2017/06/23 06:11:16
Done.
| |
69 // |webState|. | |
70 OverlayServiceFactory::GetInstance() | |
71 ->GetForBrowserState(self.browser->browser_state()) | |
72 ->SetWebStateParentCoordinator(nil, self.webState); | |
60 [super stop]; | 73 [super stop]; |
61 [self.mediator disconnect]; | 74 [self.mediator disconnect]; |
62 } | 75 } |
63 | 76 |
64 - (void)childCoordinatorDidStart:(BrowserCoordinator*)childCoordinator { | 77 - (void)childCoordinatorDidStart:(BrowserCoordinator*)childCoordinator { |
65 // Register to receive relevant ContextMenuCommands. | 78 // Register to receive relevant ContextMenuCommands. |
66 if ([childCoordinator isKindOfClass:[WebContextMenuCoordinator class]]) { | 79 if ([childCoordinator isKindOfClass:[WebContextMenuCoordinator class]]) { |
67 [self.browser->dispatcher() | 80 [self.browser->dispatcher() |
68 startDispatchingToTarget:self | 81 startDispatchingToTarget:self |
69 forSelector:@selector(executeContextMenuScript:)]; | 82 forSelector:@selector(executeContextMenuScript:)]; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 ContextMenuContextImpl* context = | 121 ContextMenuContextImpl* context = |
109 [[ContextMenuContextImpl alloc] initWithParams:params]; | 122 [[ContextMenuContextImpl alloc] initWithParams:params]; |
110 WebContextMenuCoordinator* contextMenu = | 123 WebContextMenuCoordinator* contextMenu = |
111 [[WebContextMenuCoordinator alloc] initWithContext:context]; | 124 [[WebContextMenuCoordinator alloc] initWithContext:context]; |
112 [self addChildCoordinator:contextMenu]; | 125 [self addChildCoordinator:contextMenu]; |
113 [contextMenu start]; | 126 [contextMenu start]; |
114 return YES; | 127 return YES; |
115 } | 128 } |
116 | 129 |
117 @end | 130 @end |
OLD | NEW |