Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1938)

Unified Diff: components/ntp_snippets/breaking_news/subscription_manager.cc

Issue 2925053003: [NTP::Push] Adding BreakingNewsSuggestionsProvider (Closed)
Patch Set: Fixing the build. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/ntp_snippets/breaking_news/subscription_manager.h ('k') | components/ntp_snippets/category.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/breaking_news/subscription_manager.cc
diff --git a/components/ntp_snippets/breaking_news/subscription_manager.cc b/components/ntp_snippets/breaking_news/subscription_manager.cc
index 42495e8181b082f2b88a13207ba4d710b7cf589e..5588bf91e71b4d63724db0b5f9a4b5ab1db5cbc8 100644
--- a/components/ntp_snippets/breaking_news/subscription_manager.cc
+++ b/components/ntp_snippets/breaking_news/subscription_manager.cc
@@ -4,7 +4,10 @@
#include "components/ntp_snippets/breaking_news/subscription_manager.h"
#include "base/bind.h"
+#include "base/metrics/field_trial_params.h"
#include "components/ntp_snippets/breaking_news/subscription_json_request.h"
+#include "components/ntp_snippets/features.h"
+#include "components/ntp_snippets/ntp_snippets_constants.h"
#include "components/ntp_snippets/pref_names.h"
#include "components/prefs/pref_service.h"
@@ -12,6 +15,15 @@ namespace ntp_snippets {
using internal::SubscriptionJsonRequest;
+namespace {
+
+// Variation parameter for chrome-push-subscription backend.
+const char kPushSubscriptionBackendParam[] = "push_subscription_backend";
+
+// Variation parameter for chrome-push-unsubscription backend.
+const char kPushUnsubscriptionBackendParam[] = "push_unsubscription_backend";
+}
+
SubscriptionManager::SubscriptionManager(
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter,
PrefService* pref_service,
@@ -109,4 +121,48 @@ void SubscriptionManager::RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterStringPref(prefs::kContentSuggestionsSubscriptionDataToken,
std::string());
}
+
+GURL GetPushUpdatesSubscriptionEndpoint(version_info::Channel channel) {
+ std::string endpoint = base::GetFieldTrialParamValueByFeature(
+ ntp_snippets::kContentSuggestionsPushFeature,
+ kPushSubscriptionBackendParam);
+ if (!endpoint.empty()) {
+ return GURL{endpoint};
+ }
+
+ switch (channel) {
+ case version_info::Channel::STABLE:
+ case version_info::Channel::BETA:
+ return GURL{kPushUpdatesSubscriptionServer};
+
+ case version_info::Channel::DEV:
+ case version_info::Channel::CANARY:
+ case version_info::Channel::UNKNOWN:
+ return GURL{kPushUpdatesSubscriptionStagingServer};
+ }
+ NOTREACHED();
+ return GURL{kPushUpdatesSubscriptionStagingServer};
+}
+
+GURL GetPushUpdatesUnsubscriptionEndpoint(version_info::Channel channel) {
+ std::string endpoint = base::GetFieldTrialParamValueByFeature(
+ ntp_snippets::kContentSuggestionsPushFeature,
+ kPushUnsubscriptionBackendParam);
+ if (!endpoint.empty()) {
+ return GURL{endpoint};
+ }
+
+ switch (channel) {
+ case version_info::Channel::STABLE:
+ case version_info::Channel::BETA:
+ return GURL{kPushUpdatesUnsubscriptionServer};
+
+ case version_info::Channel::DEV:
+ case version_info::Channel::CANARY:
+ case version_info::Channel::UNKNOWN:
+ return GURL{kPushUpdatesUnsubscriptionStagingServer};
+ }
+ NOTREACHED();
+ return GURL{kPushUpdatesUnsubscriptionStagingServer};
+}
} // namespace ntp_snippets
« no previous file with comments | « components/ntp_snippets/breaking_news/subscription_manager.h ('k') | components/ntp_snippets/category.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698