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

Side by Side Diff: components/ntp_snippets/remote/json_request.cc

Issue 2751093003: Unifies the additional actions for Categories (Closed)
Patch Set: Fix compilation on Android (hopefully) Created 3 years, 9 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 "components/ntp_snippets/remote/json_request.h" 5 #include "components/ntp_snippets/remote/json_request.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return "ACTIVE_NTP_USER"; 125 return "ACTIVE_NTP_USER";
126 case UserClassifier::UserClass::ACTIVE_SUGGESTIONS_CONSUMER: 126 case UserClassifier::UserClass::ACTIVE_SUGGESTIONS_CONSUMER:
127 return "ACTIVE_SUGGESTIONS_CONSUMER"; 127 return "ACTIVE_SUGGESTIONS_CONSUMER";
128 } 128 }
129 NOTREACHED(); 129 NOTREACHED();
130 return std::string(); 130 return std::string();
131 } 131 }
132 132
133 } // namespace 133 } // namespace
134 134
135 CategoryInfo BuildArticleCategoryInfo(
136 const base::Optional<base::string16>& title) {
137 return CategoryInfo(
138 title.has_value() ? title.value()
139 : l10n_util::GetStringUTF16(
140 IDS_NTP_ARTICLE_SUGGESTIONS_SECTION_HEADER),
141 ContentSuggestionsCardLayout::FULL_CARD,
142 /*has_fetch_action=*/true,
143 /*has_view_all_action=*/false,
144 /*show_if_empty=*/true,
145 l10n_util::GetStringUTF16(IDS_NTP_ARTICLE_SUGGESTIONS_SECTION_EMPTY));
146 }
147
148 CategoryInfo BuildRemoteCategoryInfo(const base::string16& title,
149 bool allow_fetching_more_results) {
150 return CategoryInfo(
151 title, ContentSuggestionsCardLayout::FULL_CARD,
152 /*has_fetch_action=*/allow_fetching_more_results,
153 /*has_view_all_action=*/false,
154 /*show_if_empty=*/false,
155 // TODO(tschumann): The message for no-articles is likely wrong
156 // and needs to be added to the stubby protocol if we want to
157 // support it.
158 l10n_util::GetStringUTF16(IDS_NTP_ARTICLE_SUGGESTIONS_SECTION_EMPTY));
159 }
160
161 JsonRequest::JsonRequest( 135 JsonRequest::JsonRequest(
162 base::Optional<Category> exclusive_category, 136 base::Optional<Category> exclusive_category,
163 base::Clock* clock, // Needed until destruction of the request. 137 base::Clock* clock, // Needed until destruction of the request.
164 const ParseJSONCallback& callback) 138 const ParseJSONCallback& callback)
165 : exclusive_category_(exclusive_category), 139 : exclusive_category_(exclusive_category),
166 clock_(clock), 140 clock_(clock),
167 parse_json_callback_(callback), 141 parse_json_callback_(callback),
168 weak_ptr_factory_(this) { 142 weak_ptr_factory_(this) {
169 creation_time_ = clock_->Now(); 143 creation_time_ = clock_->Now();
170 } 144 }
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 "NewTabPage.Languages.UILanguageRatioInTwoTopLanguages", 486 "NewTabPage.Languages.UILanguageRatioInTwoTopLanguages",
513 ratio_ui_in_both_languages * 100); 487 ratio_ui_in_both_languages * 100);
514 break; 488 break;
515 } 489 }
516 } 490 }
517 } 491 }
518 492
519 } // namespace internal 493 } // namespace internal
520 494
521 } // namespace ntp_snippets 495 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698