Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
|
vitaliii
2017/01/18 08:03:34
I have another bug for this change (crbug.com/6720
mattreynolds
2017/01/18 22:26:13
Done.
| |
| 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 <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/values.h" | |
| 13 #include "components/ntp_snippets/category.h" | 12 #include "components/ntp_snippets/category.h" |
| 14 #include "components/ntp_snippets/category_status.h" | 13 #include "components/ntp_snippets/category_status.h" |
| 15 #include "components/ntp_snippets/content_suggestion.h" | 14 #include "components/ntp_snippets/content_suggestion.h" |
| 16 #include "components/ntp_snippets/content_suggestions_provider.h" | 15 #include "components/ntp_snippets/content_suggestions_provider.h" |
| 17 #include "components/physical_web/data_source/physical_web_data_source.h" | |
| 18 #include "components/physical_web/data_source/physical_web_listener.h" | 16 #include "components/physical_web/data_source/physical_web_listener.h" |
| 19 | 17 |
| 20 class PrefRegistrySimple; | 18 class PrefRegistrySimple; |
| 21 class PrefService; | 19 class PrefService; |
| 22 class GURL; | 20 class GURL; |
|
vitaliii
2017/01/18 08:03:34
Please sort.
mattreynolds
2017/01/18 22:26:12
Done.
| |
| 23 | 21 |
| 22 namespace physical_web { | |
| 23 class PhysicalWebDataSource; | |
| 24 struct Metadata; | |
| 25 } | |
|
vitaliii
2017/01/18 08:03:34
} // namespace physical_web
mattreynolds
2017/01/18 22:26:13
Done.
| |
| 26 | |
| 24 namespace ntp_snippets { | 27 namespace ntp_snippets { |
| 25 | 28 |
| 26 // Provides content suggestions from the Physical Web Service. | 29 // Provides content suggestions from the Physical Web Service. |
| 27 class PhysicalWebPageSuggestionsProvider | 30 class PhysicalWebPageSuggestionsProvider |
| 28 : public ContentSuggestionsProvider, | 31 : public ContentSuggestionsProvider, |
| 29 public physical_web::PhysicalWebListener { | 32 public physical_web::PhysicalWebListener { |
| 30 public: | 33 public: |
| 31 PhysicalWebPageSuggestionsProvider( | 34 PhysicalWebPageSuggestionsProvider( |
| 32 ContentSuggestionsProvider::Observer* observer, | 35 ContentSuggestionsProvider::Observer* observer, |
| 33 physical_web::PhysicalWebDataSource* physical_web_data_source, | 36 physical_web::PhysicalWebDataSource* physical_web_data_source, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 // |excluded_ids| and sorted by distance (the closest first). Dismissed | 71 // |excluded_ids| and sorted by distance (the closest first). Dismissed |
| 69 // suggestions are excluded automatically (no need to add them to | 72 // suggestions are excluded automatically (no need to add them to |
| 70 // |excluded_ids|) and pruned. The raw pages are obtained from Physical Web | 73 // |excluded_ids|) and pruned. The raw pages are obtained from Physical Web |
| 71 // data source. | 74 // data source. |
| 72 std::vector<ContentSuggestion> GetMostRecentPhysicalWebPagesWithFilter( | 75 std::vector<ContentSuggestion> GetMostRecentPhysicalWebPagesWithFilter( |
| 73 int max_count, | 76 int max_count, |
| 74 const std::set<std::string>& excluded_ids); | 77 const std::set<std::string>& excluded_ids); |
| 75 | 78 |
| 76 // Converts an Physical Web page to a ContentSuggestion. | 79 // Converts an Physical Web page to a ContentSuggestion. |
| 77 ContentSuggestion ConvertPhysicalWebPage( | 80 ContentSuggestion ConvertPhysicalWebPage( |
| 78 const base::DictionaryValue& page) const; | 81 const physical_web::Metadata& page) const; |
| 79 | 82 |
| 80 // PhysicalWebListener implementation. | 83 // PhysicalWebListener implementation. |
| 81 void OnFound(const GURL& url) override; | 84 void OnFound(const GURL& url) override; |
| 82 void OnLost(const GURL& url) override; | 85 void OnLost(const GURL& url) override; |
| 83 void OnDistanceChanged(const GURL& url, double distance_estimate) override; | 86 void OnDistanceChanged(const GURL& url, double distance_estimate) override; |
| 84 | 87 |
| 85 // Fires the |OnSuggestionInvalidated| event for the suggestion corresponding | 88 // Fires the |OnSuggestionInvalidated| event for the suggestion corresponding |
| 86 // to the given |page_id| and deletes it from the dismissed IDs list, if | 89 // to the given |page_id| and deletes it from the dismissed IDs list, if |
| 87 // necessary. | 90 // necessary. |
| 88 void InvalidateSuggestion(const std::string& page_id); | 91 void InvalidateSuggestion(const std::string& page_id); |
| 89 | 92 |
| 90 // Reads dismissed IDs from Prefs. | 93 // Reads dismissed IDs from Prefs. |
| 91 std::set<std::string> ReadDismissedIDsFromPrefs() const; | 94 std::set<std::string> ReadDismissedIDsFromPrefs() const; |
| 92 | 95 |
| 93 // Writes |dismissed_ids| into Prefs. | 96 // Writes |dismissed_ids| into Prefs. |
| 94 void StoreDismissedIDsToPrefs(const std::set<std::string>& dismissed_ids); | 97 void StoreDismissedIDsToPrefs(const std::set<std::string>& dismissed_ids); |
| 95 | 98 |
| 96 CategoryStatus category_status_; | 99 CategoryStatus category_status_; |
| 97 const Category provided_category_; | 100 const Category provided_category_; |
| 98 physical_web::PhysicalWebDataSource* physical_web_data_source_; | 101 physical_web::PhysicalWebDataSource* physical_web_data_source_; |
| 99 PrefService* pref_service_; | 102 PrefService* pref_service_; |
| 100 | 103 |
| 101 DISALLOW_COPY_AND_ASSIGN(PhysicalWebPageSuggestionsProvider); | 104 DISALLOW_COPY_AND_ASSIGN(PhysicalWebPageSuggestionsProvider); |
| 102 }; | 105 }; |
| 103 | 106 |
| 104 } // namespace ntp_snippets | 107 } // namespace ntp_snippets |
| 105 | 108 |
| 106 #endif // COMPONENTS_NTP_SNIPPETS_PHYSICAL_WEB_PAGES_PHYSICAL_WEB_PAGE_SUGGESTI ONS_PROVIDER_H_ | 109 #endif // COMPONENTS_NTP_SNIPPETS_PHYSICAL_WEB_PAGES_PHYSICAL_WEB_PAGE_SUGGESTI ONS_PROVIDER_H_ |
| OLD | NEW |