| 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 "chrome/browser/ui/webui/snippets_internals_message_handler.h" | 5 #include "chrome/browser/ui/webui/snippets_internals_message_handler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 using ntp_snippets::UserClassifier; | 41 using ntp_snippets::UserClassifier; |
| 42 | 42 |
| 43 namespace { | 43 namespace { |
| 44 | 44 |
| 45 std::unique_ptr<base::DictionaryValue> PrepareSuggestion( | 45 std::unique_ptr<base::DictionaryValue> PrepareSuggestion( |
| 46 const ContentSuggestion& suggestion, | 46 const ContentSuggestion& suggestion, |
| 47 int index) { | 47 int index) { |
| 48 auto entry = base::MakeUnique<base::DictionaryValue>(); | 48 auto entry = base::MakeUnique<base::DictionaryValue>(); |
| 49 entry->SetString("idWithinCategory", suggestion.id().id_within_category()); | 49 entry->SetString("idWithinCategory", suggestion.id().id_within_category()); |
| 50 entry->SetString("url", suggestion.url().spec()); | 50 entry->SetString("url", suggestion.url().spec()); |
| 51 entry->SetString("ampUrl", suggestion.amp_url().spec()); | |
| 52 entry->SetString("title", suggestion.title()); | 51 entry->SetString("title", suggestion.title()); |
| 53 entry->SetString("snippetText", suggestion.snippet_text()); | 52 entry->SetString("snippetText", suggestion.snippet_text()); |
| 54 entry->SetString("publishDate", | 53 entry->SetString("publishDate", |
| 55 TimeFormatShortDateAndTime(suggestion.publish_date())); | 54 TimeFormatShortDateAndTime(suggestion.publish_date())); |
| 56 entry->SetString("publisherName", suggestion.publisher_name()); | 55 entry->SetString("publisherName", suggestion.publisher_name()); |
| 57 entry->SetString("id", "content-suggestion-" + base::IntToString(index)); | 56 entry->SetString("id", "content-suggestion-" + base::IntToString(index)); |
| 58 return entry; | 57 return entry; |
| 59 } | 58 } |
| 60 | 59 |
| 61 std::string GetCategoryStatusName(CategoryStatus status) { | 60 std::string GetCategoryStatusName(CategoryStatus status) { |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 | 413 |
| 415 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded( | 414 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded( |
| 416 Category category, | 415 Category category, |
| 417 std::vector<ContentSuggestion> dismissed_suggestions) { | 416 std::vector<ContentSuggestion> dismissed_suggestions) { |
| 418 if (dismissed_state_[category] == DismissedState::HIDDEN) | 417 if (dismissed_state_[category] == DismissedState::HIDDEN) |
| 419 return; | 418 return; |
| 420 dismissed_suggestions_[category] = std::move(dismissed_suggestions); | 419 dismissed_suggestions_[category] = std::move(dismissed_suggestions); |
| 421 dismissed_state_[category] = DismissedState::VISIBLE; | 420 dismissed_state_[category] = DismissedState::VISIBLE; |
| 422 SendContentSuggestions(); | 421 SendContentSuggestions(); |
| 423 } | 422 } |
| OLD | NEW |