Index: chrome/browser/extensions/activity_log/activity_log.cc |
diff --git a/chrome/browser/extensions/activity_log/activity_log.cc b/chrome/browser/extensions/activity_log/activity_log.cc |
index b2980e67733fa93d4cd631dd37fed26fc7db268f..9b617cb066f5c38ffedbb6fa72148289318e0e46 100644 |
--- a/chrome/browser/extensions/activity_log/activity_log.cc |
+++ b/chrome/browser/extensions/activity_log/activity_log.cc |
@@ -200,18 +200,15 @@ ActivityLog* ActivityLog::GetInstance(Profile* profile) { |
void ActivityLog::AddObserver(const Extension* extension, |
ActivityLog::Observer* observer) { |
if (!IsLogEnabled()) return; |
- if (observers_.count(extension) == 0) |
- observers_[extension] = new ObserverListThreadSafe<Observer>; |
- observers_[extension]->AddObserver(observer); |
+ // TODO(felt) Re-implement Observer notification HERE for the API. |
} |
void ActivityLog::RemoveObserver(const Extension* extension, |
ActivityLog::Observer* observer) { |
- if (observers_.count(extension) == 1) |
- observers_[extension]->RemoveObserver(observer); |
+ // TODO(felt) Re-implement Observer notification HERE for the API. |
} |
-void ActivityLog::LogAPIActionInternal(const Extension* extension, |
+void ActivityLog::LogAPIActionInternal(const std::string& extension_id, |
const std::string& api_call, |
ListValue* args, |
const std::string& extra, |
@@ -223,29 +220,14 @@ void ActivityLog::LogAPIActionInternal(const Extension* extension, |
APIAction::LookupTabId(api_call, args, profile_); |
} |
scoped_refptr<APIAction> action = new APIAction( |
- extension->id(), |
+ extension_id, |
base::Time::Now(), |
type, |
api_call, |
MakeArgList(args), |
extra); |
ScheduleAndForget(&ActivityDatabase::RecordAction, action); |
- |
- // 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)); |
- } |
- } |
+ // TODO(felt) Re-implement Observer notification HERE for the API. |
if (log_activity_to_stdout_) |
LOG(INFO) << action->PrintForDebug(); |
} else { |
@@ -254,7 +236,7 @@ void ActivityLog::LogAPIActionInternal(const Extension* extension, |
} |
// 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, |
ListValue* args, |
const std::string& extra) { |
@@ -262,7 +244,7 @@ void ActivityLog::LogAPIAction(const Extension* extension, |
if (!testing_mode_ && |
arg_whitelist_api_.find(api_call) == arg_whitelist_api_.end()) |
args->Clear(); |
- LogAPIActionInternal(extension, |
+ LogAPIActionInternal(extension_id, |
api_call, |
args, |
extra, |
@@ -273,7 +255,7 @@ void ActivityLog::LogAPIAction(const Extension* extension, |
// being fired and triggering extension code. Having the two separate methods |
// (LogAPIAction vs LogEventAction) lets us hide how we actually choose to |
// 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, |
ListValue* args, |
const std::string& extra) { |
@@ -281,14 +263,14 @@ void ActivityLog::LogEventAction(const Extension* extension, |
if (!testing_mode_ && |
arg_whitelist_api_.find(api_call) == arg_whitelist_api_.end()) |
args->Clear(); |
- LogAPIActionInternal(extension, |
+ LogAPIActionInternal(extension_id, |
api_call, |
args, |
extra, |
APIAction::EVENT_CALLBACK); |
} |
-void ActivityLog::LogBlockedAction(const Extension* extension, |
+void ActivityLog::LogBlockedAction(const std::string& extension_id, |
const std::string& blocked_call, |
ListValue* args, |
BlockedAction::Reason reason, |
@@ -297,27 +279,19 @@ void ActivityLog::LogBlockedAction(const Extension* extension, |
if (!testing_mode_ && |
arg_whitelist_api_.find(blocked_call) == arg_whitelist_api_.end()) |
args->Clear(); |
- scoped_refptr<BlockedAction> action = new BlockedAction(extension->id(), |
+ scoped_refptr<BlockedAction> action = new BlockedAction(extension_id, |
base::Time::Now(), |
blocked_call, |
MakeArgList(args), |
reason, |
extra); |
ScheduleAndForget(&ActivityDatabase::RecordAction, action); |
- // Display the action. |
- 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); |
- } |
+ // TODO(felt) Re-implement Observer notification HERE for the API. |
if (log_activity_to_stdout_) |
LOG(INFO) << action->PrintForDebug(); |
} |
-void ActivityLog::LogDOMActionInternal(const Extension* extension, |
+void ActivityLog::LogDOMActionInternal(const std::string& extension_id, |
const GURL& url, |
const string16& url_title, |
const std::string& api_call, |
@@ -325,7 +299,7 @@ void ActivityLog::LogDOMActionInternal(const Extension* extension, |
const std::string& extra, |
DOMAction::DOMActionType verb) { |
scoped_refptr<DOMAction> action = new DOMAction( |
- extension->id(), |
+ extension_id, |
base::Time::Now(), |
verb, |
url, |
@@ -334,29 +308,12 @@ void ActivityLog::LogDOMActionInternal(const Extension* extension, |
MakeArgList(args), |
extra); |
ScheduleAndForget(&ActivityDatabase::RecordAction, action); |
- |
- // 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 (verb == DOMAction::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)); |
- } |
- } |
+ // TODO(felt) Re-implement Observer notification HERE for the API. |
if (log_activity_to_stdout_) |
LOG(INFO) << action->PrintForDebug(); |
} |
-void ActivityLog::LogDOMAction(const Extension* extension, |
+void ActivityLog::LogDOMAction(const std::string& extension_id, |
const GURL& url, |
const string16& url_title, |
const std::string& api_call, |
@@ -374,7 +331,7 @@ void ActivityLog::LogDOMAction(const Extension* extension, |
} else if (extra == "Method") { |
action = DOMAction::METHOD; |
} |
- LogDOMActionInternal(extension, |
+ LogDOMActionInternal(extension_id, |
url, |
url_title, |
api_call, |
@@ -383,7 +340,7 @@ void ActivityLog::LogDOMAction(const Extension* extension, |
action); |
} |
-void ActivityLog::LogWebRequestAction(const Extension* extension, |
+void ActivityLog::LogWebRequestAction(const std::string& extension_id, |
const GURL& url, |
const std::string& api_call, |
scoped_ptr<DictionaryValue> details, |
@@ -405,7 +362,7 @@ void ActivityLog::LogWebRequestAction(const Extension* extension, |
serializer.SerializeAndOmitBinaryValues(*details); |
scoped_refptr<DOMAction> action = new DOMAction( |
- extension->id(), |
+ extension_id, |
base::Time::Now(), |
DOMAction::WEBREQUEST, |
url, |
@@ -414,15 +371,7 @@ void ActivityLog::LogWebRequestAction(const Extension* extension, |
details_string, |
extra); |
ScheduleAndForget(&ActivityDatabase::RecordAction, action); |
- |
- // 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()); |
- } |
+ // TODO(felt) Re-implement Observer notification HERE for the API. |
if (log_activity_to_stdout_) |
LOG(INFO) << action->PrintForDebug(); |
} |
@@ -473,7 +422,7 @@ void ActivityLog::OnScriptsExecuted( |
} |
scoped_ptr<ListValue> script_names(new ListValue()); |
script_names->Set(0, new StringValue(ext_scripts_str)); |
- LogDOMActionInternal(extension, |
+ LogDOMActionInternal(extension->id(), |
on_url, |
web_contents->GetTitle(), |
std::string(), // no api call here |