Remove Breaking News feature
The NTP Breaking News feature is no longer in use. Remove feature and
clean up dead code.
Change-Id: Ia57235abb93c78406e9ce3a56c2c0290e947dfa0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1562897
Reviewed-by: Gauthier Ambard <[email protected]>
Reviewed-by: Gabriel Charette <[email protected]>
Reviewed-by: Nicolas Ouellet-Payeur <[email protected]>
Reviewed-by: Steven Holte <[email protected]>
Reviewed-by: Patrick Noland <[email protected]>
Commit-Queue: Natalie Chouinard <[email protected]>
Cr-Commit-Position: refs/heads/master@{#651414}
diff --git a/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc b/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc
index a8988443..a3c815a1 100644
--- a/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc
+++ b/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc
@@ -16,8 +16,6 @@
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/favicon/large_icon_service_factory.h"
-#include "chrome/browser/gcm/gcm_profile_service_factory.h"
-#include "chrome/browser/gcm/instance_id/instance_id_profile_service_factory.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/image_fetcher/image_decoder_impl.h"
#include "chrome/browser/language/url_language_histogram_factory.h"
@@ -26,8 +24,6 @@
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
-#include "components/gcm_driver/gcm_profile_service.h"
-#include "components/gcm_driver/instance_id/instance_id_profile_service.h"
#include "components/image_fetcher/core/image_decoder.h"
#include "components/image_fetcher/core/image_fetcher.h"
#include "components/image_fetcher/core/image_fetcher_impl.h"
@@ -64,9 +60,6 @@
#include "chrome/browser/android/chrome_feature_list.h"
#include "chrome/browser/android/ntp/ntp_snippets_launcher.h"
#include "components/feed/feed_feature_list.h"
-#include "components/ntp_snippets/breaking_news/breaking_news_gcm_app_handler.h"
-#include "components/ntp_snippets/breaking_news/subscription_manager.h"
-#include "components/ntp_snippets/breaking_news/subscription_manager_impl.h"
#endif
#if BUILDFLAG(ENABLE_OFFLINE_PAGES)
@@ -85,7 +78,6 @@
using history::HistoryService;
using image_fetcher::ImageFetcherImpl;
using language::UrlLanguageHistogram;
-using ntp_snippets::BreakingNewsListener;
using ntp_snippets::CategoryRanker;
using ntp_snippets::ContentSuggestionsService;
using ntp_snippets::GetFetchEndpoint;
@@ -98,13 +90,6 @@
using ntp_snippets::RemoteSuggestionsStatusServiceImpl;
using ntp_snippets::UserClassifier;
-#if defined(OS_ANDROID)
-using ntp_snippets::BreakingNewsGCMAppHandler;
-using ntp_snippets::GetPushUpdatesSubscriptionEndpoint;
-using ntp_snippets::GetPushUpdatesUnsubscriptionEndpoint;
-using ntp_snippets::SubscriptionManagerImpl;
-#endif // OS_ANDROID
-
#if BUILDFLAG(ENABLE_OFFLINE_PAGES)
using ntp_snippets::PrefetchedPagesTrackerImpl;
using offline_pages::OfflinePageModel;
@@ -139,67 +124,6 @@
#endif // BUILDFLAG(ENABLE_OFFLINE_PAGES)
-#if defined(OS_ANDROID)
-
-bool AreGCMPushUpdatesEnabled() {
- return base::FeatureList::IsEnabled(ntp_snippets::kBreakingNewsPushFeature);
-}
-
-std::unique_ptr<BreakingNewsGCMAppHandler>
-MakeBreakingNewsGCMAppHandlerIfEnabled(
- Profile* profile,
- const std::string& locale,
- variations::VariationsService* variations_service) {
- PrefService* pref_service = profile->GetPrefs();
-
- if (!AreGCMPushUpdatesEnabled()) {
- BreakingNewsGCMAppHandler::ClearProfilePrefs(pref_service);
- SubscriptionManagerImpl::ClearProfilePrefs(pref_service);
- return nullptr;
- }
-
- gcm::GCMDriver* gcm_driver =
- gcm::GCMProfileServiceFactory::GetForProfile(profile)->driver();
-
- identity::IdentityManager* identity_manager =
- IdentityManagerFactory::GetForProfile(profile);
-
- scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory =
- content::BrowserContext::GetDefaultStoragePartition(profile)
- ->GetURLLoaderFactoryForBrowserProcess();
-
- std::string api_key;
- // The API is private. If we don't have the official API key, don't even try.
- if (google_apis::IsGoogleChromeAPIKeyUsed()) {
- bool is_stable_channel =
- chrome::GetChannel() == version_info::Channel::STABLE;
- api_key = is_stable_channel ? google_apis::GetAPIKey()
- : google_apis::GetNonStableAPIKey();
- }
-
- auto subscription_manager = std::make_unique<SubscriptionManagerImpl>(
- url_loader_factory, pref_service, variations_service, identity_manager,
- api_key, locale, GetPushUpdatesSubscriptionEndpoint(chrome::GetChannel()),
- GetPushUpdatesUnsubscriptionEndpoint(chrome::GetChannel()));
-
- instance_id::InstanceIDProfileService* instance_id_profile_service =
- instance_id::InstanceIDProfileServiceFactory::GetForProfile(profile);
- DCHECK(instance_id_profile_service);
- DCHECK(instance_id_profile_service->driver());
-
- return std::make_unique<BreakingNewsGCMAppHandler>(
- gcm_driver, instance_id_profile_service->driver(), pref_service,
- std::move(subscription_manager),
- base::Bind(
- &data_decoder::SafeJsonParser::Parse,
- content::ServiceManagerConnection::GetForProcess()->GetConnector()),
- base::DefaultClock::GetInstance(),
- /*token_validation_timer=*/std::make_unique<base::OneShotTimer>(),
- /*forced_subscription_timer=*/std::make_unique<base::OneShotTimer>());
-}
-
-#endif // OS_ANDROID
-
bool IsArticleProviderEnabled() {
return base::FeatureList::IsEnabled(ntp_snippets::kArticleSuggestionsFeature);
}
@@ -253,13 +177,6 @@
content::ServiceManagerConnection::GetForProcess()->GetConnector()),
GetFetchEndpoint(), api_key, user_classifier);
- std::unique_ptr<BreakingNewsListener> breaking_news_raw_data_provider;
-#if defined(OS_ANDROID)
- breaking_news_raw_data_provider = MakeBreakingNewsGCMAppHandlerIfEnabled(
- profile, g_browser_process->GetApplicationLocale(),
- g_browser_process->variations_service());
-#endif // OS_ANDROID
-
auto provider = std::make_unique<RemoteSuggestionsProviderImpl>(
service, pref_service, g_browser_process->GetApplicationLocale(),
service->category_ranker(), service->remote_suggestions_scheduler(),
@@ -272,8 +189,7 @@
database_dir),
std::make_unique<RemoteSuggestionsStatusServiceImpl>(
identity_manager->HasPrimaryAccount(), pref_service, std::string()),
- std::move(prefetched_pages_tracker),
- std::move(breaking_news_raw_data_provider), debug_logger,
+ std::move(prefetched_pages_tracker), debug_logger,
std::make_unique<base::OneShotTimer>());
service->remote_suggestions_scheduler()->SetProvider(provider.get());
@@ -317,10 +233,6 @@
// Depends on OfflinePageModelFactory in SimpleDependencyManager.
DependsOn(offline_pages::PrefetchServiceFactory::GetInstance());
#endif // BUILDFLAG(ENABLE_OFFLINE_PAGES)
-#if defined(OS_ANDROID)
- DependsOn(gcm::GCMProfileServiceFactory::GetInstance());
- DependsOn(instance_id::InstanceIDProfileServiceFactory::GetInstance());
-#endif // defined(OS_ANDROID)
}
ContentSuggestionsServiceFactory::~ContentSuggestionsServiceFactory() = default;
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 5a184580..5e52095 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -206,8 +206,6 @@
#include "chrome/browser/media/android/cdm/media_drm_origin_id_manager.h"
#include "components/cdm/browser/media_drm_storage_impl.h"
#include "components/feed/buildflags.h"
-#include "components/ntp_snippets/breaking_news/breaking_news_gcm_app_handler.h"
-#include "components/ntp_snippets/breaking_news/subscription_manager_impl.h"
#include "components/ntp_snippets/category_rankers/click_based_category_ranker.h"
#include "components/ntp_tiles/popular_sites_impl.h"
#if BUILDFLAG(ENABLE_FEED_IN_CHROME)
@@ -421,7 +419,19 @@
"ntp_suggestions.downloads.assets.dismissed_ids";
const char kDismissedOfflinePageDownloadSuggestions[] =
"ntp_suggestions.downloads.offline_pages.dismissed_ids";
-#endif
+
+// Deprecated 4/2019.
+const char kBreakingNewsSubscriptionDataToken[] =
+ "ntp_suggestions.breaking_news_subscription_data.token";
+const char kBreakingNewsSubscriptionDataIsAuthenticated[] =
+ "ntp_suggestions.breaking_news_subscription_data.is_authenticated";
+const char kBreakingNewsGCMSubscriptionTokenCache[] =
+ "ntp_suggestions.breaking_news_gcm_subscription_token_cache";
+const char kBreakingNewsGCMLastTokenValidationTime[] =
+ "ntp_suggestions.breaking_news_gcm_last_token_validation_time";
+const char kBreakingNewsGCMLastForcedSubscriptionTime[] =
+ "ntp_suggestions.breaking_news_gcm_last_forced_subscription_time";
+#endif // defined(OS_ANDROID)
// Register prefs used only for migration (clearing or moving to a new key).
void RegisterProfilePrefsForMigration(
@@ -463,7 +473,16 @@
#if defined(OS_ANDROID)
registry->RegisterListPref(kDismissedAssetDownloadSuggestions);
registry->RegisterListPref(kDismissedOfflinePageDownloadSuggestions);
-#endif
+
+ registry->RegisterStringPref(kBreakingNewsSubscriptionDataToken,
+ std::string());
+ registry->RegisterBooleanPref(kBreakingNewsSubscriptionDataIsAuthenticated,
+ false);
+ registry->RegisterStringPref(kBreakingNewsGCMSubscriptionTokenCache,
+ std::string());
+ registry->RegisterInt64Pref(kBreakingNewsGCMLastTokenValidationTime, 0);
+ registry->RegisterInt64Pref(kBreakingNewsGCMLastForcedSubscriptionTime, 0);
+#endif // defined(OS_ANDROID)
}
} // namespace
@@ -754,9 +773,7 @@
registry);
ContentSuggestionsNotifierService::RegisterProfilePrefs(registry);
explore_sites::HistoryStatisticsReporter::RegisterPrefs(registry);
- ntp_snippets::BreakingNewsGCMAppHandler::RegisterProfilePrefs(registry);
ntp_snippets::ClickBasedCategoryRanker::RegisterProfilePrefs(registry);
- ntp_snippets::SubscriptionManagerImpl::RegisterProfilePrefs(registry);
OomInterventionDecider::RegisterProfilePrefs(registry);
#endif // defined(OS_ANDROID)
@@ -1021,6 +1038,13 @@
// Added 4/2019.
profile_prefs->ClearPref(kDismissedAssetDownloadSuggestions);
profile_prefs->ClearPref(kDismissedOfflinePageDownloadSuggestions);
+
+ // Added 4/2019.
+ profile_prefs->ClearPref(kBreakingNewsSubscriptionDataToken);
+ profile_prefs->ClearPref(kBreakingNewsSubscriptionDataIsAuthenticated);
+ profile_prefs->ClearPref(kBreakingNewsGCMSubscriptionTokenCache);
+ profile_prefs->ClearPref(kBreakingNewsGCMLastTokenValidationTime);
+ profile_prefs->ClearPref(kBreakingNewsGCMLastForcedSubscriptionTime);
#endif // defined(OS_ANDROID)
#if defined(OS_CHROMEOS)
diff --git a/chrome/browser/resources/snippets_internals/snippets_internals.html b/chrome/browser/resources/snippets_internals/snippets_internals.html
index b59f1e9..4c240d4 100644
--- a/chrome/browser/resources/snippets_internals/snippets_internals.html
+++ b/chrome/browser/resources/snippets_internals/snippets_internals.html
@@ -116,9 +116,6 @@
<button id="background-fetch-button">
Fetch remote suggestions in the background in 2 seconds
</button>
- <button id="push-dummy-suggestion">
- Push dummy suggestion in 10 seconds
- </button>
<button id="last-json-button">Show the last JSON</button>
<div id="last-json-container" class="hidden">
<div id="last-json-text"></div>
diff --git a/chrome/browser/resources/snippets_internals/snippets_internals.js b/chrome/browser/resources/snippets_internals/snippets_internals.js
index 71bd8db5..27b09c3 100644
--- a/chrome/browser/resources/snippets_internals/snippets_internals.js
+++ b/chrome/browser/resources/snippets_internals/snippets_internals.js
@@ -102,13 +102,6 @@
});
}
-/* Check if pushing dummy suggestions is possible. */
-function checkIfPushingDummySuggestionPossible() {
- pageHandler.isPushingDummySuggestionPossible().then(function(response) {
- $('push-dummy-suggestion').disabled = !response.result;
- });
-}
-
/* Retrieve the remote content suggestions properties. */
function getRemoteContentSuggestionsProperties() {
pageHandler.getRemoteContentSuggestionsProperties().then(function(response) {
@@ -194,7 +187,6 @@
getUserClassifierProperties();
getCategoryRankerProperties();
getRemoteContentSuggestionsProperties();
- checkIfPushingDummySuggestionPossible();
}
/* Setup buttons and other event listeners. */
@@ -233,14 +225,6 @@
});
});
- $('push-dummy-suggestion').addEventListener('click', function(event) {
- const content = $('push-dummy-suggestion').textContent;
- $('push-dummy-suggestion').textContent = '...';
- pageHandler.pushDummySuggestionInBackground(10).then(function(response) {
- $('push-dummy-suggestion').textContent = content;
- });
- });
-
$('last-json-button').addEventListener('click', function(event) {
pageHandler.getLastJson().then(function(response) {
const container = $('last-json-container');
diff --git a/chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom b/chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom
index d7793d4a0..fc2b659 100644
--- a/chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom
+++ b/chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom
@@ -58,12 +58,6 @@
// Fetch suggestions in background after the given delay.
FetchSuggestionsInBackground(int64 delaySeconds) => ();
- // Returns if it's possible to push a dummy suggestion.
- IsPushingDummySuggestionPossible() => (bool result);
-
- // Push dummy suggestion in background after the given delay.
- PushDummySuggestionInBackground(int64 delaySeconds) => ();
-
// Download the last suggestions in json form.
GetLastJson() => (string json);
@@ -80,4 +74,4 @@
// Frontend interface.
interface Page {
OnSuggestionsChanged();
-};
\ No newline at end of file
+};
diff --git a/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.cc b/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.cc
index a357381..9102e5dd 100644
--- a/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.cc
+++ b/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.cc
@@ -11,7 +11,6 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/time/time_to_iso8601.h"
#include "chrome/browser/android/ntp/android_content_suggestions_notifier.h"
#include "chrome/common/pref_names.h"
#include "components/ntp_snippets/category_info.h"
@@ -62,16 +61,6 @@
return value ? "True" : "False";
}
-ntp_snippets::BreakingNewsListener* GetBreakingNewsListener(
- ntp_snippets::ContentSuggestionsService* service) {
- DCHECK(service);
- RemoteSuggestionsProvider* provider =
- service->remote_suggestions_provider_for_debugging();
- DCHECK(provider);
- return static_cast<ntp_snippets::RemoteSuggestionsProviderImpl*>(provider)
- ->breaking_news_listener_for_debugging();
-}
-
std::string GetCategoryStatusName(CategoryStatus status) {
switch (status) {
case CategoryStatus::INITIALIZING:
@@ -278,67 +267,6 @@
std::move(callback).Run();
}
-void SnippetsInternalsPageHandler::IsPushingDummySuggestionPossible(
- IsPushingDummySuggestionPossibleCallback callback) {
- ntp_snippets::BreakingNewsListener* listener =
- GetBreakingNewsListener(content_suggestions_service_);
-
- std::move(callback).Run(listener != nullptr && listener->IsListening());
-}
-
-void SnippetsInternalsPageHandler::PushDummySuggestionInBackground(
- int64_t delaySeconds,
- PushDummySuggestionInBackgroundCallback callback) {
- DCHECK(delaySeconds >= 0);
- suggestion_push_timer_.Start(
- FROM_HERE, base::TimeDelta::FromSeconds(delaySeconds),
- base::BindRepeating(
- &SnippetsInternalsPageHandler::PushDummySuggestionInBackgroundImpl,
- weak_ptr_factory_.GetWeakPtr(), base::Passed(std::move(callback))));
-}
-
-void SnippetsInternalsPageHandler::PushDummySuggestionInBackgroundImpl(
- PushDummySuggestionInBackgroundCallback callback) {
- std::string json = R"(
- {"categories" : [{
- "id": 1,
- "localizedTitle": "section title",
- "suggestions" : [{
- "ids" : ["http://url.com"],
- "title" : "Pushed Dummy Title %s",
- "snippet" : "Pushed Dummy Snippet",
- "fullPageUrl" : "http://url.com",
- "creationTime" : "%s",
- "expirationTime" : "%s",
- "attribution" : "Pushed Dummy Publisher",
- "imageUrl" : "https://www.google.com/favicon.ico",
- "notificationInfo": {
- "shouldNotify": true,
- "deadline": "2100-01-01T00:00:01.000Z"
- }
- }]
- }]}
- )";
-
- const base::Time now = base::Time::Now();
- json = base::StringPrintf(
- json.c_str(), base::UTF16ToUTF8(base::TimeFormatTimeOfDay(now)).c_str(),
- base::TimeToISO8601(now).c_str(),
- base::TimeToISO8601(now + base::TimeDelta::FromMinutes(60)).c_str());
-
- gcm::IncomingMessage message;
- message.data["payload"] = json;
-
- ntp_snippets::BreakingNewsListener* listener =
- GetBreakingNewsListener(content_suggestions_service_);
- DCHECK(listener);
- DCHECK(listener->IsListening());
- static_cast<ntp_snippets::BreakingNewsGCMAppHandler*>(listener)->OnMessage(
- "com.google.breakingnews.gcm", message);
-
- std::move(callback).Run();
-}
-
void SnippetsInternalsPageHandler::GetLastJson(GetLastJsonCallback callback) {
std::string json = "";
if (remote_suggestions_provider_) {
diff --git a/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h b/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h
index b134684..ae81aa2 100644
--- a/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h
+++ b/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h
@@ -41,11 +41,6 @@
void FetchSuggestionsInBackground(
int64_t,
FetchSuggestionsInBackgroundCallback) override;
- void IsPushingDummySuggestionPossible(
- IsPushingDummySuggestionPossibleCallback) override;
- void PushDummySuggestionInBackground(
- int64_t,
- PushDummySuggestionInBackgroundCallback) override;
void GetLastJson(GetLastJsonCallback) override;
void ResetNotificationState() override;
void GetSuggestionsByCategory(GetSuggestionsByCategoryCallback) override;
@@ -64,8 +59,6 @@
void FetchSuggestionsInBackgroundImpl(FetchSuggestionsInBackgroundCallback);
void GetSuggestionsByCategoryImpl(GetSuggestionsByCategoryCallback);
- void PushDummySuggestionInBackgroundImpl(
- PushDummySuggestionInBackgroundCallback);
// Misc. methods.
void CollectDismissedSuggestions(
@@ -94,7 +87,6 @@
// Timers to delay actions.
base::OneShotTimer suggestion_fetch_timer_;
- base::OneShotTimer suggestion_push_timer_;
// Handle back to the page by which we can update.
snippets_internals::mojom::PagePtr page_;