Clean up URLs from activity log when a user cleans history via the history UI...

Clean up URLs from activity log when a user cleans history via the history UI or using the extensions api.


BUG=253367

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221436 0039d316-1c4b-4281-b951-d872f2087c98
parent adb50733
......@@ -19,6 +19,7 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/extensions/activity_log/activity_log.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_special_storage_policy.h"
#include "chrome/browser/history/history_service.h"
......@@ -270,6 +271,11 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
base::Bind(&BrowsingDataRemover::OnHistoryDeletionDone,
base::Unretained(this)),
&history_task_tracker_);
// The extension activity contains details of which websites extensions
// were active on. It therefore indirectly stores details of websites a
// user has visited so best clean from here as well.
extensions::ActivityLog::GetInstance(profile_)->RemoveURLs(restrict_urls);
}
// Need to clear the host cache and accumulated speculative data, as it also
......
......@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/command_line.h"
#include "base/json/json_writer.h"
#include "base/lazy_instance.h"
#include "base/memory/scoped_ptr.h"
......@@ -17,6 +18,7 @@
#include "base/time/time.h"
#include "base/values.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/activity_log/activity_log.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/history/history_service.h"
......@@ -25,6 +27,7 @@
#include "chrome/browser/history/visit_filter.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/cancelable_task_tracker.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/api/experimental_history.h"
#include "chrome/common/extensions/api/history.h"
#include "chrome/common/pref_names.h"
......@@ -36,6 +39,7 @@ namespace extensions {
using api::experimental_history::MostVisitedItem;
using api::history::HistoryItem;
using api::history::VisitItem;
using extensions::ActivityLog;
typedef std::vector<linked_ptr<api::history::HistoryItem> >
HistoryItemList;
......@@ -223,6 +227,11 @@ ProfileKeyedAPIFactory<HistoryAPI>* HistoryAPI::GetFactoryInstance() {
return &g_factory.Get();
}
template<>
void ProfileKeyedAPIFactory<HistoryAPI>::DeclareFactoryDependencies() {
DependsOn(ActivityLogFactory::GetInstance());
}
void HistoryAPI::OnListenerAdded(const EventListenerInfo& details) {
history_event_router_.reset(new HistoryEventRouter(profile_));
ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this);
......@@ -444,6 +453,16 @@ bool HistoryDeleteUrlFunction::RunImpl() {
Profile::EXPLICIT_ACCESS);
hs->DeleteURL(url);
// Also clean out from the activity log. If the activity log testing flag is
// set then don't clean so testers can see what potentially malicious
// extensions have been trying to clean from their logs.
if (!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableExtensionActivityLogTesting)) {
ActivityLog* activity_log = ActivityLog::GetInstance(profile_);
DCHECK(activity_log);
activity_log->RemoveURL(url);
}
SendResponse(true);
return true;
}
......@@ -470,6 +489,14 @@ bool HistoryDeleteRangeFunction::RunAsyncImpl() {
base::Unretained(this)),
&task_tracker_);
// Also clean from the activity log unless in testing mode.
if (!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableExtensionActivityLogTesting)) {
ActivityLog* activity_log = ActivityLog::GetInstance(profile_);
DCHECK(activity_log);
activity_log->RemoveURLs(restrict_urls);
}
return true;
}
......@@ -493,6 +520,14 @@ bool HistoryDeleteAllFunction::RunAsyncImpl() {
base::Unretained(this)),
&task_tracker_);
// Also clean from the activity log unless in testing mode.
if (!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableExtensionActivityLogTesting)) {
ActivityLog* activity_log = ActivityLog::GetInstance(profile_);
DCHECK(activity_log);
activity_log->RemoveURLs(restrict_urls);
}
return true;
}
......
......@@ -84,6 +84,9 @@ class HistoryAPI : public ProfileKeyedAPI,
scoped_ptr<HistoryEventRouter> history_event_router_;
};
template<>
void ProfileKeyedAPIFactory<HistoryAPI>::DeclareFactoryDependencies();
// Base class for history function APIs.
class HistoryFunction : public AsyncExtensionFunction {
protected:
......
......@@ -24,6 +24,7 @@
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/activity_log/activity_log.h"
#include "chrome/browser/history/history_notifications.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/history/history_types.h"
......@@ -617,6 +618,17 @@ void BrowsingHistoryHandler::HandleRemoveVisits(const ListValue* args) {
base::Bind(&BrowsingHistoryHandler::RemoveWebHistoryComplete,
base::Unretained(this)));
}
// If the profile has activity logging enabled also clean up any URLs from
// the extension activity log. The extension activity log contains URLS
// which websites an extension has activity on so it will indirectly
// contain websites that a user has visited.
extensions::ActivityLog* activity_log =
extensions::ActivityLog::GetInstance(profile);
for (std::vector<history::ExpireHistoryArgs>::const_iterator it =
expire_list.begin(); it != expire_list.end(); ++it) {
activity_log->RemoveURLs(it->urls);
}
}
void BrowsingHistoryHandler::HandleClearBrowsingData(const ListValue* args) {
......
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