Commit 38c69cc6 authored by benwells's avatar benwells Committed by Commit bot

Clear app banner data when history is cleared.

This takes two forms. Firstly, When specific URLs are removed from the
browsing history, all historical banner data is removed for that URL.
Secondly, when browsing history is cleared, all app banner historical
data is cleared.

BUG=457407

Review URL: https://codereview.chromium.org/919843003

Cr-Commit-Position: refs/heads/master@{#316416}
parent 7fa9d30a
......@@ -79,6 +79,21 @@ base::DictionaryValue* GetAppDict(base::DictionaryValue* origin_dict,
} // namespace
void AppBannerSettingsHelper::ClearHistoryForURLs(
Profile* profile,
const std::set<GURL>& origin_urls) {
HostContentSettingsMap* settings = profile->GetHostContentSettingsMap();
for (const GURL& origin_url : origin_urls) {
ContentSettingsPattern pattern(ContentSettingsPattern::FromURL(origin_url));
if (!pattern.IsValid())
continue;
settings->SetWebsiteSetting(pattern, ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(),
nullptr);
}
}
void AppBannerSettingsHelper::RecordBannerEvent(
content::WebContents* web_contents,
const GURL& origin_url,
......
......@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_
#define CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_
#include <set>
#include <string>
#include <vector>
......@@ -16,6 +17,7 @@ class WebContents;
} // namespace content
class GURL;
class Profile;
// Utility class to record banner events for the given package or start url.
//
......@@ -44,6 +46,13 @@ class AppBannerSettingsHelper {
APP_BANNER_EVENT_NUM_EVENTS,
};
// The content setting basically records a simplified subset of history.
// For privacy reasons this needs to be cleared. The ClearHistoryForURLs
// function removes any information from the banner content settings for the
// given URls.
static void ClearHistoryForURLs(Profile* profile,
const std::set<GURL>& origin_urls);
static void RecordBannerEvent(content::WebContents* web_contents,
const GURL& origin_url,
const std::string& package_name_or_start_url,
......
......@@ -558,7 +558,7 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
#endif
#if defined(OS_ANDROID)
if (remove_mask & REMOVE_APP_BANNER_DATA) {
if (remove_mask & REMOVE_APP_BANNER_DATA || remove_mask & REMOVE_HISTORY) {
profile_->GetHostContentSettingsMap()->ClearSettingsForOneType(
CONTENT_SETTINGS_TYPE_APP_BANNER);
}
......
......@@ -20,6 +20,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "base/values.h"
#include "chrome/browser/banners/app_banner_settings_helper.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/history/history_service.h"
......@@ -670,6 +671,9 @@ void BrowsingHistoryHandler::HandleRemoveVisits(const base::ListValue* args) {
activity_log->RemoveURLs(it->urls);
}
#endif
for (const history::ExpireHistoryArgs& expire_entry : expire_list)
AppBannerSettingsHelper::ClearHistoryForURLs(profile, expire_entry.urls);
}
void BrowsingHistoryHandler::HandleClearBrowsingData(
......
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