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

Unified Diff: chrome/browser/renderer_host/chrome_render_message_filter.cc

Issue 13726026: Added ActivityLog tests and associated bugfixes/extra logging. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactored to remove strings from IPC Created 7 years, 8 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/renderer_host/chrome_render_message_filter.cc
diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.cc b/chrome/browser/renderer_host/chrome_render_message_filter.cc
index 0fbb8b021370f8b7fe92a3c4f9e395d193f85a32..58a0e33921c61bca8448ca5d1f1f657cf12d8688 100644
--- a/chrome/browser/renderer_host/chrome_render_message_filter.cc
+++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc
@@ -57,8 +57,14 @@ using WebKit::WebSecurityOrigin;
namespace {
+enum ActivityLogCallType {
+ kApiCall,
+ kEvent
+};
+
void AddAPIActionToExtensionActivityLog(
Profile* profile,
+ const ActivityLogCallType call_type,
const extensions::Extension* extension,
const std::string& api_call,
scoped_ptr<ListValue> args,
@@ -70,6 +76,7 @@ void AddAPIActionToExtensionActivityLog(
FROM_HERE,
base::Bind(&AddAPIActionToExtensionActivityLog,
profile,
+ call_type,
extension,
api_call,
base::Passed(&args),
@@ -77,8 +84,12 @@ void AddAPIActionToExtensionActivityLog(
} else {
extensions::ActivityLog* activity_log =
extensions::ActivityLog::GetInstance(profile);
- if (activity_log && activity_log->IsLogEnabled())
- activity_log->LogAPIAction(extension, api_call, args.get(), extra);
+ if (activity_log && activity_log->IsLogEnabled()) {
+ if (call_type == kApiCall)
+ activity_log->LogAPIAction(extension, api_call, args.get(), extra);
+ else if (call_type == kEvent)
+ activity_log->LogEventAction(extension, api_call, args.get(), extra);
+ }
}
}
@@ -182,6 +193,8 @@ bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message,
OnAddAPIActionToExtensionActivityLog);
IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddDOMActionToActivityLog,
OnAddDOMActionToExtensionActivityLog);
+ IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddEventToActivityLog,
+ OnAddEventToExtensionActivityLog);
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDatabase, OnAllowDatabase)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDOMStorage, OnAllowDOMStorage)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowFileSystem, OnAllowFileSystem)
@@ -591,13 +604,13 @@ void ChromeRenderMessageFilter::OnExtensionResumeRequests(int route_id) {
void ChromeRenderMessageFilter::OnAddAPIActionToExtensionActivityLog(
const std::string& extension_id,
- const ExtensionHostMsg_APIAction_Params& params) {
+ const ExtensionHostMsg_APIActionOrEvent_Params& params) {
const extensions::Extension* extension =
extension_info_map_->extensions().GetByID(extension_id);
scoped_ptr<ListValue> args(params.arguments.DeepCopy());
// The activity is recorded as an API action in the extension
// activity log.
- AddAPIActionToExtensionActivityLog(profile_, extension,
+ AddAPIActionToExtensionActivityLog(profile_, kApiCall, extension,
params.api_call, args.Pass(),
params.extra);
}
@@ -616,6 +629,19 @@ void ChromeRenderMessageFilter::OnAddDOMActionToExtensionActivityLog(
params.extra);
}
+void ChromeRenderMessageFilter::OnAddEventToExtensionActivityLog(
+ const std::string& extension_id,
+ const ExtensionHostMsg_APIActionOrEvent_Params& params) {
+ const extensions::Extension* extension =
+ extension_info_map_->extensions().GetByID(extension_id);
+ scoped_ptr<ListValue> args(params.arguments.DeepCopy());
+ // The activity is recorded as an event in the extension
+ // activity log.
+ AddAPIActionToExtensionActivityLog(profile_, kEvent, extension,
+ params.api_call, args.Pass(),
+ params.extra);
+}
+
void ChromeRenderMessageFilter::OnAllowDatabase(int render_view_id,
const GURL& origin_url,
const GURL& top_origin_url,

Powered by Google App Engine
This is Rietveld 408576698