| 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
|
|
|