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

Side by Side Diff: components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider.cc

Issue 2368583002: [NTP Snippets] Cleanups from clang-tidy (Closed)
Patch Set: rebase 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
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/physical_web_pages/physical_web_page_suggestio ns_provider.h" 5 #include "components/ntp_snippets/physical_web_pages/physical_web_page_suggestio ns_provider.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/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "ui/gfx/image/image.h" 12 #include "ui/gfx/image/image.h"
13 13
14 namespace ntp_snippets { 14 namespace ntp_snippets {
15 15
16 namespace { 16 namespace {
17 17
18 const size_t kMaxSuggestionsCount = 10; 18 const size_t kMaxSuggestionsCount = 10;
19 19
20 } // namespace 20 } // namespace
21 21
22 // TODO(vitaliii): remove when Physical Web C++ interface is provided. 22 // TODO(vitaliii): remove when Physical Web C++ interface is provided.
23 UrlInfo::UrlInfo() {} 23 UrlInfo::UrlInfo() = default;
24 UrlInfo::~UrlInfo() {} 24 UrlInfo::~UrlInfo() = default;
25 UrlInfo::UrlInfo(const UrlInfo& other) = default; 25 UrlInfo::UrlInfo(const UrlInfo& other) = default;
26 26
27 PhysicalWebPageSuggestionsProvider::PhysicalWebPageSuggestionsProvider( 27 PhysicalWebPageSuggestionsProvider::PhysicalWebPageSuggestionsProvider(
28 ContentSuggestionsProvider::Observer* observer, 28 ContentSuggestionsProvider::Observer* observer,
29 CategoryFactory* category_factory) 29 CategoryFactory* category_factory)
30 : ContentSuggestionsProvider(observer, category_factory), 30 : ContentSuggestionsProvider(observer, category_factory),
31 category_status_(CategoryStatus::AVAILABLE_LOADING), 31 category_status_(CategoryStatus::AVAILABLE_LOADING),
32 provided_category_(category_factory->FromKnownCategory( 32 provided_category_(category_factory->FromKnownCategory(
33 KnownCategories::PHYSICAL_WEB_PAGES)) { 33 KnownCategories::PHYSICAL_WEB_PAGES)) {
34 observer->OnCategoryStatusChanged(this, provided_category_, category_status_); 34 observer->OnCategoryStatusChanged(this, provided_category_, category_status_);
35 } 35 }
36 36
37 PhysicalWebPageSuggestionsProvider::~PhysicalWebPageSuggestionsProvider() {} 37 PhysicalWebPageSuggestionsProvider::~PhysicalWebPageSuggestionsProvider() =
38 default;
38 39
39 void PhysicalWebPageSuggestionsProvider::OnDisplayableUrlsChanged( 40 void PhysicalWebPageSuggestionsProvider::OnDisplayableUrlsChanged(
40 const std::vector<UrlInfo>& urls) { 41 const std::vector<UrlInfo>& urls) {
41 NotifyStatusChanged(CategoryStatus::AVAILABLE); 42 NotifyStatusChanged(CategoryStatus::AVAILABLE);
42 std::vector<ContentSuggestion> suggestions; 43 std::vector<ContentSuggestion> suggestions;
43 44
44 for (const UrlInfo& url_info : urls) { 45 for (const UrlInfo& url_info : urls) {
45 if (suggestions.size() >= kMaxSuggestionsCount) break; 46 if (suggestions.size() >= kMaxSuggestionsCount) break;
46 47
47 ContentSuggestion suggestion( 48 ContentSuggestion suggestion(
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 116
116 // Updates the |category_status_| and notifies the |observer_|, if necessary. 117 // Updates the |category_status_| and notifies the |observer_|, if necessary.
117 void PhysicalWebPageSuggestionsProvider::NotifyStatusChanged( 118 void PhysicalWebPageSuggestionsProvider::NotifyStatusChanged(
118 CategoryStatus new_status) { 119 CategoryStatus new_status) {
119 if (category_status_ == new_status) return; 120 if (category_status_ == new_status) return;
120 category_status_ = new_status; 121 category_status_ = new_status;
121 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); 122 observer()->OnCategoryStatusChanged(this, provided_category_, new_status);
122 } 123 }
123 124
124 } // namespace ntp_snippets 125 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/offline_pages/offline_page_proxy.cc ('k') | components/ntp_snippets/request_throttler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698