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/content_suggestions_service.h" | 5 #include "components/ntp_snippets/content_suggestions_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <set> | 9 #include <set> |
| 10 #include <utility> |
10 | 11 |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/location.h" | 13 #include "base/location.h" |
13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
15 #include "ui/gfx/image/image.h" | 16 #include "ui/gfx/image/image.h" |
16 | 17 |
17 namespace ntp_snippets { | 18 namespace ntp_snippets { |
18 | 19 |
19 ContentSuggestionsService::ContentSuggestionsService( | 20 ContentSuggestionsService::ContentSuggestionsService( |
20 State state, | 21 State state, |
21 history::HistoryService* history_service) | 22 history::HistoryService* history_service, |
22 : state_(state), history_service_observer_(this) { | 23 PrefService* pref_service) |
| 24 : state_(state), |
| 25 history_service_observer_(this), |
| 26 user_classifier_(pref_service) { |
23 // Can be null in tests. | 27 // Can be null in tests. |
24 if (history_service) | 28 if (history_service) |
25 history_service_observer_.Add(history_service); | 29 history_service_observer_.Add(history_service); |
26 } | 30 } |
27 | 31 |
28 ContentSuggestionsService::~ContentSuggestionsService() {} | 32 ContentSuggestionsService::~ContentSuggestionsService() {} |
29 | 33 |
30 void ContentSuggestionsService::Shutdown() { | 34 void ContentSuggestionsService::Shutdown() { |
31 ntp_snippets_service_ = nullptr; | 35 ntp_snippets_service_ = nullptr; |
32 id_category_map_.clear(); | 36 id_category_map_.clear(); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 if (left.IsKnownCategory(KnownCategories::BOOKMARKS)) | 349 if (left.IsKnownCategory(KnownCategories::BOOKMARKS)) |
346 return false; | 350 return false; |
347 if (right.IsKnownCategory(KnownCategories::BOOKMARKS)) | 351 if (right.IsKnownCategory(KnownCategories::BOOKMARKS)) |
348 return true; | 352 return true; |
349 } | 353 } |
350 return category_factory_.CompareCategories(left, right); | 354 return category_factory_.CompareCategories(left, right); |
351 }); | 355 }); |
352 } | 356 } |
353 | 357 |
354 } // namespace ntp_snippets | 358 } // namespace ntp_snippets |
OLD | NEW |