Commit 6eca52e4 authored by Sigurdur Asgeirsson's avatar Sigurdur Asgeirsson Committed by Commit Bot

Retire ScopedObserver in /chrome/browser/ui/views.

ScopedObserver is being deprecated in favor of two new classes:
- base::ScopedObservation for observers that only ever observe
  a single source.
- base::ScopedMultiSourceObservation for observers that do or may
  observe more than a single source.

This CL was uploaded by git cl split.

R=bsep@chromium.org

Bug: 1145565
Change-Id: Idda03ba1fa22200f7637e542e9bca67abc246dc1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2548022
Commit-Queue: Sigurður Ásgeirsson <siggi@chromium.org>
Auto-Submit: Sigurður Ásgeirsson <siggi@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829296}
parent 0ab2a94d
...@@ -99,8 +99,9 @@ ExclusiveAccessBubbleViews::ExclusiveAccessBubbleViews( ...@@ -99,8 +99,9 @@ ExclusiveAccessBubbleViews::ExclusiveAccessBubbleViews(
view_->SetBounds(0, 0, size.width(), size.height()); view_->SetBounds(0, 0, size.width(), size.height());
popup_->AddObserver(this); popup_->AddObserver(this);
fullscreen_observer_.Add(bubble_view_context_->GetExclusiveAccessManager() fullscreen_observation_.Observe(
->fullscreen_controller()); bubble_view_context_->GetExclusiveAccessManager()
->fullscreen_controller());
UpdateMouseWatcher(); UpdateMouseWatcher();
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/scoped_observer.h" #include "base/scoped_observation.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_bubble.h" #include "chrome/browser/ui/exclusive_access/exclusive_access_bubble.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_bubble_hide_callback.h" #include "chrome/browser/ui/exclusive_access/exclusive_access_bubble_hide_callback.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
...@@ -115,8 +115,8 @@ class ExclusiveAccessBubbleViews : public ExclusiveAccessBubble, ...@@ -115,8 +115,8 @@ class ExclusiveAccessBubbleViews : public ExclusiveAccessBubble,
SubtleNotificationView* view_; SubtleNotificationView* view_;
base::string16 browser_fullscreen_exit_accelerator_; base::string16 browser_fullscreen_exit_accelerator_;
ScopedObserver<FullscreenController, FullscreenObserver> fullscreen_observer_{ base::ScopedObservation<FullscreenController, FullscreenObserver>
this}; fullscreen_observation_{this};
DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessBubbleViews); DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessBubbleViews);
}; };
......
...@@ -91,7 +91,7 @@ FlyingIndicator::FlyingIndicator(const gfx::VectorIcon& icon, ...@@ -91,7 +91,7 @@ FlyingIndicator::FlyingIndicator(const gfx::VectorIcon& icon,
views::BubbleDialogDelegateView* const bubble_view_ptr = bubble_view.get(); views::BubbleDialogDelegateView* const bubble_view_ptr = bubble_view.get();
widget_ = widget_ =
views::BubbleDialogDelegateView::CreateBubble(std::move(bubble_view)); views::BubbleDialogDelegateView::CreateBubble(std::move(bubble_view));
scoped_observer_.Add(widget_); scoped_observation_.Observe(widget_);
// Set required frame properties. // Set required frame properties.
views::BubbleFrameView* const frame_view = views::BubbleFrameView* const frame_view =
...@@ -111,7 +111,8 @@ FlyingIndicator::FlyingIndicator(const gfx::VectorIcon& icon, ...@@ -111,7 +111,8 @@ FlyingIndicator::FlyingIndicator(const gfx::VectorIcon& icon,
FlyingIndicator::~FlyingIndicator() { FlyingIndicator::~FlyingIndicator() {
// Kill the callback before deleting the widget so we don't call it. // Kill the callback before deleting the widget so we don't call it.
done_callback_.Reset(); done_callback_.Reset();
scoped_observer_.RemoveAll(); if (scoped_observation_.IsObserving())
scoped_observation_.RemoveObservation();
if (widget_) if (widget_)
widget_->Close(); widget_->Close();
} }
...@@ -119,7 +120,7 @@ FlyingIndicator::~FlyingIndicator() { ...@@ -119,7 +120,7 @@ FlyingIndicator::~FlyingIndicator() {
void FlyingIndicator::OnWidgetDestroyed(views::Widget* widget) { void FlyingIndicator::OnWidgetDestroyed(views::Widget* widget) {
if (widget != widget_) if (widget != widget_)
return; return;
scoped_observer_.Remove(widget_); scoped_observation_.RemoveObservation();
widget_ = nullptr; widget_ = nullptr;
animation_.Stop(); animation_.Stop();
if (done_callback_) if (done_callback_)
...@@ -182,7 +183,7 @@ void FlyingIndicator::AnimationEnded(const gfx::Animation* animation) { ...@@ -182,7 +183,7 @@ void FlyingIndicator::AnimationEnded(const gfx::Animation* animation) {
if (done_callback_) if (done_callback_)
std::move(done_callback_).Run(); std::move(done_callback_).Run();
if (widget_) { if (widget_) {
scoped_observer_.Remove(widget_); scoped_observation_.RemoveObservation();
widget_->Close(); widget_->Close();
widget_ = nullptr; widget_ = nullptr;
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_VIEWS_FLYING_INDICATOR_H_ #define CHROME_BROWSER_UI_VIEWS_FLYING_INDICATOR_H_
#include "base/callback.h" #include "base/callback.h"
#include "base/scoped_observer.h" #include "base/scoped_observation.h"
#include "ui/gfx/animation/animation_delegate.h" #include "ui/gfx/animation/animation_delegate.h"
#include "ui/gfx/animation/multi_animation.h" #include "ui/gfx/animation/multi_animation.h"
#include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/point.h"
...@@ -74,7 +74,8 @@ class FlyingIndicator : public views::WidgetObserver, ...@@ -74,7 +74,8 @@ class FlyingIndicator : public views::WidgetObserver,
gfx::MultiAnimation animation_; gfx::MultiAnimation animation_;
base::OnceClosure done_callback_; base::OnceClosure done_callback_;
views::Widget* widget_ = nullptr; views::Widget* widget_ = nullptr;
ScopedObserver<views::Widget, views::WidgetObserver> scoped_observer_{this}; base::ScopedObservation<views::Widget, views::WidgetObserver>
scoped_observation_{this};
}; };
#endif // CHROME_BROWSER_UI_VIEWS_FLYING_INDICATOR_H_ #endif // CHROME_BROWSER_UI_VIEWS_FLYING_INDICATOR_H_
...@@ -162,7 +162,7 @@ HoverButton::HoverButton(PressedCallback callback, ...@@ -162,7 +162,7 @@ HoverButton::HoverButton(PressedCallback callback,
label_wrapper_ = AddChildView(std::move(label_wrapper)); label_wrapper_ = AddChildView(std::move(label_wrapper));
// Observe |label_wrapper_| bounds changes to ensure the HoverButton tooltip // Observe |label_wrapper_| bounds changes to ensure the HoverButton tooltip
// is kept in sync with the size. // is kept in sync with the size.
observed_label_.Add(label_wrapper_); label_observation_.Observe(label_wrapper_);
if (secondary_view) { if (secondary_view) {
secondary_view->SetCanProcessEventsWithinSubtree( secondary_view->SetCanProcessEventsWithinSubtree(
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/scoped_observer.h" #include "base/scoped_observation.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "ui/views/controls/button/button.h" #include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/menu_button.h" #include "ui/views/controls/button/menu_button.h"
...@@ -107,7 +107,8 @@ class HoverButton : public views::LabelButton { ...@@ -107,7 +107,8 @@ class HoverButton : public views::LabelButton {
views::View* icon_view_ = nullptr; views::View* icon_view_ = nullptr;
views::View* secondary_view_ = nullptr; views::View* secondary_view_ = nullptr;
ScopedObserver<views::View, views::ViewObserver> observed_label_{this}; base::ScopedObservation<views::View, views::ViewObserver> label_observation_{
this};
DISALLOW_COPY_AND_ASSIGN(HoverButton); DISALLOW_COPY_AND_ASSIGN(HoverButton);
}; };
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "chrome/browser/ui/hung_plugin_tab_helper.h" #include "chrome/browser/ui/hung_plugin_tab_helper.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/scoped_observer.h" #include "base/scoped_observation.h"
#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/ui/views/infobars/confirm_infobar.h" #include "chrome/browser/ui/views/infobars/confirm_infobar.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h"
...@@ -26,13 +26,14 @@ class HungPluginInfoBarObserver : public infobars::InfoBarManager::Observer { ...@@ -26,13 +26,14 @@ class HungPluginInfoBarObserver : public infobars::InfoBarManager::Observer {
private: private:
bool seen_removal_ = false; bool seen_removal_ = false;
ScopedObserver<infobars::InfoBarManager, infobars::InfoBarManager::Observer> base::ScopedObservation<infobars::InfoBarManager,
infobar_observer_{this}; infobars::InfoBarManager::Observer>
infobar_observation_{this};
}; };
HungPluginInfoBarObserver::HungPluginInfoBarObserver( HungPluginInfoBarObserver::HungPluginInfoBarObserver(
infobars::InfoBarManager* manager) { infobars::InfoBarManager* manager) {
infobar_observer_.Add(manager); infobar_observation_.Observe(manager);
} }
void HungPluginInfoBarObserver::OnInfoBarRemoved(infobars::InfoBar* infobar, void HungPluginInfoBarObserver::OnInfoBarRemoved(infobars::InfoBar* infobar,
......
...@@ -80,8 +80,8 @@ void HungPagesTableModel::InitForWebContents( ...@@ -80,8 +80,8 @@ void HungPagesTableModel::InitForWebContents(
DCHECK(!hang_monitor_restarter.is_null()); DCHECK(!hang_monitor_restarter.is_null());
DCHECK(!render_widget_host_); DCHECK(!render_widget_host_);
DCHECK(!process_observer_.IsObservingSources()); DCHECK(!process_observation_.IsObserving());
DCHECK(!widget_observer_.IsObservingSources()); DCHECK(!widget_observation_.IsObserving());
DCHECK(tab_observers_.empty()); DCHECK(tab_observers_.empty());
render_widget_host_ = render_widget_host; render_widget_host_ = render_widget_host;
...@@ -93,8 +93,8 @@ void HungPagesTableModel::InitForWebContents( ...@@ -93,8 +93,8 @@ void HungPagesTableModel::InitForWebContents(
std::make_unique<WebContentsObserverImpl>(this, hung_contents)); std::make_unique<WebContentsObserverImpl>(this, hung_contents));
} }
process_observer_.Add(render_widget_host_->GetProcess()); process_observation_.Observe(render_widget_host_->GetProcess());
widget_observer_.Add(render_widget_host_); widget_observation_.Observe(render_widget_host_);
// The world is different. // The world is different.
if (observer_) if (observer_)
...@@ -102,8 +102,8 @@ void HungPagesTableModel::InitForWebContents( ...@@ -102,8 +102,8 @@ void HungPagesTableModel::InitForWebContents(
} }
void HungPagesTableModel::Reset() { void HungPagesTableModel::Reset() {
process_observer_.RemoveAll(); process_observation_.RemoveObservation();
widget_observer_.RemoveAll(); widget_observation_.RemoveObservation();
tab_observers_.clear(); tab_observers_.clear();
render_widget_host_ = nullptr; render_widget_host_ = nullptr;
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/scoped_observer.h" #include "base/scoped_observation.h"
#include "components/favicon/content/content_favicon_driver.h" #include "components/favicon/content/content_favicon_driver.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_process_host_observer.h" #include "content/public/browser/render_process_host_observer.h"
...@@ -124,11 +124,13 @@ class HungPagesTableModel : public ui::TableModel, ...@@ -124,11 +124,13 @@ class HungPagesTableModel : public ui::TableModel,
// some more until the renderer process responds). // some more until the renderer process responds).
base::RepeatingClosure hang_monitor_restarter_; base::RepeatingClosure hang_monitor_restarter_;
ScopedObserver<content::RenderProcessHost, content::RenderProcessHostObserver> base::ScopedObservation<content::RenderProcessHost,
process_observer_{this}; content::RenderProcessHostObserver>
process_observation_{this};
ScopedObserver<content::RenderWidgetHost, content::RenderWidgetHostObserver> base::ScopedObservation<content::RenderWidgetHost,
widget_observer_{this}; content::RenderWidgetHostObserver>
widget_observation_{this};
DISALLOW_COPY_AND_ASSIGN(HungPagesTableModel); DISALLOW_COPY_AND_ASSIGN(HungPagesTableModel);
}; };
......
...@@ -89,7 +89,7 @@ class SendKeysMenuListener : public AppMenuButtonObserver { ...@@ -89,7 +89,7 @@ class SendKeysMenuListener : public AppMenuButtonObserver {
: browser_(browser), : browser_(browser),
menu_open_count_(0), menu_open_count_(0),
test_dismiss_menu_(test_dismiss_menu) { test_dismiss_menu_(test_dismiss_menu) {
observer_.Add(app_menu_button); observation_.Observe(app_menu_button);
} }
~SendKeysMenuListener() override = default; ~SendKeysMenuListener() override = default;
...@@ -103,7 +103,7 @@ class SendKeysMenuListener : public AppMenuButtonObserver { ...@@ -103,7 +103,7 @@ class SendKeysMenuListener : public AppMenuButtonObserver {
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(), FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
base::TimeDelta::FromMilliseconds(200)); base::TimeDelta::FromMilliseconds(200));
} else { } else {
observer_.RemoveAll(); observation_.RemoveObservation();
// Press DOWN to select the first item, then RETURN to select it. // Press DOWN to select the first item, then RETURN to select it.
SendKeyPress(browser_, ui::VKEY_DOWN); SendKeyPress(browser_, ui::VKEY_DOWN);
SendKeyPress(browser_, ui::VKEY_RETURN); SendKeyPress(browser_, ui::VKEY_RETURN);
...@@ -120,7 +120,8 @@ class SendKeysMenuListener : public AppMenuButtonObserver { ...@@ -120,7 +120,8 @@ class SendKeysMenuListener : public AppMenuButtonObserver {
// we dismiss it by sending the ESC key. // we dismiss it by sending the ESC key.
bool test_dismiss_menu_; bool test_dismiss_menu_;
ScopedObserver<AppMenuButton, AppMenuButtonObserver> observer_{this}; base::ScopedObservation<AppMenuButton, AppMenuButtonObserver> observation_{
this};
DISALLOW_COPY_AND_ASSIGN(SendKeysMenuListener); DISALLOW_COPY_AND_ASSIGN(SendKeysMenuListener);
}; };
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "base/macros.h" #include "base/macros.h"
#include "base/scoped_observation.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/ui/views/menu_test_base.h" #include "chrome/browser/ui/views/menu_test_base.h"
...@@ -189,8 +190,8 @@ class MenuViewDragAndDropTest : public MenuTestBase, ...@@ -189,8 +190,8 @@ class MenuViewDragAndDropTest : public MenuTestBase,
// in separate child views). // in separate child views).
bool performed_in_menu_drop_ = false; bool performed_in_menu_drop_ = false;
ScopedObserver<views::Widget, views::WidgetObserver> widget_observer_{this}; base::ScopedObservation<views::Widget, views::WidgetObserver>
widget_observation_{this};
DISALLOW_COPY_AND_ASSIGN(MenuViewDragAndDropTest); DISALLOW_COPY_AND_ASSIGN(MenuViewDragAndDropTest);
}; };
...@@ -220,7 +221,7 @@ void MenuViewDragAndDropTest::DoTestWithMenuOpen() { ...@@ -220,7 +221,7 @@ void MenuViewDragAndDropTest::DoTestWithMenuOpen() {
EXPECT_EQ(child_view, target_view_); EXPECT_EQ(child_view, target_view_);
// The menu is showing, so it has a widget we can observe now. // The menu is showing, so it has a widget we can observe now.
widget_observer_.Add(submenu->GetWidget()); widget_observation_.Observe(submenu->GetWidget());
// We do this here (instead of in BuildMenu()) so that the menu is already // We do this here (instead of in BuildMenu()) so that the menu is already
// built and the bounds are correct. // built and the bounds are correct.
...@@ -228,7 +229,8 @@ void MenuViewDragAndDropTest::DoTestWithMenuOpen() { ...@@ -228,7 +229,8 @@ void MenuViewDragAndDropTest::DoTestWithMenuOpen() {
} }
void MenuViewDragAndDropTest::TearDown() { void MenuViewDragAndDropTest::TearDown() {
widget_observer_.RemoveAll(); if (widget_observation_.IsObserving())
widget_observation_.RemoveObservation();
MenuTestBase::TearDown(); MenuTestBase::TearDown();
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/scoped_observation.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/task/current_thread.h" #include "base/task/current_thread.h"
#include "build/build_config.h" #include "build/build_config.h"
...@@ -43,10 +44,10 @@ class RenderViewContextMenuViews::SubmenuViewObserver ...@@ -43,10 +44,10 @@ class RenderViewContextMenuViews::SubmenuViewObserver
SubmenuViewObserver(RenderViewContextMenuViews* parent, SubmenuViewObserver(RenderViewContextMenuViews* parent,
views::SubmenuView* submenu_view) views::SubmenuView* submenu_view)
: parent_(parent), submenu_view_(submenu_view) { : parent_(parent), submenu_view_(submenu_view) {
observed_submenu_view_.Add(submenu_view); submenu_view_observation_.Observe(submenu_view);
auto* widget = submenu_view_->host(); auto* widget = submenu_view_->host();
if (widget) if (widget)
observed_submenu_widget_.Add(widget); submenu_widget_observation_.Observe(widget);
} }
SubmenuViewObserver(const SubmenuViewObserver&) = delete; SubmenuViewObserver(const SubmenuViewObserver&) = delete;
...@@ -72,7 +73,7 @@ class RenderViewContextMenuViews::SubmenuViewObserver ...@@ -72,7 +73,7 @@ class RenderViewContextMenuViews::SubmenuViewObserver
DCHECK_EQ(submenu_view_, observed_view); DCHECK_EQ(submenu_view_, observed_view);
auto* widget = submenu_view_->host(); auto* widget = submenu_view_->host();
if (widget) if (widget)
observed_submenu_widget_.Add(widget); submenu_widget_observation_.Observe(widget);
} }
// WidgetObserver: // WidgetObserver:
...@@ -92,9 +93,10 @@ class RenderViewContextMenuViews::SubmenuViewObserver ...@@ -92,9 +93,10 @@ class RenderViewContextMenuViews::SubmenuViewObserver
private: private:
RenderViewContextMenuViews* const parent_; RenderViewContextMenuViews* const parent_;
views::SubmenuView* const submenu_view_; views::SubmenuView* const submenu_view_;
ScopedObserver<views::View, views::ViewObserver> observed_submenu_view_{this}; base::ScopedObservation<views::View, views::ViewObserver>
ScopedObserver<views::Widget, views::WidgetObserver> observed_submenu_widget_{ submenu_view_observation_{this};
this}; base::ScopedObservation<views::Widget, views::WidgetObserver>
submenu_widget_observation_{this};
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "chrome/browser/ui/screen_capture_notification_ui.h" #include "chrome/browser/ui/screen_capture_notification_ui.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/scoped_observer.h" #include "base/scoped_multi_source_observation.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/ui/views/chrome_views_export.h" #include "chrome/browser/ui/views/chrome_views_export.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
...@@ -102,7 +102,8 @@ class ScreenCaptureNotificationUIViews : public ScreenCaptureNotificationUI, ...@@ -102,7 +102,8 @@ class ScreenCaptureNotificationUIViews : public ScreenCaptureNotificationUI,
base::OnceClosure stop_callback_; base::OnceClosure stop_callback_;
content::MediaStreamUI::SourceCallback source_callback_; content::MediaStreamUI::SourceCallback source_callback_;
ScopedObserver<views::View, views::ViewObserver> bounds_observer_{this}; base::ScopedMultiSourceObservation<views::View, views::ViewObserver>
bounds_observations_{this};
NotificationBarClientView* client_view_ = nullptr; NotificationBarClientView* client_view_ = nullptr;
views::ImageView* gripper_ = nullptr; views::ImageView* gripper_ = nullptr;
views::Label* label_ = nullptr; views::Label* label_ = nullptr;
...@@ -157,9 +158,9 @@ ScreenCaptureNotificationUIViews::ScreenCaptureNotificationUIViews( ...@@ -157,9 +158,9 @@ ScreenCaptureNotificationUIViews::ScreenCaptureNotificationUIViews(
// The client rect for NotificationBarClientView uses the bounds for the // The client rect for NotificationBarClientView uses the bounds for the
// following views. // following views.
bounds_observer_.Add(source_button_); bounds_observations_.AddObservation(source_button_);
bounds_observer_.Add(stop_button_); bounds_observations_.AddObservation(stop_button_);
bounds_observer_.Add(hide_link_); bounds_observations_.AddObservation(hide_link_);
} }
ScreenCaptureNotificationUIViews::~ScreenCaptureNotificationUIViews() { ScreenCaptureNotificationUIViews::~ScreenCaptureNotificationUIViews() {
......
...@@ -718,7 +718,7 @@ AppMenu::AppMenu(Browser* browser, int run_types, bool alert_reopen_tab_items) ...@@ -718,7 +718,7 @@ AppMenu::AppMenu(Browser* browser, int run_types, bool alert_reopen_tab_items)
: browser_(browser), : browser_(browser),
run_types_(run_types), run_types_(run_types),
alert_reopen_tab_items_(alert_reopen_tab_items) { alert_reopen_tab_items_(alert_reopen_tab_items) {
global_error_observer_.Add( global_error_observation_.Observe(
GlobalErrorServiceFactory::GetForProfile(browser->profile())); GlobalErrorServiceFactory::GetForProfile(browser->profile()));
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include <utility> #include <utility>
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h" #include "base/scoped_observation.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/timer/elapsed_timer.h" #include "base/timer/elapsed_timer.h"
#include "chrome/browser/ui/global_error/global_error_observer.h" #include "chrome/browser/ui/global_error/global_error_observer.h"
...@@ -182,8 +182,8 @@ class AppMenu : public views::MenuDelegate, ...@@ -182,8 +182,8 @@ class AppMenu : public views::MenuDelegate,
// Used for managing "Recent tabs" menu items. // Used for managing "Recent tabs" menu items.
std::unique_ptr<RecentTabsMenuModelDelegate> recent_tabs_menu_model_delegate_; std::unique_ptr<RecentTabsMenuModelDelegate> recent_tabs_menu_model_delegate_;
ScopedObserver<GlobalErrorService, GlobalErrorObserver> base::ScopedObservation<GlobalErrorService, GlobalErrorObserver>
global_error_observer_{this}; global_error_observation_{this};
// The bit mask of views::MenuRunner::RunTypes. // The bit mask of views::MenuRunner::RunTypes.
const int run_types_; const int run_types_;
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/scoped_observer.h" #include "base/scoped_observation.h"
#include "chrome/browser/ui/toolbar/app_menu_icon_controller.h" #include "chrome/browser/ui/toolbar/app_menu_icon_controller.h"
#include "chrome/browser/ui/user_education/feature_promo_controller.h" #include "chrome/browser/ui/user_education/feature_promo_controller.h"
#include "chrome/browser/ui/views/frame/app_menu_button.h" #include "chrome/browser/ui/views/frame/app_menu_button.h"
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <memory> #include <memory>
#include "base/scoped_observation.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/layout_constants.h"
...@@ -48,7 +49,7 @@ class ToolbarIconContainerView::WidgetRestoreObserver ...@@ -48,7 +49,7 @@ class ToolbarIconContainerView::WidgetRestoreObserver
explicit WidgetRestoreObserver( explicit WidgetRestoreObserver(
ToolbarIconContainerView* toolbar_icon_container_view) ToolbarIconContainerView* toolbar_icon_container_view)
: toolbar_icon_container_view_(toolbar_icon_container_view) { : toolbar_icon_container_view_(toolbar_icon_container_view) {
scoped_observer_.Add( scoped_observation_.Observe(
toolbar_icon_container_view->GetWidget()->GetRootView()); toolbar_icon_container_view->GetWidget()->GetRootView());
} }
...@@ -64,7 +65,8 @@ class ToolbarIconContainerView::WidgetRestoreObserver ...@@ -64,7 +65,8 @@ class ToolbarIconContainerView::WidgetRestoreObserver
private: private:
bool was_collapsed_ = true; bool was_collapsed_ = true;
ToolbarIconContainerView* const toolbar_icon_container_view_; ToolbarIconContainerView* const toolbar_icon_container_view_;
ScopedObserver<views::View, views::ViewObserver> scoped_observer_{this}; base::ScopedObservation<views::View, views::ViewObserver> scoped_observation_{
this};
}; };
ToolbarIconContainerView::ToolbarIconContainerView(bool uses_highlight) ToolbarIconContainerView::ToolbarIconContainerView(bool uses_highlight)
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/scoped_observer.h" #include "base/scoped_observation.h"
#include "chrome/browser/command_observer.h" #include "chrome/browser/command_observer.h"
#include "chrome/browser/ui/page_action/page_action_icon_type.h" #include "chrome/browser/ui/page_action/page_action_icon_type.h"
#include "chrome/browser/ui/toolbar/app_menu_icon_controller.h" #include "chrome/browser/ui/toolbar/app_menu_icon_controller.h"
......
...@@ -168,11 +168,13 @@ IN_PROC_BROWSER_TEST_F(ToolbarViewInteractiveUITest, ...@@ -168,11 +168,13 @@ IN_PROC_BROWSER_TEST_F(ToolbarViewInteractiveUITest,
// Set up observers that will drive the test along. // Set up observers that will drive the test along.
AppMenuButton* const app_menu_button = GetAppMenuButton(); AppMenuButton* const app_menu_button = GetAppMenuButton();
EXPECT_FALSE(app_menu_button->IsMenuShowing()); EXPECT_FALSE(app_menu_button->IsMenuShowing());
ScopedObserver<views::Widget, views::WidgetObserver> widget_observer(this); base::ScopedObservation<views::Widget, views::WidgetObserver>
widget_observer.Add( widget_observation(this);
widget_observation.Observe(
BrowserView::GetBrowserViewForBrowser(browser())->GetWidget()); BrowserView::GetBrowserViewForBrowser(browser())->GetWidget());
ScopedObserver<AppMenuButton, AppMenuButtonObserver> button_observer(this); base::ScopedObservation<AppMenuButton, AppMenuButtonObserver>
button_observer.Add(app_menu_button); button_observation(this);
button_observation.Observe(app_menu_button);
// Set up the task runner to use for posting drag actions. // Set up the task runner to use for posting drag actions.
// TODO(devlin): This is basically ViewEventTestBase::GetDragTaskRunner(). In // TODO(devlin): This is basically ViewEventTestBase::GetDragTaskRunner(). In
......
...@@ -125,7 +125,7 @@ class InteractionTracker : public ui::EventHandler, ...@@ -125,7 +125,7 @@ class InteractionTracker : public ui::EventHandler,
: native_window_(widget->GetNativeWindow()) { : native_window_(widget->GetNativeWindow()) {
if (native_window_) if (native_window_)
native_window_->AddPreTargetHandler(this); native_window_->AddPreTargetHandler(this);
scoped_widget_observer_.Add(widget); scoped_widget_observation_.Observe(widget);
} }
InteractionTracker(const InteractionTracker& other) = delete; InteractionTracker(const InteractionTracker& other) = delete;
...@@ -160,7 +160,8 @@ class InteractionTracker : public ui::EventHandler, ...@@ -160,7 +160,8 @@ class InteractionTracker : public ui::EventHandler,
void OnWidgetDestroying(views::Widget* widget) override { void OnWidgetDestroying(views::Widget* widget) override {
// Clean up all of our observers and event handlers before the native window // Clean up all of our observers and event handlers before the native window
// disappears. // disappears.
scoped_widget_observer_.Remove(widget); DCHECK(scoped_widget_observation_.IsObservingSource(widget));
scoped_widget_observation_.RemoveObservation();
if (widget->GetNativeWindow()) { if (widget->GetNativeWindow()) {
widget->GetNativeWindow()->RemovePreTargetHandler(this); widget->GetNativeWindow()->RemovePreTargetHandler(this);
native_window_ = nullptr; native_window_ = nullptr;
...@@ -169,8 +170,8 @@ class InteractionTracker : public ui::EventHandler, ...@@ -169,8 +170,8 @@ class InteractionTracker : public ui::EventHandler,
base::Optional<gfx::Point> last_interaction_location_; base::Optional<gfx::Point> last_interaction_location_;
gfx::NativeWindow native_window_; gfx::NativeWindow native_window_;
ScopedObserver<views::Widget, views::WidgetObserver> scoped_widget_observer_{ base::ScopedObservation<views::Widget, views::WidgetObserver>
this}; scoped_widget_observation_{this};
}; };
//------------------------------------------------------------------------ //------------------------------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment