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

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

Issue 2393353005: [NTP Snippets] Overwrite the title of the ARTICLES if provided by the server (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | components/ntp_snippets/remote/ntp_snippets_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/remote/ntp_snippets_service.h" 5 #include "components/ntp_snippets/remote/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
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 513
514 // If snippets were fetched successfully, update our |categories_| from each 514 // If snippets were fetched successfully, update our |categories_| from each
515 // category provided by the server. 515 // category provided by the server.
516 if (fetched_categories) { 516 if (fetched_categories) {
517 // TODO(jkrcal): A bit hard to understand with so many variables called 517 // TODO(jkrcal): A bit hard to understand with so many variables called
518 // "*categor*". Isn't here some room for simplification? 518 // "*categor*". Isn't here some room for simplification?
519 for (NTPSnippetsFetcher::FetchedCategory& fetched_category : 519 for (NTPSnippetsFetcher::FetchedCategory& fetched_category :
520 *fetched_categories) { 520 *fetched_categories) {
521 Category category = fetched_category.category; 521 Category category = fetched_category.category;
522 522
523 // The ChromeReader backend doesn't provide category titles, so don't
524 // overwrite the existing title for ARTICLES if the new one is empty.
525 // TODO(treib): Remove this check after we fully switch to the content
526 // suggestions backend.
523 // TODO(sfiera): Avoid hard-coding articles category checks in so many 527 // TODO(sfiera): Avoid hard-coding articles category checks in so many
524 // places. 528 // places.
525 if (category != articles_category_) { 529 if (category != articles_category_ ||
526 // Only update titles from server-side provided categories. 530 !fetched_category.localized_title.empty()) {
527 categories_[category].localized_title = 531 categories_[category].localized_title =
528 fetched_category.localized_title; 532 fetched_category.localized_title;
529 } 533 }
530 categories_[category].provided_by_server = true; 534 categories_[category].provided_by_server = true;
531 535
532 // TODO(tschumann): Remove this histogram once we only talk to the content 536 // TODO(tschumann): Remove this histogram once we only talk to the content
533 // suggestions cloud backend. 537 // suggestions cloud backend.
534 if (category == articles_category_) { 538 if (category == articles_category_) {
535 UMA_HISTOGRAM_SPARSE_SLOWLY( 539 UMA_HISTOGRAM_SPARSE_SLOWLY(
536 "NewTabPage.Snippets.NumArticlesFetched", 540 "NewTabPage.Snippets.NumArticlesFetched",
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 } 1008 }
1005 1009
1006 NTPSnippetsService::CategoryContent::CategoryContent() = default; 1010 NTPSnippetsService::CategoryContent::CategoryContent() = default;
1007 NTPSnippetsService::CategoryContent::CategoryContent(CategoryContent&&) = 1011 NTPSnippetsService::CategoryContent::CategoryContent(CategoryContent&&) =
1008 default; 1012 default;
1009 NTPSnippetsService::CategoryContent::~CategoryContent() = default; 1013 NTPSnippetsService::CategoryContent::~CategoryContent() = default;
1010 NTPSnippetsService::CategoryContent& NTPSnippetsService::CategoryContent:: 1014 NTPSnippetsService::CategoryContent& NTPSnippetsService::CategoryContent::
1011 operator=(CategoryContent&&) = default; 1015 operator=(CategoryContent&&) = default;
1012 1016
1013 } // namespace ntp_snippets 1017 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « no previous file | components/ntp_snippets/remote/ntp_snippets_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698