Chromium Code Reviews| Index: components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider.h |
| diff --git a/components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider.h b/components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider.h |
| index 407536f4c69e7f1d3ace57a7c4c57517d3bd99ba..fe8044a7089ca6cb18402de32de475cccad92830 100644 |
| --- a/components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider.h |
| +++ b/components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider.h |
| @@ -10,11 +10,14 @@ |
| #include <vector> |
| #include "base/callback_forward.h" |
| +#include "base/values.h" |
| #include "components/ntp_snippets/category.h" |
| #include "components/ntp_snippets/category_factory.h" |
| #include "components/ntp_snippets/category_status.h" |
| #include "components/ntp_snippets/content_suggestion.h" |
| #include "components/ntp_snippets/content_suggestions_provider.h" |
| +#include "components/physical_web/data_source/physical_web_data_source.h" |
| +#include "components/physical_web/data_source/physical_web_listener.h" |
| namespace gfx { |
| class Image; |
| @@ -22,27 +25,16 @@ class Image; |
| namespace ntp_snippets { |
| -// TODO(vitaliii): remove when Physical Web C++ interface is provided. |
| -struct UrlInfo { |
| - UrlInfo(); |
| - UrlInfo(const UrlInfo& other); |
| - ~UrlInfo(); |
| - base::Time scan_time; |
| - GURL site_url; |
| - std::string title; |
| - std::string description; |
| -}; |
| - |
| // Provides content suggestions from the Physical Web Service. |
| -class PhysicalWebPageSuggestionsProvider : public ContentSuggestionsProvider { |
| +class PhysicalWebPageSuggestionsProvider : public ContentSuggestionsProvider, |
| + public PhysicalWebListener { |
| public: |
| PhysicalWebPageSuggestionsProvider( |
| ContentSuggestionsProvider::Observer* observer, |
| - CategoryFactory* category_factory); |
| + CategoryFactory* category_factory, |
| + PhysicalWebDataSource* physical_web_data_source); |
| ~PhysicalWebPageSuggestionsProvider() override; |
| - void OnDisplayableUrlsChanged(const std::vector<UrlInfo>& urls); |
| - |
| // ContentSuggestionsProvider implementation. |
| CategoryStatus GetCategoryStatus(Category category) override; |
| CategoryInfo GetCategoryInfo(Category category) override; |
| @@ -63,10 +55,28 @@ class PhysicalWebPageSuggestionsProvider : public ContentSuggestionsProvider { |
| void ClearDismissedSuggestionsForDebugging(Category category) override; |
| private: |
| + friend class PhysicalWebPageSuggestionsProviderTest; |
| + |
| + // Updates the |category_status_| and notifies the |observer_|, if necessary. |
| void NotifyStatusChanged(CategoryStatus new_status); |
| + // Manually requests all physical web pages and updates the suggestions. |
| + void FetchPhysicalWebPages(); |
| + |
| + // Converts an Physical Web page to a ContentSuggestion for the |
| + // |provided_category_|. |
|
Marc Treib
2016/11/23 09:47:52
nit: I wouldn't mention provided_category_; it's n
vitaliii
2016/11/23 14:16:53
Done.
|
| + ContentSuggestion ConvertPhysicalWebPage( |
| + const base::DictionaryValue* out_value) const; |
|
Marc Treib
2016/11/23 09:47:52
out_value isn't a good name; this is an input.
Als
vitaliii
2016/11/23 14:16:53
Done.
|
| + |
| + // PhysicalWebListener implementation. |
| + void OnFound(const std::string& url) override; |
| + void OnLost(const std::string& url) override; |
| + void OnDistanceChanged(const std::string& url, |
| + double distance_estimate) override; |
| + |
| CategoryStatus category_status_; |
| const Category provided_category_; |
| + PhysicalWebDataSource* physical_web_data_source_; |
| DISALLOW_COPY_AND_ASSIGN(PhysicalWebPageSuggestionsProvider); |
| }; |