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

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

Issue 11946028: Record event activity to the extension activity log. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix for ExtensionService being unavailable during unit tests Created 7 years, 11 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.cc
diff --git a/chrome/browser/extensions/activity_log.cc b/chrome/browser/extensions/activity_log.cc
index afdaa83dae8bfee8917fcbd6bada01b53f920c0c..7e6c5579e8aa135bd66459cfce889637d723429a 100644
--- a/chrome/browser/extensions/activity_log.cc
+++ b/chrome/browser/extensions/activity_log.cc
@@ -161,8 +161,9 @@ void ActivityLog::LogAPIAction(const Extension* extension,
scoped_refptr<APIAction> action = new APIAction(
extension->id(),
base::Time::Now(),
- APIAction::StringAsActionType(verb),
- APIAction::StringAsTargetType(manager),
+ APIAction::CALL,
+ APIAction::StringAsVerb(verb),
+ APIAction::StringAsTarget(manager),
call_signature,
extra);
ScheduleAndForget(&ActivityDatabase::RecordAction, action);
@@ -175,13 +176,47 @@ void ActivityLog::LogAPIAction(const Extension* extension,
ActivityLog::ACTIVITY_EXTENSION_API_CALL,
call_signature);
}
- if (log_activity_to_stdout_)
+ if (log_activity_to_stdout_) {
LOG(INFO) << action->PrettyPrintForDebug();
+ }
} else {
LOG(ERROR) << "Unknown API call! " << name;
}
}
+void ActivityLog::LogEventAction(const Extension* extension,
+ const std::string& name,
+ const ListValue* args,
+ const std::string& extra) {
+ std::string verb, manager;
+ bool matches = RE2::FullMatch(name, "(.*?)\\.(.*)", &manager, &verb);
+ if (matches) {
+ std::string call_signature = MakeCallSignature(name, args);
+ scoped_refptr<APIAction> action = new APIAction(
+ extension->id(),
+ base::Time::Now(),
+ APIAction::EVENT_CALLBACK,
+ APIAction::StringAsVerb(verb),
+ APIAction::StringAsTarget(manager),
+ call_signature,
+ extra);
+ ScheduleAndForget(&ActivityDatabase::RecordAction, action);
+
+ // Display the action.
+ ObserverMap::const_iterator iter = observers_.find(extension);
+ if (iter != observers_.end()) {
+ iter->second->Notify(&Observer::OnExtensionActivity,
+ extension,
+ ActivityLog::ACTIVITY_EVENT_DISPATCH,
+ call_signature);
+ }
+ if (log_activity_to_stdout_)
+ LOG(INFO) << action->PrettyPrintForDebug();
+ } else {
+ LOG(ERROR) << "Unknown event type! " << name;
+ }
+}
+
void ActivityLog::LogBlockedAction(const Extension* extension,
const std::string& blocked_name,
const ListValue* args,
@@ -289,6 +324,8 @@ const char* ActivityLog::ActivityToString(Activity activity) {
return "api_block";
case ActivityLog::ACTIVITY_CONTENT_SCRIPT:
return "content_script";
+ case ActivityLog::ACTIVITY_EVENT_DISPATCH:
+ return "event_dispatch";
default:
NOTREACHED();
return "";
@@ -296,4 +333,3 @@ const char* ActivityLog::ActivityToString(Activity activity) {
}
} // namespace extensions
-

Powered by Google App Engine
This is Rietveld 408576698