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" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "components/bookmarks/browser/bookmark_model.h" | 16 #include "components/bookmarks/browser/bookmark_model.h" |
17 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" | 17 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" |
18 #include "components/ntp_snippets/category_factory.h" | 18 #include "components/ntp_snippets/category.h" |
19 #include "components/ntp_snippets/content_suggestion.h" | 19 #include "components/ntp_snippets/content_suggestion.h" |
20 #include "components/ntp_snippets/features.h" | 20 #include "components/ntp_snippets/features.h" |
21 #include "components/ntp_snippets/pref_names.h" | 21 #include "components/ntp_snippets/pref_names.h" |
22 #include "components/prefs/pref_registry_simple.h" | 22 #include "components/prefs/pref_registry_simple.h" |
23 #include "components/prefs/pref_service.h" | 23 #include "components/prefs/pref_service.h" |
24 #include "components/variations/variations_associated_data.h" | 24 #include "components/variations/variations_associated_data.h" |
25 #include "grit/components_strings.h" | 25 #include "grit/components_strings.h" |
26 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
27 #include "ui/gfx/image/image.h" | 27 #include "ui/gfx/image/image.h" |
28 | 28 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 bool AreDesktopVisitsConsidered() { | 64 bool AreDesktopVisitsConsidered() { |
65 return variations::GetVariationParamByFeatureAsBool( | 65 return variations::GetVariationParamByFeatureAsBool( |
66 ntp_snippets::kBookmarkSuggestionsFeature, | 66 ntp_snippets::kBookmarkSuggestionsFeature, |
67 kConsiderDesktopVisitsParamName, false); | 67 kConsiderDesktopVisitsParamName, false); |
68 } | 68 } |
69 | 69 |
70 } // namespace | 70 } // namespace |
71 | 71 |
72 BookmarkSuggestionsProvider::BookmarkSuggestionsProvider( | 72 BookmarkSuggestionsProvider::BookmarkSuggestionsProvider( |
73 ContentSuggestionsProvider::Observer* observer, | 73 ContentSuggestionsProvider::Observer* observer, |
74 CategoryFactory* category_factory, | |
75 bookmarks::BookmarkModel* bookmark_model, | 74 bookmarks::BookmarkModel* bookmark_model, |
76 PrefService* pref_service) | 75 PrefService* pref_service) |
77 : ContentSuggestionsProvider(observer, category_factory), | 76 : ContentSuggestionsProvider(observer), |
78 category_status_(CategoryStatus::AVAILABLE_LOADING), | 77 category_status_(CategoryStatus::AVAILABLE_LOADING), |
79 provided_category_( | 78 provided_category_( |
80 category_factory->FromKnownCategory(KnownCategories::BOOKMARKS)), | 79 Category::FromKnownCategory(KnownCategories::BOOKMARKS)), |
81 bookmark_model_(bookmark_model), | 80 bookmark_model_(bookmark_model), |
82 fetch_requested_(false), | 81 fetch_requested_(false), |
83 end_of_list_last_visit_date_(GetThresholdTime()), | 82 end_of_list_last_visit_date_(GetThresholdTime()), |
84 consider_bookmark_visits_from_desktop_(AreDesktopVisitsConsidered()) { | 83 consider_bookmark_visits_from_desktop_(AreDesktopVisitsConsidered()) { |
85 observer->OnCategoryStatusChanged(this, provided_category_, category_status_); | 84 observer->OnCategoryStatusChanged(this, provided_category_, category_status_); |
86 pref_service->ClearPref(kDeprecatedBookmarksFirstM54StartPref); | 85 pref_service->ClearPref(kDeprecatedBookmarksFirstM54StartPref); |
87 bookmark_model_->AddObserver(this); | 86 bookmark_model_->AddObserver(this); |
88 FetchBookmarks(); | 87 FetchBookmarks(); |
89 } | 88 } |
90 | 89 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 void BookmarkSuggestionsProvider::NotifyStatusChanged( | 323 void BookmarkSuggestionsProvider::NotifyStatusChanged( |
325 CategoryStatus new_status) { | 324 CategoryStatus new_status) { |
326 if (category_status_ == new_status) { | 325 if (category_status_ == new_status) { |
327 return; | 326 return; |
328 } | 327 } |
329 category_status_ = new_status; | 328 category_status_ = new_status; |
330 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); | 329 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); |
331 } | 330 } |
332 | 331 |
333 } // namespace ntp_snippets | 332 } // namespace ntp_snippets |
OLD | NEW |