| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/tab_collection/tab_collection_mediator.h" | 5 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/scoped_observer.h" | 8 #include "base/scoped_observer.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #import "ios/chrome/browser/web_state_list/web_state_list.h" | 10 #import "ios/chrome/browser/web_state_list/web_state_list.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 #pragma mark - Public | 43 #pragma mark - Public |
| 44 | 44 |
| 45 - (void)disconnect { | 45 - (void)disconnect { |
| 46 self.webStateList = nullptr; | 46 self.webStateList = nullptr; |
| 47 } | 47 } |
| 48 | 48 |
| 49 #pragma mark - Properties | 49 #pragma mark - Properties |
| 50 | 50 |
| 51 - (void)setWebStateList:(WebStateList*)webStateList { | 51 - (void)setWebStateList:(WebStateList*)webStateList { |
| 52 // TODO(crbug.com/727427):Add support for DCHECK(webStateList). |
| 52 _scopedWebStateListObserver->RemoveAll(); | 53 _scopedWebStateListObserver->RemoveAll(); |
| 53 _webStateList = webStateList; | 54 _webStateList = webStateList; |
| 54 [self populateConsumerItems]; | 55 [self populateConsumerItems]; |
| 55 if (_webStateList) { | 56 if (_webStateList) { |
| 56 _scopedWebStateListObserver->Add(_webStateList); | 57 _scopedWebStateListObserver->Add(_webStateList); |
| 57 } | 58 } |
| 58 } | 59 } |
| 59 | 60 |
| 60 - (void)setConsumer:(id<TabCollectionConsumer>)consumer { | 61 - (void)setConsumer:(id<TabCollectionConsumer>)consumer { |
| 61 _consumer = consumer; | 62 _consumer = consumer; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 138 |
| 138 - (void)populateConsumerItems { | 139 - (void)populateConsumerItems { |
| 139 if (self.consumer && self.webStateList) { | 140 if (self.consumer && self.webStateList) { |
| 140 [self.consumer populateItems:[self tabCollectionItemsFromWebStateList: | 141 [self.consumer populateItems:[self tabCollectionItemsFromWebStateList: |
| 141 self.webStateList]]; | 142 self.webStateList]]; |
| 142 [self.consumer selectItemAtIndex:self.webStateList->active_index()]; | 143 [self.consumer selectItemAtIndex:self.webStateList->active_index()]; |
| 143 } | 144 } |
| 144 } | 145 } |
| 145 | 146 |
| 146 @end | 147 @end |
| OLD | NEW |