Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(955)

Side by Side Diff: chrome/browser/ui/webui/snippets_internals_message_handler.cc

Issue 2377663002: [NTP Snippets] Introduce ContentSuggestion::ID (Closed)
Patch Set: rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 23 matching lines...) Expand all
34 using ntp_snippets::CategoryStatus; 34 using ntp_snippets::CategoryStatus;
35 using ntp_snippets::KnownCategories; 35 using ntp_snippets::KnownCategories;
36 using ntp_snippets::UserClassifier; 36 using ntp_snippets::UserClassifier;
37 37
38 namespace { 38 namespace {
39 39
40 std::unique_ptr<base::DictionaryValue> PrepareSuggestion( 40 std::unique_ptr<base::DictionaryValue> PrepareSuggestion(
41 const ContentSuggestion& suggestion, 41 const ContentSuggestion& suggestion,
42 int index) { 42 int index) {
43 auto entry = base::MakeUnique<base::DictionaryValue>(); 43 auto entry = base::MakeUnique<base::DictionaryValue>();
44 entry->SetString("suggestionId", suggestion.id()); 44 entry->SetString("idWithinCategory", suggestion.id().id_within_category());
45 entry->SetString("url", suggestion.url().spec()); 45 entry->SetString("url", suggestion.url().spec());
46 entry->SetString("ampUrl", suggestion.amp_url().spec()); 46 entry->SetString("ampUrl", suggestion.amp_url().spec());
47 entry->SetString("title", suggestion.title()); 47 entry->SetString("title", suggestion.title());
48 entry->SetString("snippetText", suggestion.snippet_text()); 48 entry->SetString("snippetText", suggestion.snippet_text());
49 entry->SetString("publishDate", 49 entry->SetString("publishDate",
50 TimeFormatShortDateAndTime(suggestion.publish_date())); 50 TimeFormatShortDateAndTime(suggestion.publish_date()));
51 entry->SetString("publisherName", suggestion.publisher_name()); 51 entry->SetString("publisherName", suggestion.publisher_name());
52 entry->SetString("id", "content-suggestion-" + base::IntToString(index)); 52 entry->SetString("id", "content-suggestion-" + base::IntToString(index));
53 return entry; 53 return entry;
54 } 54 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 void SnippetsInternalsMessageHandler::OnCategoryStatusChanged( 138 void SnippetsInternalsMessageHandler::OnCategoryStatusChanged(
139 Category category, 139 Category category,
140 CategoryStatus new_status) { 140 CategoryStatus new_status) {
141 if (!dom_loaded_) 141 if (!dom_loaded_)
142 return; 142 return;
143 SendContentSuggestions(); 143 SendContentSuggestions();
144 } 144 }
145 145
146 void SnippetsInternalsMessageHandler::OnSuggestionInvalidated( 146 void SnippetsInternalsMessageHandler::OnSuggestionInvalidated(
147 ntp_snippets::Category category, 147 const ntp_snippets::ContentSuggestion::ID& suggestion_id) {
148 const std::string& suggestion_id) {
149 if (!dom_loaded_) 148 if (!dom_loaded_)
150 return; 149 return;
151 SendContentSuggestions(); 150 SendContentSuggestions();
152 } 151 }
153 152
154 void SnippetsInternalsMessageHandler::ContentSuggestionsServiceShutdown() {} 153 void SnippetsInternalsMessageHandler::ContentSuggestionsServiceShutdown() {}
155 154
156 void SnippetsInternalsMessageHandler::HandleRefreshContent( 155 void SnippetsInternalsMessageHandler::HandleRefreshContent(
157 const base::ListValue* args) { 156 const base::ListValue* args) {
158 DCHECK_EQ(0u, args->GetSize()); 157 DCHECK_EQ(0u, args->GetSize());
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 407
409 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded( 408 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded(
410 Category category, 409 Category category,
411 std::vector<ContentSuggestion> dismissed_suggestions) { 410 std::vector<ContentSuggestion> dismissed_suggestions) {
412 if (dismissed_state_[category] == DismissedState::HIDDEN) 411 if (dismissed_state_[category] == DismissedState::HIDDEN)
413 return; 412 return;
414 dismissed_suggestions_[category] = std::move(dismissed_suggestions); 413 dismissed_suggestions_[category] = std::move(dismissed_suggestions);
415 dismissed_state_[category] = DismissedState::VISIBLE; 414 dismissed_state_[category] = DismissedState::VISIBLE;
416 SendContentSuggestions(); 415 SendContentSuggestions();
417 } 416 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698