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 <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 GetMostRecentPhysicalWebPagesWithFilter( | 146 GetMostRecentPhysicalWebPagesWithFilter( |
147 kMaxSuggestionsCount, | 147 kMaxSuggestionsCount, |
148 /*excluded_ids=*/std::set<std::string>())); | 148 /*excluded_ids=*/std::set<std::string>())); |
149 } | 149 } |
150 | 150 |
151 std::vector<ContentSuggestion> | 151 std::vector<ContentSuggestion> |
152 PhysicalWebPageSuggestionsProvider::GetMostRecentPhysicalWebPagesWithFilter( | 152 PhysicalWebPageSuggestionsProvider::GetMostRecentPhysicalWebPagesWithFilter( |
153 int max_quantity, | 153 int max_quantity, |
154 const std::set<std::string>& excluded_ids) { | 154 const std::set<std::string>& excluded_ids) { |
155 std::unique_ptr<ListValue> page_values = | 155 std::unique_ptr<ListValue> page_values = |
156 physical_web_data_source_->GetMetadata(); | 156 physical_web_data_source_->GetMetadataListValue(); |
157 | 157 |
158 std::vector<const DictionaryValue*> page_dictionaries; | 158 std::vector<const DictionaryValue*> page_dictionaries; |
159 for (const std::unique_ptr<Value>& page_value : *page_values) { | 159 for (const std::unique_ptr<Value>& page_value : *page_values) { |
160 const DictionaryValue* page_dictionary; | 160 const DictionaryValue* page_dictionary; |
161 if (!page_value->GetAsDictionary(&page_dictionary)) { | 161 if (!page_value->GetAsDictionary(&page_dictionary)) { |
162 LOG(DFATAL) << "Physical Web page is not a dictionary."; | 162 LOG(DFATAL) << "Physical Web page is not a dictionary."; |
163 continue; | 163 continue; |
164 } | 164 } |
165 if (!excluded_ids.count(GetPageId(*page_dictionary))) { | 165 if (!excluded_ids.count(GetPageId(*page_dictionary))) { |
166 page_dictionaries.push_back(page_dictionary); | 166 page_dictionaries.push_back(page_dictionary); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 FetchPhysicalWebPages(); | 233 FetchPhysicalWebPages(); |
234 } | 234 } |
235 | 235 |
236 void PhysicalWebPageSuggestionsProvider::OnDistanceChanged( | 236 void PhysicalWebPageSuggestionsProvider::OnDistanceChanged( |
237 const std::string& url, | 237 const std::string& url, |
238 double distance_estimate) { | 238 double distance_estimate) { |
239 FetchPhysicalWebPages(); | 239 FetchPhysicalWebPages(); |
240 } | 240 } |
241 | 241 |
242 } // namespace ntp_snippets | 242 } // namespace ntp_snippets |
OLD | NEW |