| Index: ios/clean/chrome/browser/ui/omnibox/location_bar_mediator.mm
 | 
| diff --git a/ios/clean/chrome/browser/ui/omnibox/location_bar_mediator.mm b/ios/clean/chrome/browser/ui/omnibox/location_bar_mediator.mm
 | 
| index 1ff70c0ea6e5fb63a75394fc04e1e802c5b9502c..99ccc909045783ea1aac6bb6d5174029316e00b9 100644
 | 
| --- a/ios/clean/chrome/browser/ui/omnibox/location_bar_mediator.mm
 | 
| +++ b/ios/clean/chrome/browser/ui/omnibox/location_bar_mediator.mm
 | 
| @@ -5,6 +5,7 @@
 | 
|  #import "ios/clean/chrome/browser/ui/omnibox/location_bar_mediator.h"
 | 
|  
 | 
|  #include "base/memory/ptr_util.h"
 | 
| +#include "base/scoped_observer.h"
 | 
|  #include "base/strings/utf_string_conversions.h"
 | 
|  #include "ios/chrome/browser/ui/toolbar/toolbar_model_delegate_ios.h"
 | 
|  #include "ios/chrome/browser/ui/toolbar/toolbar_model_impl_ios.h"
 | 
| @@ -29,6 +30,8 @@
 | 
|    // Observes the WebStateList so that this mediator can update the UI when the
 | 
|    // active WebState changes.
 | 
|    std::unique_ptr<WebStateListObserverBridge> _webStateListObserver;
 | 
| +  std::unique_ptr<ScopedObserver<WebStateList, WebStateListObserverBridge>>
 | 
| +      _scopedWebStateListObserver;
 | 
|  
 | 
|    // Used to update the UI in response to WebState observer notifications.  This
 | 
|    // observer is always observing the currently-active WebState and may be
 | 
| @@ -54,7 +57,10 @@
 | 
|      _webStateList = webStateList;
 | 
|  
 | 
|      _webStateListObserver = base::MakeUnique<WebStateListObserverBridge>(self);
 | 
| -    _webStateList->AddObserver(_webStateListObserver.get());
 | 
| +    _scopedWebStateListObserver = base::MakeUnique<
 | 
| +        ScopedObserver<WebStateList, WebStateListObserverBridge>>(
 | 
| +        _webStateListObserver.get());
 | 
| +    _scopedWebStateListObserver->Add(_webStateList);
 | 
|      web::WebState* webState = _webStateList->GetActiveWebState();
 | 
|      if (webState) {
 | 
|        _webStateObserver =
 | 
| @@ -69,10 +75,6 @@
 | 
|    return self;
 | 
|  }
 | 
|  
 | 
| -- (void)dealloc {
 | 
| -  _webStateList->RemoveObserver(_webStateListObserver.get());
 | 
| -}
 | 
| -
 | 
|  - (void)setLocationBar:(std::unique_ptr<LocationBarController>)locationBar {
 | 
|    _locationBar = std::move(locationBar);
 | 
|    _locationBar->OnToolbarUpdated();
 | 
| 
 |