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

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

Issue 2914263002: [NTP::Push] Adding Breaking News Subscription Manager (Closed)
Patch Set: bauerb@ comments. 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
Index: components/ntp_snippets/breaking_news/subscription_manager.h
diff --git a/components/ntp_snippets/breaking_news/subscription_manager.h b/components/ntp_snippets/breaking_news/subscription_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..ab98e8d8a241068bae556a601523d79062c82156
--- /dev/null
+++ b/components/ntp_snippets/breaking_news/subscription_manager.h
@@ -0,0 +1,45 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_NTP_SNIPPETS_BREAKING_NEWS_SUBSCRIPTION_MANAGER_H_
+#define COMPONENTS_NTP_SNIPPETS_BREAKING_NEWS_SUBSCRIPTION_MANAGER_H_
+
+#include "components/ntp_snippets/breaking_news/subscription_json_request.h"
+#include "net/url_request/url_request_context_getter.h"
+#include "url/gurl.h"
+
+namespace ntp_snippets {
+
+class SubscriptionManager {
+ public:
+ SubscriptionManager(
+ scoped_refptr<net::URLRequestContextGetter> url_request_context_getter,
+ PrefService* pref_service);
+
+ ~SubscriptionManager();
+
+ void Subscribe(const std::string& token);
+ void Unsubscribe(const std::string& token);
+
+ private:
+ // Holds the URL request context.
+ scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
+
+ std::unique_ptr<internal::SubscriptionJsonRequest> subscription_request_;
+
+ // API endpoint for subscribing.
+ // TODO(mamir): retrieve the correct fetch point
+ // See:
+ // components/ntp_snippets/remote/remote_suggestions_fetcher.cc?type=cs&l=175
+ const GURL subscribe_url_{"http://valid-url.test"};
+
+ std::string subscription_token_;
+ PrefService* pref_service_;
+
+ void DidSubscribe(const ntp_snippets::Status& status);
+
+ DISALLOW_COPY_AND_ASSIGN(SubscriptionManager);
+};
+}
+#endif // COMPONENTS_NTP_SNIPPETS_BREAKING_NEWS_SUBSCRIPTION_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698