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" |
jkrcal
2017/06/09 11:32:59
please use the new api, instead:
base/metrics/fie
mamir
2017/06/09 14:41:01
Done.
|
namespace ntp_snippets { |
using internal::SubscriptionJsonRequest; |
+namespace { |
+ |
+// Variation parameter for chrome-push-subscription backend. |
+const char kPushSubscriptionBackend[] = "push_subscription_backend"; |
jkrcal
2017/06/09 11:32:59
consistency nit: Can you name it kPushSubscription
mamir
2017/06/09 14:41:01
Done.
|
+ |
+// Variation parameter for chrome-push-unsubscription backend. |
+const char kPushUnsubscriptionBackend[] = "push_unsubscription_backend"; |
jkrcal
2017/06/09 11:32:59
ditto
mamir
2017/06/09 14:41:01
Done.
|
+} |
+ |
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( |
jkrcal
2017/06/09 11:32:59
Please use the new API with the same parameters:
b
mamir
2017/06/09 14:41:01
Done.
|
+ 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( |
jkrcal
2017/06/09 11:32:59
ditto
mamir
2017/06/09 14:41:01
Done.
|
+ 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 |