Commit f9ff1905 authored by Becca Hughes's avatar Becca Hughes Committed by Commit Bot

Support provider selection for signed out users

Adds support for provider selection for signed out
users by storing their selection in a pref.

Change-Id: I8f2016556542007e634ef450f1a9fb1f766af33d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2523560Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarTommy Steimel <steimel@chromium.org>
Commit-Queue: Becca Hughes <beccahughes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826018}
parent a2c6108b
......@@ -284,6 +284,35 @@ void KaleidoscopeDataProviderImpl::GetCollections(const std::string& request,
weak_ptr_factory.GetWeakPtr(), request, std::move(cb)));
}
void KaleidoscopeDataProviderImpl::GetSignedOutProviders(
GetSignedOutProvidersCallback cb) {
DCHECK(!identity_manager_->HasPrimaryAccount(
signin::ConsentLevel::kNotRequired));
auto* providers = profile_->GetPrefs()->GetList(
kaleidoscope::prefs::kKaleidoscopeSignedOutProviders);
std::vector<std::string> providers_copy;
for (auto& provider : providers->GetList()) {
providers_copy.push_back(provider.GetString());
}
std::move(cb).Run(providers_copy);
}
void KaleidoscopeDataProviderImpl::SetSignedOutProviders(
const std::vector<std::string>& providers) {
DCHECK(!identity_manager_->HasPrimaryAccount(
signin::ConsentLevel::kNotRequired));
auto providers_copy = std::make_unique<base::Value>(base::Value::Type::LIST);
for (auto& provider : providers) {
providers_copy->Append(provider);
}
profile_->GetPrefs()->Set(
kaleidoscope::prefs::kKaleidoscopeSignedOutProviders, *providers_copy);
}
void KaleidoscopeDataProviderImpl::OnGotCredentialsForCollections(
const std::string& request,
GetCollectionsCallback cb,
......
......@@ -65,6 +65,9 @@ class KaleidoscopeDataProviderImpl
void SendFeedback() override;
void GetCollections(const std::string& request,
GetCollectionsCallback cb) override;
void GetSignedOutProviders(GetSignedOutProvidersCallback cb) override;
void SetSignedOutProviders(
const std::vector<std::string>& providers) override;
private:
media_history::MediaHistoryKeyedService* GetMediaHistoryService();
......
......@@ -17,10 +17,14 @@ const char kKaleidoscopeAutoSelectMediaFeeds[] =
const char kKaleidoscopePolicyEnabled[] = "kaleidoscope.enabled_by_policy";
const char kKaleidoscopeSignedOutProviders[] =
"kaleidoscope.signed_out_providers";
void RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterIntegerPref(kKaleidoscopeFirstRunCompleted, 0);
registry->RegisterBooleanPref(kKaleidoscopeAutoSelectMediaFeeds, false);
registry->RegisterBooleanPref(kKaleidoscopePolicyEnabled, true);
registry->RegisterListPref(kKaleidoscopeSignedOutProviders);
}
} // namespace prefs
......
......@@ -21,6 +21,9 @@ extern const char kKaleidoscopeAutoSelectMediaFeeds[];
// Stores true if Kaleidoscope has been enabled/disabled by an administrator.
extern const char kKaleidoscopePolicyEnabled[];
// Stores the list of provider IDs if the user is signed out.
extern const char kKaleidoscopeSignedOutProviders[];
void RegisterProfilePrefs(PrefRegistrySimple* registry);
} // namespace prefs
......
......@@ -96,6 +96,16 @@ interface KaleidoscopeDataProvider {
// contains the request to be sent to the server. The request is the
// GetCollectionsRequest proto here: go/ks-media-proto.
GetCollections(string request) => (GetCollectionsResponse response);
// Gets a list of stored providers that will be used to filter the
// recommendations on the server if the user is signed out. They are arbitary
// strings that are provided by the server, stored locally and then retrieved
// when Kaleidoscope is loaded.
GetSignedOutProviders() => (array<string> providers);
// Stores a list of providers that were chosen by the user. Only used if the
// user is signed out.
SetSignedOutProviders(array<string> providers);
};
enum GetCollectionsResult {
......
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