| Index: ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.mm
|
| diff --git a/ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.mm b/ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.mm
|
| index dcf98cfadba86dd395bae0f67cedaeeabbb9d66a..a8a89f6c7da1ed06cd281bdbc741f51abe7e8c00 100644
|
| --- a/ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.mm
|
| +++ b/ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.mm
|
| @@ -5,6 +5,7 @@
|
| #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.h"
|
|
|
| #include "base/memory/ptr_util.h"
|
| +#include "base/scoped_observer.h"
|
| #include "base/strings/sys_string_conversions.h"
|
| #import "ios/chrome/browser/web_state_list/web_state_list.h"
|
| #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_consumer.h"
|
| @@ -16,11 +17,24 @@
|
|
|
| @implementation TabCollectionMediator {
|
| std::unique_ptr<WebStateListObserverBridge> _webStateListObserver;
|
| + std::unique_ptr<ScopedObserver<WebStateList, WebStateListObserverBridge>>
|
| + _scopedWebStateListObserver;
|
| }
|
|
|
| @synthesize webStateList = _webStateList;
|
| @synthesize consumer = _consumer;
|
|
|
| +- (instancetype)init {
|
| + self = [super init];
|
| + if (self) {
|
| + _webStateListObserver = base::MakeUnique<WebStateListObserverBridge>(self);
|
| + _scopedWebStateListObserver = base::MakeUnique<
|
| + ScopedObserver<WebStateList, WebStateListObserverBridge>>(
|
| + _webStateListObserver.get());
|
| + }
|
| + return self;
|
| +}
|
| +
|
| - (void)dealloc {
|
| [self disconnect];
|
| }
|
| @@ -34,16 +48,12 @@
|
| #pragma mark - Properties
|
|
|
| - (void)setWebStateList:(WebStateList*)webStateList {
|
| - if (_webStateList) {
|
| - _webStateList->RemoveObserver(_webStateListObserver.get());
|
| - _webStateListObserver.reset();
|
| - }
|
| + _scopedWebStateListObserver->RemoveAll();
|
| _webStateList = webStateList;
|
| if (!_webStateList) {
|
| return;
|
| }
|
| - _webStateListObserver = base::MakeUnique<WebStateListObserverBridge>(self);
|
| - _webStateList->AddObserver(_webStateListObserver.get());
|
| + _scopedWebStateListObserver->Add(_webStateList);
|
| }
|
|
|
| #pragma mark - TabCollectionDataSource
|
|
|