Chromium Code Reviews| 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/offline_pages/recent_tab_suggestions_provider. h" | 5 #include "components/ntp_snippets/offline_pages/recent_tab_suggestions_provider. h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 if (offline_page.title.empty()) { | 284 if (offline_page.title.empty()) { |
| 285 // TODO(vitaliii): Remove this fallback once the OfflinePageModel provides | 285 // TODO(vitaliii): Remove this fallback once the OfflinePageModel provides |
| 286 // titles for all (relevant) OfflinePageItems. | 286 // titles for all (relevant) OfflinePageItems. |
| 287 suggestion.set_title(base::UTF8ToUTF16(offline_page.url.spec())); | 287 suggestion.set_title(base::UTF8ToUTF16(offline_page.url.spec())); |
| 288 } else { | 288 } else { |
| 289 suggestion.set_title(offline_page.title); | 289 suggestion.set_title(offline_page.title); |
| 290 } | 290 } |
| 291 suggestion.set_publish_date(offline_page.creation_time); | 291 suggestion.set_publish_date(offline_page.creation_time); |
| 292 suggestion.set_publisher_name(base::UTF8ToUTF16(offline_page.url.host())); | 292 suggestion.set_publisher_name(base::UTF8ToUTF16(offline_page.url.host())); |
| 293 auto extra = base::MakeUnique<RecentTabSuggestionExtra>(); | 293 auto extra = base::MakeUnique<RecentTabSuggestionExtra>(); |
| 294 extra->tab_id = offline_page.client_id.id; | 294 int tab_id; |
| 295 bool success = base::StringToInt(offline_page.client_id.id, &tab_id); | |
| 296 DCHECK(success); | |
| 297 extra->tab_id = tab_id; | |
|
jkrcal
2017/02/01 09:27:13
Wouldn't it make sense to filter out the suggestio
vitaliii
2017/02/01 09:34:29
There is a DCHECK for this.
The assumption is that
| |
| 295 extra->offline_page_id = offline_page.offline_id; | 298 extra->offline_page_id = offline_page.offline_id; |
| 296 suggestion.set_recent_tab_suggestion_extra(std::move(extra)); | 299 suggestion.set_recent_tab_suggestion_extra(std::move(extra)); |
| 297 return suggestion; | 300 return suggestion; |
| 298 } | 301 } |
| 299 | 302 |
| 300 std::vector<ContentSuggestion> | 303 std::vector<ContentSuggestion> |
| 301 RecentTabSuggestionsProvider::GetMostRecentlyCreatedWithoutDuplicates( | 304 RecentTabSuggestionsProvider::GetMostRecentlyCreatedWithoutDuplicates( |
| 302 std::vector<const OfflinePageItem*> offline_page_items) const { | 305 std::vector<const OfflinePageItem*> offline_page_items) const { |
| 303 // |std::unique| only removes duplicates that immediately follow each other. | 306 // |std::unique| only removes duplicates that immediately follow each other. |
| 304 // Thus, first, we have to sort by URL and creation time and only then remove | 307 // Thus, first, we have to sort by URL and creation time and only then remove |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 } | 346 } |
| 344 | 347 |
| 345 void RecentTabSuggestionsProvider::StoreDismissedIDsToPrefs( | 348 void RecentTabSuggestionsProvider::StoreDismissedIDsToPrefs( |
| 346 const std::set<std::string>& dismissed_ids) { | 349 const std::set<std::string>& dismissed_ids) { |
| 347 prefs::StoreDismissedIDsToPrefs(pref_service_, | 350 prefs::StoreDismissedIDsToPrefs(pref_service_, |
| 348 prefs::kDismissedRecentOfflineTabSuggestions, | 351 prefs::kDismissedRecentOfflineTabSuggestions, |
| 349 dismissed_ids); | 352 dismissed_ids); |
| 350 } | 353 } |
| 351 | 354 |
| 352 } // namespace ntp_snippets | 355 } // namespace ntp_snippets |
| OLD | NEW |