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

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

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

Bug: 1145565
Change-Id: I797bd54b97c8b3059fc5d824fff85f1ee296d4f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2548002
Auto-Submit: Sigurður Ásgeirsson <siggi@chromium.org>
Commit-Queue: Ben Wells <benwells@chromium.org>
Reviewed-by: default avatarBen Wells <benwells@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830106}
parent 4411d610
......@@ -36,7 +36,7 @@ ExtensionActionPlatformDelegate::Create(
ExtensionActionPlatformDelegateViews::ExtensionActionPlatformDelegateViews(
ExtensionActionViewController* controller)
: controller_(controller) {
command_service_observer_.Add(
command_service_observation_.Observe(
extensions::CommandService::Get(controller_->browser()->profile()));
}
......@@ -133,7 +133,7 @@ void ExtensionActionPlatformDelegateViews::OnExtensionCommandRemoved(
}
void ExtensionActionPlatformDelegateViews::OnCommandServiceDestroying() {
command_service_observer_.RemoveAll();
command_service_observation_.RemoveObservation();
}
bool ExtensionActionPlatformDelegateViews::AcceleratorPressed(
......
......@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_ACTION_PLATFORM_DELEGATE_VIEWS_H_
#include "base/macros.h"
#include "base/scoped_observer.h"
#include "base/scoped_observation.h"
#include "chrome/browser/extensions/api/commands/command_service.h"
#include "chrome/browser/ui/extensions/extension_action_platform_delegate.h"
#include "ui/base/accelerators/accelerator.h"
......@@ -60,9 +60,9 @@ class ExtensionActionPlatformDelegateViews
// for (to show the popup).
std::unique_ptr<ui::Accelerator> action_keybinding_;
ScopedObserver<extensions::CommandService,
base::ScopedObservation<extensions::CommandService,
extensions::CommandService::Observer>
command_service_observer_{this};
command_service_observation_{this};
DISALLOW_COPY_AND_ASSIGN(ExtensionActionPlatformDelegateViews);
};
......
......@@ -207,7 +207,7 @@ ExtensionInstallDialogView::ExtensionInstallDialogView(
extensions::ExtensionRegistry* extension_registry =
extensions::ExtensionRegistry::Get(profile_);
extension_registry_observer_.Add(extension_registry);
extension_registry_observation_.Observe(extension_registry);
int buttons = prompt_->GetDialogButtons();
DCHECK(buttons & ui::DIALOG_BUTTON_CANCEL);
......@@ -418,7 +418,8 @@ void ExtensionInstallDialogView::OnShutdown(
extensions::ExtensionRegistry* extension_registry =
extensions::ExtensionRegistry::Get(profile_);
DCHECK_EQ(extension_registry, registry);
extension_registry_observer_.Remove(extension_registry);
DCHECK(extension_registry_observation_.IsObservingSource(extension_registry));
extension_registry_observation_.RemoveObservation();
CloseDialog();
}
......
......@@ -9,7 +9,7 @@
#include "base/macros.h"
#include "base/optional.h"
#include "base/scoped_observer.h"
#include "base/scoped_observation.h"
#include "base/timer/elapsed_timer.h"
#include "base/timer/timer.h"
#include "chrome/browser/extensions/extension_install_prompt.h"
......@@ -91,9 +91,9 @@ class ExtensionInstallDialogView
ExtensionInstallPrompt::DoneCallback done_callback_;
std::unique_ptr<ExtensionInstallPrompt::Prompt> prompt_;
base::string16 title_;
ScopedObserver<extensions::ExtensionRegistry,
base::ScopedObservation<extensions::ExtensionRegistry,
extensions::ExtensionRegistryObserver>
extension_registry_observer_{this};
extension_registry_observation_{this};
// The scroll view containing all the details for the dialog (including all
// collapsible/expandable sections).
......
......@@ -55,8 +55,8 @@ void ExtensionPopup::ShowPopup(
// This is removed in ExtensionPopup::OnWidgetDestroying(), which is
// guaranteed to be called before the Widget goes away. It's not safe to use
// a ScopedObserver for this, since the activation client may be deleted
// without a call back to this class.
// a base::ScopedObservation for this, since the activation client may be
// deleted without a call back to this class.
wm::GetActivationClient(native_view->GetRootWindow())->AddObserver(popup);
chrome::RecordDialogCreation(chrome::DialogIdentifier::EXTENSION_POPUP_AURA);
......@@ -162,7 +162,7 @@ void ExtensionPopup::OnExtensionUnloaded(
host_.reset();
// Stop observing the registry immediately to prevent any subsequent
// notifications, since Widget::Close is asynchronous.
extension_registry_observer_.RemoveAll();
extension_registry_observation_.RemoveObservation();
GetWidget()->Close();
}
......@@ -220,7 +220,6 @@ ExtensionPopup::ExtensionPopup(
arrow,
views::BubbleBorder::SMALL_SHADOW),
host_(std::move(host)),
extension_registry_observer_(this),
show_action_(show_action) {
SetButtons(ui::DIALOG_BUTTON_NONE);
set_use_round_corners(false);
......@@ -247,7 +246,7 @@ ExtensionPopup::ExtensionPopup(
content::DevToolsAgentHost::AddObserver(this);
host_->browser()->tab_strip_model()->AddObserver(this);
extension_registry_observer_.Add(
extension_registry_observation_.Observe(
extensions::ExtensionRegistry::Get(host_->browser_context()));
// If the host had somehow finished loading, then we'd miss the notification
......
......@@ -8,7 +8,7 @@
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/scoped_observer.h"
#include "base/scoped_observation.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
#include "chrome/browser/ui/views/extensions/extension_view_views.h"
......@@ -133,9 +133,9 @@ class ExtensionPopup : public views::BubbleDialogDelegateView,
ExtensionViewViews* extension_view_;
ScopedObserver<extensions::ExtensionRegistry,
base::ScopedObservation<extensions::ExtensionRegistry,
extensions::ExtensionRegistryObserver>
extension_registry_observer_;
extension_registry_observation_{this};
ShowAction show_action_;
......
......@@ -67,7 +67,6 @@ ExtensionsMenuView::ExtensionsMenuView(
extensions_container_(extensions_container),
allow_pinning_(allow_pinning),
toolbar_model_(ToolbarActionsModel::Get(browser_->profile())),
toolbar_model_observer_(this),
cant_access_{nullptr, nullptr,
IDS_EXTENSIONS_MENU_CANT_ACCESS_SITE_DATA_SHORT,
IDS_EXTENSIONS_MENU_CANT_ACCESS_SITE_DATA,
......@@ -80,7 +79,7 @@ ExtensionsMenuView::ExtensionsMenuView(
IDS_EXTENSIONS_MENU_ACCESSING_SITE_DATA_SHORT,
IDS_EXTENSIONS_MENU_ACCESSING_SITE_DATA,
ToolbarActionViewController::PageInteractionStatus::kActive} {
toolbar_model_observer_.Add(toolbar_model_);
toolbar_model_observation_.Observe(toolbar_model_);
browser_->tab_strip_model()->AddObserver(this);
set_margins(gfx::Insets(0));
......
......@@ -9,7 +9,7 @@
#include <vector>
#include "base/auto_reset.h"
#include "base/scoped_observer.h"
#include "base/scoped_observation.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
#include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
#include "chrome/browser/ui/toolbar/toolbar_actions_model.h"
......@@ -163,8 +163,8 @@ class ExtensionsMenuView : public views::BubbleDialogDelegateView,
ExtensionsContainer* const extensions_container_;
bool allow_pinning_;
ToolbarActionsModel* const toolbar_model_;
ScopedObserver<ToolbarActionsModel, ToolbarActionsModel::Observer>
toolbar_model_observer_;
base::ScopedObservation<ToolbarActionsModel, ToolbarActionsModel::Observer>
toolbar_model_observation_{this};
std::vector<ExtensionsMenuItemView*> extensions_menu_items_;
views::Button* manage_extensions_button_for_testing_ = nullptr;
......
......@@ -43,13 +43,12 @@ ExtensionsToolbarContainer::ExtensionsToolbarContainer(Browser* browser,
: ToolbarIconContainerView(/*uses_highlight=*/true),
browser_(browser),
model_(ToolbarActionsModel::Get(browser_->profile())),
model_observer_(this),
extensions_button_(new ExtensionsToolbarButton(browser_, this)),
display_mode_(display_mode) {
// The container shouldn't show unless / until we have extensions available.
SetVisible(false);
model_observer_.Add(model_);
model_observation_.Observe(model_);
// Do not flip the Extensions icon in RTL.
extensions_button_->SetFlipCanvasOnPaintForRTLUI(false);
......
......@@ -12,6 +12,7 @@
#include <vector>
#include "base/optional.h"
#include "base/scoped_observation.h"
#include "chrome/browser/ui/extensions/extensions_container.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
#include "chrome/browser/ui/toolbar/toolbar_actions_model.h"
......@@ -217,8 +218,8 @@ class ExtensionsToolbarContainer : public ToolbarIconContainerView,
Browser* const browser_;
ToolbarActionsModel* const model_;
ScopedObserver<ToolbarActionsModel, ToolbarActionsModel::Observer>
model_observer_;
base::ScopedObservation<ToolbarActionsModel, ToolbarActionsModel::Observer>
model_observation_{this};
ExtensionsToolbarButton* const extensions_button_;
DisplayMode display_mode_;
......
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