Index: chrome/browser/extensions/extension_function_dispatcher.cc |
=================================================================== |
--- chrome/browser/extensions/extension_function_dispatcher.cc (revision 172624) |
+++ chrome/browser/extensions/extension_function_dispatcher.cc (working copy) |
@@ -45,41 +45,28 @@ |
const char kQuotaExceeded[] = "quota exceeded"; |
void LogSuccess(const Extension* extension, |
- const ExtensionHostMsg_Request_Params& params) { |
+ const ExtensionHostMsg_Request_Params& params, |
+ Profile* profile) { |
extensions::ActivityLog* activity_log = |
- extensions::ActivityLog::GetInstance(); |
- if (activity_log->HasObservers(extension)) { |
- std::string call_signature = params.name + "("; |
- ListValue::const_iterator it = params.arguments.begin(); |
- for (; it != params.arguments.end(); ++it) { |
- std::string arg; |
- JSONStringValueSerializer serializer(&arg); |
- if (serializer.SerializeAndOmitBinaryValues(**it)) { |
- if (it != params.arguments.begin()) |
- call_signature += ", "; |
- call_signature += arg; |
- } |
- } |
- call_signature += ")"; |
- |
- activity_log->Log(extension, |
- extensions::ActivityLog::ACTIVITY_EXTENSION_API_CALL, |
- call_signature); |
- } |
+ extensions::ActivityLog::GetInstance(profile); |
+ if (activity_log->HasObservers(extension)) |
+ activity_log->LogManagerAction(extension, params.name, params.arguments); |
} |
void LogFailure(const Extension* extension, |
- const std::string& func_name, |
- const char* reason) { |
+ const ExtensionHostMsg_Request_Params& params, |
+ const char* reason, |
+ Profile* profile) { |
extensions::ActivityLog* activity_log = |
- extensions::ActivityLog::GetInstance(); |
- if (activity_log->HasObservers(extension)) { |
- activity_log->Log(extension, |
- extensions::ActivityLog::ACTIVITY_EXTENSION_API_BLOCK, |
- func_name + ": " + reason); |
- } |
+ extensions::ActivityLog::GetInstance(profile); |
+ if (activity_log->HasObservers(extension)) |
+ activity_log->LogBlockedAction(extension, |
+ params.name, |
+ params.arguments, |
+ reason); |
} |
+ |
// Separate copy of ExtensionAPI used for IO thread extension functions. We need |
// this because ExtensionAPI has mutable data. It should be possible to remove |
// this once all the extension APIs are updated to the feature system. |
@@ -129,7 +116,7 @@ |
const ExtensionHostMsg_Request_Params& params) { |
const Extension* extension = |
extension_info_map->extensions().GetByID(params.extension_id); |
- |
+ Profile* profile_cast = static_cast<Profile*>(profile); |
scoped_refptr<ExtensionFunction> function( |
CreateExtensionFunction(params, extension, render_process_id, |
extension_info_map->process_map(), |
@@ -137,7 +124,7 @@ |
profile, |
ipc_sender, NULL, routing_id)); |
if (!function) { |
- LogFailure(extension, params.name, kAccessDenied); |
+ LogFailure(extension, params, kAccessDenied, profile_cast); |
return; |
} |
@@ -153,7 +140,7 @@ |
extension_info_map->IsIncognitoEnabled(extension->id())); |
if (!CheckPermissions(function, extension, params, ipc_sender, routing_id)) { |
- LogFailure(extension, params.name, kAccessDenied); |
+ LogFailure(extension, params, kAccessDenied, profile_cast); |
return; |
} |
@@ -164,10 +151,10 @@ |
base::TimeTicks::Now()); |
if (violation_error.empty()) { |
function->Run(); |
- LogSuccess(extension, params); |
+ LogSuccess(extension, params, profile_cast); |
} else { |
function->OnQuotaExceeded(violation_error); |
- LogFailure(extension, params.name, kQuotaExceeded); |
+ LogFailure(extension, params, kQuotaExceeded, profile_cast); |
} |
} |
@@ -205,7 +192,7 @@ |
profile(), render_view_host, render_view_host, |
render_view_host->GetRoutingID())); |
if (!function) { |
- LogFailure(extension, params.name, kAccessDenied); |
+ LogFailure(extension, params, kAccessDenied, profile()); |
return; |
} |
@@ -221,7 +208,7 @@ |
if (!CheckPermissions(function, extension, params, render_view_host, |
render_view_host->GetRoutingID())) { |
- LogFailure(extension, params.name, kAccessDenied); |
+ LogFailure(extension, params, kAccessDenied, profile()); |
return; |
} |
@@ -235,10 +222,10 @@ |
ExternalProtocolHandler::PermitLaunchUrl(); |
function->Run(); |
- LogSuccess(extension, params); |
+ LogSuccess(extension, params, profile()); |
} else { |
function->OnQuotaExceeded(violation_error); |
- LogFailure(extension, params.name, kQuotaExceeded); |
+ LogFailure(extension, params, kQuotaExceeded, profile()); |
} |
// Note: do not access |this| after this point. We may have been deleted |