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

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: Update database schema if needed 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..5d806d1897aa21855d73717f2eff8a0b5d13088f 100644
--- a/chrome/browser/extensions/activity_log.cc
+++ b/chrome/browser/extensions/activity_log.cc
@@ -161,6 +161,7 @@ void ActivityLog::LogAPIAction(const Extension* extension,
scoped_refptr<APIAction> action = new APIAction(
extension->id(),
base::Time::Now(),
+ APIAction::CALL,
APIAction::StringAsActionType(verb),
APIAction::StringAsTargetType(manager),
call_signature,
@@ -175,6 +176,40 @@ void ActivityLog::LogAPIAction(const Extension* extension,
ActivityLog::ACTIVITY_EXTENSION_API_CALL,
call_signature);
}
+ 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::StringAsActionType(verb),
+ APIAction::StringAsTargetType(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 {
@@ -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 "";

Powered by Google App Engine
This is Rietveld 408576698