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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/ntp_snippets/breaking_news/subscription_manager.h" 5 #include "components/ntp_snippets/breaking_news/subscription_manager.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/metrics/field_trial_params.h"
7 #include "components/ntp_snippets/breaking_news/subscription_json_request.h" 8 #include "components/ntp_snippets/breaking_news/subscription_json_request.h"
9 #include "components/ntp_snippets/features.h"
10 #include "components/ntp_snippets/ntp_snippets_constants.h"
8 #include "components/ntp_snippets/pref_names.h" 11 #include "components/ntp_snippets/pref_names.h"
9 #include "components/prefs/pref_service.h" 12 #include "components/prefs/pref_service.h"
10 13
11 namespace ntp_snippets { 14 namespace ntp_snippets {
12 15
13 using internal::SubscriptionJsonRequest; 16 using internal::SubscriptionJsonRequest;
14 17
18 namespace {
19
20 // Variation parameter for chrome-push-subscription backend.
21 const char kPushSubscriptionBackendParam[] = "push_subscription_backend";
22
23 // Variation parameter for chrome-push-unsubscription backend.
24 const char kPushUnsubscriptionBackendParam[] = "push_unsubscription_backend";
25 }
26
15 SubscriptionManager::SubscriptionManager( 27 SubscriptionManager::SubscriptionManager(
16 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, 28 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter,
17 PrefService* pref_service, 29 PrefService* pref_service,
18 const GURL& subscribe_url, 30 const GURL& subscribe_url,
19 const GURL& unsubscribe_url) 31 const GURL& unsubscribe_url)
20 : url_request_context_getter_(std::move(url_request_context_getter)), 32 : url_request_context_getter_(std::move(url_request_context_getter)),
21 pref_service_(pref_service), 33 pref_service_(pref_service),
22 subscribe_url_(subscribe_url), 34 subscribe_url_(subscribe_url),
23 unsubscribe_url_(unsubscribe_url) {} 35 unsubscribe_url_(unsubscribe_url) {}
24 36
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 default: 114 default:
103 // TODO(mamir): handle failure. 115 // TODO(mamir): handle failure.
104 break; 116 break;
105 } 117 }
106 } 118 }
107 119
108 void SubscriptionManager::RegisterProfilePrefs(PrefRegistrySimple* registry) { 120 void SubscriptionManager::RegisterProfilePrefs(PrefRegistrySimple* registry) {
109 registry->RegisterStringPref(prefs::kContentSuggestionsSubscriptionDataToken, 121 registry->RegisterStringPref(prefs::kContentSuggestionsSubscriptionDataToken,
110 std::string()); 122 std::string());
111 } 123 }
124
125 GURL GetPushUpdatesSubscriptionEndpoint(version_info::Channel channel) {
126 std::string endpoint = base::GetFieldTrialParamValueByFeature(
127 ntp_snippets::kContentSuggestionsPushFeature,
128 kPushSubscriptionBackendParam);
129 if (!endpoint.empty()) {
130 return GURL{endpoint};
131 }
132
133 switch (channel) {
134 case version_info::Channel::STABLE:
135 case version_info::Channel::BETA:
136 return GURL{kPushUpdatesSubscriptionServer};
137
138 case version_info::Channel::DEV:
139 case version_info::Channel::CANARY:
140 case version_info::Channel::UNKNOWN:
141 return GURL{kPushUpdatesSubscriptionStagingServer};
142 }
143 NOTREACHED();
144 return GURL{kPushUpdatesSubscriptionStagingServer};
145 }
146
147 GURL GetPushUpdatesUnsubscriptionEndpoint(version_info::Channel channel) {
148 std::string endpoint = base::GetFieldTrialParamValueByFeature(
149 ntp_snippets::kContentSuggestionsPushFeature,
150 kPushUnsubscriptionBackendParam);
151 if (!endpoint.empty()) {
152 return GURL{endpoint};
153 }
154
155 switch (channel) {
156 case version_info::Channel::STABLE:
157 case version_info::Channel::BETA:
158 return GURL{kPushUpdatesUnsubscriptionServer};
159
160 case version_info::Channel::DEV:
161 case version_info::Channel::CANARY:
162 case version_info::Channel::UNKNOWN:
163 return GURL{kPushUpdatesUnsubscriptionStagingServer};
164 }
165 NOTREACHED();
166 return GURL{kPushUpdatesUnsubscriptionStagingServer};
167 }
112 } // namespace ntp_snippets 168 } // namespace ntp_snippets
OLDNEW
« 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