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 "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.
| |
5 #include "components/ntp_snippets/content_suggestion.h" | 6 #include "components/ntp_snippets/content_suggestion.h" |
6 | 7 |
7 namespace ntp_snippets { | 8 namespace ntp_snippets { |
8 | 9 |
10 namespace { | |
11 | |
12 const char kCombinedIDFormat[] = "%d:%s"; | |
13 | |
14 // Helper function to combine ID and provider_type into a common ID to make it | |
15 // unique. | |
16 std::string CombineID(ContentSuggestionsProviderType provider_type, | |
17 const std::string& original_id) { | |
18 return base::StringPrintf(kCombinedIDFormat, provider_type, | |
19 original_id.c_str()); | |
20 } | |
21 | |
22 } // namespace | |
23 | |
9 ContentSuggestion::ContentSuggestion( | 24 ContentSuggestion::ContentSuggestion( |
10 const std::string& id, | 25 const std::string& original_id, |
11 const ContentSuggestionsProviderType provider, | 26 const ContentSuggestionsProviderType provider_type, |
12 const ContentSuggestionCategory category, | 27 const ContentSuggestionCategory category, |
13 const GURL& url) | 28 const GURL& url) |
14 : id_(id), provider_(provider), category_(category), url_(url), score_(0) {} | 29 : id_(CombineID(provider_type, original_id)), |
30 category_(category), | |
31 url_(url), | |
32 score_(0) {} | |
33 | |
34 ContentSuggestion::ContentSuggestion(ContentSuggestion&&) = default; | |
35 | |
36 ContentSuggestion& ContentSuggestion::operator=(ContentSuggestion&&) = default; | |
15 | 37 |
16 ContentSuggestion::~ContentSuggestion() {} | 38 ContentSuggestion::~ContentSuggestion() {} |
17 | 39 |
18 } // namespace ntp_snippets | 40 } // namespace ntp_snippets |
OLD | NEW |