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

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

Issue 16286017: Revert 203950 "Remove Activity Log usage of Extension objects" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 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 | trunk/src/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: trunk/src/chrome/browser/extensions/activity_log/activity_log.h
===================================================================
--- trunk/src/chrome/browser/extensions/activity_log/activity_log.h (revision 203966)
+++ trunk/src/chrome/browser/extensions/activity_log/activity_log.h (working copy)
@@ -38,10 +38,20 @@
class ActivityLog : public BrowserContextKeyedService,
public TabHelper::ScriptExecutionObserver {
public:
+ enum Activity {
+ ACTIVITY_EXTENSION_API_CALL, // Extension API invocation is called.
+ ACTIVITY_EXTENSION_API_BLOCK, // Extension API invocation is blocked.
+ ACTIVITY_CONTENT_SCRIPT, // Content script is executing.
+ ACTIVITY_EVENT_DISPATCH, // Event sent to listener in extension.
+ };
+
// Observers can listen for activity events.
class Observer {
public:
- virtual void OnExtensionActivity(scoped_refptr<Action> activity) = 0;
+ virtual void OnExtensionActivity(
+ const Extension* extension,
+ Activity activity,
+ const std::string& message) = 0;
};
// ActivityLog is a singleton, so don't instantiate it with the constructor;
@@ -58,13 +68,17 @@
static void RecomputeLoggingIsEnabled();
// Add/remove observer.
- void AddObserver(Observer* observer);
- void RemoveObserver(Observer* observer);
+ void AddObserver(const Extension* extension, Observer* observer);
+ void RemoveObserver(const Extension* extension,
+ Observer* observer);
+ // Check for the existence observer list by extension_id.
+ bool HasObservers(const Extension* extension) const;
+
// Log a successful API call made by an extension.
// This will create an APIAction for storage in the database.
// (Note: implemented as a wrapper for LogAPIActionInternal.)
- void LogAPIAction(const std::string& extension_id,
+ void LogAPIAction(const Extension* extension,
const std::string& name, // e.g., tabs.get
ListValue* args, // the argument values e.g. 46
const std::string& extra); // any extra logging info
@@ -72,14 +86,14 @@
// Log an event notification delivered to an extension.
// This will create an APIAction for storage in the database.
// (Note: implemented as a wrapper for LogAPIActionInternal.)
- void LogEventAction(const std::string& extension_id,
+ void LogEventAction(const Extension* extension,
const std::string& name, // e.g., tabs.onUpdate
ListValue* args, // arguments to the callback
const std::string& extra); // any extra logging info
// Log a blocked API call made by an extension.
// This will create a BlockedAction for storage in the database.
- void LogBlockedAction(const std::string& extension_id,
+ void LogBlockedAction(const Extension* extension,
const std::string& blocked_call, // e.g., tabs.get
ListValue* args, // argument values
const BlockedAction::Reason reason, // why it's blocked
@@ -87,7 +101,7 @@
// Log an interaction between an extension and a URL.
// This will create a DOMAction for storage in the database.
- void LogDOMAction(const std::string& extension_id,
+ void LogDOMAction(const Extension* extension,
const GURL& url, // target URL
const string16& url_title, // title of the URL
const std::string& api_call, // api call
@@ -97,7 +111,7 @@
// Log a use of the WebRequest API to redirect, cancel, or modify page
// headers.
- void LogWebRequestAction(const std::string& extension_id,
+ void LogWebRequestAction(const Extension* extension,
const GURL& url,
const std::string& api_call,
scoped_ptr<base::DictionaryValue> details,
@@ -128,7 +142,7 @@
// We log callbacks and API calls very similarly, so we handle them the same
// way internally.
void LogAPIActionInternal(
- const std::string& extension_id,
+ const Extension* extension,
const std::string& api_call,
ListValue* args,
const std::string& extra,
@@ -145,6 +159,8 @@
// The callback when initializing the database.
void OnDBInitComplete();
+ static const char* ActivityToString(Activity activity);
+
// The Schedule methods dispatch the calls to the database on a
// separate thread. We dispatch to the UI thread if the DB thread doesn't
// exist, which should only happen in tests where there is no DB thread.
@@ -170,6 +186,10 @@
}
typedef ObserverListThreadSafe<Observer> ObserverList;
+ typedef std::map<const Extension*, scoped_refptr<ObserverList> >
+ ObserverMap;
+ // A map of extensions to activity observers for that extension.
+ ObserverMap observers_;
// The database wrapper that does the actual database I/O.
// We initialize this on the same thread as the ActivityLog, but then
« no previous file with comments | « no previous file | trunk/src/chrome/browser/extensions/activity_log/activity_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698