Commit 75253f16 authored by Becca Hughes's avatar Becca Hughes Committed by Commit Bot

Turn Media Feeds on by default

Also fixes a bug in RelList::ValidateTokenValue where || was used instead of
&&, causing <something that happened, presumably incorrectly>.

BUG=1053599

Intent-to-Ship: https://groups.google.com/a/chromium.org/g/blink-dev/c/OXZLwImwdbc/m/ltULzqsAAgAJ
Change-Id: I32efa63c43fdb5ca641e8afae3c49f42d9013f28
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2341934
Commit-Queue: Becca Hughes <beccahughes@chromium.org>
Reviewed-by: default avatarTommy Steimel <steimel@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Auto-Submit: Becca Hughes <beccahughes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797304}
parent 95488451
......@@ -20,7 +20,13 @@
MediaFeedsContentsObserver::MediaFeedsContentsObserver(
content::WebContents* web_contents)
: content::WebContentsObserver(web_contents) {}
: content::WebContentsObserver(web_contents) {
// The cookie observer cannot be created at initialization of
// MediaFeedsService because the network service is not ready and therefore we
// should create it when we get a web contents.
if (auto* service = GetService())
service->EnsureCookieObserver();
}
MediaFeedsContentsObserver::~MediaFeedsContentsObserver() = default;
......@@ -56,6 +62,9 @@ void MediaFeedsContentsObserver::DidFinishLoad(
return;
}
// Clear the old binding for the old frame.
render_frame_.reset();
render_frame_host->GetRemoteAssociatedInterfaces()->GetInterface(
&render_frame_);
......
......@@ -77,6 +77,7 @@ class CookieChangeListener : public network::mojom::CookieChangeListener {
DCHECK(profile);
DCHECK(!profile->IsOffTheRecord());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
MaybeStartListening();
}
......@@ -154,12 +155,7 @@ constexpr base::TimeDelta kTopFeedsMinWatchTime =
base::TimeDelta::FromMinutes(30);
MediaFeedsService::MediaFeedsService(Profile* profile)
: cookie_change_listener_(std::make_unique<CookieChangeListener>(
profile,
base::BindRepeating(&MediaFeedsService::OnResetOriginFromCookie,
base::Unretained(this)))),
profile_(profile),
clock_(base::DefaultClock::GetInstance()) {
: profile_(profile), clock_(base::DefaultClock::GetInstance()) {
DCHECK(!profile->IsOffTheRecord());
pref_change_registrar_.Init(profile_->GetPrefs());
......@@ -659,4 +655,13 @@ void MediaFeedsService::OnDiscoveredFeed() {
weak_factory_.GetWeakPtr()));
}
void MediaFeedsService::EnsureCookieObserver() {
if (cookie_change_listener_)
return;
cookie_change_listener_ = std::make_unique<CookieChangeListener>(
profile_, base::BindRepeating(&MediaFeedsService::OnResetOriginFromCookie,
base::Unretained(this)));
}
} // namespace media_feeds
......@@ -112,6 +112,8 @@ class MediaFeedsService : public KeyedService {
bool HasCookieObserverForTest() const;
void EnsureCookieObserver();
private:
friend class MediaFeedsServiceTest;
......
......@@ -343,7 +343,7 @@ TEST_F('MediaFeedsWebUIBrowserTest', 'ConfigTable', function() {
assertDeepEquals(
[
'Background Fetching Enabled (value)',
'Disabled',
'Enabled',
'Background Fetching Enabled (pref)',
'Disabled (Toggle)',
],
......@@ -361,7 +361,7 @@ TEST_F('MediaFeedsWebUIBrowserTest', 'ConfigTable', function() {
assertDeepEquals(
[
'Background Fetching Enabled (value)',
'Disabled',
'Enabled',
'Background Fetching Enabled (pref)',
'Enabled (Toggle)',
],
......
......@@ -57,6 +57,8 @@ TEST_F('MediaHistoryStatsWebUIBrowserTest', 'MAYBE_All', function() {
assertDeepEquals(
[
['mediaFeed', '0'],
['mediaFeedItem', '0'],
['mediaImage', '0'],
['meta', '3'],
['origin', '0'],
......
......@@ -690,12 +690,11 @@ const base::Feature kMediaEngagementHTTPSOnly{
// Enables Media Feeds to allow sites to provide specific recommendations for
// users.
const base::Feature kMediaFeeds{"MediaFeeds",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kMediaFeeds{"MediaFeeds", base::FEATURE_ENABLED_BY_DEFAULT};
// Enables fetching Media Feeds periodically in the background.
const base::Feature kMediaFeedsBackgroundFetching{
"MediaFeedsBackgroundFetching", base::FEATURE_DISABLED_BY_DEFAULT};
"MediaFeedsBackgroundFetching", base::FEATURE_ENABLED_BY_DEFAULT};
// Enables checking Media Feeds against safe search to prevent adult content.
const base::Feature kMediaFeedsSafeSearch{"MediaFeedsSafeSearch",
......
......@@ -60,7 +60,7 @@ bool RelList::ValidateTokenValue(const AtomicString& token_value,
return true;
}
if (RuntimeEnabledFeatures::MediaFeedsEnabled(
GetElement().GetExecutionContext()) ||
GetElement().GetExecutionContext()) &&
token_value == "media-feed") {
return true;
}
......
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