| Index: chrome/browser/extensions/activity_log/activity_log.h
|
| diff --git a/chrome/browser/extensions/activity_log/activity_log.h b/chrome/browser/extensions/activity_log/activity_log.h
|
| index 84ffd397f6cf95a39659e5a262e7176a0f5189d1..f763413abebd132171e29043affac7cef44d2255 100644
|
| --- a/chrome/browser/extensions/activity_log/activity_log.h
|
| +++ b/chrome/browser/extensions/activity_log/activity_log.h
|
| @@ -10,17 +10,15 @@
|
| #include <vector>
|
|
|
| #include "base/callback.h"
|
| -#include "base/memory/singleton.h"
|
| #include "base/observer_list_threadsafe.h"
|
| #include "base/synchronization/lock.h"
|
| #include "base/threading/thread.h"
|
| #include "chrome/browser/extensions/activity_log/activity_actions.h"
|
| #include "chrome/browser/extensions/activity_log/activity_log_policy.h"
|
| +#include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
|
| #include "chrome/browser/extensions/install_observer.h"
|
| #include "chrome/browser/extensions/tab_helper.h"
|
| #include "chrome/common/extensions/dom_action_types.h"
|
| -#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
|
| -#include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h"
|
| #include "extensions/browser/api_activity_monitor.h"
|
|
|
| class Profile;
|
| @@ -39,7 +37,9 @@ class InstallTracker;
|
|
|
| // A utility for tracing interesting activity for each extension.
|
| // It writes to an ActivityDatabase on a separate thread to record the activity.
|
| -class ActivityLog : public BrowserContextKeyedService,
|
| +// Each profile has different extensions, so we keep a different database for
|
| +// each profile.
|
| +class ActivityLog : public ProfileKeyedAPI,
|
| public ApiActivityMonitor,
|
| public TabHelper::ScriptExecutionObserver,
|
| public InstallObserver {
|
| @@ -51,8 +51,10 @@ class ActivityLog : public BrowserContextKeyedService,
|
| virtual void OnExtensionActivity(scoped_refptr<Action> activity) = 0;
|
| };
|
|
|
| - // ActivityLog is a singleton, so don't instantiate it with the constructor;
|
| - // use GetInstance instead.
|
| + static ProfileKeyedAPIFactory<ActivityLog>* GetFactoryInstance();
|
| +
|
| + // ActivityLog is a BrowserContextKeyedService, so don't instantiate it with
|
| + // the constructor; use GetInstance instead.
|
| static ActivityLog* GetInstance(content::BrowserContext* context);
|
|
|
| // Add/remove observer: the activityLogPrivate API only listens when the
|
| @@ -127,11 +129,11 @@ class ActivityLog : public BrowserContextKeyedService,
|
| void DeleteDatabase();
|
|
|
| private:
|
| - friend class ActivityLogFactory;
|
| friend class ActivityLogTest;
|
| + friend class ProfileKeyedAPIFactory<ActivityLog>;
|
| friend class RenderViewActivityLogTest;
|
|
|
| - explicit ActivityLog(Profile* profile);
|
| + explicit ActivityLog(content::BrowserContext* context);
|
| virtual ~ActivityLog();
|
|
|
| // Specifies if the Watchdog app is active (installed & enabled).
|
| @@ -165,6 +167,11 @@ class ActivityLog : public BrowserContextKeyedService,
|
| void ChooseDatabasePolicy();
|
| void SetDatabasePolicy(ActivityLogPolicy::PolicyType policy_type);
|
|
|
| + // ProfileKeyedAPI implementation.
|
| + static const char* service_name() { return "ActivityLog"; }
|
| + static const bool kServiceRedirectedInIncognito = true;
|
| + static const bool kServiceIsCreatedWithBrowserContext = false;
|
| +
|
| typedef ObserverListThreadSafe<Observer> ObserverList;
|
| scoped_refptr<ObserverList> observers_;
|
|
|
| @@ -215,31 +222,8 @@ class ActivityLog : public BrowserContextKeyedService,
|
| DISALLOW_COPY_AND_ASSIGN(ActivityLog);
|
| };
|
|
|
| -// Each profile has different extensions, so we keep a different database for
|
| -// each profile.
|
| -class ActivityLogFactory : public BrowserContextKeyedServiceFactory {
|
| - public:
|
| - static ActivityLog* GetForBrowserContext(content::BrowserContext* context) {
|
| - return static_cast<ActivityLog*>(
|
| - GetInstance()->GetServiceForBrowserContext(context, true));
|
| - }
|
| -
|
| - static ActivityLogFactory* GetInstance();
|
| -
|
| - private:
|
| - friend struct DefaultSingletonTraits<ActivityLogFactory>;
|
| - ActivityLogFactory();
|
| - virtual ~ActivityLogFactory();
|
| -
|
| - virtual BrowserContextKeyedService* BuildServiceInstanceFor(
|
| - content::BrowserContext* profile) const OVERRIDE;
|
| -
|
| - virtual content::BrowserContext* GetBrowserContextToUse(
|
| - content::BrowserContext* context) const OVERRIDE;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(ActivityLogFactory);
|
| -};
|
| -
|
| +template <>
|
| +void ProfileKeyedAPIFactory<ActivityLog>::DeclareFactoryDependencies();
|
|
|
| } // namespace extensions
|
|
|
|
|