Commit 196d63b9 authored by Evan Stade's avatar Evan Stade Committed by Chromium LUCI CQ

Remove some Chrome dependencies from AppBannerSettingsHelper.

Bug: 1147268
Change-Id: I7b67ba260d5b2f818ee52308a25cec8d496dac1d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2638218Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845775}
parent bc227842
......@@ -16,12 +16,12 @@
#include "base/util/values/values_util.h"
#include "chrome/browser/banners/app_banner_manager.h"
#include "chrome/browser/banners/app_banner_metrics.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/permissions/permissions_client.h"
#include "components/variations/variations_associated_data.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/web_contents.h"
#include "url/gurl.h"
......@@ -89,12 +89,13 @@ class AppPrefs {
const GURL& origin,
const std::string& package_name_or_start_url)
: origin_(origin) {
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
if (profile->IsOffTheRecord() || !origin.is_valid())
content::BrowserContext* browser_context =
web_contents->GetBrowserContext();
if (browser_context->IsOffTheRecord() || !origin.is_valid())
return;
settings_ = HostContentSettingsMapFactory::GetForProfile(profile);
settings_ =
permissions::PermissionsClient::Get()->GetSettingsMap(browser_context);
origin_dict_ = GetOriginAppBannerData(settings_, origin);
dict_ = origin_dict_->FindKeyOfType(package_name_or_start_url,
base::Value::Type::DICTIONARY);
......@@ -249,10 +250,10 @@ void NextInstallTextAnimation::RecordToPrefs(content::WebContents* web_contents,
const char AppBannerSettingsHelper::kInstantAppsKey[] = "instantapps";
void AppBannerSettingsHelper::ClearHistoryForURLs(
Profile* profile,
content::BrowserContext* browser_context,
const std::set<GURL>& origin_urls) {
HostContentSettingsMap* settings =
HostContentSettingsMapFactory::GetForProfile(profile);
permissions::PermissionsClient::Get()->GetSettingsMap(browser_context);
for (const GURL& origin_url : origin_urls) {
settings->SetWebsiteSettingDefaultScope(
origin_url, GURL(), ContentSettingsType::APP_BANNER, nullptr);
......@@ -398,11 +399,12 @@ void AppBannerSettingsHelper::RecordMinutesFromFirstVisitToShow(
TrackMinutesFromFirstVisitToBannerShown(minutes);
}
bool AppBannerSettingsHelper::WasLaunchedRecently(Profile* profile,
bool AppBannerSettingsHelper::WasLaunchedRecently(
content::BrowserContext* browser_context,
const GURL& origin_url,
base::Time now) {
HostContentSettingsMap* settings =
HostContentSettingsMapFactory::GetForProfile(profile);
permissions::PermissionsClient::Get()->GetSettingsMap(browser_context);
std::unique_ptr<base::DictionaryValue> origin_dict =
GetOriginAppBannerData(settings, origin_url);
......
......@@ -13,11 +13,11 @@
#include "base/time/time.h"
namespace content {
class BrowserContext;
class WebContents;
} // namespace content
class GURL;
class Profile;
namespace webapps {
......@@ -80,7 +80,7 @@ class AppBannerSettingsHelper {
// 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,
static void ClearHistoryForURLs(content::BrowserContext* browser_context,
const std::set<GURL>& origin_urls);
// Record a banner installation event, for either a WEB or NATIVE app.
......@@ -148,7 +148,7 @@ class AppBannerSettingsHelper {
// last ten days. This allows services outside app banners to utilise the
// content setting that ensures app banners are not shown for sites which ave
// already been added to homescreen.
static bool WasLaunchedRecently(Profile* profile,
static bool WasLaunchedRecently(content::BrowserContext* browser_context,
const GURL& origin_url,
base::Time now);
......
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