Commit 34ce1481 authored by Ian Wells's avatar Ian Wells Committed by Commit Bot

Reland "Add InterestFeedV2 feature flag"

This is a reland of b84a396f

Original change's description:
> Add InterestFeedV2 feature flag
>
> If enabled, the v2 feed stream loading task is kicked off when the NTP
> or start surface is created. Not currently user-visible; this is
> happening silently while the existing feed is created and shown.
>
> The binary size increase is mainly due to generated proto code that was
> added previously but has not been linked until now. We are generating
> the sources with "option optimize_for = LITE_RUNTIME;" which matches the
> existing feed library and provides an acceptable speed/size tradeoff.
>
> Once the v2 feed component is fully launched, we can begin removing the
> existing feed library. For a recent measurement of the binary size we
> would eliminate by removing the existing feed library, see this CL:
> https://chromium-review.googlesource.com/c/chromium/src/+/1829821.
>
> Binary-Size: The increase is temporary (see above).
> Bug: 1044139
> Change-Id: Ic596d28e03300ad617f98f0b725cdf5ed1b0b986
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2132648
> Reviewed-by: Dan H <harringtond@chromium.org>
> Commit-Queue: Ian Wells <iwells@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#756004}

Binary-Size: Temporary. See the original CL description.
Bug: 1044139
Change-Id: I820a43891b7db4e0b335a51e51fe452fe325f44c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134936
Commit-Queue: Ian Wells <iwells@chromium.org>
Reviewed-by: default avatarDan H <harringtond@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756314}
parent de933c19
......@@ -35,6 +35,8 @@ import org.chromium.chrome.browser.feed.library.api.host.stream.SnackbarCallback
import org.chromium.chrome.browser.feed.library.api.host.stream.StreamConfiguration;
import org.chromium.chrome.browser.feed.library.api.host.stream.TooltipApi;
import org.chromium.chrome.browser.feed.tooltip.BasicTooltipApi;
import org.chromium.chrome.browser.feed.v2.FeedStreamSurface;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.native_page.ContextMenuManager;
import org.chromium.chrome.browser.ntp.NewTabPageLayout;
import org.chromium.chrome.browser.ntp.SnapScrollHelper;
......@@ -63,6 +65,7 @@ public class FeedSurfaceCoordinator {
private final int mDefaultMargin;
private final int mWideMargin;
private final FeedSurfaceMediator mMediator;
private FeedStreamSurface mFeedStreamSurface;
private UiConfig mUiConfig;
private FrameLayout mRootView;
......@@ -292,6 +295,12 @@ public class FeedSurfaceCoordinator {
// Mediator should be created before any Stream changes.
mMediator = new FeedSurfaceMediator(this, snapScrollHelper);
// Native should already have been loaded because of FeedSurfaceMediator.
if (ChromeFeatureList.isEnabled(ChromeFeatureList.INTEREST_FEED_V2)) {
// TODO(iwells): Temporary. This should probably move to FeedSurfaceMediator.
mFeedStreamSurface = new FeedStreamSurface(mActivity);
}
}
public void destroy() {
......
......@@ -2741,6 +2741,9 @@ const FeatureEntry kFeatureEntries[] = {
flag_descriptions::kInterestFeedNotificationsName,
flag_descriptions::kInterestFeedNotificationsDescription, kOsAndroid,
FEATURE_VALUE_TYPE(feed::kInterestFeedNotifications)},
{"interest-feed-v2", flag_descriptions::kInterestFeedV2Name,
flag_descriptions::kInterestFeedV2Description, kOsAndroid,
FEATURE_VALUE_TYPE(feed::kInterestFeedV2)},
{"offlining-recent-pages", flag_descriptions::kOffliningRecentPagesName,
flag_descriptions::kOffliningRecentPagesDescription, kOsAndroid,
FEATURE_VALUE_TYPE(offline_pages::kOffliningRecentPagesFeature)},
......
......@@ -7,7 +7,12 @@
#include "base/android/jni_android.h"
#include "base/android/jni_array.h"
#include "chrome/android/chrome_jni_headers/FeedStreamSurface_jni.h"
#include "chrome/browser/android/feed/v2/feed_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "components/feed/core/proto/v2/ui.pb.h"
#include "components/feed/core/v2/public/feed_service.h"
#include "components/feed/core/v2/public/feed_stream_api.h"
using base::android::JavaParamRef;
using base::android::JavaRef;
......@@ -21,16 +26,31 @@ static jlong JNI_FeedStreamSurface_Init(JNIEnv* env,
return reinterpret_cast<intptr_t>(new FeedStreamSurface(j_this));
}
FeedStreamSurface::FeedStreamSurface(const JavaRef<jobject>& j_this) {
FeedStreamSurface::FeedStreamSurface(const JavaRef<jobject>& j_this)
: feed_stream_api_(nullptr) {
java_ref_.Reset(j_this);
// TODO(iwells): check that this profile is okay to use. what about first run?
Profile* profile = ProfileManager::GetLastUsedProfile();
if (!profile)
return;
feed_stream_api_ =
FeedServiceFactory::GetForBrowserContext(profile)->GetStream();
if (feed_stream_api_)
feed_stream_api_->AttachSurface(this);
}
FeedStreamSurface::~FeedStreamSurface() {}
FeedStreamSurface::~FeedStreamSurface() {
if (feed_stream_api_)
feed_stream_api_->DetachSurface(this);
}
void FeedStreamSurface::OnStreamUpdated(
void FeedStreamSurface::StreamUpdate(
const feedui::StreamUpdate& stream_update) {
JNIEnv* env = base::android::AttachCurrentThread();
int32_t data_size = stream_update.ByteSize();
std::vector<uint8_t> data;
data.resize(data_size);
stream_update.SerializeToArray(data.data(), data_size);
......
......@@ -8,6 +8,7 @@
#include "base/android/jni_android.h"
#include "base/android/scoped_java_ref.h"
#include "base/macros.h"
#include "components/feed/core/v2/public/feed_stream_api.h"
namespace feedui {
class StreamUpdate;
......@@ -17,10 +18,13 @@ namespace feed {
// Native access to |FeedStreamSurface| in Java.
// Created once for each NTP/start surface.
class FeedStreamSurface {
class FeedStreamSurface : public FeedStreamApi::SurfaceInterface {
public:
explicit FeedStreamSurface(const base::android::JavaRef<jobject>& j_this);
~FeedStreamSurface();
~FeedStreamSurface() override;
// SurfaceInterface implementation.
void StreamUpdate(const feedui::StreamUpdate& update) override;
void OnStreamUpdated(const feedui::StreamUpdate& stream_update);
......@@ -63,7 +67,7 @@ class FeedStreamSurface {
private:
base::android::ScopedJavaGlobalRef<jobject> java_ref_;
FeedStreamApi* feed_stream_api_;
DISALLOW_COPY_AND_ASSIGN(FeedStreamSurface);
};
......
......@@ -2646,6 +2646,11 @@
"owners": [ "iwells", "//chrome/android/feed/OWNERS" ],
"expiry_milestone": 80
},
{
"name": "interest-feed-v2",
"owners": [ "//chrome/android/feed/OWNERS", "feed@chromium.org" ],
"expiry_milestone": 95
},
{
"name": "ios-breadcrumbs",
"owners": [ "michaeldo" ],
......
......@@ -2419,6 +2419,11 @@ const char kInterestFeedContentSuggestionsDescription[] =
const char kInterestFeedContentSuggestionsName[] =
"Interest Feed Content Suggestions";
const char kInterestFeedV2Name[] = "Interest Feed v2";
const char kInterestFeedV2Description[] =
"Show content suggestions on the New Tab Page and Start Surface using the "
"new Feed Component.";
const char kInterestFeedFeedbackDescription[] =
"Allow the user to provide feedback from a feed card.";
const char kInterestFeedFeedbackName[] = "Interest Feed Feedback";
......
......@@ -1403,6 +1403,9 @@ extern const char kInterestFeedNotificationsDescription[];
extern const char kInterestFeedContentSuggestionsName[];
extern const char kInterestFeedContentSuggestionsDescription[];
extern const char kInterestFeedV2Name[];
extern const char kInterestFeedV2Description[];
extern const char kInterestFeedFeedbackName[];
extern const char kInterestFeedFeedbackDescription[];
......
......@@ -92,6 +92,7 @@ const base::Feature* kFeaturesExposedToJava[] = {
&feature_engagement::kIPHChromeDuetTabSwitcherFeature,
&feed::kInterestFeedContentSuggestions,
&feed::kInterestFeedFeedback,
&feed::kInterestFeedV2,
&feed::kReportFeedUserActions,
&kAdjustWebApkInstallationSpace,
&kAllowNewIncognitoTabIntents,
......
......@@ -18,7 +18,7 @@ import java.util.Map;
* Java accessor for base/feature_list.h state.
*
* This class provides methods to access values of feature flags registered in
* |kFeaturesExposedToJava| in chrome/browser/android/chrome_feature_list.cc and as a constant
* |kFeaturesExposedToJava| in chrome/browser/android/flags/chrome_feature_list.cc and as a constant
* in this class.
*
* This class also provides methods to access values of field trial parameters associated to those
......@@ -304,6 +304,7 @@ public abstract class ChromeFeatureList {
public static final String INSTANT_START = "InstantStart";
public static final String INTEREST_FEED_CONTENT_SUGGESTIONS = "InterestFeedContentSuggestions";
public static final String INTEREST_FEED_FEEDBACK = "InterestFeedFeedback";
public static final String INTEREST_FEED_V2 = "InterestFeedV2";
public static final String KITKAT_SUPPORTED = "KitKatSupported";
public static final String LOOKALIKE_NAVIGATION_URL_SUGGESTIONS_UI =
"LookalikeUrlNavigationSuggestionsUI";
......
......@@ -30,4 +30,7 @@ const base::Feature kInterestFeedFeedback{"InterestFeedFeedback",
const base::Feature kReportFeedUserActions{"ReportFeedUserActions",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kInterestFeedV2{"InterestFeedV2",
base::FEATURE_DISABLED_BY_DEFAULT};
} // namespace feed
......@@ -28,6 +28,8 @@ extern const base::Feature kInterestFeedFeedback;
// for personalization.
extern const base::Feature kReportFeedUserActions;
extern const base::Feature kInterestFeedV2;
} // namespace feed
#endif // COMPONENTS_FEED_FEED_FEATURE_LIST_H_
......@@ -39161,6 +39161,7 @@ from previous Chrome versions.
<int value="-164539906"
label="OmniboxPreserveDefaultMatchAgainstAsyncUpdate:disabled"/>
<int value="-161782023" label="AndroidMessagesProdEndpoint:enabled"/>
<int value="-160571071" label="InterestFeedV2:enabled"/>
<int value="-159877930" label="MaterialDesignUserManager:disabled"/>
<int value="-158549277" label="enable-embeddedsearch-api"/>
<int value="-152677714" label="AsmJsToWebAssembly:enabled"/>
......@@ -40502,6 +40503,7 @@ from previous Chrome versions.
<int value="1431934725" label="OmniboxAutocompleteTitles:disabled"/>
<int value="1434515920" label="ReaderModeInCCT:enabled"/>
<int value="1435251818" label="AutofillNoLocalSaveOnUploadSuccess:enabled"/>
<int value="1436454450" label="InterestFeedV2:disabled"/>
<int value="1437413720" label="CooperativeScheduling:disabled"/>
<int value="1441897340" label="AndroidSpellCheckerNonLowEnd:enabled"/>
<int value="1442129147"
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