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

Side by Side Diff: components/ntp_snippets/offline_pages/offline_page_suggestions_provider.cc

Issue 2260703004: Remove ContentSuggestionsProvider::GetProvidedCategories(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months 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/offline_pages/offline_page_suggestions_provide r.h" 5 #include "components/ntp_snippets/offline_pages/offline_page_suggestions_provide r.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/guid.h" 10 #include "base/guid.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 downloads_status_(downloads_enabled ? CategoryStatus::AVAILABLE_LOADING 55 downloads_status_(downloads_enabled ? CategoryStatus::AVAILABLE_LOADING
56 : CategoryStatus::NOT_PROVIDED), 56 : CategoryStatus::NOT_PROVIDED),
57 offline_page_model_(offline_page_model), 57 offline_page_model_(offline_page_model),
58 recent_tabs_category_( 58 recent_tabs_category_(
59 category_factory->FromKnownCategory(KnownCategories::RECENT_TABS)), 59 category_factory->FromKnownCategory(KnownCategories::RECENT_TABS)),
60 downloads_category_( 60 downloads_category_(
61 category_factory->FromKnownCategory(KnownCategories::DOWNLOADS)), 61 category_factory->FromKnownCategory(KnownCategories::DOWNLOADS)),
62 pref_service_(pref_service), 62 pref_service_(pref_service),
63 download_manager_ui_enabled_(download_manager_ui_enabled) { 63 download_manager_ui_enabled_(download_manager_ui_enabled) {
64 DCHECK(recent_tabs_enabled || downloads_enabled); 64 DCHECK(recent_tabs_enabled || downloads_enabled);
65 if (recent_tabs_enabled) {
66 observer->OnCategoryStatusChanged(this, recent_tabs_category_,
67 recent_tabs_status_);
68 }
69 if (downloads_enabled) {
70 observer->OnCategoryStatusChanged(this, downloads_category_,
71 downloads_status_);
72 }
65 offline_page_model_->AddObserver(this); 73 offline_page_model_->AddObserver(this);
66 FetchOfflinePages(); 74 FetchOfflinePages();
67 } 75 }
68 76
69 OfflinePageSuggestionsProvider::~OfflinePageSuggestionsProvider() { 77 OfflinePageSuggestionsProvider::~OfflinePageSuggestionsProvider() {
70 offline_page_model_->RemoveObserver(this); 78 offline_page_model_->RemoveObserver(this);
71 } 79 }
72 80
73 // static 81 // static
74 void OfflinePageSuggestionsProvider::RegisterProfilePrefs( 82 void OfflinePageSuggestionsProvider::RegisterProfilePrefs(
75 PrefRegistrySimple* registry) { 83 PrefRegistrySimple* registry) {
76 registry->RegisterListPref(prefs::kDismissedRecentOfflineTabSuggestions); 84 registry->RegisterListPref(prefs::kDismissedRecentOfflineTabSuggestions);
77 registry->RegisterListPref(prefs::kDismissedDownloadSuggestions); 85 registry->RegisterListPref(prefs::kDismissedDownloadSuggestions);
78 } 86 }
79 87
80 //////////////////////////////////////////////////////////////////////////////// 88 ////////////////////////////////////////////////////////////////////////////////
81 // Private methods 89 // Private methods
82 90
83 std::vector<Category> OfflinePageSuggestionsProvider::GetProvidedCategories() {
84 std::vector<Category> provided_categories;
85 if (recent_tabs_status_ != CategoryStatus::NOT_PROVIDED)
86 provided_categories.push_back(recent_tabs_category_);
87 if (downloads_status_ != CategoryStatus::NOT_PROVIDED)
88 provided_categories.push_back(downloads_category_);
89 return provided_categories;
90 }
91
92 CategoryStatus OfflinePageSuggestionsProvider::GetCategoryStatus( 91 CategoryStatus OfflinePageSuggestionsProvider::GetCategoryStatus(
93 Category category) { 92 Category category) {
94 if (category == recent_tabs_category_) 93 if (category == recent_tabs_category_)
95 return recent_tabs_status_; 94 return recent_tabs_status_;
96 if (category == downloads_category_) 95 if (category == downloads_category_)
97 return downloads_status_; 96 return downloads_status_;
98 NOTREACHED() << "Unknown category " << category.id(); 97 NOTREACHED() << "Unknown category " << category.id();
99 return CategoryStatus::NOT_PROVIDED; 98 return CategoryStatus::NOT_PROVIDED;
100 } 99 }
101 100
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 void OfflinePageSuggestionsProvider::StoreDismissedIDsToPrefs( 360 void OfflinePageSuggestionsProvider::StoreDismissedIDsToPrefs(
362 Category category, 361 Category category,
363 const std::set<std::string>& dismissed_ids) { 362 const std::set<std::string>& dismissed_ids) {
364 base::ListValue list; 363 base::ListValue list;
365 for (const std::string& dismissed_id : dismissed_ids) 364 for (const std::string& dismissed_id : dismissed_ids)
366 list.AppendString(dismissed_id); 365 list.AppendString(dismissed_id);
367 pref_service_->Set(GetDismissedPref(category), list); 366 pref_service_->Set(GetDismissedPref(category), list);
368 } 367 }
369 368
370 } // namespace ntp_snippets 369 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698