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 "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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 using ntp_snippets::UserClassifier; | 46 using ntp_snippets::UserClassifier; |
| 47 | 47 |
| 48 namespace { | 48 namespace { |
| 49 | 49 |
| 50 std::unique_ptr<base::DictionaryValue> PrepareSuggestion( | 50 std::unique_ptr<base::DictionaryValue> PrepareSuggestion( |
| 51 const ContentSuggestion& suggestion, | 51 const ContentSuggestion& suggestion, |
| 52 int index) { | 52 int index) { |
| 53 auto entry = base::MakeUnique<base::DictionaryValue>(); | 53 auto entry = base::MakeUnique<base::DictionaryValue>(); |
| 54 entry->SetString("idWithinCategory", suggestion.id().id_within_category()); | 54 entry->SetString("idWithinCategory", suggestion.id().id_within_category()); |
| 55 entry->SetString("url", suggestion.url().spec()); | 55 entry->SetString("url", suggestion.url().spec()); |
| 56 entry->SetString("urlWithFavicon", | |
| 57 suggestion.url_with_favicon().GetWithEmptyPath().spec()); | |
|
vitaliii
2017/04/19 09:02:10
Why do you remove path?
jkrcal
2017/04/19 10:26:48
To do the same what is done in ContentSuggestionsS
vitaliii
2017/04/19 10:47:44
Do you mean that ContentSuggestionsService ignores
jkrcal
2017/04/19 11:44:07
Okay, done.
| |
| 56 entry->SetString("title", suggestion.title()); | 58 entry->SetString("title", suggestion.title()); |
| 57 entry->SetString("snippetText", suggestion.snippet_text()); | 59 entry->SetString("snippetText", suggestion.snippet_text()); |
| 58 entry->SetString("publishDate", | 60 entry->SetString("publishDate", |
| 59 TimeFormatShortDateAndTime(suggestion.publish_date())); | 61 TimeFormatShortDateAndTime(suggestion.publish_date())); |
| 60 entry->SetString("fetchDate", | 62 entry->SetString("fetchDate", |
| 61 TimeFormatShortDateAndTime(suggestion.fetch_date())); | 63 TimeFormatShortDateAndTime(suggestion.fetch_date())); |
| 62 entry->SetString("publisherName", suggestion.publisher_name()); | 64 entry->SetString("publisherName", suggestion.publisher_name()); |
| 63 entry->SetString("id", "content-suggestion-" + base::IntToString(index)); | 65 entry->SetString("id", "content-suggestion-" + base::IntToString(index)); |
| 64 entry->SetDouble("score", suggestion.score()); | 66 entry->SetDouble("score", suggestion.score()); |
| 65 | 67 |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 455 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded( | 457 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded( |
| 456 Category category, | 458 Category category, |
| 457 std::vector<ContentSuggestion> dismissed_suggestions) { | 459 std::vector<ContentSuggestion> dismissed_suggestions) { |
| 458 if (dismissed_state_[category] == DismissedState::HIDDEN) { | 460 if (dismissed_state_[category] == DismissedState::HIDDEN) { |
| 459 return; | 461 return; |
| 460 } | 462 } |
| 461 dismissed_suggestions_[category] = std::move(dismissed_suggestions); | 463 dismissed_suggestions_[category] = std::move(dismissed_suggestions); |
| 462 dismissed_state_[category] = DismissedState::VISIBLE; | 464 dismissed_state_[category] = DismissedState::VISIBLE; |
| 463 SendContentSuggestions(); | 465 SendContentSuggestions(); |
| 464 } | 466 } |
| OLD | NEW |