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

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

Issue 2558743003: Add generic functions for getting typed variation parameter values (Closed)
Patch Set: Alexei's comments Created 4 years 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 "bookmarks_consider_desktop_visits"; 42 "bookmarks_consider_desktop_visits";
43 43
44 // TODO(treib,jkrcal): Remove this after M57. 44 // TODO(treib,jkrcal): Remove this after M57.
45 const char kDeprecatedBookmarksFirstM54StartPref[] = 45 const char kDeprecatedBookmarksFirstM54StartPref[] =
46 "ntp_suggestions.bookmarks.first_M54_start"; 46 "ntp_suggestions.bookmarks.first_M54_start";
47 47
48 // Any bookmark created or visited after this time will be considered recent. 48 // Any bookmark created or visited after this time will be considered recent.
49 // Note that bookmarks can be shown that do not meet this threshold. 49 // Note that bookmarks can be shown that do not meet this threshold.
50 base::Time GetThresholdTime() { 50 base::Time GetThresholdTime() {
51 return base::Time::Now() - 51 return base::Time::Now() -
52 base::TimeDelta::FromDays(GetParamAsInt( 52 base::TimeDelta::FromDays(variations::GetVariationParamByFeatureAsInt(
53 ntp_snippets::kBookmarkSuggestionsFeature, 53 ntp_snippets::kBookmarkSuggestionsFeature,
54 kMaxBookmarkAgeInDaysParamName, kMaxBookmarkAgeInDays)); 54 kMaxBookmarkAgeInDaysParamName, kMaxBookmarkAgeInDays));
55 } 55 }
56 56
57 // The maximum number of suggestions ever provided. 57 // The maximum number of suggestions ever provided.
58 int GetMaxCount() { 58 int GetMaxCount() {
59 return GetParamAsInt(ntp_snippets::kBookmarkSuggestionsFeature, 59 return variations::GetVariationParamByFeatureAsInt(
60 kMaxBookmarksParamName, kMaxBookmarks); 60 ntp_snippets::kBookmarkSuggestionsFeature, kMaxBookmarksParamName,
61 kMaxBookmarks);
61 } 62 }
62 63
63 bool AreDesktopVisitsConsidered() { 64 bool AreDesktopVisitsConsidered() {
64 return GetParamAsBool(ntp_snippets::kBookmarkSuggestionsFeature, 65 return variations::GetVariationParamByFeatureAsBool(
65 kConsiderDesktopVisitsParamName, false); 66 ntp_snippets::kBookmarkSuggestionsFeature,
67 kConsiderDesktopVisitsParamName, false);
66 } 68 }
67 69
68 } // namespace 70 } // namespace
69 71
70 BookmarkSuggestionsProvider::BookmarkSuggestionsProvider( 72 BookmarkSuggestionsProvider::BookmarkSuggestionsProvider(
71 ContentSuggestionsProvider::Observer* observer, 73 ContentSuggestionsProvider::Observer* observer,
72 CategoryFactory* category_factory, 74 CategoryFactory* category_factory,
73 bookmarks::BookmarkModel* bookmark_model, 75 bookmarks::BookmarkModel* bookmark_model,
74 PrefService* pref_service) 76 PrefService* pref_service)
75 : ContentSuggestionsProvider(observer, category_factory), 77 : ContentSuggestionsProvider(observer, category_factory),
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 void BookmarkSuggestionsProvider::NotifyStatusChanged( 325 void BookmarkSuggestionsProvider::NotifyStatusChanged(
324 CategoryStatus new_status) { 326 CategoryStatus new_status) {
325 if (category_status_ == new_status) { 327 if (category_status_ == new_status) {
326 return; 328 return;
327 } 329 }
328 category_status_ = new_status; 330 category_status_ = new_status;
329 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); 331 observer()->OnCategoryStatusChanged(this, provided_category_, new_status);
330 } 332 }
331 333
332 } // namespace ntp_snippets 334 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « chrome/browser/ntp_snippets/download_suggestions_provider.cc ('k') | components/ntp_snippets/features.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698