Commit 59c7bfec authored by Tommy Steimel's avatar Tommy Steimel Committed by Commit Bot

Kaleidoscope: Receive Media Feeds consent data from the frontend

Bug: b:154517281
Change-Id: I4dbdbfb787db3d6436def3f77a2d19b0052a26ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2361044
Commit-Queue: Tommy Steimel <steimel@chromium.org>
Reviewed-by: default avatarBecca Hughes <beccahughes@chromium.org>
Reviewed-by: default avatarChris Palmer <palmer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799878}
parent 2dcf0ac3
...@@ -236,8 +236,8 @@ class MediaHistoryKeyedService : public KeyedService, ...@@ -236,8 +236,8 @@ class MediaHistoryKeyedService : public KeyedService,
// Returns Media Feeds. // Returns Media Feeds.
struct GetMediaFeedsRequest { struct GetMediaFeedsRequest {
enum class Type { enum class Type {
// Return all the fields for debugging. // Return all the fields.
kDebugAll, kAll,
// Returns the top feeds to be fetched. These will be sorted by the // Returns the top feeds to be fetched. These will be sorted by the
// by audio+video watchtime descending and we will also populate the // by audio+video watchtime descending and we will also populate the
...@@ -263,7 +263,7 @@ class MediaHistoryKeyedService : public KeyedService, ...@@ -263,7 +263,7 @@ class MediaHistoryKeyedService : public KeyedService,
GetMediaFeedsRequest(); GetMediaFeedsRequest();
GetMediaFeedsRequest(const GetMediaFeedsRequest& t); GetMediaFeedsRequest(const GetMediaFeedsRequest& t);
Type type = Type::kDebugAll; Type type = Type::kAll;
// The maximum number of feeds to return. Only valid for |kTopFeedsForFetch| // The maximum number of feeds to return. Only valid for |kTopFeedsForFetch|
// and |kTopFeedsForDisplay|. // and |kTopFeedsForDisplay|.
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/chrome_pages.h"
#include "chrome/common/channel_info.h" #include "chrome/common/channel_info.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/signin/public/identity_manager/access_token_info.h" #include "components/signin/public/identity_manager/access_token_info.h"
#include "components/signin/public/identity_manager/identity_manager.h" #include "components/signin/public/identity_manager/identity_manager.h"
...@@ -164,6 +165,35 @@ void KaleidoscopeDataProviderImpl::SetFirstRunExperienceCompleted() { ...@@ -164,6 +165,35 @@ void KaleidoscopeDataProviderImpl::SetFirstRunExperienceCompleted() {
kKaleidoscopeFirstRunLatestVersion); kKaleidoscopeFirstRunLatestVersion);
} }
void KaleidoscopeDataProviderImpl::GetAllMediaFeeds(
GetAllMediaFeedsCallback cb) {
GetMediaHistoryService()->GetMediaFeeds(
media_history::MediaHistoryKeyedService::GetMediaFeedsRequest(),
std::move(cb));
}
void KaleidoscopeDataProviderImpl::SetMediaFeedsConsent(
bool accepted_media_feeds,
bool accepted_auto_select_media_feeds,
const std::vector<int64_t>& enabled_feed_ids,
const std::vector<int64_t>& disabled_feed_ids) {
auto* prefs = profile_->GetPrefs();
if (!prefs)
return;
prefs->SetBoolean(prefs::kMediaFeedsBackgroundFetching, accepted_media_feeds);
// If the user declined to use Media Feeds at all, then there's nothing left
// to do.
if (!accepted_media_feeds)
return;
prefs->SetBoolean(kaleidoscope::prefs::kKaleidoscopeAutoSelectMediaFeeds,
accepted_auto_select_media_feeds);
// TODO(b/154517281): Update the MediaFeeds service with the allowlisted
// feeds from |enabled_feed_ids| and |disabled_feed_ids|.
}
void KaleidoscopeDataProviderImpl::GetHighWatchTimeOrigins( void KaleidoscopeDataProviderImpl::GetHighWatchTimeOrigins(
GetHighWatchTimeOriginsCallback cb) { GetHighWatchTimeOriginsCallback cb) {
GetMediaHistoryService()->GetHighWatchTimeOrigins(kProviderHighWatchTimeMin, GetMediaHistoryService()->GetHighWatchTimeOrigins(kProviderHighWatchTimeMin,
......
...@@ -50,6 +50,12 @@ class KaleidoscopeDataProviderImpl ...@@ -50,6 +50,12 @@ class KaleidoscopeDataProviderImpl
void GetShouldShowFirstRunExperience( void GetShouldShowFirstRunExperience(
GetShouldShowFirstRunExperienceCallback cb) override; GetShouldShowFirstRunExperienceCallback cb) override;
void SetFirstRunExperienceCompleted() override; void SetFirstRunExperienceCompleted() override;
void GetAllMediaFeeds(GetAllMediaFeedsCallback cb) override;
void SetMediaFeedsConsent(
bool accepted_media_feeds,
bool accepted_auto_select_media_feeds,
const std::vector<int64_t>& enabled_feed_ids,
const std::vector<int64_t>& disabled_feed_ids) override;
void GetHighWatchTimeOrigins(GetHighWatchTimeOriginsCallback cb) override; void GetHighWatchTimeOrigins(GetHighWatchTimeOriginsCallback cb) override;
void SendFeedback() override; void SendFeedback() override;
......
...@@ -12,8 +12,12 @@ namespace prefs { ...@@ -12,8 +12,12 @@ namespace prefs {
const char kKaleidoscopeFirstRunCompleted[] = const char kKaleidoscopeFirstRunCompleted[] =
"kaleidoscope.first_run_completed"; "kaleidoscope.first_run_completed";
const char kKaleidoscopeAutoSelectMediaFeeds[] =
"kaleidoscope.auto_select_media_feeds";
void RegisterProfilePrefs(PrefRegistrySimple* registry) { void RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterIntegerPref(kKaleidoscopeFirstRunCompleted, 0); registry->RegisterIntegerPref(kKaleidoscopeFirstRunCompleted, 0);
registry->RegisterBooleanPref(kKaleidoscopeAutoSelectMediaFeeds, false);
} }
} // namespace prefs } // namespace prefs
......
...@@ -14,6 +14,10 @@ namespace prefs { ...@@ -14,6 +14,10 @@ namespace prefs {
// successfully by the user. // successfully by the user.
extern const char kKaleidoscopeFirstRunCompleted[]; extern const char kKaleidoscopeFirstRunCompleted[];
// Stores true if the user has consented to us selecting Media Feeds for display
// automatically.
extern const char kKaleidoscopeAutoSelectMediaFeeds[];
void RegisterProfilePrefs(PrefRegistrySimple* registry); void RegisterProfilePrefs(PrefRegistrySimple* registry);
} // namespace prefs } // namespace prefs
......
...@@ -58,6 +58,15 @@ interface KaleidoscopeDataProvider { ...@@ -58,6 +58,15 @@ interface KaleidoscopeDataProvider {
// Called when the user successfully completes the first run experience. // Called when the user successfully completes the first run experience.
SetFirstRunExperienceCompleted(); SetFirstRunExperienceCompleted();
// Returns all the Media Feeds so the user can choose which ones they want to enable/disable.
GetAllMediaFeeds() => (array<media_feeds.mojom.MediaFeed> feeds);
// Called when the user completes the consent screen for Media Feeds.
SetMediaFeedsConsent(bool accepted_media_feeds,
bool accepted_auto_select_media_feeds,
array<int64> enabled_feed_ids,
array<int64> disabled_feed_ids);
// Returns all the watch time origins from media history store that have // Returns all the watch time origins from media history store that have
// watch time above a threshold. // watch time above a threshold.
GetHighWatchTimeOrigins() => (array<url.mojom.Origin> origins); GetHighWatchTimeOrigins() => (array<url.mojom.Origin> origins);
......
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