Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5664)

Unified Diff: chrome/browser/extensions/activity_log/activity_log.cc

Issue 298023009: Remove InstallTracker's extension load, unload observer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/activity_log/activity_log.cc
diff --git a/chrome/browser/extensions/activity_log/activity_log.cc b/chrome/browser/extensions/activity_log/activity_log.cc
index 9b8d5836212dd4dee5aff690c9906330c93683f8..b4389392bf21ef5c15ae7752b15cb1f716362753 100644
--- a/chrome/browser/extensions/activity_log/activity_log.cc
+++ b/chrome/browser/extensions/activity_log/activity_log.cc
@@ -361,7 +361,7 @@ ActivityLog::ActivityLog(content::BrowserContext* context)
db_enabled_(false),
testing_mode_(false),
has_threads_(true),
- tracker_(NULL),
+ extension_registry_observer_(this),
watchdog_apps_active_(0) {
// This controls whether logging statements are printed & which policy is set.
testing_mode_ = CommandLine::ForCurrentProcess()->HasSwitch(
@@ -393,7 +393,7 @@ ActivityLog::ActivityLog(content::BrowserContext* context)
ExtensionSystem::Get(profile_)->ready().Post(
FROM_HERE,
- base::Bind(&ActivityLog::InitInstallTracker, base::Unretained(this)));
+ base::Bind(&ActivityLog::StartObserving, base::Unretained(this)));
// None of this should run on Android since the AL is behind ENABLE_EXTENSION
// checks. However, UmaPolicy can't even compile on Android because it uses
@@ -438,12 +438,6 @@ void ActivityLog::SetDatabasePolicy(
database_policy_type_ = policy_type;
}
-// SHUT DOWN. ------------------------------------------------------------------
-
-void ActivityLog::Shutdown() {
- if (tracker_) tracker_->RemoveObserver(this);
-}
-
ActivityLog::~ActivityLog() {
if (uma_policy_)
uma_policy_->Close();
@@ -453,9 +447,8 @@ ActivityLog::~ActivityLog() {
// MAINTAIN STATUS. ------------------------------------------------------------
-void ActivityLog::InitInstallTracker() {
- tracker_ = InstallTrackerFactory::GetForProfile(profile_);
- tracker_->AddObserver(this);
+void ActivityLog::StartObserving() {
+ extension_registry_observer_.Add(ExtensionRegistry::Get(profile_));
}
void ActivityLog::ChooseDatabasePolicy() {
@@ -481,7 +474,8 @@ void ActivityLog::SetWatchdogAppActiveForTesting(bool active) {
watchdog_apps_active_ = active ? 1 : 0;
}
-void ActivityLog::OnExtensionLoaded(const Extension* extension) {
+void ActivityLog::OnExtensionLoaded(content::BrowserContext* browser_context,
+ const Extension* extension) {
if (!ActivityLogAPI::IsExtensionWhitelisted(extension->id())) return;
if (has_threads_)
db_enabled_ = true;
@@ -492,7 +486,9 @@ void ActivityLog::OnExtensionLoaded(const Extension* extension) {
ChooseDatabasePolicy();
}
-void ActivityLog::OnExtensionUnloaded(const Extension* extension) {
+void ActivityLog::OnExtensionUnloaded(content::BrowserContext* browser_context,
+ const Extension* extension,
+ UnloadedExtensionInfo::Reason reason) {
if (!ActivityLogAPI::IsExtensionWhitelisted(extension->id())) return;
watchdog_apps_active_--;
profile_->GetPrefs()->SetInteger(prefs::kWatchdogExtensionActive,
@@ -505,7 +501,9 @@ void ActivityLog::OnExtensionUnloaded(const Extension* extension) {
}
// OnExtensionUnloaded will also be called right before this.
-void ActivityLog::OnExtensionUninstalled(const Extension* extension) {
+void ActivityLog::OnExtensionUninstalled(
+ content::BrowserContext* browser_context,
+ const Extension* extension) {
if (ActivityLogAPI::IsExtensionWhitelisted(extension->id()) &&
!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableExtensionActivityLogging) &&
@@ -697,7 +695,6 @@ void ActivityLog::DeleteDatabase() {
template <>
void BrowserContextKeyedAPIFactory<ActivityLog>::DeclareFactoryDependencies() {
DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
- DependsOn(InstallTrackerFactory::GetInstance());
not at google - send to devlin 2014/05/29 18:09:29 strictly speaking you should add ExtensionRegistry
limasdf 2014/05/30 21:00:49 Done.
}
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698