| 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 01570be2ddee0274479c51c5cc5162a0bc0d146b..fa39717004859910c08a5a3eae6ebb0820dea4bb 100644
|
| --- a/components/ntp_snippets/breaking_news/subscription_manager.cc
|
| +++ b/components/ntp_snippets/breaking_news/subscription_manager.cc
|
| @@ -5,13 +5,25 @@
|
| #include "components/ntp_snippets/breaking_news/subscription_manager.h"
|
| #include "base/bind.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"
|
| +#include "components/variations/variations_associated_data.h"
|
|
|
| namespace ntp_snippets {
|
|
|
| using internal::SubscriptionJsonRequest;
|
|
|
| +namespace {
|
| +
|
| +// Variation parameter for chrome-push-subscription backend.
|
| +const char kPushSubscriptionBackend[] = "push_subscription_backend";
|
| +
|
| +// Variation parameter for chrome-push-unsubscription backend.
|
| +const char kPushUnsubscriptionBackend[] = "push_unsubscription_backend";
|
| +}
|
| +
|
| SubscriptionManager::SubscriptionManager(
|
| scoped_refptr<net::URLRequestContextGetter> url_request_context_getter,
|
| PrefService* pref_service,
|
| @@ -89,4 +101,46 @@ void SubscriptionManager::RegisterProfilePrefs(PrefRegistrySimple* registry) {
|
| registry->RegisterStringPref(prefs::kContentSuggestionsSubscriptionDataToken,
|
| std::string());
|
| }
|
| +
|
| +GURL GetPushUpdatesSubscriptionEndpoint(version_info::Channel channel) {
|
| + std::string endpoint = variations::GetVariationParamValueByFeature(
|
| + ntp_snippets::kContentSuggestionsPushFeature, kPushSubscriptionBackend);
|
| + 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 = variations::GetVariationParamValueByFeature(
|
| + ntp_snippets::kContentSuggestionsPushFeature, kPushUnsubscriptionBackend);
|
| + 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
|
|
|