| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef COMPONENTS_NTP_SNIPPETS_PHYSICAL_WEB_PAGES_PHYSICAL_WEB_PAGE_SUGGESTIONS
_PROVIDER_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_PHYSICAL_WEB_PAGES_PHYSICAL_WEB_PAGE_SUGGESTIONS
_PROVIDER_H_ |
| 6 #define COMPONENTS_NTP_SNIPPETS_PHYSICAL_WEB_PAGES_PHYSICAL_WEB_PAGE_SUGGESTIONS
_PROVIDER_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_PHYSICAL_WEB_PAGES_PHYSICAL_WEB_PAGE_SUGGESTIONS
_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | |
| 10 #include <vector> | 9 #include <vector> |
| 11 | 10 |
| 12 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 13 #include "base/values.h" | 12 #include "base/values.h" |
| 14 #include "components/ntp_snippets/category.h" | 13 #include "components/ntp_snippets/category.h" |
| 15 #include "components/ntp_snippets/category_factory.h" | 14 #include "components/ntp_snippets/category_factory.h" |
| 16 #include "components/ntp_snippets/category_status.h" | 15 #include "components/ntp_snippets/category_status.h" |
| 17 #include "components/ntp_snippets/content_suggestion.h" | 16 #include "components/ntp_snippets/content_suggestion.h" |
| 18 #include "components/ntp_snippets/content_suggestions_provider.h" | 17 #include "components/ntp_snippets/content_suggestions_provider.h" |
| 19 #include "components/physical_web/data_source/physical_web_data_source.h" | 18 #include "components/physical_web/data_source/physical_web_data_source.h" |
| 20 #include "components/physical_web/data_source/physical_web_listener.h" | 19 #include "components/physical_web/data_source/physical_web_listener.h" |
| 21 | 20 |
| 22 class PrefRegistrySimple; | 21 class PrefRegistrySimple; |
| 23 class PrefService; | 22 class PrefService; |
| 23 class GURL; |
| 24 | 24 |
| 25 namespace ntp_snippets { | 25 namespace ntp_snippets { |
| 26 | 26 |
| 27 // Provides content suggestions from the Physical Web Service. | 27 // Provides content suggestions from the Physical Web Service. |
| 28 class PhysicalWebPageSuggestionsProvider | 28 class PhysicalWebPageSuggestionsProvider |
| 29 : public ContentSuggestionsProvider, | 29 : public ContentSuggestionsProvider, |
| 30 public physical_web::PhysicalWebListener { | 30 public physical_web::PhysicalWebListener { |
| 31 public: | 31 public: |
| 32 PhysicalWebPageSuggestionsProvider( | 32 PhysicalWebPageSuggestionsProvider( |
| 33 ContentSuggestionsProvider::Observer* observer, | 33 ContentSuggestionsProvider::Observer* observer, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // data source. | 73 // data source. |
| 74 std::vector<ContentSuggestion> GetMostRecentPhysicalWebPagesWithFilter( | 74 std::vector<ContentSuggestion> GetMostRecentPhysicalWebPagesWithFilter( |
| 75 int max_count, | 75 int max_count, |
| 76 const std::set<std::string>& excluded_ids); | 76 const std::set<std::string>& excluded_ids); |
| 77 | 77 |
| 78 // Converts an Physical Web page to a ContentSuggestion. | 78 // Converts an Physical Web page to a ContentSuggestion. |
| 79 ContentSuggestion ConvertPhysicalWebPage( | 79 ContentSuggestion ConvertPhysicalWebPage( |
| 80 const base::DictionaryValue& page) const; | 80 const base::DictionaryValue& page) const; |
| 81 | 81 |
| 82 // PhysicalWebListener implementation. | 82 // PhysicalWebListener implementation. |
| 83 void OnFound(const std::string& url) override; | 83 void OnFound(const GURL& url) override; |
| 84 void OnLost(const std::string& url) override; | 84 void OnLost(const GURL& url) override; |
| 85 void OnDistanceChanged(const std::string& url, | 85 void OnDistanceChanged(const GURL& url, double distance_estimate) override; |
| 86 double distance_estimate) override; | |
| 87 | 86 |
| 88 // Fires the |OnSuggestionInvalidated| event for the suggestion corresponding | 87 // Fires the |OnSuggestionInvalidated| event for the suggestion corresponding |
| 89 // to the given |page_id| and deletes it from the dismissed IDs list, if | 88 // to the given |page_id| and deletes it from the dismissed IDs list, if |
| 90 // necessary. | 89 // necessary. |
| 91 void InvalidateSuggestion(const std::string& page_id); | 90 void InvalidateSuggestion(const std::string& page_id); |
| 92 | 91 |
| 93 // Reads dismissed IDs from Prefs. | 92 // Reads dismissed IDs from Prefs. |
| 94 std::set<std::string> ReadDismissedIDsFromPrefs() const; | 93 std::set<std::string> ReadDismissedIDsFromPrefs() const; |
| 95 | 94 |
| 96 // Writes |dismissed_ids| into Prefs. | 95 // Writes |dismissed_ids| into Prefs. |
| 97 void StoreDismissedIDsToPrefs(const std::set<std::string>& dismissed_ids); | 96 void StoreDismissedIDsToPrefs(const std::set<std::string>& dismissed_ids); |
| 98 | 97 |
| 99 CategoryStatus category_status_; | 98 CategoryStatus category_status_; |
| 100 const Category provided_category_; | 99 const Category provided_category_; |
| 101 physical_web::PhysicalWebDataSource* physical_web_data_source_; | 100 physical_web::PhysicalWebDataSource* physical_web_data_source_; |
| 102 PrefService* pref_service_; | 101 PrefService* pref_service_; |
| 103 | 102 |
| 104 DISALLOW_COPY_AND_ASSIGN(PhysicalWebPageSuggestionsProvider); | 103 DISALLOW_COPY_AND_ASSIGN(PhysicalWebPageSuggestionsProvider); |
| 105 }; | 104 }; |
| 106 | 105 |
| 107 } // namespace ntp_snippets | 106 } // namespace ntp_snippets |
| 108 | 107 |
| 109 #endif // COMPONENTS_NTP_SNIPPETS_PHYSICAL_WEB_PAGES_PHYSICAL_WEB_PAGE_SUGGESTI
ONS_PROVIDER_H_ | 108 #endif // COMPONENTS_NTP_SNIPPETS_PHYSICAL_WEB_PAGES_PHYSICAL_WEB_PAGE_SUGGESTI
ONS_PROVIDER_H_ |
| OLD | NEW |