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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 - (void)dealloc { | 44 - (void)dealloc { |
45 [self disconnect]; | 45 [self disconnect]; |
46 } | 46 } |
47 | 47 |
48 #pragma mark - Public | 48 #pragma mark - Public |
49 | 49 |
50 - (void)disconnect { | 50 - (void)disconnect { |
51 _webStateList = nullptr; | 51 _webStateList = nullptr; |
52 _webStateObserver.reset(); | 52 _webStateObserver.reset(); |
| 53 _scopedWebStateListObserver->RemoveAll(); |
53 } | 54 } |
54 | 55 |
55 #pragma mark - Properties | 56 #pragma mark - Properties |
56 | 57 |
57 - (void)setWebStateList:(WebStateList*)webStateList { | 58 - (void)setWebStateList:(WebStateList*)webStateList { |
58 DCHECK(webStateList); | 59 DCHECK(webStateList); |
59 _scopedWebStateListObserver->RemoveAll(); | 60 _scopedWebStateListObserver->RemoveAll(); |
60 _webStateList = webStateList; | 61 _webStateList = webStateList; |
61 _scopedWebStateListObserver->Add(_webStateList); | 62 _scopedWebStateListObserver->Add(_webStateList); |
62 _webStateObserver = base::MakeUnique<web::WebStateObserverBridge>( | 63 _webStateObserver = base::MakeUnique<web::WebStateObserverBridge>( |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 - (void)populateConsumerItems { | 168 - (void)populateConsumerItems { |
168 if (self.consumer && self.webStateList) { | 169 if (self.consumer && self.webStateList) { |
169 [self.consumer | 170 [self.consumer |
170 populateItems:[self | 171 populateItems:[self |
171 tabCollectionItemsFromWebStateList:self.webStateList] | 172 tabCollectionItemsFromWebStateList:self.webStateList] |
172 selectedIndex:self.webStateList->active_index()]; | 173 selectedIndex:self.webStateList->active_index()]; |
173 } | 174 } |
174 } | 175 } |
175 | 176 |
176 @end | 177 @end |
OLD | NEW |