| 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/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/coordinator_context/coordinator_context.h" | |
| 12 #import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal.
h" | 11 #import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal.
h" |
| 13 #include "ios/web/public/web_state/web_state.h" | 12 #include "ios/web/public/web_state/web_state.h" |
| 14 #import "ios/web/public/web_state/web_state_delegate_bridge.h" | 13 #import "ios/web/public/web_state/web_state_delegate_bridge.h" |
| 15 | 14 |
| 16 #if !defined(__has_feature) || !__has_feature(objc_arc) | 15 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 17 #error "This file requires ARC support." | 16 #error "This file requires ARC support." |
| 18 #endif | 17 #endif |
| 19 | 18 |
| 20 @interface WebCoordinator ()<CRWWebStateDelegate> { | 19 @interface WebCoordinator ()<CRWWebStateDelegate> { |
| 21 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate; | 20 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 39 | 38 |
| 40 - (void)setWebState:(web::WebState*)webState { | 39 - (void)setWebState:(web::WebState*)webState { |
| 41 _webState = webState; | 40 _webState = webState; |
| 42 self.webState->SetDelegate(_webStateDelegate.get()); | 41 self.webState->SetDelegate(_webStateDelegate.get()); |
| 43 self.mediator.webState = self.webState; | 42 self.mediator.webState = self.webState; |
| 44 } | 43 } |
| 45 | 44 |
| 46 - (void)start { | 45 - (void)start { |
| 47 self.viewController = [[WebContentsViewController alloc] init]; | 46 self.viewController = [[WebContentsViewController alloc] init]; |
| 48 self.mediator.consumer = self.viewController; | 47 self.mediator.consumer = self.viewController; |
| 49 | |
| 50 // Reminder: this is a no-op if |baseViewController| is nil, for example | |
| 51 // when this coordinator's view controller will be contained instead of | |
| 52 // presented. | |
| 53 [self.context.baseViewController presentViewController:self.viewController | |
| 54 animated:self.context.animated | |
| 55 completion:nil]; | |
| 56 [super start]; | 48 [super start]; |
| 57 } | 49 } |
| 58 | 50 |
| 59 - (void)stop { | 51 - (void)stop { |
| 60 [super stop]; | 52 [super stop]; |
| 61 // PLACEHOLDER: This is how the webUsageEnabled is set to false. Find a | 53 // PLACEHOLDER: This is how the webUsageEnabled is set to false. Find a |
| 62 // better way in the future. | 54 // better way in the future. |
| 63 self.mediator.webState = nullptr; | 55 self.mediator.webState = nullptr; |
| 64 } | 56 } |
| 65 | 57 |
| 66 - (void)childCoordinatorDidStart:(BrowserCoordinator*)childCoordinator { | 58 - (void)childCoordinatorDidStart:(BrowserCoordinator*)childCoordinator { |
| 67 DCHECK([childCoordinator isKindOfClass:[WebContextMenuCoordinator class]]); | 59 DCHECK([childCoordinator isKindOfClass:[WebContextMenuCoordinator class]]); |
| 68 [self.viewController presentViewController:childCoordinator.viewController | 60 [self.viewController presentViewController:childCoordinator.viewController |
| 69 animated:YES | 61 animated:YES |
| 70 completion:nil]; | 62 completion:nil]; |
| 71 } | 63 } |
| 72 | 64 |
| 73 #pragma mark - CRWWebStateDelegate | 65 #pragma mark - CRWWebStateDelegate |
| 74 | 66 |
| 75 - (BOOL)webState:(web::WebState*)webState | 67 - (BOOL)webState:(web::WebState*)webState |
| 76 handleContextMenu:(const web::ContextMenuParams&)params { | 68 handleContextMenu:(const web::ContextMenuParams&)params { |
| 77 WebContextMenuCoordinator* contextMenu = | 69 WebContextMenuCoordinator* contextMenu = |
| 78 [[WebContextMenuCoordinator alloc] init]; | 70 [[WebContextMenuCoordinator alloc] init]; |
| 79 [self addChildCoordinator:contextMenu]; | 71 [self addChildCoordinator:contextMenu]; |
| 80 [contextMenu start]; | 72 [contextMenu start]; |
| 81 return YES; | 73 return YES; |
| 82 } | 74 } |
| 83 | 75 |
| 84 @end | 76 @end |
| OLD | NEW |