OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // ====== New Architecture ===== |
| 6 // = This code is only used in the new iOS Chrome architecture. = |
| 7 // ============================================================================ |
| 8 |
| 9 #import "ios/chrome/browser/ui/toolbar/toolbar_coordinator.h" |
| 10 |
| 11 #include "base/strings/sys_string_conversions.h" |
| 12 #import "ios/chrome/browser/browser_coordinator+internal.h" |
| 13 #import "ios/chrome/browser/ui/toolbar/toolbar_view_controller.h" |
| 14 #import "ios/chrome/browser/ui/tools/tools_coordinator.h" |
| 15 #include "ios/web/public/web_state/web_state.h" |
| 16 |
| 17 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 18 #error "This file requires ARC support." |
| 19 #endif |
| 20 |
| 21 @interface ToolbarCoordinator ()<ToolbarActionDelegate> |
| 22 @property(nonatomic, weak) ToolsCoordinator* toolsMenuCoordinator; |
| 23 @property(nonatomic, strong) ToolbarViewController* viewController; |
| 24 @end |
| 25 |
| 26 @implementation ToolbarCoordinator |
| 27 @synthesize toolsMenuCoordinator = _toolsMenuCoordinator; |
| 28 @synthesize viewController = _viewController; |
| 29 |
| 30 - (void)start { |
| 31 self.viewController = [[ToolbarViewController alloc] init]; |
| 32 self.viewController.actionDelegate = self; |
| 33 |
| 34 [self.rootViewController presentViewController:self.viewController |
| 35 animated:YES |
| 36 completion:nil]; |
| 37 } |
| 38 |
| 39 #pragma mark - CRWWebStateObserver |
| 40 |
| 41 - (void)webStateDidLoadPage:(web::WebState*)webState { |
| 42 const GURL& pageURL = webState->GetVisibleURL(); |
| 43 [self.viewController |
| 44 setCurrentPageText:base::SysUTF8ToNSString(pageURL.spec())]; |
| 45 } |
| 46 |
| 47 #pragma mark - ToolbarActionDelegate |
| 48 |
| 49 - (void)showToolsMenu { |
| 50 ToolsCoordinator* toolsCoordinator = [[ToolsCoordinator alloc] init]; |
| 51 [self addChildCoordinator:toolsCoordinator]; |
| 52 [toolsCoordinator start]; |
| 53 self.toolsMenuCoordinator = toolsCoordinator; |
| 54 } |
| 55 |
| 56 - (void)closeToolsMenu { |
| 57 [self.toolsMenuCoordinator stop]; |
| 58 [self removeChildCoordinator:self.toolsMenuCoordinator]; |
| 59 } |
| 60 |
| 61 @end |
OLD | NEW |