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/offline_pages/recent_tab_suggestions_provider.
h" | 5 #include "components/ntp_snippets/offline_pages/recent_tab_suggestions_provider.
h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.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 "components/ntp_snippets/features.h" | 15 #include "components/ntp_snippets/features.h" |
16 #include "components/ntp_snippets/pref_names.h" | 16 #include "components/ntp_snippets/pref_names.h" |
17 #include "components/ntp_snippets/pref_util.h" | 17 #include "components/ntp_snippets/pref_util.h" |
18 #include "components/offline_pages/core/client_policy_controller.h" | 18 #include "components/offline_pages/core/client_policy_controller.h" |
19 #include "components/offline_pages/core/offline_page_item.h" | 19 #include "components/offline_pages/core/offline_page_item.h" |
20 #include "components/offline_pages/core/offline_page_model_query.h" | 20 #include "components/offline_pages/core/offline_page_model_query.h" |
21 #include "components/prefs/pref_registry_simple.h" | 21 #include "components/prefs/pref_registry_simple.h" |
22 #include "components/prefs/pref_service.h" | 22 #include "components/prefs/pref_service.h" |
| 23 #include "components/variations/variations_associated_data.h" |
23 #include "grit/components_strings.h" | 24 #include "grit/components_strings.h" |
24 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
25 #include "ui/gfx/image/image.h" | 26 #include "ui/gfx/image/image.h" |
26 | 27 |
27 using offline_pages::ClientId; | 28 using offline_pages::ClientId; |
28 using offline_pages::OfflinePageItem; | 29 using offline_pages::OfflinePageItem; |
29 using offline_pages::OfflinePageModelQuery; | 30 using offline_pages::OfflinePageModelQuery; |
30 using offline_pages::OfflinePageModelQueryBuilder; | 31 using offline_pages::OfflinePageModelQueryBuilder; |
31 | 32 |
32 namespace ntp_snippets { | 33 namespace ntp_snippets { |
33 | 34 |
34 namespace { | 35 namespace { |
35 | 36 |
36 const int kDefaultMaxSuggestionsCount = 5; | 37 const int kDefaultMaxSuggestionsCount = 5; |
37 | 38 |
38 const char* kMaxSuggestionsCountParamName = "recent_tabs_max_count"; | 39 const char* kMaxSuggestionsCountParamName = "recent_tabs_max_count"; |
39 | 40 |
40 int GetMaxSuggestionsCount() { | 41 int GetMaxSuggestionsCount() { |
41 return GetParamAsInt(kRecentOfflineTabSuggestionsFeature, | 42 return variations::GetVariationParamByFeatureAsInt( |
42 kMaxSuggestionsCountParamName, | 43 kRecentOfflineTabSuggestionsFeature, kMaxSuggestionsCountParamName, |
43 kDefaultMaxSuggestionsCount); | 44 kDefaultMaxSuggestionsCount); |
44 } | 45 } |
45 | 46 |
46 struct OrderOfflinePagesByMostRecentlyCreatedFirst { | 47 struct OrderOfflinePagesByMostRecentlyCreatedFirst { |
47 bool operator()(const OfflinePageItem* left, | 48 bool operator()(const OfflinePageItem* left, |
48 const OfflinePageItem* right) const { | 49 const OfflinePageItem* right) const { |
49 return left->creation_time > right->creation_time; | 50 return left->creation_time > right->creation_time; |
50 } | 51 } |
51 }; | 52 }; |
52 | 53 |
53 struct OrderOfflinePagesByUrlAndThenMostRecentlyCreatedFirst { | 54 struct OrderOfflinePagesByUrlAndThenMostRecentlyCreatedFirst { |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 } | 338 } |
338 | 339 |
339 void RecentTabSuggestionsProvider::StoreDismissedIDsToPrefs( | 340 void RecentTabSuggestionsProvider::StoreDismissedIDsToPrefs( |
340 const std::set<std::string>& dismissed_ids) { | 341 const std::set<std::string>& dismissed_ids) { |
341 prefs::StoreDismissedIDsToPrefs(pref_service_, | 342 prefs::StoreDismissedIDsToPrefs(pref_service_, |
342 prefs::kDismissedRecentOfflineTabSuggestions, | 343 prefs::kDismissedRecentOfflineTabSuggestions, |
343 dismissed_ids); | 344 dismissed_ids); |
344 } | 345 } |
345 | 346 |
346 } // namespace ntp_snippets | 347 } // namespace ntp_snippets |
OLD | NEW |