| 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
|
|
|