OLD | NEW |
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 ContentSuggestionsProvider::Observer* observer, | 73 ContentSuggestionsProvider::Observer* observer, |
74 CategoryFactory* category_factory, | 74 CategoryFactory* category_factory, |
75 bookmarks::BookmarkModel* bookmark_model) | 75 bookmarks::BookmarkModel* bookmark_model) |
76 : ContentSuggestionsProvider(observer, category_factory), | 76 : ContentSuggestionsProvider(observer, category_factory), |
77 category_status_(CategoryStatus::AVAILABLE_LOADING), | 77 category_status_(CategoryStatus::AVAILABLE_LOADING), |
78 provided_category_( | 78 provided_category_( |
79 category_factory->FromKnownCategory(KnownCategories::BOOKMARKS)), | 79 category_factory->FromKnownCategory(KnownCategories::BOOKMARKS)), |
80 bookmark_model_(bookmark_model), | 80 bookmark_model_(bookmark_model), |
81 fetch_requested_(false), | 81 fetch_requested_(false), |
82 end_of_list_last_visit_date_(GetThresholdTime()) { | 82 end_of_list_last_visit_date_(GetThresholdTime()) { |
| 83 observer->OnCategoryStatusChanged(this, provided_category_, category_status_); |
83 bookmark_model_->AddObserver(this); | 84 bookmark_model_->AddObserver(this); |
84 FetchBookmarks(); | 85 FetchBookmarks(); |
85 } | 86 } |
86 | 87 |
87 BookmarkSuggestionsProvider::~BookmarkSuggestionsProvider() { | 88 BookmarkSuggestionsProvider::~BookmarkSuggestionsProvider() { |
88 bookmark_model_->RemoveObserver(this); | 89 bookmark_model_->RemoveObserver(this); |
89 } | 90 } |
90 | 91 |
91 //////////////////////////////////////////////////////////////////////////////// | 92 //////////////////////////////////////////////////////////////////////////////// |
92 // Private methods | 93 // Private methods |
93 | 94 |
94 std::vector<Category> BookmarkSuggestionsProvider::GetProvidedCategories() { | |
95 return std::vector<Category>({provided_category_}); | |
96 } | |
97 | |
98 CategoryStatus BookmarkSuggestionsProvider::GetCategoryStatus( | 95 CategoryStatus BookmarkSuggestionsProvider::GetCategoryStatus( |
99 Category category) { | 96 Category category) { |
100 DCHECK_EQ(category, provided_category_); | 97 DCHECK_EQ(category, provided_category_); |
101 return category_status_; | 98 return category_status_; |
102 } | 99 } |
103 | 100 |
104 CategoryInfo BookmarkSuggestionsProvider::GetCategoryInfo(Category category) { | 101 CategoryInfo BookmarkSuggestionsProvider::GetCategoryInfo(Category category) { |
105 return CategoryInfo( | 102 return CategoryInfo( |
106 l10n_util::GetStringUTF16(IDS_NTP_BOOKMARK_SUGGESTIONS_SECTION_HEADER), | 103 l10n_util::GetStringUTF16(IDS_NTP_BOOKMARK_SUGGESTIONS_SECTION_HEADER), |
107 ContentSuggestionsCardLayout::MINIMAL_CARD, /* has_more_button */ true); | 104 ContentSuggestionsCardLayout::MINIMAL_CARD, /* has_more_button */ true); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 235 |
239 void BookmarkSuggestionsProvider::NotifyStatusChanged( | 236 void BookmarkSuggestionsProvider::NotifyStatusChanged( |
240 CategoryStatus new_status) { | 237 CategoryStatus new_status) { |
241 if (category_status_ == new_status) | 238 if (category_status_ == new_status) |
242 return; | 239 return; |
243 category_status_ = new_status; | 240 category_status_ = new_status; |
244 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); | 241 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); |
245 } | 242 } |
246 | 243 |
247 } // namespace ntp_snippets | 244 } // namespace ntp_snippets |
OLD | NEW |