Commit fdeeee36 authored by Tommy Steimel's avatar Tommy Steimel Committed by Commit Bot

Kaleidoscope: Add API for determining whether to show FRE

This CL adds two new methods to the KaleidoscopeDataProvider API which
allow the page to query whether or not to show the first run experience
and to tell the browser when first run is successfully completed.

Bug: b:154517281
Change-Id: I18bafb0239b86384e42d45078b2184d8ed5d911b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2354460Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarBecca Hughes <beccahughes@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Tommy Steimel <steimel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798368}
parent 29499d24
......@@ -3277,6 +3277,8 @@ static_library("browser") {
"media/kaleidoscope/constants.h",
"media/kaleidoscope/kaleidoscope_data_provider_impl.cc",
"media/kaleidoscope/kaleidoscope_data_provider_impl.h",
"media/kaleidoscope/kaleidoscope_prefs.cc",
"media/kaleidoscope/kaleidoscope_prefs.h",
"media/kaleidoscope/kaleidoscope_switches.cc",
"media/kaleidoscope/kaleidoscope_switches.h",
"media/kaleidoscope/kaleidoscope_tab_helper.cc",
......
......@@ -10,3 +10,5 @@ const char kKaleidoscopeUIURL[] = "chrome://kaleidoscope";
const char kKaleidoscopeUntrustedContentUIURL[] =
"chrome-untrusted://kaleidoscope/";
const int kKaleidoscopeFirstRunLatestVersion = 1;
......@@ -11,4 +11,7 @@ extern const char kKaleidoscopeUIURL[];
extern const char kKaleidoscopeUntrustedContentUIURL[];
// The current latest version of the first run experience.
extern const int kKaleidoscopeFirstRunLatestVersion;
#endif // CHROME_BROWSER_MEDIA_KALEIDOSCOPE_CONSTANTS_H_
......@@ -11,10 +11,12 @@
#include "chrome/browser/media/history/media_history_keyed_service.h"
#include "chrome/browser/media/history/media_history_keyed_service_factory.h"
#include "chrome/browser/media/kaleidoscope/constants.h"
#include "chrome/browser/media/kaleidoscope/kaleidoscope_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/common/channel_info.h"
#include "components/prefs/pref_service.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/primary_account_access_token_fetcher.h"
......@@ -122,6 +124,46 @@ void KaleidoscopeDataProviderImpl::GetCredentials(GetCredentialsCallback cb) {
signin::ConsentLevel::kNotRequired);
}
void KaleidoscopeDataProviderImpl::GetShouldShowFirstRunExperience(
GetShouldShowFirstRunExperienceCallback cb) {
// If the flag for forcing the first run experience to show is set, then just
// show it.
if (base::FeatureList::IsEnabled(
media::kKaleidoscopeForceShowFirstRunExperience)) {
std::move(cb).Run(true);
return;
}
// Otherwise, check to see if the user has already completed the latest first
// run experience.
auto* prefs = profile_->GetPrefs();
if (!prefs) {
std::move(cb).Run(true);
return;
}
// If the pref is unset or lower than the current version, then we haven't
// shown the current first run experience before and we should show it now.
const base::Value* pref = prefs->GetUserPrefValue(
kaleidoscope::prefs::kKaleidoscopeFirstRunCompleted);
if (!pref || pref->GetInt() < kKaleidoscopeFirstRunLatestVersion) {
std::move(cb).Run(true);
return;
}
// Otherwise, we have shown it and don't need to.
std::move(cb).Run(false);
}
void KaleidoscopeDataProviderImpl::SetFirstRunExperienceCompleted() {
auto* prefs = profile_->GetPrefs();
if (!prefs)
return;
prefs->SetInteger(kaleidoscope::prefs::kKaleidoscopeFirstRunCompleted,
kKaleidoscopeFirstRunLatestVersion);
}
void KaleidoscopeDataProviderImpl::GetHighWatchTimeOrigins(
GetHighWatchTimeOriginsCallback cb) {
GetMediaHistoryService()->GetHighWatchTimeOrigins(kProviderHighWatchTimeMin,
......
......@@ -47,6 +47,9 @@ class KaleidoscopeDataProviderImpl
media::mojom::KaleidoscopeTab tab,
GetContinueWatchingMediaFeedItemsCallback callback) override;
void GetCredentials(GetCredentialsCallback cb) override;
void GetShouldShowFirstRunExperience(
GetShouldShowFirstRunExperienceCallback cb) override;
void SetFirstRunExperienceCompleted() override;
void GetHighWatchTimeOrigins(GetHighWatchTimeOriginsCallback cb) override;
void SendFeedback() override;
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/media/kaleidoscope/kaleidoscope_prefs.h"
#include "components/prefs/pref_registry_simple.h"
namespace kaleidoscope {
namespace prefs {
const char kKaleidoscopeFirstRunCompleted[] =
"kaleidoscope.first_run_completed";
void RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterIntegerPref(kKaleidoscopeFirstRunCompleted, 0);
}
} // namespace prefs
} // namespace kaleidoscope
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_MEDIA_KALEIDOSCOPE_KALEIDOSCOPE_PREFS_H_
#define CHROME_BROWSER_MEDIA_KALEIDOSCOPE_KALEIDOSCOPE_PREFS_H_
class PrefRegistrySimple;
namespace kaleidoscope {
namespace prefs {
// Stores the latest version of the first run experience that was completed
// successfully by the user.
extern const char kKaleidoscopeFirstRunCompleted[];
void RegisterProfilePrefs(PrefRegistrySimple* registry);
} // namespace prefs
} // namespace kaleidoscope
#endif // CHROME_BROWSER_MEDIA_KALEIDOSCOPE_KALEIDOSCOPE_PREFS_H_
......@@ -52,6 +52,12 @@ interface KaleidoscopeDataProvider {
// Retrieves the current credentials.
GetCredentials() => (Credentials? credentials, CredentialsResult result);
// Returns true if the first run experience should be shown.
GetShouldShowFirstRunExperience() => (bool should_show_first_run);
// Called when the user successfully completes the first run experience.
SetFirstRunExperienceCompleted();
// Returns all the watch time origins from media history store that have
// watch time above a threshold.
GetHighWatchTimeOrigins() => (array<url.mojom.Origin> origins);
......
......@@ -399,6 +399,7 @@
#if !defined(OS_ANDROID)
#include "chrome/browser/media/feeds/media_feeds_service.h"
#include "chrome/browser/media/kaleidoscope/kaleidoscope_prefs.h"
#endif
#if defined(USE_X11)
......@@ -1133,6 +1134,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry,
#if !defined(OS_ANDROID)
media_feeds::MediaFeedsService::RegisterProfilePrefs(registry);
kaleidoscope::prefs::RegisterProfilePrefs(registry);
#endif
RegisterProfilePrefsForMigration(registry);
......
......@@ -765,6 +765,10 @@ const base::Feature kInternalMediaSession {
const base::Feature kKaleidoscope{"Kaleidoscope",
base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kKaleidoscopeForceShowFirstRunExperience{
"KaleidoscopeForceShowFirstRunExperience",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kKaleidoscopeModule{"KaleidoscopeModule",
base::FEATURE_DISABLED_BY_DEFAULT};
......
......@@ -133,6 +133,8 @@ MEDIA_EXPORT extern const base::Feature kHardwareMediaKeyHandling;
MEDIA_EXPORT extern const base::Feature kHardwareSecureDecryption;
MEDIA_EXPORT extern const base::Feature kInternalMediaSession;
MEDIA_EXPORT extern const base::Feature kKaleidoscope;
MEDIA_EXPORT extern const base::Feature
kKaleidoscopeForceShowFirstRunExperience;
MEDIA_EXPORT extern const base::Feature kKaleidoscopeModule;
MEDIA_EXPORT extern const base::Feature kLiveCaption;
MEDIA_EXPORT extern const base::Feature kLowDelayVideoRenderingOnLiveStream;
......
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