Chromium Code Reviews| Index: components/ntp_snippets/content_suggestion.cc |
| diff --git a/components/ntp_snippets/content_suggestion.cc b/components/ntp_snippets/content_suggestion.cc |
| index 0fa4f0cd9dde852a8d368ad0476df7c59c1faadf..871af7133b12a041a2d5e54f9872a55292e156c6 100644 |
| --- a/components/ntp_snippets/content_suggestion.cc |
| +++ b/components/ntp_snippets/content_suggestion.cc |
| @@ -2,16 +2,38 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include "base/strings/stringprintf.h" |
|
Marc Treib
2016/07/01 09:15:33
This should go below the include for the content_s
Philipp Keck
2016/07/01 13:00:04
Done.
|
| #include "components/ntp_snippets/content_suggestion.h" |
| namespace ntp_snippets { |
| +namespace { |
| + |
| +const char kCombinedIDFormat[] = "%d:%s"; |
| + |
| +// Helper function to combine ID and provider_type into a common ID to make it |
| +// unique. |
| +std::string CombineID(ContentSuggestionsProviderType provider_type, |
| + const std::string& original_id) { |
| + return base::StringPrintf(kCombinedIDFormat, provider_type, |
| + original_id.c_str()); |
| +} |
| + |
| +} // namespace |
| + |
| ContentSuggestion::ContentSuggestion( |
| - const std::string& id, |
| - const ContentSuggestionsProviderType provider, |
| + const std::string& original_id, |
| + const ContentSuggestionsProviderType provider_type, |
| const ContentSuggestionCategory category, |
| const GURL& url) |
| - : id_(id), provider_(provider), category_(category), url_(url), score_(0) {} |
| + : id_(CombineID(provider_type, original_id)), |
| + category_(category), |
| + url_(url), |
| + score_(0) {} |
| + |
| +ContentSuggestion::ContentSuggestion(ContentSuggestion&&) = default; |
| + |
| +ContentSuggestion& ContentSuggestion::operator=(ContentSuggestion&&) = default; |
| ContentSuggestion::~ContentSuggestion() {} |