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 #include "components/ntp_snippets/physical_web_pages/physical_web_page_suggestio
ns_provider.h" | 5 #include "components/ntp_snippets/physical_web_pages/physical_web_page_suggestio
ns_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 29 matching lines...) Expand all Loading... |
40 &raw_resolved_url)) { | 40 &raw_resolved_url)) { |
41 LOG(DFATAL) << physical_web::kResolvedUrlKey << " field is missing."; | 41 LOG(DFATAL) << physical_web::kResolvedUrlKey << " field is missing."; |
42 } | 42 } |
43 return raw_resolved_url; | 43 return raw_resolved_url; |
44 } | 44 } |
45 | 45 |
46 } // namespace | 46 } // namespace |
47 | 47 |
48 PhysicalWebPageSuggestionsProvider::PhysicalWebPageSuggestionsProvider( | 48 PhysicalWebPageSuggestionsProvider::PhysicalWebPageSuggestionsProvider( |
49 ContentSuggestionsProvider::Observer* observer, | 49 ContentSuggestionsProvider::Observer* observer, |
50 CategoryFactory* category_factory, | |
51 physical_web::PhysicalWebDataSource* physical_web_data_source, | 50 physical_web::PhysicalWebDataSource* physical_web_data_source, |
52 PrefService* pref_service) | 51 PrefService* pref_service) |
53 : ContentSuggestionsProvider(observer, category_factory), | 52 : ContentSuggestionsProvider(observer), |
54 category_status_(CategoryStatus::AVAILABLE), | 53 category_status_(CategoryStatus::AVAILABLE), |
55 provided_category_(category_factory->FromKnownCategory( | 54 provided_category_( |
56 KnownCategories::PHYSICAL_WEB_PAGES)), | 55 Category::FromKnownCategory(KnownCategories::PHYSICAL_WEB_PAGES)), |
57 physical_web_data_source_(physical_web_data_source), | 56 physical_web_data_source_(physical_web_data_source), |
58 pref_service_(pref_service) { | 57 pref_service_(pref_service) { |
59 observer->OnCategoryStatusChanged(this, provided_category_, category_status_); | 58 observer->OnCategoryStatusChanged(this, provided_category_, category_status_); |
60 physical_web_data_source_->RegisterListener(this); | 59 physical_web_data_source_->RegisterListener(this); |
61 // TODO(vitaliii): Rewrite initial fetch once crbug.com/667754 is resolved. | 60 // TODO(vitaliii): Rewrite initial fetch once crbug.com/667754 is resolved. |
62 FetchPhysicalWebPages(); | 61 FetchPhysicalWebPages(); |
63 } | 62 } |
64 | 63 |
65 PhysicalWebPageSuggestionsProvider::~PhysicalWebPageSuggestionsProvider() { | 64 PhysicalWebPageSuggestionsProvider::~PhysicalWebPageSuggestionsProvider() { |
66 physical_web_data_source_->UnregisterListener(this); | 65 physical_web_data_source_->UnregisterListener(this); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 } | 306 } |
308 | 307 |
309 void PhysicalWebPageSuggestionsProvider::StoreDismissedIDsToPrefs( | 308 void PhysicalWebPageSuggestionsProvider::StoreDismissedIDsToPrefs( |
310 const std::set<std::string>& dismissed_ids) { | 309 const std::set<std::string>& dismissed_ids) { |
311 prefs::StoreDismissedIDsToPrefs(pref_service_, | 310 prefs::StoreDismissedIDsToPrefs(pref_service_, |
312 prefs::kDismissedPhysicalWebPageSuggestions, | 311 prefs::kDismissedPhysicalWebPageSuggestions, |
313 dismissed_ids); | 312 dismissed_ids); |
314 } | 313 } |
315 | 314 |
316 } // namespace ntp_snippets | 315 } // namespace ntp_snippets |
OLD | NEW |