Skip to content

Commit

Permalink
[Merge 103] [journeys] Respect AllowDeletingBrowserHistory in WebUI H…
Browse files Browse the repository at this point in the history
…andler

We should enforce it at the UI level too, but this minimal fix is
designed to be mergeable, so we can fix prior versions of Chrome too.

(cherry picked from commit 2323d6f)

Bug: 1327743
Change-Id: I51c7eb8bbbb339a6c3bf3e11921191a22615d308
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3656845
Reviewed-by: Sophie Chang <sophiechang@chromium.org>
Commit-Queue: Tommy Li <tommycli@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1005971}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3661441
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/5060@{#183}
Cr-Branched-From: b83393d-refs/heads/main@{#1002911}
  • Loading branch information
Tommy Li authored and Chromium LUCI CQ committed May 23, 2022
1 parent 8bf4b88 commit a1138ed
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/common/pref_names.h"
#include "components/history/core/browser/history_types.h"
#include "components/history_clusters/core/config.h"
#include "components/history_clusters/core/features.h"
Expand Down Expand Up @@ -249,6 +250,16 @@ void HistoryClustersHandler::LoadMoreClusters(const std::string& query) {
void HistoryClustersHandler::RemoveVisits(
std::vector<mojom::URLVisitPtr> visits,
RemoveVisitsCallback callback) {
// TODO(crbug.com/1327743): Enforced here because enforcing at the UI level is
// too complicated to merge. We can consider removing this clause or turning
// it to a DCHECK after we enforce it at the UI level, but it's essentially
// harmless to keep it here too.
if (!profile_->GetPrefs()->GetBoolean(
::prefs::kAllowDeletingBrowserHistory)) {
std::move(callback).Run(false);
return;
}

// Reject the request if a pending task exists or the set of visits is empty.
if (remove_task_tracker_.HasTrackedTasks() || visits.empty()) {
std::move(callback).Run(false);
Expand Down

0 comments on commit a1138ed

Please sign in to comment.