Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(576)

Unified Diff: ios/clean/chrome/browser/ui/omnibox/location_bar_mediator.mm

Issue 2820493002: Use a scoped WebStateListObserverBridge. (Closed)
Patch Set: Feedback Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « no previous file | ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698