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