Commit 69e083e4 authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Remove NOTIFICATION_PROFILE_DESTROYED from ErrorConsole

Bug: 268984
Change-Id: Iba37b8c99f51e34d49546403fe02597b16552af5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1873327Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708321}
parent f98182e8
......@@ -12,16 +12,11 @@
#include "base/lazy_instance.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/error_console/error_console_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/crx_file/id_util.h"
#include "components/prefs/pref_service.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/constants.h"
......@@ -198,10 +193,9 @@ void ErrorConsole::Enable() {
// also create an ExtensionPrefs object.
prefs_ = ExtensionPrefs::Get(profile_);
notification_registrar_.Add(
this,
chrome::NOTIFICATION_PROFILE_DESTROYED,
content::NotificationService::AllBrowserContextsAndSources());
profile_observer_.Add(profile_);
if (profile_->HasOffTheRecordProfile())
profile_observer_.Add(profile_->GetOffTheRecordProfile());
const ExtensionSet& extensions =
ExtensionRegistry::Get(profile_)->enabled_extensions();
......@@ -213,7 +207,7 @@ void ErrorConsole::Enable() {
}
void ErrorConsole::Disable() {
notification_registrar_.RemoveAll();
profile_observer_.RemoveAll();
errors_.RemoveAllErrors();
enabled_ = false;
}
......@@ -264,11 +258,12 @@ void ErrorConsole::AddManifestErrorsForExtension(const Extension* extension) {
}
}
void ErrorConsole::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
Profile* profile = content::Source<Profile>(source).ptr();
void ErrorConsole::OnOffTheRecordProfileCreated(Profile* off_the_record) {
profile_observer_.Add(off_the_record);
}
void ErrorConsole::OnProfileWillBeDestroyed(Profile* profile) {
profile_observer_.Remove(profile);
// If incognito profile which we are associated with is destroyed, also
// destroy all incognito errors.
if (profile->IsOffTheRecord() && profile_->IsSameProfile(profile))
......
......@@ -16,10 +16,10 @@
#include "base/observer_list.h"
#include "base/scoped_observer.h"
#include "base/threading/thread_checker.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_observer.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/prefs/pref_change_registrar.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "extensions/browser/error_map.h"
#include "extensions/browser/extension_error.h"
#include "extensions/browser/extension_registry.h"
......@@ -27,12 +27,8 @@
namespace content {
class BrowserContext;
class NotificationDetails;
class NotificationSource;
}
class Profile;
namespace extensions {
class Extension;
class ExtensionPrefs;
......@@ -44,7 +40,7 @@ class ExtensionPrefs;
// This class is owned by ExtensionSystem, making it, in effect, a
// BrowserContext-keyed service.
class ErrorConsole : public KeyedService,
public content::NotificationObserver,
public ProfileObserver,
public ExtensionRegistryObserver {
public:
class Observer {
......@@ -159,10 +155,9 @@ class ErrorConsole : public KeyedService,
// Add manifest errors from an extension's install warnings.
void AddManifestErrorsForExtension(const Extension* extension);
// content::NotificationObserver implementation.
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
// ProfileObserver:
void OnOffTheRecordProfileCreated(Profile* off_the_record) override;
void OnProfileWillBeDestroyed(Profile* profile) override;
// Returns the applicable bit mask of reporting preferences for the extension.
int GetMaskForExtension(const std::string& extension_id) const;
......@@ -196,7 +191,7 @@ class ErrorConsole : public KeyedService,
// is dependent on ExtensionPrefs.
ExtensionPrefs* prefs_;
content::NotificationRegistrar notification_registrar_;
ScopedObserver<Profile, ProfileObserver> profile_observer_{this};
PrefChangeRegistrar pref_registrar_;
ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
......
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