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

Unified Diff: chrome/browser/extensions/api/history/history_api.cc

Issue 23785002: Clean up activity log URLs when history is cleaned. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Declare dependency Created 7 years, 3 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
« no previous file with comments | « chrome/browser/extensions/api/history/history_api.h ('k') | chrome/browser/ui/webui/history_ui.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/history/history_api.cc
diff --git a/chrome/browser/extensions/api/history/history_api.cc b/chrome/browser/extensions/api/history/history_api.cc
index e387b4f417935db2918ece5a031a515c18ea3788..8faa05675dc05bb16922c1b6f165620eb0cfd493 100644
--- a/chrome/browser/extensions/api/history/history_api.cc
+++ b/chrome/browser/extensions/api/history/history_api.cc
@@ -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;
}
« no previous file with comments | « chrome/browser/extensions/api/history/history_api.h ('k') | chrome/browser/ui/webui/history_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698