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

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

Issue 2077723002: [Extensions] Short-circuit activity logging if not enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add Test Created 4 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/extensions/activity_log/activity_log.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 567cda8e3223f0bf933354d8288fa0f4dbdc1e58..76e927658d1764dbd66f62d9ba191f98789bd26c 100644
--- a/chrome/browser/extensions/activity_log/activity_log.h
+++ b/chrome/browser/extensions/activity_log/activity_log.h
@@ -16,11 +16,11 @@
#include "base/macros.h"
#include "base/observer_list_threadsafe.h"
#include "base/scoped_observer.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 "extensions/browser/api_activity_monitor.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
#include "extensions/browser/extension_registry_observer.h"
#include "extensions/browser/script_execution_observer.h"
@@ -46,9 +46,9 @@ class ExtensionRegistry;
// each profile.
//
class ActivityLog : public BrowserContextKeyedAPI,
- public ApiActivityMonitor,
public ScriptExecutionObserver,
- public ExtensionRegistryObserver {
+ public ExtensionRegistryObserver,
+ public content::NotificationObserver {
public:
// Observers can listen for activity events. There is probably only one
// observer: the activityLogPrivate API.
@@ -73,6 +73,9 @@ class ActivityLog : public BrowserContextKeyedAPI,
// mode.
void LogAction(scoped_refptr<Action> action);
+ // Returns true if an event for the given extension should be logged.
+ bool ShouldLog(const std::string& extension_id) const;
+
// Gets all actions that match the specified fields. URLs are treated like
// prefixes; other fields are exact matches. Empty strings are not matched to
// anything. For daysAgo, today is 0, yesterday is 1, etc.; a negative number
@@ -99,16 +102,6 @@ class ActivityLog : public BrowserContextKeyedAPI,
const Extension* extension,
extensions::UninstallReason reason) override;
- // ApiActivityMonitor.
- void OnApiEventDispatched(
- const std::string& extension_id,
- const std::string& event_name,
- std::unique_ptr<base::ListValue> event_args) override;
- void OnApiFunctionCalled(
- const std::string& extension_id,
- const std::string& api_name,
- std::unique_ptr<base::ListValue> event_args) override;
-
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
// Remove actions from the activity log database which IDs specified in the
@@ -158,6 +151,14 @@ class ActivityLog : public BrowserContextKeyedAPI,
void ChooseDatabasePolicy();
void SetDatabasePolicy(ActivityLogPolicy::PolicyType policy_type);
+ // Checks the current |is_active_| state and modifies it if appropriate.
+ void CheckActive();
+
+ // content::NotificationObserver:
+ void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) override;
+
// BrowserContextKeyedAPI implementation.
static const char* service_name() { return "ActivityLog"; }
static const bool kServiceRedirectedInIncognito = true;
@@ -202,6 +203,11 @@ class ActivityLog : public BrowserContextKeyedAPI,
// extension IDs, this needs to be an int to count how many are installed.
int watchdog_apps_active_;
+ // True if the activity log is currently active.
+ bool is_active_;
+
+ content::NotificationRegistrar registrar_;
+
FRIEND_TEST_ALL_PREFIXES(ActivityLogApiTest, TriggerEvent);
FRIEND_TEST_ALL_PREFIXES(ActivityLogEnabledTest, AppAndCommandLine);
FRIEND_TEST_ALL_PREFIXES(ActivityLogEnabledTest, CommandLineSwitch);
« no previous file with comments | « no previous file | chrome/browser/extensions/activity_log/activity_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698