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

Unified Diff: components/ntp_snippets/offline_pages/offline_page_suggestions_provider.h

Issue 2139293004: [TEMP - DO NOT SUBMIT] OfflinePagesProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@internalspage
Patch Set: Implement OfflinePage conversion Created 4 years, 5 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/offline_pages/offline_page_suggestions_provider.h
diff --git a/components/ntp_snippets/offline_pages/offline_page_suggestions_provider.h b/components/ntp_snippets/offline_pages/offline_page_suggestions_provider.h
new file mode 100644
index 0000000000000000000000000000000000000000..a82f4883e9fcc996fcd8f51694a2648525a907b2
--- /dev/null
+++ b/components/ntp_snippets/offline_pages/offline_page_suggestions_provider.h
@@ -0,0 +1,80 @@
+// Copyright 2016 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_OFFLINE_PAGES_OFFLINE_PAGE_SUGGESTIONS_PROVIDER_H_
+#define COMPONENTS_NTP_SNIPPETS_OFFLINE_PAGES_OFFLINE_PAGE_SUGGESTIONS_PROVIDER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/callback_forward.h"
+#include "components/keyed_service/core/keyed_service.h"
+#include "components/ntp_snippets/content_suggestion.h"
+#include "components/ntp_snippets/content_suggestions_category.h"
+#include "components/ntp_snippets/content_suggestions_category_status.h"
+#include "components/ntp_snippets/content_suggestions_provider.h"
+#include "components/offline_pages/offline_page_item.h"
+#include "components/offline_pages/offline_page_model.h"
+#include "components/offline_pages/offline_page_types.h"
+
+namespace gfx {
+class Image;
+}
+
+namespace ntp_snippets {
+
+// Provides content suggestions from the offline pages model.
+// Currently, those are only the pages that the user last navigated to in an
+// open tab and offlined bookmarks.
+class OfflinePageSuggestionsProvider
+ : public KeyedService,
+ public ContentSuggestionsProvider,
+ public offline_pages::OfflinePageModel::Observer {
+ public:
+ using ImageFetchedCallback =
+ base::Callback<void(const std::string& suggestion_id, const gfx::Image&)>;
+
+ OfflinePageSuggestionsProvider(
+ offline_pages::OfflinePageModel* offline_page_model);
+ ~OfflinePageSuggestionsProvider() override;
+
+ // Inherited from KeyedService.
+ void Shutdown() override;
+
+ private:
+ // ContentSuggestionsProvider implementation
+ void SetObserver(ContentSuggestionsProvider::Observer* observer) override;
+ ContentSuggestionsCategoryStatus GetCategoryStatus(
+ ContentSuggestionsCategory category) override;
+ void DiscardSuggestion(const std::string& suggestion_id) override;
+ void FetchSuggestionImage(const std::string& suggestion_id,
+ const ImageFetchedCallback& callback) override;
+ void ClearCachedSuggestionsForDebugging() override;
+ void ClearDiscardedSuggestionsForDebugging() override;
+
+ // OfflinePageModel::Observer implementation
+ void OfflinePageModelLoaded(offline_pages::OfflinePageModel* model) override;
+ void OfflinePageModelChanged(offline_pages::OfflinePageModel* model) override;
+ void OfflinePageDeleted(int64_t offline_id,
+ const offline_pages::ClientId& client_id) override;
+
+ // Queries the OfflinePageModel for offline pages
+ void FetchOfflinePages();
+
+ // Callback from the OfflinePageModel
+ void OnOfflinePagesLoaded(
+ const offline_pages::MultipleOfflinePageItemResult& result);
+
+ ContentSuggestionsCategoryStatus category_status_;
+
+ ContentSuggestionsProvider::Observer* observer_ = nullptr;
+
+ offline_pages::OfflinePageModel* offline_page_model_;
+
+ DISALLOW_COPY_AND_ASSIGN(OfflinePageSuggestionsProvider);
+};
+
+} // namespace ntp_snippets
+
+#endif // COMPONENTS_NTP_SNIPPETS_OFFLINE_PAGES_OFFLINE_PAGE_SUGGESTIONS_PROVIDER_H_
« no previous file with comments | « components/ntp_snippets/offline_pages/DEPS ('k') | components/ntp_snippets/offline_pages/offline_page_suggestions_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698