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 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 #pragma mark - Properties | 47 #pragma mark - Properties |
48 | 48 |
49 - (void)setBrowser:(Browser*)browser { | 49 - (void)setBrowser:(Browser*)browser { |
50 [super setBrowser:browser]; | 50 [super setBrowser:browser]; |
51 | 51 |
52 for (int i = 0; i < 7; i++) { | 52 for (int i = 0; i < 7; i++) { |
53 web::WebState::CreateParams webStateCreateParams(browser->browser_state()); | 53 web::WebState::CreateParams webStateCreateParams(browser->browser_state()); |
54 std::unique_ptr<web::WebState> webState = | 54 std::unique_ptr<web::WebState> webState = |
55 web::WebState::Create(webStateCreateParams); | 55 web::WebState::Create(webStateCreateParams); |
56 self.webStateList.InsertWebState(0, webState.release(), nullptr); | 56 self.webStateList.InsertWebState(0, webState.release()); |
57 } | 57 } |
58 self.webStateList.ActivateWebStateAt(0); | 58 self.webStateList.ActivateWebStateAt(0); |
59 } | 59 } |
60 | 60 |
61 - (WebStateList&)webStateList { | 61 - (WebStateList&)webStateList { |
62 return self.browser->web_state_list(); | 62 return self.browser->web_state_list(); |
63 } | 63 } |
64 | 64 |
65 #pragma mark - BrowserCoordinator | 65 #pragma mark - BrowserCoordinator |
66 | 66 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 std::unique_ptr<web::WebState> closedWebState( | 103 std::unique_ptr<web::WebState> closedWebState( |
104 self.webStateList.DetachWebStateAt(index)); | 104 self.webStateList.DetachWebStateAt(index)); |
105 } | 105 } |
106 | 106 |
107 - (void)createAndShowNewTab { | 107 - (void)createAndShowNewTab { |
108 web::WebState::CreateParams webStateCreateParams( | 108 web::WebState::CreateParams webStateCreateParams( |
109 self.browser->browser_state()); | 109 self.browser->browser_state()); |
110 std::unique_ptr<web::WebState> webState = | 110 std::unique_ptr<web::WebState> webState = |
111 web::WebState::Create(webStateCreateParams); | 111 web::WebState::Create(webStateCreateParams); |
112 self.webStateList.InsertWebState(self.webStateList.count(), | 112 self.webStateList.InsertWebState(self.webStateList.count(), |
113 webState.release(), nullptr); | 113 webState.release()); |
114 [self showTabAtIndex:self.webStateList.count() - 1]; | 114 [self showTabAtIndex:self.webStateList.count() - 1]; |
115 } | 115 } |
116 | 116 |
117 #pragma mark - TabGridCommands | 117 #pragma mark - TabGridCommands |
118 | 118 |
119 - (void)showTabGrid { | 119 - (void)showTabGrid { |
120 // This object should only ever have at most one child. | 120 // This object should only ever have at most one child. |
121 DCHECK_LE(self.children.count, 1UL); | 121 DCHECK_LE(self.children.count, 1UL); |
122 BrowserCoordinator* child = [self.children anyObject]; | 122 BrowserCoordinator* child = [self.children anyObject]; |
123 [child stop]; | 123 [child stop]; |
(...skipping 28 matching lines...) Expand all Loading... |
152 web::WebState* activeWebState = self.webStateList.GetActiveWebState(); | 152 web::WebState* activeWebState = self.webStateList.GetActiveWebState(); |
153 web::NavigationManager::WebLoadParams params(net::GURLWithNSURL(URL)); | 153 web::NavigationManager::WebLoadParams params(net::GURLWithNSURL(URL)); |
154 params.transition_type = ui::PAGE_TRANSITION_LINK; | 154 params.transition_type = ui::PAGE_TRANSITION_LINK; |
155 activeWebState->GetNavigationManager()->LoadURLWithParams(params); | 155 activeWebState->GetNavigationManager()->LoadURLWithParams(params); |
156 if (!self.children.count) { | 156 if (!self.children.count) { |
157 [self showTabAtIndex:self.webStateList.active_index()]; | 157 [self showTabAtIndex:self.webStateList.active_index()]; |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 @end | 161 @end |
OLD | NEW |