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 @@ ...@@ -16,12 +16,12 @@
#include "base/util/values/values_util.h" #include "base/util/values/values_util.h"
#include "chrome/browser/banners/app_banner_manager.h" #include "chrome/browser/banners/app_banner_manager.h"
#include "chrome/browser/banners/app_banner_metrics.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 "chrome/common/chrome_switches.h"
#include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings_pattern.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 "components/variations/variations_associated_data.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -89,12 +89,13 @@ class AppPrefs { ...@@ -89,12 +89,13 @@ class AppPrefs {
const GURL& origin, const GURL& origin,
const std::string& package_name_or_start_url) const std::string& package_name_or_start_url)
: origin_(origin) { : origin_(origin) {
Profile* profile = content::BrowserContext* browser_context =
Profile::FromBrowserContext(web_contents->GetBrowserContext()); web_contents->GetBrowserContext();
if (profile->IsOffTheRecord() || !origin.is_valid()) if (browser_context->IsOffTheRecord() || !origin.is_valid())
return; return;
settings_ = HostContentSettingsMapFactory::GetForProfile(profile); settings_ =
permissions::PermissionsClient::Get()->GetSettingsMap(browser_context);
origin_dict_ = GetOriginAppBannerData(settings_, origin); origin_dict_ = GetOriginAppBannerData(settings_, origin);
dict_ = origin_dict_->FindKeyOfType(package_name_or_start_url, dict_ = origin_dict_->FindKeyOfType(package_name_or_start_url,
base::Value::Type::DICTIONARY); base::Value::Type::DICTIONARY);
...@@ -249,10 +250,10 @@ void NextInstallTextAnimation::RecordToPrefs(content::WebContents* web_contents, ...@@ -249,10 +250,10 @@ void NextInstallTextAnimation::RecordToPrefs(content::WebContents* web_contents,
const char AppBannerSettingsHelper::kInstantAppsKey[] = "instantapps"; const char AppBannerSettingsHelper::kInstantAppsKey[] = "instantapps";
void AppBannerSettingsHelper::ClearHistoryForURLs( void AppBannerSettingsHelper::ClearHistoryForURLs(
Profile* profile, content::BrowserContext* browser_context,
const std::set<GURL>& origin_urls) { const std::set<GURL>& origin_urls) {
HostContentSettingsMap* settings = HostContentSettingsMap* settings =
HostContentSettingsMapFactory::GetForProfile(profile); permissions::PermissionsClient::Get()->GetSettingsMap(browser_context);
for (const GURL& origin_url : origin_urls) { for (const GURL& origin_url : origin_urls) {
settings->SetWebsiteSettingDefaultScope( settings->SetWebsiteSettingDefaultScope(
origin_url, GURL(), ContentSettingsType::APP_BANNER, nullptr); origin_url, GURL(), ContentSettingsType::APP_BANNER, nullptr);
...@@ -398,11 +399,12 @@ void AppBannerSettingsHelper::RecordMinutesFromFirstVisitToShow( ...@@ -398,11 +399,12 @@ void AppBannerSettingsHelper::RecordMinutesFromFirstVisitToShow(
TrackMinutesFromFirstVisitToBannerShown(minutes); TrackMinutesFromFirstVisitToBannerShown(minutes);
} }
bool AppBannerSettingsHelper::WasLaunchedRecently(Profile* profile, bool AppBannerSettingsHelper::WasLaunchedRecently(
const GURL& origin_url, content::BrowserContext* browser_context,
base::Time now) { const GURL& origin_url,
base::Time now) {
HostContentSettingsMap* settings = HostContentSettingsMap* settings =
HostContentSettingsMapFactory::GetForProfile(profile); permissions::PermissionsClient::Get()->GetSettingsMap(browser_context);
std::unique_ptr<base::DictionaryValue> origin_dict = std::unique_ptr<base::DictionaryValue> origin_dict =
GetOriginAppBannerData(settings, origin_url); GetOriginAppBannerData(settings, origin_url);
......
...@@ -13,11 +13,11 @@ ...@@ -13,11 +13,11 @@
#include "base/time/time.h" #include "base/time/time.h"
namespace content { namespace content {
class BrowserContext;
class WebContents; class WebContents;
} // namespace content } // namespace content
class GURL; class GURL;
class Profile;
namespace webapps { namespace webapps {
...@@ -80,7 +80,7 @@ class AppBannerSettingsHelper { ...@@ -80,7 +80,7 @@ class AppBannerSettingsHelper {
// For privacy reasons this needs to be cleared. The ClearHistoryForURLs // For privacy reasons this needs to be cleared. The ClearHistoryForURLs
// function removes any information from the banner content settings for the // function removes any information from the banner content settings for the
// given URls. // given URls.
static void ClearHistoryForURLs(Profile* profile, static void ClearHistoryForURLs(content::BrowserContext* browser_context,
const std::set<GURL>& origin_urls); const std::set<GURL>& origin_urls);
// Record a banner installation event, for either a WEB or NATIVE app. // Record a banner installation event, for either a WEB or NATIVE app.
...@@ -148,7 +148,7 @@ class AppBannerSettingsHelper { ...@@ -148,7 +148,7 @@ class AppBannerSettingsHelper {
// last ten days. This allows services outside app banners to utilise the // 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 // content setting that ensures app banners are not shown for sites which ave
// already been added to homescreen. // already been added to homescreen.
static bool WasLaunchedRecently(Profile* profile, static bool WasLaunchedRecently(content::BrowserContext* browser_context,
const GURL& origin_url, const GURL& origin_url,
base::Time now); 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