| 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 // ====== New Architecture ===== | 5 // ====== New Architecture ===== |
| 6 // = This code is only used in the new iOS Chrome architecture. = | 6 // = This code is only used in the new iOS Chrome architecture. = |
| 7 // ============================================================================ | 7 // ============================================================================ |
| 8 | 8 |
| 9 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_coordinator.h" | 9 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_coordinator.h" |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 | 12 |
| 13 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
| 14 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 14 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 15 #import "ios/clean/chrome/browser/browser_coordinator+internal.h" | 15 #import "ios/clean/chrome/browser/browser_coordinator+internal.h" |
| 16 #import "ios/clean/chrome/browser/ui/commands/settings_commands.h" | 16 #import "ios/clean/chrome/browser/ui/commands/settings_commands.h" |
| 17 #import "ios/clean/chrome/browser/ui/commands/tab_commands.h" | 17 #import "ios/clean/chrome/browser/ui/commands/tab_commands.h" |
| 18 #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h" | 18 #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h" |
| 19 #import "ios/clean/chrome/browser/ui/settings/settings_coordinator.h" | 19 #import "ios/clean/chrome/browser/ui/settings/settings_coordinator.h" |
| 20 #import "ios/clean/chrome/browser/ui/tab/tab_coordinator.h" |
| 20 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.h" | 21 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.h" |
| 21 #import "ios/clean/chrome/browser/ui/tab_strip/tab_strip_container_coordinator.h
" | |
| 22 #import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h" | 22 #import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h" |
| 23 #import "ios/web/public/navigation_manager.h" | 23 #import "ios/web/public/navigation_manager.h" |
| 24 #include "ios/web/public/web_state/web_state.h" | 24 #include "ios/web/public/web_state/web_state.h" |
| 25 #import "net/base/mac/url_conversions.h" | 25 #import "net/base/mac/url_conversions.h" |
| 26 #include "ui/base/page_transition_types.h" | 26 #include "ui/base/page_transition_types.h" |
| 27 | 27 |
| 28 #if !defined(__has_feature) || !__has_feature(objc_arc) | 28 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 29 #error "This file requires ARC support." | 29 #error "This file requires ARC support." |
| 30 #endif | 30 #endif |
| 31 | 31 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 NSString* urlText = @"<New Tab>"; | 90 NSString* urlText = @"<New Tab>"; |
| 91 if (url.is_valid()) { | 91 if (url.is_valid()) { |
| 92 urlText = base::SysUTF8ToNSString(url.spec()); | 92 urlText = base::SysUTF8ToNSString(url.spec()); |
| 93 } | 93 } |
| 94 return urlText; | 94 return urlText; |
| 95 } | 95 } |
| 96 | 96 |
| 97 #pragma mark - TabCommands | 97 #pragma mark - TabCommands |
| 98 | 98 |
| 99 - (void)showTabAtIndexPath:(NSIndexPath*)indexPath { | 99 - (void)showTabAtIndexPath:(NSIndexPath*)indexPath { |
| 100 TabStripContainerCoordinator* tabCoordinator = | 100 TabCoordinator* tabCoordinator = [[TabCoordinator alloc] init]; |
| 101 [[TabStripContainerCoordinator alloc] init]; | |
| 102 size_t index = static_cast<size_t>(indexPath.item); | 101 size_t index = static_cast<size_t>(indexPath.item); |
| 103 DCHECK(index < _webStates.size()); | 102 DCHECK(index < _webStates.size()); |
| 104 tabCoordinator.webState = _webStates[index].get(); | 103 tabCoordinator.webState = _webStates[index].get(); |
| 105 tabCoordinator.presentationKey = indexPath; | 104 tabCoordinator.presentationKey = indexPath; |
| 106 [self addChildCoordinator:tabCoordinator]; | 105 [self addChildCoordinator:tabCoordinator]; |
| 107 [tabCoordinator start]; | 106 [tabCoordinator start]; |
| 108 _activeWebStateIndex = index; | 107 _activeWebStateIndex = index; |
| 109 } | 108 } |
| 110 | 109 |
| 111 #pragma mark - TabGridCommands | 110 #pragma mark - TabGridCommands |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 activeWebState->GetNavigationManager()->LoadURLWithParams(params); | 145 activeWebState->GetNavigationManager()->LoadURLWithParams(params); |
| 147 if (!self.children.count) { | 146 if (!self.children.count) { |
| 148 [self showTabAtIndexPath:[NSIndexPath | 147 [self showTabAtIndexPath:[NSIndexPath |
| 149 indexPathForItem:static_cast<NSUInteger>( | 148 indexPathForItem:static_cast<NSUInteger>( |
| 150 _activeWebStateIndex) | 149 _activeWebStateIndex) |
| 151 inSection:0]]; | 150 inSection:0]]; |
| 152 } | 151 } |
| 153 } | 152 } |
| 154 | 153 |
| 155 @end | 154 @end |
| OLD | NEW |