Commit c9446ff3 authored by Sigurdur Asgeirsson's avatar Sigurdur Asgeirsson Committed by Commit Bot

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

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=mfoltz@chromium.org

Bug: 1145565
Change-Id: Iaa4fc1526f737ad71819f92887baf319aa117bd1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2547773
Auto-Submit: Sigurður Ásgeirsson <siggi@chromium.org>
Reviewed-by: default avatarmark a. foltz <mfoltz@chromium.org>
Commit-Queue: mark a. foltz <mfoltz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828997}
parent d5b78751
......@@ -63,7 +63,7 @@ bool MediaRouterDialogControllerViews::ShowMediaRouterDialogForPresentation(
// computation of |anchor_bounds| in CreateMediaRouterDialog() below, but
// just doing the same thing here doesn't work. I suspect that approach
// will work, though, once the issue causing the blue border is fixed.
scoped_widget_observer_.Add(
scoped_widget_observations_.AddObservation(
MediaDialogView::ShowDialog(media_button, service, profile));
return true;
} else {
......@@ -104,7 +104,8 @@ void MediaRouterDialogControllerViews::CreateMediaRouterDialog(
dialog_creation_time,
activation_location);
}
scoped_widget_observer_.Add(CastDialogView::GetCurrentDialogWidget());
scoped_widget_observations_.AddObservation(
CastDialogView::GetCurrentDialogWidget());
if (dialog_creation_callback_)
dialog_creation_callback_.Run();
......@@ -129,11 +130,11 @@ void MediaRouterDialogControllerViews::Reset() {
}
void MediaRouterDialogControllerViews::OnWidgetClosing(views::Widget* widget) {
DCHECK(scoped_widget_observer_.IsObserving(widget));
DCHECK(scoped_widget_observations_.IsObservingSource(widget));
if (ui_)
ui_->LogMediaSinkStatus();
Reset();
scoped_widget_observer_.Remove(widget);
scoped_widget_observations_.RemoveObservation(widget);
}
void MediaRouterDialogControllerViews::SetDialogCreationCallbackForTesting(
......
......@@ -9,7 +9,7 @@
#include "base/macros.h"
#include "base/observer_list.h"
#include "base/scoped_observer.h"
#include "base/scoped_multi_source_observation.h"
#include "chrome/browser/ui/media_router/media_router_ui_service.h"
#include "components/media_router/browser/media_router_dialog_controller.h"
#include "content/public/browser/web_contents_user_data.h"
......@@ -73,8 +73,8 @@ class MediaRouterDialogControllerViews
base::RepeatingClosure dialog_creation_callback_;
ScopedObserver<views::Widget, views::WidgetObserver> scoped_widget_observer_{
this};
base::ScopedMultiSourceObservation<views::Widget, views::WidgetObserver>
scoped_widget_observations_{this};
// Service that provides MediaRouterActionController. It outlives |this|.
MediaRouterUIService* const media_router_ui_service_;
......
......@@ -49,7 +49,7 @@
#if defined(OS_CHROMEOS)
#include "ash/public/cpp/window_properties.h"
#include "base/callback.h"
#include "base/scoped_observer.h"
#include "base/scoped_observation.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
......@@ -67,7 +67,7 @@ class FullscreenWindowObserver : public aura::WindowObserver {
FullscreenWindowObserver(aura::Window* observed_window,
base::RepeatingClosure on_fullscreen_change)
: on_fullscreen_change_(on_fullscreen_change) {
observed_window_.Add(observed_window);
window_observation_.Observe(observed_window);
}
~FullscreenWindowObserver() override = default;
......@@ -89,12 +89,13 @@ class FullscreenWindowObserver : public aura::WindowObserver {
}
void OnWindowDestroying(aura::Window* window) override {
observed_window_.Remove(window);
window_observation_.RemoveObservation();
}
base::RepeatingClosure on_fullscreen_change_;
ScopedObserver<aura::Window, aura::WindowObserver> observed_window_{this};
base::ScopedObservation<aura::Window, aura::WindowObserver>
window_observation_{this};
DISALLOW_COPY_AND_ASSIGN(FullscreenWindowObserver);
};
......
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