Skip to content

Commit

Permalink
Remove more android-only Zine code
Browse files Browse the repository at this point in the history
* ntp_snippets code in src/chrome is obsolete, since src/chrome
  is not used in iOS. Much of the removal was from there.
* Changed code to assume that the InterestFeedContentSuggestions
  feature is enabled (and therefore zine is not).

Bug: 1069183, 678590
Change-Id: I3b31f85a26d8ac8ff3807eee392c1994a91d0f9c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2414997
Commit-Queue: Dan H <harringtond@chromium.org>
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Reviewed-by: Filip Gorski <fgorski@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Reviewed-by: Carlos Knippschild <carlosk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812104}
  • Loading branch information
Dan Harrington authored and Commit Bot committed Sep 30, 2020
1 parent b35f546 commit 4d502ff
Show file tree
Hide file tree
Showing 54 changed files with 35 additions and 1,653 deletions.
4 changes: 0 additions & 4 deletions chrome/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,6 @@ android_library("chrome_java") {
"//components/consent_auditor:consent_auditor_java",
"//components/data_reduction_proxy/core/browser:data_reduction_proxy_savings_cleared_enum_java",
"//components/dom_distiller/core:distiller_type_java",
"//components/ntp_snippets:ntp_snippets_java_enums_srcjar",
"//components/ntp_tiles:ntp_tiles_enums_java",
"//components/offline_pages/core:offline_page_model_enums_java",
"//components/search_engines:search_engine_type_java",
Expand Down Expand Up @@ -712,7 +711,6 @@ java_cpp_enum("chrome_android_java_enums_srcjar") {
"//chrome/browser/notifications/notification_channels_provider_android.h",
"//chrome/browser/notifications/notification_handler.h",
"//chrome/browser/notifications/notification_platform_bridge_android.cc",
"//chrome/browser/ntp_snippets/ntp_snippets_metrics.h",
"//chrome/browser/profiles/profile_metrics.h",
]
}
Expand Down Expand Up @@ -3184,8 +3182,6 @@ generate_jni("chrome_jni_headers") {
"java/src/org/chromium/chrome/browser/ntp/LogoBridge.java",
"java/src/org/chromium/chrome/browser/ntp/RecentTabsPagePrefs.java",
"java/src/org/chromium/chrome/browser/ntp/RecentlyClosedBridge.java",
"java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsBridge.java",
"java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsLauncher.java",
"java/src/org/chromium/chrome/browser/offlinepages/AutoFetchNotifier.java",
"java/src/org/chromium/chrome/browser/offlinepages/BackgroundSchedulerBridge.java",
"java/src/org/chromium/chrome/browser/offlinepages/CctOfflinePageModelObserver.java",
Expand Down
2 changes: 0 additions & 2 deletions chrome/android/chrome_java_sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -1023,8 +1023,6 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/ntp/search/SearchBoxViewBinder.java",
"java/src/org/chromium/chrome/browser/ntp/snippets/SectionHeader.java",
"java/src/org/chromium/chrome/browser/ntp/snippets/SectionHeaderView.java",
"java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsBridge.java",
"java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsLauncher.java",
"java/src/org/chromium/chrome/browser/offlinepages/AutoFetchNotifier.java",
"java/src/org/chromium/chrome/browser/offlinepages/BackgroundScheduler.java",
"java/src/org/chromium/chrome/browser/offlinepages/BackgroundSchedulerBridge.java",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ private LoadUrlParams createLoadUrlParams(String url) {
params.setReferrer(
new Referrer(SuggestionsConfig.getReferrerUrl(
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS),
// WARNING: ReferrerPolicy.ALWAYS is assumed by other Chrome code for NTP
// tiles to set consider_for_ntp_most_visited.
ReferrerPolicy.ALWAYS));
return params;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ public final class FeedFeatures {
*/
public static boolean isReportingUserActions() {
return ChromeFeatureList.isEnabled(ChromeFeatureList.INTEREST_FEED_V2)
|| (ChromeFeatureList.isEnabled(ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS)
&& ChromeFeatureList.isEnabled(ChromeFeatureList.REPORT_FEED_USER_ACTIONS));
|| ChromeFeatureList.isEnabled(ChromeFeatureList.REPORT_FEED_USER_ACTIONS);
}

/**
Expand All @@ -27,10 +26,7 @@ public static boolean isReportingUserActions() {
*/
public static boolean cachedIsReportingUserActions() {
return CachedFeatureFlags.isEnabled(ChromeFeatureList.INTEREST_FEED_V2)
|| (CachedFeatureFlags.isEnabled(
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS)
&& CachedFeatureFlags.isEnabled(
ChromeFeatureList.REPORT_FEED_USER_ACTIONS));
|| CachedFeatureFlags.isEnabled(ChromeFeatureList.REPORT_FEED_USER_ACTIONS);
}

public static boolean isV2Enabled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,8 @@ private void openUrl(String url, int disposition) {
LoadUrlParams params = new LoadUrlParams(url, PageTransition.AUTO_BOOKMARK);
params.setReferrer(
new Referrer(SuggestionsConfig.getReferrerUrl(ChromeFeatureList.INTEREST_FEED_V2),
// WARNING: ReferrerPolicy.ALWAYS is assumed by other Chrome code for NTP
// tiles to set consider_for_ntp_most_visited.
ReferrerPolicy.ALWAYS));
Tab tab = mPageNavigationDelegate.openUrl(disposition, params);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import org.chromium.chrome.browser.background_sync.BackgroundSyncBackgroundTaskScheduler;
import org.chromium.chrome.browser.init.ChromeBrowserInitializer;
import org.chromium.chrome.browser.init.ServiceManagerStartupUtils;
import org.chromium.chrome.browser.ntp.snippets.SnippetsBridge;
import org.chromium.chrome.browser.ntp.snippets.SnippetsLauncher;
import org.chromium.chrome.browser.offlinepages.BackgroundScheduler;
import org.chromium.chrome.browser.offlinepages.OfflinePageUtils;
import org.chromium.content_public.browser.UiThreadTaskTraits;
Expand Down Expand Up @@ -51,11 +49,6 @@ public int onRunTask(final TaskParams params) {
rescheduleOfflinePages();
break;

case SnippetsLauncher.TASK_TAG_WIFI:
case SnippetsLauncher.TASK_TAG_FALLBACK:
handleSnippetsOnPersistentSchedulerWakeUp(context, taskTag);
break;

// This is only for tests.
case ServiceManagerStartupUtils.TASK_TAG:
handleServicificationStartupTask(context, taskTag);
Expand All @@ -70,25 +63,10 @@ public int onRunTask(final TaskParams params) {
return GcmNetworkManager.RESULT_SUCCESS;
}

private void handleSnippetsOnPersistentSchedulerWakeUp(Context context, String tag) {
if (!SnippetsLauncher.hasInstance()) launchBrowser(context, tag);
snippetsOnPersistentSchedulerWakeUp();
}

private void handleServicificationStartupTask(Context context, String tag) {
launchBrowser(context, tag);
}

@VisibleForTesting
protected void snippetsOnPersistentSchedulerWakeUp() {
SnippetsBridge.onPersistentSchedulerWakeUp();
}

@VisibleForTesting
protected void snippetsOnBrowserUpgraded() {
SnippetsBridge.onBrowserUpgraded();
}

@VisibleForTesting
protected void launchBrowser(Context context, String tag) {
Log.i(TAG, "Launching browser");
Expand All @@ -100,15 +78,6 @@ protected void rescheduleBackgroundSyncTasksOnUpgrade() {
rescheduleOneShotBackgroundSyncTasks();
}

private void handleSnippetsOnBrowserUpgraded() {
if (SnippetsLauncher.shouldNotifyOnBrowserUpgraded()) {
if (!SnippetsLauncher.hasInstance()) {
launchBrowser(this, /*tag=*/""); // The |tag| doesn't matter here.
}
snippetsOnBrowserUpgraded();
}
}

/** Reschedules offline pages (using appropriate version of Background Task Scheduler). */
private void rescheduleOfflinePages() {
BackgroundScheduler.getInstance().reschedule();
Expand All @@ -123,6 +92,5 @@ private void rescheduleOneShotBackgroundSyncTasks() {
@Override
public void onInitializeTasks() {
rescheduleBackgroundSyncTasksOnUpgrade();
handleSnippetsOnBrowserUpgraded();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public void cacheNativeFlags() {
ChromeFeatureList.HOMEPAGE_LOCATION_POLICY,
ChromeFeatureList.IMMERSIVE_UI_MODE,
ChromeFeatureList.INSTANT_START,
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS,
ChromeFeatureList.INTEREST_FEED_V2,
ChromeFeatureList.MESSAGES_FOR_ANDROID_INFRASTRUCTURE,
ChromeFeatureList.OMNIBOX_SUGGESTIONS_RECYCLER_VIEW,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

import androidx.annotation.Nullable;

import org.chromium.chrome.browser.flags.ChromeFeatureList;

import java.util.HashMap;
import java.util.Map;

Expand All @@ -23,10 +21,7 @@ public class InterestFeedFeedbackSource implements FeedbackSource {

InterestFeedFeedbackSource(@Nullable Map<String, String> feedContext) {
mMap = new HashMap<>();
mMap.put(KEY,
ChromeFeatureList.isEnabled(ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS)
? ENABLED_VALUE
: DISABLED_VALUE);
mMap.put(KEY, ENABLED_VALUE);

// For each key in feedContext, add that to the feedback map too.
if (feedContext != null) mMap.putAll(feedContext);
Expand Down
Loading

0 comments on commit 4d502ff

Please sign in to comment.