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

Side by Side Diff: components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc

Issue 2260703004: Remove ContentSuggestionsProvider::GetProvidedCategories(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Philipp's comments and rebase. 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 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/bookmarks/bookmark_suggestions_provider.h" 5 #include "components/ntp_snippets/bookmarks/bookmark_suggestions_provider.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 CategoryFactory* category_factory, 85 CategoryFactory* category_factory,
86 bookmarks::BookmarkModel* bookmark_model, 86 bookmarks::BookmarkModel* bookmark_model,
87 PrefService* pref_service) 87 PrefService* pref_service)
88 : ContentSuggestionsProvider(observer, category_factory), 88 : ContentSuggestionsProvider(observer, category_factory),
89 category_status_(CategoryStatus::AVAILABLE_LOADING), 89 category_status_(CategoryStatus::AVAILABLE_LOADING),
90 provided_category_( 90 provided_category_(
91 category_factory->FromKnownCategory(KnownCategories::BOOKMARKS)), 91 category_factory->FromKnownCategory(KnownCategories::BOOKMARKS)),
92 bookmark_model_(bookmark_model), 92 bookmark_model_(bookmark_model),
93 fetch_requested_(false), 93 fetch_requested_(false),
94 end_of_list_last_visit_date_(GetThresholdTime()) { 94 end_of_list_last_visit_date_(GetThresholdTime()) {
95 observer->OnCategoryStatusChanged(this, provided_category_, category_status_);
95 base::Time first_m54_start; 96 base::Time first_m54_start;
96 base::Time now = base::Time::Now(); 97 base::Time now = base::Time::Now();
97 if (pref_service->HasPrefPath(prefs::kBookmarksFirstM54Start)) { 98 if (pref_service->HasPrefPath(prefs::kBookmarksFirstM54Start)) {
98 first_m54_start = base::Time::FromInternalValue( 99 first_m54_start = base::Time::FromInternalValue(
99 pref_service->GetInt64(prefs::kBookmarksFirstM54Start)); 100 pref_service->GetInt64(prefs::kBookmarksFirstM54Start));
100 } else { 101 } else {
101 first_m54_start = now; 102 first_m54_start = now;
102 pref_service->SetInt64(prefs::kBookmarksFirstM54Start, 103 pref_service->SetInt64(prefs::kBookmarksFirstM54Start,
103 first_m54_start.ToInternalValue()); 104 first_m54_start.ToInternalValue());
104 } 105 }
(...skipping 10 matching lines...) Expand all
115 116
116 // static 117 // static
117 void BookmarkSuggestionsProvider::RegisterProfilePrefs( 118 void BookmarkSuggestionsProvider::RegisterProfilePrefs(
118 PrefRegistrySimple* registry) { 119 PrefRegistrySimple* registry) {
119 registry->RegisterInt64Pref(prefs::kBookmarksFirstM54Start, 0); 120 registry->RegisterInt64Pref(prefs::kBookmarksFirstM54Start, 0);
120 } 121 }
121 122
122 //////////////////////////////////////////////////////////////////////////////// 123 ////////////////////////////////////////////////////////////////////////////////
123 // Private methods 124 // Private methods
124 125
125 std::vector<Category> BookmarkSuggestionsProvider::GetProvidedCategories() {
126 return std::vector<Category>({provided_category_});
127 }
128
129 CategoryStatus BookmarkSuggestionsProvider::GetCategoryStatus( 126 CategoryStatus BookmarkSuggestionsProvider::GetCategoryStatus(
130 Category category) { 127 Category category) {
131 DCHECK_EQ(category, provided_category_); 128 DCHECK_EQ(category, provided_category_);
132 return category_status_; 129 return category_status_;
133 } 130 }
134 131
135 CategoryInfo BookmarkSuggestionsProvider::GetCategoryInfo(Category category) { 132 CategoryInfo BookmarkSuggestionsProvider::GetCategoryInfo(Category category) {
136 return CategoryInfo( 133 return CategoryInfo(
137 l10n_util::GetStringUTF16(IDS_NTP_BOOKMARK_SUGGESTIONS_SECTION_HEADER), 134 l10n_util::GetStringUTF16(IDS_NTP_BOOKMARK_SUGGESTIONS_SECTION_HEADER),
138 ContentSuggestionsCardLayout::MINIMAL_CARD, 135 ContentSuggestionsCardLayout::MINIMAL_CARD,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 271
275 void BookmarkSuggestionsProvider::NotifyStatusChanged( 272 void BookmarkSuggestionsProvider::NotifyStatusChanged(
276 CategoryStatus new_status) { 273 CategoryStatus new_status) {
277 if (category_status_ == new_status) 274 if (category_status_ == new_status)
278 return; 275 return;
279 category_status_ = new_status; 276 category_status_ = new_status;
280 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); 277 observer()->OnCategoryStatusChanged(this, provided_category_, new_status);
281 } 278 }
282 279
283 } // namespace ntp_snippets 280 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698