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

Remove Activity Log usage of Extension objects

Previously, the AL used Extension objects when notifying the UI of new activity. If an extension were uninstalled in the middle of logging something, the Extension object would be deallocated before the UI tried to use the reference. Since we are replacing the old UI, I am switching to using IDs instead of Extension objects.

[[[ Reverted because it was causing heapcheck failures. Retrying a new version. ]]]

BUG=236395

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=203218

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=203618

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=203950

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204054 0039d316-1c4b-4281-b951-d872f2087c98
parent 16354054
...@@ -157,21 +157,16 @@ ActivityLog* ActivityLog::GetInstance(Profile* profile) { ...@@ -157,21 +157,16 @@ ActivityLog* ActivityLog::GetInstance(Profile* profile) {
return ActivityLogFactory::GetForProfile(profile); return ActivityLogFactory::GetForProfile(profile);
} }
void ActivityLog::AddObserver(const Extension* extension, void ActivityLog::AddObserver(ActivityLog::Observer* observer) {
ActivityLog::Observer* observer) {
if (!IsLogEnabled()) return; if (!IsLogEnabled()) return;
if (observers_.count(extension) == 0) // TODO(felt) Re-implement Observer notification HERE for the API.
observers_[extension] = new ObserverListThreadSafe<Observer>;
observers_[extension]->AddObserver(observer);
} }
void ActivityLog::RemoveObserver(const Extension* extension, void ActivityLog::RemoveObserver(ActivityLog::Observer* observer) {
ActivityLog::Observer* observer) { // TODO(felt) Re-implement Observer notification HERE for the API.
if (observers_.count(extension) == 1)
observers_[extension]->RemoveObserver(observer);
} }
void ActivityLog::LogAPIActionInternal(const Extension* extension, void ActivityLog::LogAPIActionInternal(const std::string& extension_id,
const std::string& api_call, const std::string& api_call,
ListValue* args, ListValue* args,
const std::string& extra, const std::string& extra,
...@@ -183,29 +178,14 @@ void ActivityLog::LogAPIActionInternal(const Extension* extension, ...@@ -183,29 +178,14 @@ void ActivityLog::LogAPIActionInternal(const Extension* extension,
APIAction::LookupTabId(api_call, args, profile_); APIAction::LookupTabId(api_call, args, profile_);
} }
scoped_refptr<APIAction> action = new APIAction( scoped_refptr<APIAction> action = new APIAction(
extension->id(), extension_id,
base::Time::Now(), base::Time::Now(),
type, type,
api_call, api_call,
MakeArgList(args), MakeArgList(args),
extra); extra);
ScheduleAndForget(&ActivityDatabase::RecordAction, action); ScheduleAndForget(&ActivityDatabase::RecordAction, action);
// TODO(felt) Re-implement Observer notification HERE for the API.
// Display the action.
ObserverMap::const_iterator iter = observers_.find(extension);
if (iter != observers_.end()) {
if (type == APIAction::CALL) {
iter->second->Notify(&Observer::OnExtensionActivity,
extension,
ActivityLog::ACTIVITY_EXTENSION_API_CALL,
MakeCallSignature(api_call, args));
} else if (type == APIAction::EVENT_CALLBACK) {
iter->second->Notify(&Observer::OnExtensionActivity,
extension,
ActivityLog::ACTIVITY_EVENT_DISPATCH,
MakeCallSignature(api_call, args));
}
}
if (log_activity_to_stdout_) if (log_activity_to_stdout_)
LOG(INFO) << action->PrintForDebug(); LOG(INFO) << action->PrintForDebug();
} else { } else {
...@@ -214,7 +194,7 @@ void ActivityLog::LogAPIActionInternal(const Extension* extension, ...@@ -214,7 +194,7 @@ void ActivityLog::LogAPIActionInternal(const Extension* extension,
} }
// A wrapper around LogAPIActionInternal, but we know it's an API call. // A wrapper around LogAPIActionInternal, but we know it's an API call.
void ActivityLog::LogAPIAction(const Extension* extension, void ActivityLog::LogAPIAction(const std::string& extension_id,
const std::string& api_call, const std::string& api_call,
ListValue* args, ListValue* args,
const std::string& extra) { const std::string& extra) {
...@@ -222,7 +202,7 @@ void ActivityLog::LogAPIAction(const Extension* extension, ...@@ -222,7 +202,7 @@ void ActivityLog::LogAPIAction(const Extension* extension,
if (!testing_mode_ && if (!testing_mode_ &&
arg_whitelist_api_.find(api_call) == arg_whitelist_api_.end()) arg_whitelist_api_.find(api_call) == arg_whitelist_api_.end())
args->Clear(); args->Clear();
LogAPIActionInternal(extension, LogAPIActionInternal(extension_id,
api_call, api_call,
args, args,
extra, extra,
...@@ -233,7 +213,7 @@ void ActivityLog::LogAPIAction(const Extension* extension, ...@@ -233,7 +213,7 @@ void ActivityLog::LogAPIAction(const Extension* extension,
// being fired and triggering extension code. Having the two separate methods // being fired and triggering extension code. Having the two separate methods
// (LogAPIAction vs LogEventAction) lets us hide how we actually choose to // (LogAPIAction vs LogEventAction) lets us hide how we actually choose to
// handle them. Right now they're being handled almost the same. // handle them. Right now they're being handled almost the same.
void ActivityLog::LogEventAction(const Extension* extension, void ActivityLog::LogEventAction(const std::string& extension_id,
const std::string& api_call, const std::string& api_call,
ListValue* args, ListValue* args,
const std::string& extra) { const std::string& extra) {
...@@ -241,14 +221,14 @@ void ActivityLog::LogEventAction(const Extension* extension, ...@@ -241,14 +221,14 @@ void ActivityLog::LogEventAction(const Extension* extension,
if (!testing_mode_ && if (!testing_mode_ &&
arg_whitelist_api_.find(api_call) == arg_whitelist_api_.end()) arg_whitelist_api_.find(api_call) == arg_whitelist_api_.end())
args->Clear(); args->Clear();
LogAPIActionInternal(extension, LogAPIActionInternal(extension_id,
api_call, api_call,
args, args,
extra, extra,
APIAction::EVENT_CALLBACK); APIAction::EVENT_CALLBACK);
} }
void ActivityLog::LogBlockedAction(const Extension* extension, void ActivityLog::LogBlockedAction(const std::string& extension_id,
const std::string& blocked_call, const std::string& blocked_call,
ListValue* args, ListValue* args,
BlockedAction::Reason reason, BlockedAction::Reason reason,
...@@ -257,27 +237,19 @@ void ActivityLog::LogBlockedAction(const Extension* extension, ...@@ -257,27 +237,19 @@ void ActivityLog::LogBlockedAction(const Extension* extension,
if (!testing_mode_ && if (!testing_mode_ &&
arg_whitelist_api_.find(blocked_call) == arg_whitelist_api_.end()) arg_whitelist_api_.find(blocked_call) == arg_whitelist_api_.end())
args->Clear(); args->Clear();
scoped_refptr<BlockedAction> action = new BlockedAction(extension->id(), scoped_refptr<BlockedAction> action = new BlockedAction(extension_id,
base::Time::Now(), base::Time::Now(),
blocked_call, blocked_call,
MakeArgList(args), MakeArgList(args),
reason, reason,
extra); extra);
ScheduleAndForget(&ActivityDatabase::RecordAction, action); ScheduleAndForget(&ActivityDatabase::RecordAction, action);
// Display the action. // TODO(felt) Re-implement Observer notification HERE for the API.
ObserverMap::const_iterator iter = observers_.find(extension);
if (iter != observers_.end()) {
std::string blocked_str = MakeCallSignature(blocked_call, args);
iter->second->Notify(&Observer::OnExtensionActivity,
extension,
ActivityLog::ACTIVITY_EXTENSION_API_BLOCK,
blocked_str);
}
if (log_activity_to_stdout_) if (log_activity_to_stdout_)
LOG(INFO) << action->PrintForDebug(); LOG(INFO) << action->PrintForDebug();
} }
void ActivityLog::LogDOMAction(const Extension* extension, void ActivityLog::LogDOMAction(const std::string& extension_id,
const GURL& url, const GURL& url,
const string16& url_title, const string16& url_title,
const std::string& api_call, const std::string& api_call,
...@@ -288,7 +260,7 @@ void ActivityLog::LogDOMAction(const Extension* extension, ...@@ -288,7 +260,7 @@ void ActivityLog::LogDOMAction(const Extension* extension,
if (call_type == DomActionType::METHOD && api_call == "XMLHttpRequest.open") if (call_type == DomActionType::METHOD && api_call == "XMLHttpRequest.open")
call_type = DomActionType::XHR; 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(),
call_type, call_type,
url, url,
...@@ -297,29 +269,12 @@ void ActivityLog::LogDOMAction(const Extension* extension, ...@@ -297,29 +269,12 @@ void ActivityLog::LogDOMAction(const Extension* extension,
MakeArgList(args), MakeArgList(args),
extra); extra);
ScheduleAndForget(&ActivityDatabase::RecordAction, action); ScheduleAndForget(&ActivityDatabase::RecordAction, action);
// TODO(felt) Re-implement Observer notification HERE for the API.
// Display the action.
ObserverMap::const_iterator iter = observers_.find(extension);
if (iter != observers_.end()) {
// TODO(felt): This is a kludge, planning to update this when new
// UI is in place.
if (call_type == DomActionType::INSERTED) {
iter->second->Notify(&Observer::OnExtensionActivity,
extension,
ActivityLog::ACTIVITY_CONTENT_SCRIPT,
action->PrintForDebug());
} else {
iter->second->Notify(&Observer::OnExtensionActivity,
extension,
ActivityLog::ACTIVITY_CONTENT_SCRIPT,
MakeCallSignature(api_call, args));
}
}
if (log_activity_to_stdout_) if (log_activity_to_stdout_)
LOG(INFO) << action->PrintForDebug(); LOG(INFO) << action->PrintForDebug();
} }
void ActivityLog::LogWebRequestAction(const Extension* extension, void ActivityLog::LogWebRequestAction(const std::string& extension_id,
const GURL& url, const GURL& url,
const std::string& api_call, const std::string& api_call,
scoped_ptr<DictionaryValue> details, scoped_ptr<DictionaryValue> details,
...@@ -341,7 +296,7 @@ void ActivityLog::LogWebRequestAction(const Extension* extension, ...@@ -341,7 +296,7 @@ void ActivityLog::LogWebRequestAction(const Extension* extension,
serializer.SerializeAndOmitBinaryValues(*details); serializer.SerializeAndOmitBinaryValues(*details);
scoped_refptr<DOMAction> action = new DOMAction( scoped_refptr<DOMAction> action = new DOMAction(
extension->id(), extension_id,
base::Time::Now(), base::Time::Now(),
DomActionType::WEBREQUEST, DomActionType::WEBREQUEST,
url, url,
...@@ -350,15 +305,7 @@ void ActivityLog::LogWebRequestAction(const Extension* extension, ...@@ -350,15 +305,7 @@ void ActivityLog::LogWebRequestAction(const Extension* extension,
details_string, details_string,
extra); extra);
ScheduleAndForget(&ActivityDatabase::RecordAction, action); ScheduleAndForget(&ActivityDatabase::RecordAction, action);
// TODO(felt) Re-implement Observer notification HERE for the API.
// Display the action.
ObserverMap::const_iterator iter = observers_.find(extension);
if (iter != observers_.end()) {
iter->second->Notify(&Observer::OnExtensionActivity,
extension,
ActivityLog::ACTIVITY_CONTENT_SCRIPT,
action->PrintForDebug());
}
if (log_activity_to_stdout_) if (log_activity_to_stdout_)
LOG(INFO) << action->PrintForDebug(); LOG(INFO) << action->PrintForDebug();
} }
...@@ -409,7 +356,7 @@ void ActivityLog::OnScriptsExecuted( ...@@ -409,7 +356,7 @@ 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));
LogDOMAction(extension, LogDOMAction(extension->id(),
on_url, on_url,
web_contents->GetTitle(), web_contents->GetTitle(),
std::string(), // no api call here std::string(), // no api call here
...@@ -425,21 +372,4 @@ void ActivityLog::DatabaseErrorCallback(int error, sql::Statement* stmt) { ...@@ -425,21 +372,4 @@ void ActivityLog::DatabaseErrorCallback(int error, sql::Statement* stmt) {
ScheduleAndForget(&ActivityDatabase::KillDatabase); ScheduleAndForget(&ActivityDatabase::KillDatabase);
} }
// static
const char* ActivityLog::ActivityToString(Activity activity) {
switch (activity) {
case ActivityLog::ACTIVITY_EXTENSION_API_CALL:
return "api_call";
case ActivityLog::ACTIVITY_EXTENSION_API_BLOCK:
return "api_block";
case ActivityLog::ACTIVITY_CONTENT_SCRIPT:
return "content_script";
case ActivityLog::ACTIVITY_EVENT_DISPATCH:
return "event_dispatch";
default:
NOTREACHED();
return "";
}
}
} // namespace extensions } // namespace extensions
...@@ -38,20 +38,10 @@ class Extension; ...@@ -38,20 +38,10 @@ class Extension;
class ActivityLog : public BrowserContextKeyedService, class ActivityLog : public BrowserContextKeyedService,
public TabHelper::ScriptExecutionObserver { public TabHelper::ScriptExecutionObserver {
public: public:
enum Activity {
ACTIVITY_EXTENSION_API_CALL, // Extension API invocation is called.
ACTIVITY_EXTENSION_API_BLOCK, // Extension API invocation is blocked.
ACTIVITY_CONTENT_SCRIPT, // Content script is executing.
ACTIVITY_EVENT_DISPATCH, // Event sent to listener in extension.
};
// Observers can listen for activity events. // Observers can listen for activity events.
class Observer { class Observer {
public: public:
virtual void OnExtensionActivity( virtual void OnExtensionActivity(scoped_refptr<Action> activity) = 0;
const Extension* extension,
Activity activity,
const std::string& message) = 0;
}; };
// ActivityLog is a singleton, so don't instantiate it with the constructor; // ActivityLog is a singleton, so don't instantiate it with the constructor;
...@@ -68,17 +58,13 @@ class ActivityLog : public BrowserContextKeyedService, ...@@ -68,17 +58,13 @@ class ActivityLog : public BrowserContextKeyedService,
static void RecomputeLoggingIsEnabled(); static void RecomputeLoggingIsEnabled();
// Add/remove observer. // Add/remove observer.
void AddObserver(const Extension* extension, Observer* observer); void AddObserver(Observer* observer);
void RemoveObserver(const Extension* extension, void RemoveObserver(Observer* observer);
Observer* observer);
// Check for the existence observer list by extension_id.
bool HasObservers(const Extension* extension) const;
// Log a successful API call made by an extension. // Log a successful API call made by an extension.
// This will create an APIAction for storage in the database. // This will create an APIAction for storage in the database.
// (Note: implemented as a wrapper for LogAPIActionInternal.) // (Note: implemented as a wrapper for LogAPIActionInternal.)
void LogAPIAction(const Extension* extension, void LogAPIAction(const std::string& extension_id,
const std::string& name, // e.g., tabs.get const std::string& name, // e.g., tabs.get
ListValue* args, // the argument values e.g. 46 ListValue* args, // the argument values e.g. 46
const std::string& extra); // any extra logging info const std::string& extra); // any extra logging info
...@@ -86,14 +72,14 @@ class ActivityLog : public BrowserContextKeyedService, ...@@ -86,14 +72,14 @@ class ActivityLog : public BrowserContextKeyedService,
// Log an event notification delivered to an extension. // Log an event notification delivered to an extension.
// This will create an APIAction for storage in the database. // This will create an APIAction for storage in the database.
// (Note: implemented as a wrapper for LogAPIActionInternal.) // (Note: implemented as a wrapper for LogAPIActionInternal.)
void LogEventAction(const Extension* extension, void LogEventAction(const std::string& extension_id,
const std::string& name, // e.g., tabs.onUpdate const std::string& name, // e.g., tabs.onUpdate
ListValue* args, // arguments to the callback ListValue* args, // arguments to the callback
const std::string& extra); // any extra logging info const std::string& extra); // any extra logging info
// Log a blocked API call made by an extension. // Log a blocked API call made by an extension.
// This will create a BlockedAction for storage in the database. // This will create a BlockedAction for storage in the database.
void LogBlockedAction(const Extension* extension, void LogBlockedAction(const std::string& extension_id,
const std::string& blocked_call, // e.g., tabs.get const std::string& blocked_call, // e.g., tabs.get
ListValue* args, // argument values ListValue* args, // argument values
const BlockedAction::Reason reason, // why it's blocked const BlockedAction::Reason reason, // why it's blocked
...@@ -101,7 +87,7 @@ class ActivityLog : public BrowserContextKeyedService, ...@@ -101,7 +87,7 @@ 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.
void LogDOMAction(const Extension* extension, void LogDOMAction(const std::string& extension_id,
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
...@@ -111,7 +97,7 @@ class ActivityLog : public BrowserContextKeyedService, ...@@ -111,7 +97,7 @@ class ActivityLog : public BrowserContextKeyedService,
// 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
// headers. // headers.
void LogWebRequestAction(const Extension* extension, void LogWebRequestAction(const std::string& extension_id,
const GURL& url, const GURL& url,
const std::string& api_call, const std::string& api_call,
scoped_ptr<base::DictionaryValue> details, scoped_ptr<base::DictionaryValue> details,
...@@ -142,7 +128,7 @@ class ActivityLog : public BrowserContextKeyedService, ...@@ -142,7 +128,7 @@ class ActivityLog : public BrowserContextKeyedService,
// We log callbacks and API calls very similarly, so we handle them the same // We log callbacks and API calls very similarly, so we handle them the same
// way internally. // way internally.
void LogAPIActionInternal( void LogAPIActionInternal(
const Extension* extension, const std::string& extension_id,
const std::string& api_call, const std::string& api_call,
ListValue* args, ListValue* args,
const std::string& extra, const std::string& extra,
...@@ -159,8 +145,6 @@ class ActivityLog : public BrowserContextKeyedService, ...@@ -159,8 +145,6 @@ class ActivityLog : public BrowserContextKeyedService,
// The callback when initializing the database. // The callback when initializing the database.
void OnDBInitComplete(); void OnDBInitComplete();
static const char* ActivityToString(Activity activity);
// The Schedule methods dispatch the calls to the database on a // The Schedule methods dispatch the calls to the database on a
// separate thread. We dispatch to the UI thread if the DB thread doesn't // separate thread. We dispatch to the UI thread if the DB thread doesn't
// exist, which should only happen in tests where there is no DB thread. // exist, which should only happen in tests where there is no DB thread.
...@@ -186,10 +170,6 @@ class ActivityLog : public BrowserContextKeyedService, ...@@ -186,10 +170,6 @@ class ActivityLog : public BrowserContextKeyedService,
} }
typedef ObserverListThreadSafe<Observer> ObserverList; typedef ObserverListThreadSafe<Observer> ObserverList;
typedef std::map<const Extension*, scoped_refptr<ObserverList> >
ObserverMap;
// A map of extensions to activity observers for that extension.
ObserverMap observers_;
// The database wrapper that does the actual database I/O. // The database wrapper that does the actual database I/O.
// We initialize this on the same thread as the ActivityLog, but then // We initialize this on the same thread as the ActivityLog, but then
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
#include "base/run_loop.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/activity_log/dom_actions.h"
...@@ -13,7 +15,6 @@ ...@@ -13,7 +15,6 @@
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/dom_action_types.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/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/test/test_browser_thread.h" #include "content/public/test/test_browser_thread.h"
...@@ -26,34 +27,44 @@ ...@@ -26,34 +27,44 @@
#include "chrome/browser/chromeos/settings/device_settings_service.h" #include "chrome/browser/chromeos/settings/device_settings_service.h"
#endif #endif
namespace {
const char kExtensionId[] = "abc";
} // namespace
namespace extensions { namespace extensions {
class ActivityLogTest : public ChromeRenderViewHostTestHarness { class ActivityLogTest : public testing::Test {
public: public:
ActivityLogTest() ActivityLogTest()
: ui_thread_(BrowserThread::UI, base::MessageLoop::current()), : message_loop_(base::MessageLoop::TYPE_IO),
db_thread_(BrowserThread::DB, base::MessageLoop::current()), ui_thread_(BrowserThread::UI, &message_loop_),
file_thread_(BrowserThread::FILE, base::MessageLoop::current()) {} db_thread_(BrowserThread::DB, &message_loop_),
file_thread_(BrowserThread::FILE, &message_loop_),
io_thread_(BrowserThread::IO, &message_loop_) {}
virtual void SetUp() OVERRIDE { virtual void SetUp() OVERRIDE {
ChromeRenderViewHostTestHarness::SetUp();
CommandLine command_line(CommandLine::NO_PROGRAM); CommandLine command_line(CommandLine::NO_PROGRAM);
profile_ = profile_.reset(new TestingProfile());
Profile::FromBrowserContext(web_contents()->GetBrowserContext());
extension_service_ = static_cast<TestExtensionSystem*>(
ExtensionSystem::Get(profile_))->CreateExtensionService(
&command_line, base::FilePath(), false);
CommandLine::ForCurrentProcess()->AppendSwitch( CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableExtensionActivityLogging); switches::kEnableExtensionActivityLogging);
CommandLine::ForCurrentProcess()->AppendSwitch( CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableExtensionActivityLogTesting); switches::kEnableExtensionActivityLogTesting);
ActivityLog::RecomputeLoggingIsEnabled(); ActivityLog::RecomputeLoggingIsEnabled();
extension_service_ = static_cast<TestExtensionSystem*>(
ExtensionSystem::Get(profile_.get()))->CreateExtensionService(
&command_line, base::FilePath(), false);
} }
virtual ~ActivityLogTest() { virtual void TearDown() OVERRIDE {
base::MessageLoop::current()->PostTask(FROM_HERE, base::RunLoop().RunUntilIdle();
base::MessageLoop::QuitClosure()); profile_.reset(NULL);
base::MessageLoop::current()->Run(); base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::MessageLoop::QuitClosure(),
base::TimeDelta::FromSeconds(4)); // Don't hang on failure.
base::RunLoop().RunUntilIdle();
} }
static void RetrieveActions_LogAndFetchActions( static void RetrieveActions_LogAndFetchActions(
...@@ -64,7 +75,8 @@ class ActivityLogTest : public ChromeRenderViewHostTestHarness { ...@@ -64,7 +75,8 @@ class ActivityLogTest : public ChromeRenderViewHostTestHarness {
static void Arguments_Missing( static void Arguments_Missing(
scoped_ptr<std::vector<scoped_refptr<Action> > > i) { scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
scoped_refptr<Action> last = i->front(); scoped_refptr<Action> last = i->front();
std::string noargs = "ID: odlameecjipmbmbejkplpemijjgpljce, CATEGORY: " std::string id(kExtensionId);
std::string noargs = "ID: " + id + ", CATEGORY: "
"CALL, API: tabs.testMethod, ARGS: "; "CALL, API: tabs.testMethod, ARGS: ";
ASSERT_EQ(noargs, last->PrintForDebug()); ASSERT_EQ(noargs, last->PrintForDebug());
} }
...@@ -72,19 +84,22 @@ class ActivityLogTest : public ChromeRenderViewHostTestHarness { ...@@ -72,19 +84,22 @@ class ActivityLogTest : public ChromeRenderViewHostTestHarness {
static void Arguments_Present( static void Arguments_Present(
scoped_ptr<std::vector<scoped_refptr<Action> > > i) { scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
scoped_refptr<Action> last = i->front(); scoped_refptr<Action> last = i->front();
std::string args = "ID: odlameecjipmbmbejkplpemijjgpljce, CATEGORY: " std::string id(kExtensionId);
std::string args = "ID: " + id + ", CATEGORY: "
"CALL, API: extension.connect, ARGS: \"hello\", \"world\""; "CALL, API: extension.connect, ARGS: \"hello\", \"world\"";
ASSERT_EQ(args, last->PrintForDebug()); ASSERT_EQ(args, last->PrintForDebug());
} }
protected: protected:
scoped_ptr<TestingProfile> profile_;
ExtensionService* extension_service_; ExtensionService* extension_service_;
Profile* profile_;
private: private:
base::MessageLoop message_loop_;
content::TestBrowserThread ui_thread_; content::TestBrowserThread ui_thread_;
content::TestBrowserThread db_thread_; content::TestBrowserThread db_thread_;
content::TestBrowserThread file_thread_; content::TestBrowserThread file_thread_;
content::TestBrowserThread io_thread_;
#if defined OS_CHROMEOS #if defined OS_CHROMEOS
chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
...@@ -98,7 +113,6 @@ TEST_F(ActivityLogTest, Enabled) { ...@@ -98,7 +113,6 @@ TEST_F(ActivityLogTest, Enabled) {
} }
TEST_F(ActivityLogTest, Construct) { TEST_F(ActivityLogTest, Construct) {
ActivityLog* activity_log = ActivityLog::GetInstance(profile_);
scoped_refptr<const Extension> extension = scoped_refptr<const Extension> extension =
ExtensionBuilder() ExtensionBuilder()
.SetManifest(DictionaryBuilder() .SetManifest(DictionaryBuilder()
...@@ -107,29 +121,22 @@ TEST_F(ActivityLogTest, Construct) { ...@@ -107,29 +121,22 @@ TEST_F(ActivityLogTest, Construct) {
.Set("manifest_version", 2)) .Set("manifest_version", 2))
.Build(); .Build();
extension_service_->AddExtension(extension); extension_service_->AddExtension(extension);
ActivityLog* activity_log = ActivityLog::GetInstance(profile_.get());
scoped_ptr<ListValue> args(new ListValue()); scoped_ptr<ListValue> args(new ListValue());
ASSERT_TRUE(ActivityLog::IsLogEnabled()); ASSERT_TRUE(ActivityLog::IsLogEnabled());
activity_log->LogAPIAction( activity_log->LogAPIAction(
extension, std::string("tabs.testMethod"), args.get(), std::string()); kExtensionId, std::string("tabs.testMethod"), args.get(), std::string());
} }
TEST_F(ActivityLogTest, LogAndFetchActions) { TEST_F(ActivityLogTest, LogAndFetchActions) {
ActivityLog* activity_log = ActivityLog::GetInstance(profile_); ActivityLog* activity_log = ActivityLog::GetInstance(profile_.get());
scoped_refptr<const Extension> extension =
ExtensionBuilder()
.SetManifest(DictionaryBuilder()
.Set("name", "Test extension")
.Set("version", "1.0.0")
.Set("manifest_version", 2))
.Build();
extension_service_->AddExtension(extension);
scoped_ptr<ListValue> args(new ListValue()); scoped_ptr<ListValue> args(new ListValue());
ASSERT_TRUE(ActivityLog::IsLogEnabled()); ASSERT_TRUE(ActivityLog::IsLogEnabled());
// Write some API calls // Write some API calls
activity_log->LogAPIAction( activity_log->LogAPIAction(
extension, std::string("tabs.testMethod"), args.get(), std::string()); kExtensionId, std::string("tabs.testMethod"), args.get(), std::string());
activity_log->LogDOMAction(extension, activity_log->LogDOMAction(kExtensionId,
GURL("http://www.google.com"), GURL("http://www.google.com"),
string16(), string16(),
std::string("document.write"), std::string("document.write"),
...@@ -137,35 +144,26 @@ TEST_F(ActivityLogTest, LogAndFetchActions) { ...@@ -137,35 +144,26 @@ TEST_F(ActivityLogTest, LogAndFetchActions) {
DomActionType::METHOD, DomActionType::METHOD,
std::string("extra")); std::string("extra"));
activity_log->GetActions( activity_log->GetActions(
extension->id(), kExtensionId,
0, 0,
base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions)); base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions));
} }
TEST_F(ActivityLogTest, LogWithoutArguments) { TEST_F(ActivityLogTest, LogWithoutArguments) {
ActivityLog* activity_log = ActivityLog::GetInstance(profile_); ActivityLog* activity_log = ActivityLog::GetInstance(profile_.get());
activity_log->SetArgumentLoggingForTesting(false); activity_log->SetArgumentLoggingForTesting(false);
scoped_refptr<const Extension> extension =
ExtensionBuilder()
.SetManifest(DictionaryBuilder()
.Set("name", "Test extension")
.Set("version", "1.0.0")
.Set("manifest_version", 2))
.Build();
extension_service_->AddExtension(extension);
ASSERT_TRUE(ActivityLog::IsLogEnabled()); ASSERT_TRUE(ActivityLog::IsLogEnabled());
scoped_ptr<ListValue> args(new ListValue()); scoped_ptr<ListValue> args(new ListValue());
args->Set(0, new base::StringValue("hello")); args->Set(0, new base::StringValue("hello"));
args->Set(1, new base::StringValue("world")); args->Set(1, new base::StringValue("world"));
activity_log->LogAPIAction( activity_log->LogAPIAction(
extension, std::string("tabs.testMethod"), args.get(), std::string()); kExtensionId, std::string("tabs.testMethod"), args.get(), std::string());
activity_log->GetActions( activity_log->GetActions(
extension->id(), 0, base::Bind(ActivityLogTest::Arguments_Missing)); kExtensionId, 0, base::Bind(ActivityLogTest::Arguments_Missing));
} }
TEST_F(ActivityLogTest, LogWithArguments) { TEST_F(ActivityLogTest, LogWithArguments) {
ActivityLog* activity_log = ActivityLog::GetInstance(profile_);
scoped_refptr<const Extension> extension = scoped_refptr<const Extension> extension =
ExtensionBuilder() ExtensionBuilder()
.SetManifest(DictionaryBuilder() .SetManifest(DictionaryBuilder()
...@@ -174,15 +172,18 @@ TEST_F(ActivityLogTest, LogWithArguments) { ...@@ -174,15 +172,18 @@ TEST_F(ActivityLogTest, LogWithArguments) {
.Set("manifest_version", 2)) .Set("manifest_version", 2))
.Build(); .Build();
extension_service_->AddExtension(extension); extension_service_->AddExtension(extension);
ActivityLog* activity_log = ActivityLog::GetInstance(profile_.get());
ASSERT_TRUE(ActivityLog::IsLogEnabled()); ASSERT_TRUE(ActivityLog::IsLogEnabled());
scoped_ptr<ListValue> args(new ListValue()); scoped_ptr<ListValue> args(new ListValue());
args->Set(0, new base::StringValue("hello")); args->Set(0, new base::StringValue("hello"));
args->Set(1, new base::StringValue("world")); args->Set(1, new base::StringValue("world"));
activity_log->LogAPIAction( activity_log->LogAPIAction(kExtensionId,
extension, std::string("extension.connect"), args.get(), std::string()); std::string("extension.connect"),
args.get(),
std::string());
activity_log->GetActions( activity_log->GetActions(
extension->id(), 0, base::Bind(ActivityLogTest::Arguments_Present)); kExtensionId, 0, base::Bind(ActivityLogTest::Arguments_Present));
} }
} // namespace extensions } // namespace extensions
......
...@@ -1601,30 +1601,14 @@ void LogExtensionActivity(Profile* profile, ...@@ -1601,30 +1601,14 @@ void LogExtensionActivity(Profile* profile,
url, url,
api_call, api_call,
details.release())); details.release()));
} else {
// An ExtensionService might not be running during unit tests, or an
// extension might have been unloadd by the time we get to logging it. In
// those cases log a warning.
ExtensionService* extension_service =
extensions::ExtensionSystem::Get(profile)->extension_service();
if (!extension_service) {
LOG(WARNING) << "ExtensionService does not seem to be available "
<< "(this may be normal for unit tests)";
} else {
const Extension* extension =
extension_service->extensions()->GetByID(extension_id);
if (!extension) {
LOG(WARNING) << "Extension " << extension_id << " not found!";
} else { } else {
extensions::ActivityLog::GetInstance(profile)->LogWebRequestAction( extensions::ActivityLog::GetInstance(profile)->LogWebRequestAction(
extension, extension_id,
url, url,
api_call, api_call,
details.Pass(), details.Pass(),
""); "");
} }
}
}
} }
} // namespace } // namespace
......
...@@ -111,25 +111,8 @@ void EventRouter::LogExtensionEventMessage(void* profile_id, ...@@ -111,25 +111,8 @@ void EventRouter::LogExtensionEventMessage(void* profile_id,
Profile* profile = reinterpret_cast<Profile*>(profile_id); Profile* profile = reinterpret_cast<Profile*>(profile_id);
if (!g_browser_process->profile_manager()->IsValidProfile(profile)) if (!g_browser_process->profile_manager()->IsValidProfile(profile))
return; return;
// An ExtensionService might not be running during unit tests, or an
// extension might have been unloaded by the time we get to logging it. In
// those cases log a warning.
ExtensionService* extension_service =
ExtensionSystem::Get(profile)->extension_service();
if (!extension_service) {
LOG(WARNING) << "ExtensionService does not seem to be available "
<< "(this may be normal for unit tests)";
} else {
const Extension* extension =
extension_service->extensions()->GetByID(extension_id);
if (!extension) {
LOG(WARNING) << "Extension " << extension_id << " not found!";
} else {
ActivityLog::GetInstance(profile)->LogEventAction( ActivityLog::GetInstance(profile)->LogEventAction(
extension, event_name, event_args.get(), std::string()); extension_id, event_name, event_args.get(), std::string());
}
}
} }
} }
......
...@@ -46,7 +46,7 @@ using WebKit::WebSecurityOrigin; ...@@ -46,7 +46,7 @@ using WebKit::WebSecurityOrigin;
namespace { namespace {
void LogSuccess(const Extension* extension, void LogSuccess(const std::string& extension_id,
const std::string& api_name, const std::string& api_name,
scoped_ptr<ListValue> args, scoped_ptr<ListValue> args,
Profile* profile) { Profile* profile) {
...@@ -56,18 +56,19 @@ void LogSuccess(const Extension* extension, ...@@ -56,18 +56,19 @@ void LogSuccess(const Extension* extension,
BrowserThread::PostTask(BrowserThread::UI, BrowserThread::PostTask(BrowserThread::UI,
FROM_HERE, FROM_HERE,
base::Bind(&LogSuccess, base::Bind(&LogSuccess,
extension, extension_id,
api_name, api_name,
base::Passed(&args), base::Passed(&args),
profile)); profile));
} else { } else {
extensions::ActivityLog* activity_log = extensions::ActivityLog* activity_log =
extensions::ActivityLog::GetInstance(profile); extensions::ActivityLog::GetInstance(profile);
activity_log->LogAPIAction(extension, api_name, args.get(), std::string()); activity_log->LogAPIAction(
extension_id, api_name, args.get(), std::string());
} }
} }
void LogFailure(const Extension* extension, void LogFailure(const std::string& extension_id,
const std::string& api_name, const std::string& api_name,
scoped_ptr<ListValue> args, scoped_ptr<ListValue> args,
extensions::BlockedAction::Reason reason, extensions::BlockedAction::Reason reason,
...@@ -78,7 +79,7 @@ void LogFailure(const Extension* extension, ...@@ -78,7 +79,7 @@ void LogFailure(const Extension* extension,
BrowserThread::PostTask(BrowserThread::UI, BrowserThread::PostTask(BrowserThread::UI,
FROM_HERE, FROM_HERE,
base::Bind(&LogFailure, base::Bind(&LogFailure,
extension, extension_id,
api_name, api_name,
base::Passed(&args), base::Passed(&args),
reason, reason,
...@@ -87,7 +88,7 @@ void LogFailure(const Extension* extension, ...@@ -87,7 +88,7 @@ void LogFailure(const Extension* extension,
extensions::ActivityLog* activity_log = extensions::ActivityLog* activity_log =
extensions::ActivityLog::GetInstance(profile); extensions::ActivityLog::GetInstance(profile);
activity_log->LogBlockedAction( activity_log->LogBlockedAction(
extension, api_name, args.get(), reason, std::string()); extension_id, api_name, args.get(), reason, std::string());
} }
} }
...@@ -264,7 +265,7 @@ void ExtensionFunctionDispatcher::DispatchOnIOThread( ...@@ -264,7 +265,7 @@ void ExtensionFunctionDispatcher::DispatchOnIOThread(
scoped_ptr<ListValue> args(params.arguments.DeepCopy()); scoped_ptr<ListValue> args(params.arguments.DeepCopy());
if (!function.get()) { if (!function.get()) {
LogFailure(extension, LogFailure(extension->id(),
params.name, params.name,
args.Pass(), args.Pass(),
extensions::BlockedAction::ACCESS_DENIED, extensions::BlockedAction::ACCESS_DENIED,
...@@ -284,7 +285,7 @@ void ExtensionFunctionDispatcher::DispatchOnIOThread( ...@@ -284,7 +285,7 @@ void ExtensionFunctionDispatcher::DispatchOnIOThread(
extension_info_map->IsIncognitoEnabled(extension->id())); extension_info_map->IsIncognitoEnabled(extension->id()));
if (!CheckPermissions(function.get(), extension, params, callback)) { if (!CheckPermissions(function.get(), extension, params, callback)) {
LogFailure(extension, LogFailure(extension->id(),
params.name, params.name,
args.Pass(), args.Pass(),
extensions::BlockedAction::ACCESS_DENIED, extensions::BlockedAction::ACCESS_DENIED,
...@@ -298,13 +299,13 @@ void ExtensionFunctionDispatcher::DispatchOnIOThread( ...@@ -298,13 +299,13 @@ void ExtensionFunctionDispatcher::DispatchOnIOThread(
&params.arguments, &params.arguments,
base::TimeTicks::Now()); base::TimeTicks::Now());
if (violation_error.empty()) { if (violation_error.empty()) {
LogSuccess(extension, LogSuccess(extension->id(),
params.name, params.name,
args.Pass(), args.Pass(),
profile_cast); profile_cast);
function->Run(); function->Run();
} else { } else {
LogFailure(extension, LogFailure(extension->id(),
params.name, params.name,
args.Pass(), args.Pass(),
extensions::BlockedAction::QUOTA_EXCEEDED, extensions::BlockedAction::QUOTA_EXCEEDED,
...@@ -369,7 +370,7 @@ void ExtensionFunctionDispatcher::DispatchWithCallback( ...@@ -369,7 +370,7 @@ void ExtensionFunctionDispatcher::DispatchWithCallback(
scoped_ptr<ListValue> args(params.arguments.DeepCopy()); scoped_ptr<ListValue> args(params.arguments.DeepCopy());
if (!function.get()) { if (!function.get()) {
LogFailure(extension, LogFailure(extension->id(),
params.name, params.name,
args.Pass(), args.Pass(),
extensions::BlockedAction::ACCESS_DENIED, extensions::BlockedAction::ACCESS_DENIED,
...@@ -389,7 +390,7 @@ void ExtensionFunctionDispatcher::DispatchWithCallback( ...@@ -389,7 +390,7 @@ void ExtensionFunctionDispatcher::DispatchWithCallback(
function->set_include_incognito(service->CanCrossIncognito(extension)); function->set_include_incognito(service->CanCrossIncognito(extension));
if (!CheckPermissions(function.get(), extension, params, callback)) { if (!CheckPermissions(function.get(), extension, params, callback)) {
LogFailure(extension, LogFailure(extension->id(),
params.name, params.name,
args.Pass(), args.Pass(),
extensions::BlockedAction::ACCESS_DENIED, extensions::BlockedAction::ACCESS_DENIED,
...@@ -405,10 +406,10 @@ void ExtensionFunctionDispatcher::DispatchWithCallback( ...@@ -405,10 +406,10 @@ void ExtensionFunctionDispatcher::DispatchWithCallback(
if (violation_error.empty()) { if (violation_error.empty()) {
// See crbug.com/39178. // See crbug.com/39178.
ExternalProtocolHandler::PermitLaunchUrl(); ExternalProtocolHandler::PermitLaunchUrl();
LogSuccess(extension, params.name, args.Pass(), profile()); LogSuccess(extension->id(), params.name, args.Pass(), profile());
function->Run(); function->Run();
} else { } else {
LogFailure(extension, LogFailure(extension->id(),
params.name, params.name,
args.Pass(), args.Pass(),
extensions::BlockedAction::QUOTA_EXCEEDED, extensions::BlockedAction::QUOTA_EXCEEDED,
......
...@@ -64,7 +64,7 @@ enum ActivityLogCallType { ...@@ -64,7 +64,7 @@ enum ActivityLogCallType {
void AddAPIActionToExtensionActivityLog( void AddAPIActionToExtensionActivityLog(
Profile* profile, Profile* profile,
const ActivityLogCallType call_type, const ActivityLogCallType call_type,
const extensions::Extension* extension, const std::string& extension_id,
const std::string& api_call, const std::string& api_call,
scoped_ptr<ListValue> args, scoped_ptr<ListValue> args,
const std::string& extra) { const std::string& extra) {
...@@ -76,7 +76,7 @@ void AddAPIActionToExtensionActivityLog( ...@@ -76,7 +76,7 @@ void AddAPIActionToExtensionActivityLog(
base::Bind(&AddAPIActionToExtensionActivityLog, base::Bind(&AddAPIActionToExtensionActivityLog,
profile, profile,
call_type, call_type,
extension, extension_id,
api_call, api_call,
base::Passed(&args), base::Passed(&args),
extra)); extra));
...@@ -85,30 +85,36 @@ void AddAPIActionToExtensionActivityLog( ...@@ -85,30 +85,36 @@ void AddAPIActionToExtensionActivityLog(
extensions::ActivityLog::GetInstance(profile); extensions::ActivityLog::GetInstance(profile);
if (activity_log->IsLogEnabled()) { if (activity_log->IsLogEnabled()) {
if (call_type == ACTIVITYAPI) if (call_type == ACTIVITYAPI)
activity_log->LogAPIAction(extension, api_call, args.get(), extra); activity_log->LogAPIAction(extension_id,
api_call,
args.get(),
extra);
else if (call_type == ACTIVITYEVENT) else if (call_type == ACTIVITYEVENT)
activity_log->LogEventAction(extension, api_call, args.get(), extra); activity_log->LogEventAction(extension_id,
api_call,
args.get(),
extra);
} }
} }
} }
void AddBlockedActionToExtensionActivityLog( void AddBlockedActionToExtensionActivityLog(
Profile* profile, Profile* profile,
const extensions::Extension* extension, const std::string& extension_id,
const std::string& api_call) { const std::string& api_call) {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(BrowserThread::UI, BrowserThread::PostTask(BrowserThread::UI,
FROM_HERE, FROM_HERE,
base::Bind(&AddBlockedActionToExtensionActivityLog, base::Bind(&AddBlockedActionToExtensionActivityLog,
profile, profile,
extension, extension_id,
api_call)); api_call));
} 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()) {
scoped_ptr<ListValue> empty_args(new ListValue()); scoped_ptr<ListValue> empty_args(new ListValue());
activity_log->LogBlockedAction(extension, activity_log->LogBlockedAction(extension_id,
api_call, api_call,
empty_args.get(), empty_args.get(),
extensions::BlockedAction::ACCESS_DENIED, extensions::BlockedAction::ACCESS_DENIED,
...@@ -119,7 +125,7 @@ void AddBlockedActionToExtensionActivityLog( ...@@ -119,7 +125,7 @@ void AddBlockedActionToExtensionActivityLog(
void AddDOMActionToExtensionActivityLog( void AddDOMActionToExtensionActivityLog(
Profile* profile, Profile* profile,
const extensions::Extension* extension, const std::string& extension_id,
const GURL& url, const GURL& url,
const string16& url_title, const string16& url_title,
const std::string& api_call, const std::string& api_call,
...@@ -132,7 +138,7 @@ void AddDOMActionToExtensionActivityLog( ...@@ -132,7 +138,7 @@ void AddDOMActionToExtensionActivityLog(
FROM_HERE, FROM_HERE,
base::Bind(&AddDOMActionToExtensionActivityLog, base::Bind(&AddDOMActionToExtensionActivityLog,
profile, profile,
extension, extension_id,
url, url,
url_title, url_title,
api_call, api_call,
...@@ -143,7 +149,7 @@ void AddDOMActionToExtensionActivityLog( ...@@ -143,7 +149,7 @@ void AddDOMActionToExtensionActivityLog(
extensions::ActivityLog::GetInstance(profile); extensions::ActivityLog::GetInstance(profile);
if (activity_log->IsLogEnabled()) if (activity_log->IsLogEnabled())
activity_log->LogDOMAction( activity_log->LogDOMAction(
extension, url, url_title, api_call, args.get(), extension_id, url, url_title, api_call, args.get(),
static_cast<extensions::DomActionType::Type>(call_type), ""); static_cast<extensions::DomActionType::Type>(call_type), "");
} }
} }
...@@ -649,12 +655,10 @@ void ChromeRenderMessageFilter::OnExtensionResumeRequests(int route_id) { ...@@ -649,12 +655,10 @@ void ChromeRenderMessageFilter::OnExtensionResumeRequests(int route_id) {
void ChromeRenderMessageFilter::OnAddAPIActionToExtensionActivityLog( void ChromeRenderMessageFilter::OnAddAPIActionToExtensionActivityLog(
const std::string& extension_id, const std::string& extension_id,
const ExtensionHostMsg_APIActionOrEvent_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()); scoped_ptr<ListValue> args(params.arguments.DeepCopy());
// The activity is recorded as an API action in the extension // The activity is recorded as an API action in the extension
// activity log. // activity log.
AddAPIActionToExtensionActivityLog(profile_, ACTIVITYAPI, extension, AddAPIActionToExtensionActivityLog(profile_, ACTIVITYAPI, extension_id,
params.api_call, args.Pass(), params.api_call, args.Pass(),
params.extra); params.extra);
} }
...@@ -662,12 +666,10 @@ void ChromeRenderMessageFilter::OnAddAPIActionToExtensionActivityLog( ...@@ -662,12 +666,10 @@ void ChromeRenderMessageFilter::OnAddAPIActionToExtensionActivityLog(
void ChromeRenderMessageFilter::OnAddDOMActionToExtensionActivityLog( void ChromeRenderMessageFilter::OnAddDOMActionToExtensionActivityLog(
const std::string& extension_id, const std::string& extension_id,
const ExtensionHostMsg_DOMAction_Params& params) { const ExtensionHostMsg_DOMAction_Params& params) {
const extensions::Extension* extension =
extension_info_map_->extensions().GetByID(extension_id);
scoped_ptr<ListValue> args(params.arguments.DeepCopy()); scoped_ptr<ListValue> args(params.arguments.DeepCopy());
// The activity is recorded as a DOM action on the extension // The activity is recorded as a DOM action on the extension
// activity log. // activity log.
AddDOMActionToExtensionActivityLog(profile_, extension, AddDOMActionToExtensionActivityLog(profile_, extension_id,
params.url, params.url_title, params.url, params.url_title,
params.api_call, args.Pass(), params.api_call, args.Pass(),
params.call_type); params.call_type);
...@@ -676,12 +678,10 @@ void ChromeRenderMessageFilter::OnAddDOMActionToExtensionActivityLog( ...@@ -676,12 +678,10 @@ void ChromeRenderMessageFilter::OnAddDOMActionToExtensionActivityLog(
void ChromeRenderMessageFilter::OnAddEventToExtensionActivityLog( void ChromeRenderMessageFilter::OnAddEventToExtensionActivityLog(
const std::string& extension_id, const std::string& extension_id,
const ExtensionHostMsg_APIActionOrEvent_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()); scoped_ptr<ListValue> args(params.arguments.DeepCopy());
// The activity is recorded as an event in the extension // The activity is recorded as an event in the extension
// activity log. // activity log.
AddAPIActionToExtensionActivityLog(profile_, ACTIVITYEVENT, extension, AddAPIActionToExtensionActivityLog(profile_, ACTIVITYEVENT, extension_id,
params.api_call, args.Pass(), params.api_call, args.Pass(),
params.extra); params.extra);
} }
...@@ -689,10 +689,8 @@ void ChromeRenderMessageFilter::OnAddEventToExtensionActivityLog( ...@@ -689,10 +689,8 @@ void ChromeRenderMessageFilter::OnAddEventToExtensionActivityLog(
void ChromeRenderMessageFilter::OnAddBlockedCallToExtensionActivityLog( void ChromeRenderMessageFilter::OnAddBlockedCallToExtensionActivityLog(
const std::string& extension_id, const std::string& extension_id,
const std::string& function_name) { const std::string& function_name) {
const extensions::Extension* extension =
extension_info_map_->extensions().GetByID(extension_id);
AddBlockedActionToExtensionActivityLog(profile_, AddBlockedActionToExtensionActivityLog(profile_,
extension, extension_id,
function_name); function_name);
} }
......
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