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

Side by Side Diff: components/ntp_snippets/offline_pages/offline_page_suggestions_provider.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
« no previous file with comments | « components/ntp_snippets/ntp_snippets_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/ntp_snippets/offline_pages/offline_page_suggestions_provide r.h" 5 #include "components/ntp_snippets/offline_pages/offline_page_suggestions_provide r.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/utf_string_conversions.h"
9 10
10 using offline_pages::MultipleOfflinePageItemResult; 11 using offline_pages::MultipleOfflinePageItemResult;
11 using offline_pages::OfflinePageModel; 12 using offline_pages::OfflinePageModel;
12 using offline_pages::OfflinePageItem; 13 using offline_pages::OfflinePageItem;
13 14
14 namespace ntp_snippets { 15 namespace ntp_snippets {
15 16
16 namespace { 17 namespace {
17 18
18 const int kMaxSuggestionsCount = 5; 19 const int kMaxSuggestionsCount = 5;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // TODO(pke): Make sure the URL is actually opened as an offline URL. 113 // TODO(pke): Make sure the URL is actually opened as an offline URL.
113 // Currently, the browser opens the offline URL and then immediately 114 // Currently, the browser opens the offline URL and then immediately
114 // redirects to the online URL if the device is online. 115 // redirects to the online URL if the device is online.
115 ContentSuggestion suggestion( 116 ContentSuggestion suggestion(
116 MakeUniqueID(provided_category_, base::IntToString(item.offline_id)), 117 MakeUniqueID(provided_category_, base::IntToString(item.offline_id)),
117 item.GetOfflineURL()); 118 item.GetOfflineURL());
118 119
119 // TODO(pke): Sort my most recently visited and only keep the top one of 120 // TODO(pke): Sort my most recently visited and only keep the top one of
120 // multiple entries for the same URL. 121 // multiple entries for the same URL.
121 // TODO(pke): Get more reasonable data from the OfflinePageModel here. 122 // TODO(pke): Get more reasonable data from the OfflinePageModel here.
122 suggestion.set_title(item.url.spec()); 123 suggestion.set_title(base::UTF8ToUTF16(item.url.spec()));
123 suggestion.set_snippet_text(std::string()); 124 suggestion.set_snippet_text(base::string16());
124 suggestion.set_publish_date(item.creation_time); 125 suggestion.set_publish_date(item.creation_time);
125 suggestion.set_publisher_name(item.url.host()); 126 suggestion.set_publisher_name(base::UTF8ToUTF16(item.url.host()));
126 suggestions.emplace_back(std::move(suggestion)); 127 suggestions.emplace_back(std::move(suggestion));
127 if (suggestions.size() == kMaxSuggestionsCount) 128 if (suggestions.size() == kMaxSuggestionsCount)
128 break; 129 break;
129 } 130 }
130 131
131 observer_->OnNewSuggestions(provided_category_, std::move(suggestions)); 132 observer_->OnNewSuggestions(provided_category_, std::move(suggestions));
132 } 133 }
133 134
134 void OfflinePageSuggestionsProvider::NotifyStatusChanged( 135 void OfflinePageSuggestionsProvider::NotifyStatusChanged(
135 CategoryStatus new_status) { 136 CategoryStatus new_status) {
136 if (category_status_ == new_status) 137 if (category_status_ == new_status)
137 return; 138 return;
138 category_status_ = new_status; 139 category_status_ = new_status;
139 140
140 if (!observer_) 141 if (!observer_)
141 return; 142 return;
142 observer_->OnCategoryStatusChanged(provided_category_, new_status); 143 observer_->OnCategoryStatusChanged(provided_category_, new_status);
143 } 144 }
144 145
145 } // namespace ntp_snippets 146 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/ntp_snippets_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698