| 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/commands/toolbar_commands.h" | |
| 14 #import "ios/chrome/browser/ui/toolbar/toolbar_view_controller.h" | |
| 15 #import "ios/chrome/browser/ui/tools/tools_coordinator.h" | |
| 16 #include "ios/web/public/web_state/web_state.h" | |
| 17 | |
| 18 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 19 #error "This file requires ARC support." | |
| 20 #endif | |
| 21 | |
| 22 @interface ToolbarCoordinator ()<ToolbarCommands> | |
| 23 @property(nonatomic, weak) ToolsCoordinator* toolsMenuCoordinator; | |
| 24 @property(nonatomic, strong) ToolbarViewController* viewController; | |
| 25 @end | |
| 26 | |
| 27 @implementation ToolbarCoordinator | |
| 28 @synthesize toolsMenuCoordinator = _toolsMenuCoordinator; | |
| 29 @synthesize viewController = _viewController; | |
| 30 | |
| 31 - (void)start { | |
| 32 self.viewController = [[ToolbarViewController alloc] init]; | |
| 33 self.viewController.toolbarCommandHandler = self; | |
| 34 | |
| 35 [self.rootViewController presentViewController:self.viewController | |
| 36 animated:YES | |
| 37 completion:nil]; | |
| 38 } | |
| 39 | |
| 40 #pragma mark - CRWWebStateObserver | |
| 41 | |
| 42 - (void)webState:(web::WebState*)webState didLoadPageWithSuccess:(BOOL)success { | |
| 43 const GURL& pageURL = webState->GetVisibleURL(); | |
| 44 [self.viewController | |
| 45 setCurrentPageText:base::SysUTF8ToNSString(pageURL.spec())]; | |
| 46 } | |
| 47 | |
| 48 #pragma mark - ToolbarCommands | |
| 49 | |
| 50 - (void)showToolsMenu { | |
| 51 ToolsCoordinator* toolsCoordinator = [[ToolsCoordinator alloc] init]; | |
| 52 [self addChildCoordinator:toolsCoordinator]; | |
| 53 [toolsCoordinator start]; | |
| 54 self.toolsMenuCoordinator = toolsCoordinator; | |
| 55 } | |
| 56 | |
| 57 - (void)closeToolsMenu { | |
| 58 [self.toolsMenuCoordinator stop]; | |
| 59 [self removeChildCoordinator:self.toolsMenuCoordinator]; | |
| 60 } | |
| 61 | |
| 62 @end | |
| OLD | NEW |