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

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

Issue 12517011: Added activity logging for ext APIs with custom bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added an earlier check for the IPC communication Created 7 years, 9 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 0c7b1535920d470bda0fd782467745fa2b097ee7..0fbb8b021370f8b7fe92a3c4f9e395d193f85a32 100644
--- a/chrome/browser/renderer_host/chrome_render_message_filter.cc
+++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc
@@ -57,6 +57,31 @@ using WebKit::WebSecurityOrigin;
namespace {
+void AddAPIActionToExtensionActivityLog(
+ Profile* profile,
+ const extensions::Extension* extension,
+ const std::string& api_call,
+ scoped_ptr<ListValue> args,
+ const std::string& extra) {
+ // The ActivityLog can only be accessed from the main (UI) thread. If we're
+ // running on the wrong thread, re-dispatch from the main thread.
palmer 2013/03/21 18:39:38 In theory, this shouldn't happen? Can you use a DC
felt 2013/03/21 21:59:23 I found in testing (with a DCHECK) that this is al
palmer 2013/03/21 22:16:55 The only reason to think otherwise was that I didn
+ if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
+ BrowserThread::PostTask(BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&AddAPIActionToExtensionActivityLog,
+ profile,
+ extension,
+ api_call,
+ base::Passed(&args),
+ extra));
+ } else {
+ extensions::ActivityLog* activity_log =
+ extensions::ActivityLog::GetInstance(profile);
+ if (activity_log && activity_log->IsLogEnabled())
+ activity_log->LogAPIAction(extension, api_call, args.get(), extra);
+ }
+}
+
void AddDOMActionToExtensionActivityLog(
Profile* profile,
const extensions::Extension* extension,
@@ -81,7 +106,7 @@ void AddDOMActionToExtensionActivityLog(
} else {
extensions::ActivityLog* activity_log =
extensions::ActivityLog::GetInstance(profile);
- if (activity_log)
+ if (activity_log && activity_log->IsLogEnabled())
activity_log->LogDOMAction(extension, url, url_title,
api_call, args.get(), extra);
}
@@ -153,6 +178,8 @@ bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message,
IPC_MESSAGE_HANDLER(ExtensionHostMsg_SuspendAck, OnExtensionSuspendAck)
IPC_MESSAGE_HANDLER(ExtensionHostMsg_ResumeRequests,
OnExtensionResumeRequests);
+ IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddAPIActionToActivityLog,
+ OnAddAPIActionToExtensionActivityLog);
IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddDOMActionToActivityLog,
OnAddDOMActionToExtensionActivityLog);
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDatabase, OnAllowDatabase)
@@ -562,6 +589,19 @@ void ChromeRenderMessageFilter::OnExtensionResumeRequests(int route_id) {
render_process_id_, route_id);
}
+void ChromeRenderMessageFilter::OnAddAPIActionToExtensionActivityLog(
+ const std::string& extension_id,
+ const ExtensionHostMsg_APIAction_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,
+ params.api_call, args.Pass(),
+ params.extra);
+}
+
void ChromeRenderMessageFilter::OnAddDOMActionToExtensionActivityLog(
const std::string& extension_id,
const ExtensionHostMsg_DOMAction_Params& params) {

Powered by Google App Engine
This is Rietveld 408576698