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

Side by Side Diff: components/ntp_snippets/ntp_snippets_service.cc

Issue 2197223002: Use base::string16 for user-visible texts in ContentSuggestion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/ntp_snippets/ntp_snippets_service.h" 5 #include "components/ntp_snippets/ntp_snippets_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/location.h" 14 #include "base/location.h"
15 #include "base/metrics/histogram_macros.h" 15 #include "base/metrics/histogram_macros.h"
16 #include "base/metrics/sparse_histogram.h" 16 #include "base/metrics/sparse_histogram.h"
17 #include "base/path_service.h" 17 #include "base/path_service.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/utf_string_conversions.h"
19 #include "base/task_runner_util.h" 20 #include "base/task_runner_util.h"
20 #include "base/time/time.h" 21 #include "base/time/time.h"
21 #include "base/values.h" 22 #include "base/values.h"
22 #include "components/data_use_measurement/core/data_use_user_data.h" 23 #include "components/data_use_measurement/core/data_use_user_data.h"
23 #include "components/image_fetcher/image_decoder.h" 24 #include "components/image_fetcher/image_decoder.h"
24 #include "components/image_fetcher/image_fetcher.h" 25 #include "components/image_fetcher/image_fetcher.h"
25 #include "components/ntp_snippets/ntp_snippets_constants.h" 26 #include "components/ntp_snippets/ntp_snippets_constants.h"
26 #include "components/ntp_snippets/ntp_snippets_database.h" 27 #include "components/ntp_snippets/ntp_snippets_database.h"
27 #include "components/ntp_snippets/pref_names.h" 28 #include "components/ntp_snippets/pref_names.h"
28 #include "components/ntp_snippets/switches.h" 29 #include "components/ntp_snippets/switches.h"
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 return; 782 return;
782 783
783 std::vector<ContentSuggestion> result; 784 std::vector<ContentSuggestion> result;
784 for (const std::unique_ptr<NTPSnippet>& snippet : snippets_) { 785 for (const std::unique_ptr<NTPSnippet>& snippet : snippets_) {
785 if (!snippet->is_complete()) 786 if (!snippet->is_complete())
786 continue; 787 continue;
787 ContentSuggestion suggestion( 788 ContentSuggestion suggestion(
788 MakeUniqueID(provided_category_, snippet->id()), 789 MakeUniqueID(provided_category_, snippet->id()),
789 snippet->best_source().url); 790 snippet->best_source().url);
790 suggestion.set_amp_url(snippet->best_source().amp_url); 791 suggestion.set_amp_url(snippet->best_source().amp_url);
791 suggestion.set_title(snippet->title()); 792 suggestion.set_title(base::UTF8ToUTF16(snippet->title()));
792 suggestion.set_snippet_text(snippet->snippet()); 793 suggestion.set_snippet_text(base::UTF8ToUTF16(snippet->snippet()));
793 suggestion.set_publish_date(snippet->publish_date()); 794 suggestion.set_publish_date(snippet->publish_date());
794 suggestion.set_publisher_name(snippet->best_source().publisher_name); 795 suggestion.set_publisher_name(
796 base::UTF8ToUTF16(snippet->best_source().publisher_name));
795 suggestion.set_score(snippet->score()); 797 suggestion.set_score(snippet->score());
796 result.emplace_back(std::move(suggestion)); 798 result.emplace_back(std::move(suggestion));
797 } 799 }
798 observer_->OnNewSuggestions(provided_category_, std::move(result)); 800 observer_->OnNewSuggestions(provided_category_, std::move(result));
799 } 801 }
800 802
801 void NTPSnippetsService::NotifyCategoryStatusChanged() { 803 void NTPSnippetsService::NotifyCategoryStatusChanged() {
802 if (observer_) { 804 if (observer_) {
803 observer_->OnCategoryStatusChanged(provided_category_, category_status_); 805 observer_->OnCategoryStatusChanged(provided_category_, category_status_);
804 } 806 }
805 } 807 }
806 808
807 } // namespace ntp_snippets 809 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698