Commit d15e8a03 authored by felt@chromium.org's avatar felt@chromium.org

Moved DOMActionType information from extras into a real field (ActivityLog)

Previously, the DOMActionType was being sent from the renderer to the browser ActivityLog as a string. It was then being turned into an enum. I've now moved it to its own proper field, and it's being marshaled across the renderer/browser boundary as an int that matches an enum instead of as a string.

R=mpcomplete@chromium.org
BUG=229703

Review URL: https://chromiumcodereview.appspot.com/15520002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203037 0039d316-1c4b-4281-b951-d872f2087c98
parent 75d6c4b4
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "chrome/browser/extensions/test_extension_system.h" #include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/dom_action_types.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
...@@ -201,7 +202,7 @@ TEST_F(ActivityDatabaseTest, GetTodaysActions) { ...@@ -201,7 +202,7 @@ TEST_F(ActivityDatabaseTest, GetTodaysActions) {
scoped_refptr<DOMAction> dom_action = new DOMAction( scoped_refptr<DOMAction> dom_action = new DOMAction(
"punky", "punky",
mock_clock.Now(), mock_clock.Now(),
DOMAction::MODIFIED, DomActionType::MODIFIED,
GURL("http://www.google.com"), GURL("http://www.google.com"),
string16(), string16(),
"lets", "lets",
...@@ -210,7 +211,7 @@ TEST_F(ActivityDatabaseTest, GetTodaysActions) { ...@@ -210,7 +211,7 @@ TEST_F(ActivityDatabaseTest, GetTodaysActions) {
scoped_refptr<DOMAction> extra_dom_action = new DOMAction( scoped_refptr<DOMAction> extra_dom_action = new DOMAction(
"scoobydoo", "scoobydoo",
mock_clock.Now(), mock_clock.Now(),
DOMAction::MODIFIED, DomActionType::MODIFIED,
GURL("http://www.google.com"), GURL("http://www.google.com"),
string16(), string16(),
"lets", "lets",
...@@ -262,7 +263,7 @@ TEST_F(ActivityDatabaseTest, GetOlderActions) { ...@@ -262,7 +263,7 @@ TEST_F(ActivityDatabaseTest, GetOlderActions) {
scoped_refptr<DOMAction> dom_action = new DOMAction( scoped_refptr<DOMAction> dom_action = new DOMAction(
"punky", "punky",
mock_clock.Now() - base::TimeDelta::FromDays(3), mock_clock.Now() - base::TimeDelta::FromDays(3),
DOMAction::MODIFIED, DomActionType::MODIFIED,
GURL("http://www.google.com"), GURL("http://www.google.com"),
string16(), string16(),
"lets", "lets",
...@@ -271,7 +272,7 @@ TEST_F(ActivityDatabaseTest, GetOlderActions) { ...@@ -271,7 +272,7 @@ TEST_F(ActivityDatabaseTest, GetOlderActions) {
scoped_refptr<DOMAction> toonew_dom_action = new DOMAction( scoped_refptr<DOMAction> toonew_dom_action = new DOMAction(
"punky", "punky",
mock_clock.Now(), mock_clock.Now(),
DOMAction::MODIFIED, DomActionType::MODIFIED,
GURL("http://www.google.com"), GURL("http://www.google.com"),
string16(), string16(),
"too new", "too new",
...@@ -280,7 +281,7 @@ TEST_F(ActivityDatabaseTest, GetOlderActions) { ...@@ -280,7 +281,7 @@ TEST_F(ActivityDatabaseTest, GetOlderActions) {
scoped_refptr<DOMAction> tooold_dom_action = new DOMAction( scoped_refptr<DOMAction> tooold_dom_action = new DOMAction(
"punky", "punky",
mock_clock.Now() - base::TimeDelta::FromDays(7), mock_clock.Now() - base::TimeDelta::FromDays(7),
DOMAction::MODIFIED, DomActionType::MODIFIED,
GURL("http://www.google.com"), GURL("http://www.google.com"),
string16(), string16(),
"too old", "too old",
......
...@@ -313,17 +313,20 @@ void ActivityLog::LogBlockedAction(const Extension* extension, ...@@ -313,17 +313,20 @@ void ActivityLog::LogBlockedAction(const Extension* extension,
LOG(INFO) << action->PrintForDebug(); LOG(INFO) << action->PrintForDebug();
} }
void ActivityLog::LogDOMActionInternal(const Extension* extension, void ActivityLog::LogDOMAction(const Extension* extension,
const GURL& url, const GURL& url,
const string16& url_title, const string16& url_title,
const std::string& api_call, const std::string& api_call,
const ListValue* args, const ListValue* args,
const std::string& extra, DomActionType::Type call_type,
DOMAction::DOMActionType verb) { const std::string& extra) {
if (!IsLogEnabled()) return;
if (call_type == DomActionType::METHOD && api_call == "XMLHttpRequest.open")
call_type = DomActionType::XHR;
scoped_refptr<DOMAction> action = new DOMAction( scoped_refptr<DOMAction> action = new DOMAction(
extension->id(), extension->id(),
base::Time::Now(), base::Time::Now(),
verb, call_type,
url, url,
url_title, url_title,
api_call, api_call,
...@@ -336,7 +339,7 @@ void ActivityLog::LogDOMActionInternal(const Extension* extension, ...@@ -336,7 +339,7 @@ void ActivityLog::LogDOMActionInternal(const Extension* extension,
if (iter != observers_.end()) { if (iter != observers_.end()) {
// TODO(felt): This is a kludge, planning to update this when new // TODO(felt): This is a kludge, planning to update this when new
// UI is in place. // UI is in place.
if (verb == DOMAction::INSERTED) { if (call_type == DomActionType::INSERTED) {
iter->second->Notify(&Observer::OnExtensionActivity, iter->second->Notify(&Observer::OnExtensionActivity,
extension, extension,
ActivityLog::ACTIVITY_CONTENT_SCRIPT, ActivityLog::ACTIVITY_CONTENT_SCRIPT,
...@@ -352,33 +355,6 @@ void ActivityLog::LogDOMActionInternal(const Extension* extension, ...@@ -352,33 +355,6 @@ void ActivityLog::LogDOMActionInternal(const Extension* extension,
LOG(INFO) << action->PrintForDebug(); LOG(INFO) << action->PrintForDebug();
} }
void ActivityLog::LogDOMAction(const Extension* extension,
const GURL& url,
const string16& url_title,
const std::string& api_call,
const ListValue* args,
const std::string& extra) {
if (!IsLogEnabled()) return;
DOMAction::DOMActionType action = DOMAction::MODIFIED;
if (extra == "Getter") {
action = DOMAction::GETTER;
} else if (extra == "Setter") {
action = DOMAction::SETTER;
} else if (api_call == "XMLHttpRequest.open") {
// Has to come before the Method check because XHR is also a Method.
action = DOMAction::XHR;
} else if (extra == "Method") {
action = DOMAction::METHOD;
}
LogDOMActionInternal(extension,
url,
url_title,
api_call,
args,
extra,
action);
}
void ActivityLog::LogWebRequestAction(const Extension* extension, void ActivityLog::LogWebRequestAction(const Extension* extension,
const GURL& url, const GURL& url,
const std::string& api_call, const std::string& api_call,
...@@ -403,7 +379,7 @@ void ActivityLog::LogWebRequestAction(const Extension* extension, ...@@ -403,7 +379,7 @@ void ActivityLog::LogWebRequestAction(const Extension* extension,
scoped_refptr<DOMAction> action = new DOMAction( scoped_refptr<DOMAction> action = new DOMAction(
extension->id(), extension->id(),
base::Time::Now(), base::Time::Now(),
DOMAction::WEBREQUEST, DomActionType::WEBREQUEST,
url, url,
null_title, null_title,
api_call, api_call,
...@@ -469,13 +445,13 @@ void ActivityLog::OnScriptsExecuted( ...@@ -469,13 +445,13 @@ void ActivityLog::OnScriptsExecuted(
} }
scoped_ptr<ListValue> script_names(new ListValue()); scoped_ptr<ListValue> script_names(new ListValue());
script_names->Set(0, new StringValue(ext_scripts_str)); script_names->Set(0, new StringValue(ext_scripts_str));
LogDOMActionInternal(extension, LogDOMAction(extension,
on_url, on_url,
web_contents->GetTitle(), web_contents->GetTitle(),
std::string(), // no api call here std::string(), // no api call here
script_names.get(), script_names.get(),
std::string(), // no extras either DomActionType::INSERTED,
DOMAction::INSERTED); std::string()); // no extras either
} }
} }
} }
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "chrome/browser/extensions/activity_log/activity_database.h" #include "chrome/browser/extensions/activity_log/activity_database.h"
#include "chrome/browser/extensions/tab_helper.h" #include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/dom_action_types.h"
#include "components/browser_context_keyed_service/browser_context_dependency_manager.h" #include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
#include "components/browser_context_keyed_service/browser_context_keyed_service.h" #include "components/browser_context_keyed_service/browser_context_keyed_service.h"
#include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h" #include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h"
...@@ -100,13 +101,12 @@ class ActivityLog : public BrowserContextKeyedService, ...@@ -100,13 +101,12 @@ class ActivityLog : public BrowserContextKeyedService,
// Log an interaction between an extension and a URL. // Log an interaction between an extension and a URL.
// This will create a DOMAction for storage in the database. // This will create a DOMAction for storage in the database.
// The technical message might be the list of content scripts that have been
// injected, or the DOM API call; it's what's shown under "More".
void LogDOMAction(const Extension* extension, void LogDOMAction(const Extension* extension,
const GURL& url, // target URL const GURL& url, // target URL
const string16& url_title, // title of the URL const string16& url_title, // title of the URL
const std::string& api_call, // api call const std::string& api_call, // api call
const ListValue* args, // arguments const ListValue* args, // arguments
DomActionType::Type call_type, // type of the call
const std::string& extra); // extra logging info const std::string& extra); // extra logging info
// Log a use of the WebRequest API to redirect, cancel, or modify page // Log a use of the WebRequest API to redirect, cancel, or modify page
...@@ -149,16 +149,6 @@ class ActivityLog : public BrowserContextKeyedService, ...@@ -149,16 +149,6 @@ class ActivityLog : public BrowserContextKeyedService,
const std::string& extra, const std::string& extra,
const APIAction::Type type); const APIAction::Type type);
// We log content script injection and DOM API calls using the same underlying
// mechanism, so they have the same internal logging structure.
void LogDOMActionInternal(const Extension* extension,
const GURL& url,
const string16& url_title,
const std::string& api_call,
const ListValue* args,
const std::string& extra,
DOMAction::DOMActionType verb);
// TabHelper::ScriptExecutionObserver implementation. // TabHelper::ScriptExecutionObserver implementation.
// Fires when a ContentScript is executed. // Fires when a ContentScript is executed.
virtual void OnScriptsExecuted( virtual void OnScriptsExecuted(
......
...@@ -6,10 +6,12 @@ ...@@ -6,10 +6,12 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/synchronization/waitable_event.h" #include "base/synchronization/waitable_event.h"
#include "chrome/browser/extensions/activity_log/activity_log.h" #include "chrome/browser/extensions/activity_log/activity_log.h"
#include "chrome/browser/extensions/activity_log/dom_actions.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/test_extension_system.h" #include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/dom_action_types.h"
#include "chrome/common/extensions/extension_builder.h" #include "chrome/common/extensions/extension_builder.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
...@@ -132,6 +134,7 @@ TEST_F(ActivityLogTest, LogAndFetchActions) { ...@@ -132,6 +134,7 @@ TEST_F(ActivityLogTest, LogAndFetchActions) {
string16(), string16(),
std::string("document.write"), std::string("document.write"),
args.get(), args.get(),
DomActionType::METHOD,
std::string("extra")); std::string("extra"));
activity_log->GetActions( activity_log->GetActions(
extension->id(), extension->id(),
......
...@@ -22,7 +22,7 @@ const char* DOMAction::kTableFieldTypes[] = ...@@ -22,7 +22,7 @@ const char* DOMAction::kTableFieldTypes[] =
DOMAction::DOMAction(const std::string& extension_id, DOMAction::DOMAction(const std::string& extension_id,
const base::Time& time, const base::Time& time,
const DOMActionType verb, const DomActionType::Type verb,
const GURL& url, const GURL& url,
const string16& url_title, const string16& url_title,
const std::string& api_call, const std::string& api_call,
...@@ -39,7 +39,7 @@ DOMAction::DOMAction(const std::string& extension_id, ...@@ -39,7 +39,7 @@ DOMAction::DOMAction(const std::string& extension_id,
DOMAction::DOMAction(const sql::Statement& s) DOMAction::DOMAction(const sql::Statement& s)
: Action(s.ColumnString(0), : Action(s.ColumnString(0),
base::Time::FromInternalValue(s.ColumnInt64(1))), base::Time::FromInternalValue(s.ColumnInt64(1))),
verb_(static_cast<DOMActionType>(s.ColumnInt(2))), verb_(static_cast<DomActionType::Type>(s.ColumnInt(2))),
url_(GURL(s.ColumnString(3))), url_(GURL(s.ColumnString(3))),
url_title_(s.ColumnString16(4)), url_title_(s.ColumnString16(4)),
api_call_(s.ColumnString(5)), api_call_(s.ColumnString(5)),
...@@ -100,7 +100,7 @@ void DOMAction::Record(sql::Connection* db) { ...@@ -100,7 +100,7 @@ void DOMAction::Record(sql::Connection* db) {
} }
std::string DOMAction::PrintForDebug() { std::string DOMAction::PrintForDebug() {
if (verb_ == INSERTED) if (verb_ == DomActionType::INSERTED)
return "Injected scripts (" + args_ + ") onto " return "Injected scripts (" + args_ + ") onto "
+ std::string(url_.spec()); + std::string(url_.spec());
else else
...@@ -110,19 +110,19 @@ std::string DOMAction::PrintForDebug() { ...@@ -110,19 +110,19 @@ std::string DOMAction::PrintForDebug() {
std::string DOMAction::VerbAsString() const { std::string DOMAction::VerbAsString() const {
switch (verb_) { switch (verb_) {
case GETTER: case DomActionType::GETTER:
return "GETTER"; return "GETTER";
case SETTER: case DomActionType::SETTER:
return "SETTER"; return "SETTER";
case METHOD: case DomActionType::METHOD:
return "METHOD"; return "METHOD";
case INSERTED: case DomActionType::INSERTED:
return "INSERTED"; return "INSERTED";
case XHR: case DomActionType::XHR:
return "XHR"; return "XHR";
case WEBREQUEST: case DomActionType::WEBREQUEST:
return "WEBREQUEST"; return "WEBREQUEST";
case MODIFIED: // legacy case DomActionType::MODIFIED: // legacy
return "MODIFIED"; return "MODIFIED";
default: default:
NOTREACHED(); NOTREACHED();
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/string16.h" #include "base/string16.h"
#include "chrome/browser/extensions/activity_log/activity_actions.h" #include "chrome/browser/extensions/activity_log/activity_actions.h"
#include "chrome/common/extensions/dom_action_types.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
namespace extensions { namespace extensions {
...@@ -15,18 +16,6 @@ namespace extensions { ...@@ -15,18 +16,6 @@ namespace extensions {
// content script insertions. // content script insertions.
class DOMAction : public Action { class DOMAction : public Action {
public: public:
// These values should not be changed. Append any additional values to the
// end with sequential numbers.
enum DOMActionType {
GETTER = 0, // For Content Script DOM manipulations
SETTER = 1, // For Content Script DOM manipulations
METHOD = 2, // For Content Script DOM manipulations
INSERTED = 3, // For when Content Scripts are added to pages
XHR = 4, // When an extension core sends an XHR
WEBREQUEST = 5, // When a page request is modified with the WebRequest API
MODIFIED = 6, // For legacy, also used as a catch-all
};
static const char* kTableName; static const char* kTableName;
static const char* kTableContentFields[]; static const char* kTableContentFields[];
static const char* kTableFieldTypes[]; static const char* kTableFieldTypes[];
...@@ -41,7 +30,7 @@ class DOMAction : public Action { ...@@ -41,7 +30,7 @@ class DOMAction : public Action {
// but args should be the name of the content script. // but args should be the name of the content script.
DOMAction(const std::string& extension_id, DOMAction(const std::string& extension_id,
const base::Time& time, const base::Time& time,
const DOMActionType verb, // what happened const DomActionType::Type verb, // what happened
const GURL& url, // the url of the page the const GURL& url, // the url of the page the
// script is running on // script is running on
const string16& url_title, // the page title const string16& url_title, // the page title
...@@ -70,7 +59,7 @@ class DOMAction : public Action { ...@@ -70,7 +59,7 @@ class DOMAction : public Action {
virtual ~DOMAction(); virtual ~DOMAction();
private: private:
DOMActionType verb_; DomActionType::Type verb_;
GURL url_; GURL url_;
string16 url_title_; string16 url_title_;
std::string api_call_; std::string api_call_;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h"
#include "chrome/browser/extensions/activity_log/activity_log.h" #include "chrome/browser/extensions/activity_log/activity_log.h"
#include "chrome/browser/extensions/activity_log/blocked_actions.h" #include "chrome/browser/extensions/activity_log/blocked_actions.h"
#include "chrome/browser/extensions/activity_log/dom_actions.h"
#include "chrome/browser/extensions/api/messaging/message_service.h" #include "chrome/browser/extensions/api/messaging/message_service.h"
#include "chrome/browser/extensions/event_router.h" #include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_function_dispatcher.h" #include "chrome/browser/extensions/extension_function_dispatcher.h"
...@@ -31,6 +32,7 @@ ...@@ -31,6 +32,7 @@
#include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/api/i18n/default_locale_handler.h" #include "chrome/common/extensions/api/i18n/default_locale_handler.h"
#include "chrome/common/extensions/dom_action_types.h"
#include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_file_util.h" #include "chrome/common/extensions/extension_file_util.h"
#include "chrome/common/extensions/extension_messages.h" #include "chrome/common/extensions/extension_messages.h"
...@@ -122,7 +124,7 @@ void AddDOMActionToExtensionActivityLog( ...@@ -122,7 +124,7 @@ void AddDOMActionToExtensionActivityLog(
const string16& url_title, const string16& url_title,
const std::string& api_call, const std::string& api_call,
scoped_ptr<ListValue> args, scoped_ptr<ListValue> args,
const std::string& extra) { const int call_type) {
// The ActivityLog can only be accessed from the main (UI) thread. If we're // 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. // running on the wrong thread, re-dispatch from the main thread.
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
...@@ -135,13 +137,14 @@ void AddDOMActionToExtensionActivityLog( ...@@ -135,13 +137,14 @@ void AddDOMActionToExtensionActivityLog(
url_title, url_title,
api_call, api_call,
base::Passed(&args), base::Passed(&args),
extra)); call_type));
} else { } else {
extensions::ActivityLog* activity_log = extensions::ActivityLog* activity_log =
extensions::ActivityLog::GetInstance(profile); extensions::ActivityLog::GetInstance(profile);
if (activity_log->IsLogEnabled()) if (activity_log->IsLogEnabled())
activity_log->LogDOMAction(extension, url, url_title, activity_log->LogDOMAction(
api_call, args.get(), extra); extension, url, url_title, api_call, args.get(),
static_cast<extensions::DomActionType::Type>(call_type), "");
} }
} }
...@@ -663,7 +666,7 @@ void ChromeRenderMessageFilter::OnAddDOMActionToExtensionActivityLog( ...@@ -663,7 +666,7 @@ void ChromeRenderMessageFilter::OnAddDOMActionToExtensionActivityLog(
AddDOMActionToExtensionActivityLog(profile_, extension, AddDOMActionToExtensionActivityLog(profile_, extension,
params.url, params.url_title, params.url, params.url_title,
params.api_call, args.Pass(), params.api_call, args.Pass(),
params.extra); params.call_type);
} }
void ChromeRenderMessageFilter::OnAddEventToExtensionActivityLog( void ChromeRenderMessageFilter::OnAddEventToExtensionActivityLog(
......
...@@ -207,6 +207,7 @@ ...@@ -207,6 +207,7 @@
'common/extensions/csp_handler.h', 'common/extensions/csp_handler.h',
'common/extensions/csp_validator.cc', 'common/extensions/csp_validator.cc',
'common/extensions/csp_validator.h', 'common/extensions/csp_validator.h',
'common/extensions/dom_action_types.h',
'common/extensions/extension.cc', 'common/extensions/extension.cc',
'common/extensions/extension.h', 'common/extensions/extension.h',
'common/extensions/extension_constants.cc', 'common/extensions/extension_constants.cc',
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_COMMON_EXTENSIONS_DOM_ACTION_TYPES_H_
#define CHROME_COMMON_EXTENSIONS_DOM_ACTION_TYPES_H_
namespace extensions {
struct DomActionType {
// These values should not be changed. Append any additional values to the
// end with sequential numbers.
enum Type {
GETTER = 0, // For Content Script DOM manipulations
SETTER = 1, // For Content Script DOM manipulations
METHOD = 2, // For Content Script DOM manipulations
INSERTED = 3, // For when Content Scripts are added to pages
XHR = 4, // When an extension core sends an XHR
WEBREQUEST = 5, // When a page request is modified with the WebRequest API
MODIFIED = 6, // For legacy, also used as a catch-all
};
};
} // namespace
#endif // CHROME_COMMON_EXTENSIONS_DOM_ACTION_TYPES_H_
...@@ -57,8 +57,8 @@ IPC_STRUCT_BEGIN(ExtensionHostMsg_DOMAction_Params) ...@@ -57,8 +57,8 @@ IPC_STRUCT_BEGIN(ExtensionHostMsg_DOMAction_Params)
// List of arguments. // List of arguments.
IPC_STRUCT_MEMBER(ListValue, arguments) IPC_STRUCT_MEMBER(ListValue, arguments)
// Extra logging information. // Type of DOM API call.
IPC_STRUCT_MEMBER(std::string, extra) IPC_STRUCT_MEMBER(int, call_type)
IPC_STRUCT_END() IPC_STRUCT_END()
// Parameters structure for ExtensionHostMsg_Request. // Parameters structure for ExtensionHostMsg_Request.
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "chrome/renderer/extensions/dom_activity_logger.h" #include "chrome/renderer/extensions/dom_activity_logger.h"
#include "base/logging.h" #include "base/logging.h"
#include "chrome/common/extensions/dom_action_types.h"
#include "chrome/common/extensions/extension_messages.h" #include "chrome/common/extensions/extension_messages.h"
#include "chrome/renderer/chrome_render_process_observer.h" #include "chrome/renderer/chrome_render_process_observer.h"
#include "content/public/renderer/render_thread.h" #include "content/public/renderer/render_thread.h"
...@@ -21,13 +22,13 @@ DOMActivityLogger::DOMActivityLogger(const std::string& extension_id, ...@@ -21,13 +22,13 @@ DOMActivityLogger::DOMActivityLogger(const std::string& extension_id,
const GURL& url, const GURL& url,
const string16& title) const string16& title)
: extension_id_(extension_id), url_(url), title_(title) { : extension_id_(extension_id), url_(url), title_(title) {
} } // namespace extensions
void DOMActivityLogger::log( void DOMActivityLogger::log(
const WebString& api_name, const WebString& api_name,
int argc, int argc,
const v8::Handle<v8::Value> argv[], const v8::Handle<v8::Value> argv[],
const WebString& extra_info) { const WebString& call_type) {
scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
scoped_ptr<ListValue> argv_list_value(new ListValue()); scoped_ptr<ListValue> argv_list_value(new ListValue());
for (int i =0; i < argc; i++) { for (int i =0; i < argc; i++) {
...@@ -39,7 +40,13 @@ void DOMActivityLogger::log( ...@@ -39,7 +40,13 @@ void DOMActivityLogger::log(
params.url_title = title_; params.url_title = title_;
params.api_call = api_name.utf8(); params.api_call = api_name.utf8();
params.arguments.Swap(argv_list_value.get()); params.arguments.Swap(argv_list_value.get());
params.extra = extra_info.utf8(); const std::string type = call_type.utf8();
if (type == "Getter")
params.call_type = DomActionType::GETTER;
else if (type == "Setter")
params.call_type = DomActionType::SETTER;
else
params.call_type = DomActionType::METHOD;
content::RenderThread::Get()->Send( content::RenderThread::Get()->Send(
new ExtensionHostMsg_AddDOMActionToActivityLog(extension_id_, params)); new ExtensionHostMsg_AddDOMActionToActivityLog(extension_id_, params));
......
...@@ -33,7 +33,7 @@ class DOMActivityLogger: public WebKit::WebDOMActivityLogger { ...@@ -33,7 +33,7 @@ class DOMActivityLogger: public WebKit::WebDOMActivityLogger {
virtual void log(const WebString& api_name, virtual void log(const WebString& api_name,
int argc, int argc,
const v8::Handle<v8::Value> argv[], const v8::Handle<v8::Value> argv[],
const WebString& extra_info); const WebString& call_type);
// If extension activity logging is enabled then check (using the // If extension activity logging is enabled then check (using the
// WebKit API) if there is no logger attached to the world corresponding // WebKit API) if there is no logger attached to the world corresponding
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment