Commit 27853d5c authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Remove NOTIFICATION_PROFILE_DESTROYED from ChromeExtensionMessageFilter

Bug: 268984
Change-Id: I1e4e34c663cfa2c2cc2d5d903ee506b7171c4881
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1869022Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708035}
parent 707870e6
...@@ -15,14 +15,12 @@ ...@@ -15,14 +15,12 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/activity_log/activity_action_constants.h" #include "chrome/browser/extensions/activity_log/activity_action_constants.h"
#include "chrome/browser/extensions/activity_log/activity_actions.h" #include "chrome/browser/extensions/activity_log/activity_actions.h"
#include "chrome/browser/extensions/activity_log/activity_log.h" #include "chrome/browser/extensions/activity_log/activity_log.h"
#include "chrome/browser/extensions/api/activity_log_private/activity_log_private_api.h" #include "chrome/browser/extensions/api/activity_log_private/activity_log_private_api.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h" #include "extensions/browser/extension_system.h"
...@@ -67,9 +65,7 @@ ChromeExtensionMessageFilter::ChromeExtensionMessageFilter( ...@@ -67,9 +65,7 @@ ChromeExtensionMessageFilter::ChromeExtensionMessageFilter(
extension_info_map_( extension_info_map_(
extensions::ExtensionSystem::Get(profile)->info_map()) { extensions::ExtensionSystem::Get(profile)->info_map()) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
notification_registrar_.Add(this, observed_profiles_.Add(profile);
chrome::NOTIFICATION_PROFILE_DESTROYED,
content::Source<Profile>(profile));
} }
ChromeExtensionMessageFilter::~ChromeExtensionMessageFilter() { ChromeExtensionMessageFilter::~ChromeExtensionMessageFilter() {
...@@ -234,12 +230,10 @@ void ChromeExtensionMessageFilter::OnAddEventToExtensionActivityLog( ...@@ -234,12 +230,10 @@ void ChromeExtensionMessageFilter::OnAddEventToExtensionActivityLog(
AddActionToExtensionActivityLog(profile_, activity_log_, action); AddActionToExtensionActivityLog(profile_, activity_log_, action);
} }
void ChromeExtensionMessageFilter::Observe( void ChromeExtensionMessageFilter::OnProfileWillBeDestroyed(Profile* profile) {
int type, DCHECK_EQ(profile_, profile);
const content::NotificationSource& source, observed_profiles_.Remove(profile_);
const content::NotificationDetails& details) { profile_ = nullptr;
DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
profile_ = NULL;
activity_log_ = nullptr; activity_log_ = nullptr;
} }
......
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
#include <vector> #include <vector>
#include "base/macros.h" #include "base/macros.h"
#include "base/scoped_observer.h"
#include "base/sequenced_task_runner_helpers.h" #include "base/sequenced_task_runner_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_observer.h"
#include "content/public/browser/browser_message_filter.h" #include "content/public/browser/browser_message_filter.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
class Profile;
struct ExtensionHostMsg_APIActionOrEvent_Params; struct ExtensionHostMsg_APIActionOrEvent_Params;
struct ExtensionHostMsg_DOMAction_Params; struct ExtensionHostMsg_DOMAction_Params;
...@@ -28,7 +28,7 @@ struct Message; ...@@ -28,7 +28,7 @@ struct Message;
// This class filters out incoming Chrome-specific IPC messages from the // This class filters out incoming Chrome-specific IPC messages from the
// extension process on the IPC thread. // extension process on the IPC thread.
class ChromeExtensionMessageFilter : public content::BrowserMessageFilter, class ChromeExtensionMessageFilter : public content::BrowserMessageFilter,
public content::NotificationObserver { public ProfileObserver {
public: public:
ChromeExtensionMessageFilter(int render_process_id, Profile* profile); ChromeExtensionMessageFilter(int render_process_id, Profile* profile);
...@@ -68,10 +68,8 @@ class ChromeExtensionMessageFilter : public content::BrowserMessageFilter, ...@@ -68,10 +68,8 @@ class ChromeExtensionMessageFilter : public content::BrowserMessageFilter,
const std::string& extension_id, const std::string& extension_id,
const ExtensionHostMsg_APIActionOrEvent_Params& params); const ExtensionHostMsg_APIActionOrEvent_Params& params);
// content::NotificationObserver implementation. // ProfileObserver:
void Observe(int type, void OnProfileWillBeDestroyed(Profile* profile) override;
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
// Returns true if an action should be logged for the given extension. // Returns true if an action should be logged for the given extension.
bool ShouldLogExtensionAction(const std::string& extension_id) const; bool ShouldLogExtensionAction(const std::string& extension_id) const;
...@@ -90,7 +88,7 @@ class ChromeExtensionMessageFilter : public content::BrowserMessageFilter, ...@@ -90,7 +88,7 @@ class ChromeExtensionMessageFilter : public content::BrowserMessageFilter,
scoped_refptr<extensions::InfoMap> extension_info_map_; scoped_refptr<extensions::InfoMap> extension_info_map_;
content::NotificationRegistrar notification_registrar_; ScopedObserver<Profile, ProfileObserver> observed_profiles_{this};
DISALLOW_COPY_AND_ASSIGN(ChromeExtensionMessageFilter); DISALLOW_COPY_AND_ASSIGN(ChromeExtensionMessageFilter);
}; };
......
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