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

Side by Side Diff: chrome/browser/ntp_tiles/chrome_most_visited_sites_factory.cc

Issue 2928823003: Make it possible to build without enable_supervised_users.
Patch Set: Does it still compile with the feature enabled? Created 3 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ntp_tiles/chrome_most_visited_sites_factory.h" 5 #include "chrome/browser/ntp_tiles/chrome_most_visited_sites_factory.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/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "chrome/browser/favicon/favicon_service_factory.h" 13 #include "chrome/browser/favicon/favicon_service_factory.h"
14 #include "chrome/browser/favicon/large_icon_service_factory.h" 14 #include "chrome/browser/favicon/large_icon_service_factory.h"
15 #include "chrome/browser/history/top_sites_factory.h" 15 #include "chrome/browser/history/top_sites_factory.h"
16 #include "chrome/browser/ntp_tiles/chrome_popular_sites_factory.h" 16 #include "chrome/browser/ntp_tiles/chrome_popular_sites_factory.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/search/suggestions/image_decoder_impl.h" 18 #include "chrome/browser/search/suggestions/image_decoder_impl.h"
19 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" 19 #include "chrome/browser/search/suggestions/suggestions_service_factory.h"
20 #include "chrome/browser/supervised_user/supervised_user_service.h"
21 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
22 #include "chrome/browser/supervised_user/supervised_user_service_observer.h"
23 #include "chrome/browser/supervised_user/supervised_user_url_filter.h"
24 #include "chrome/browser/thumbnails/thumbnail_list_source.h" 20 #include "chrome/browser/thumbnails/thumbnail_list_source.h"
21 #include "chrome/common/features.h"
25 #include "components/history/core/browser/top_sites.h" 22 #include "components/history/core/browser/top_sites.h"
26 #include "components/image_fetcher/core/image_fetcher_impl.h" 23 #include "components/image_fetcher/core/image_fetcher_impl.h"
27 #include "components/ntp_tiles/icon_cacher_impl.h" 24 #include "components/ntp_tiles/icon_cacher_impl.h"
28 #include "components/ntp_tiles/metrics.h" 25 #include "components/ntp_tiles/metrics.h"
29 #include "components/ntp_tiles/most_visited_sites.h" 26 #include "components/ntp_tiles/most_visited_sites.h"
30 27
28 #if BUILDFLAG(ENABLE_SUPERVISED_USERS)
29 #include "chrome/browser/supervised_user/supervised_user_service.h"
30 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
31 #include "chrome/browser/supervised_user/supervised_user_service_observer.h"
32 #include "chrome/browser/supervised_user/supervised_user_url_filter.h"
33 #endif
34
31 using suggestions::SuggestionsServiceFactory; 35 using suggestions::SuggestionsServiceFactory;
32 36
33 namespace { 37 namespace {
34 38
39 #if BUILDFLAG(ENABLE_SUPERVISED_USERS)
35 class SupervisorBridge : public ntp_tiles::MostVisitedSitesSupervisor, 40 class SupervisorBridge : public ntp_tiles::MostVisitedSitesSupervisor,
36 public SupervisedUserServiceObserver { 41 public SupervisedUserServiceObserver {
37 public: 42 public:
38 explicit SupervisorBridge(Profile* profile); 43 explicit SupervisorBridge(Profile* profile);
39 ~SupervisorBridge() override; 44 ~SupervisorBridge() override;
40 45
41 void SetObserver(Observer* observer) override; 46 void SetObserver(Observer* observer) override;
42 bool IsBlocked(const GURL& url) override; 47 bool IsBlocked(const GURL& url) override;
43 std::vector<MostVisitedSitesSupervisor::Whitelist> whitelists() override; 48 std::vector<MostVisitedSitesSupervisor::Whitelist> whitelists() override;
44 bool IsChildProfile() override; 49 bool IsChildProfile() override;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 101
97 bool SupervisorBridge::IsChildProfile() { 102 bool SupervisorBridge::IsChildProfile() {
98 return profile_->IsChild(); 103 return profile_->IsChild();
99 } 104 }
100 105
101 void SupervisorBridge::OnURLFilterChanged() { 106 void SupervisorBridge::OnURLFilterChanged() {
102 if (supervisor_observer_) { 107 if (supervisor_observer_) {
103 supervisor_observer_->OnBlockedSitesChanged(); 108 supervisor_observer_->OnBlockedSitesChanged();
104 } 109 }
105 } 110 }
111 #endif // BUILDFLAG(ENABLE_SUPERVISED_USERS)
106 112
107 } // namespace 113 } // namespace
108 114
109 // static 115 // static
110 std::unique_ptr<ntp_tiles::MostVisitedSites> 116 std::unique_ptr<ntp_tiles::MostVisitedSites>
111 ChromeMostVisitedSitesFactory::NewForProfile(Profile* profile) { 117 ChromeMostVisitedSitesFactory::NewForProfile(Profile* profile) {
112 // MostVisitedSites doesn't exist in incognito profiles. 118 // MostVisitedSites doesn't exist in incognito profiles.
113 if (profile->IsOffTheRecord()) { 119 if (profile->IsOffTheRecord()) {
114 return nullptr; 120 return nullptr;
115 } 121 }
116 122
117 return base::MakeUnique<ntp_tiles::MostVisitedSites>( 123 return base::MakeUnique<ntp_tiles::MostVisitedSites>(
118 profile->GetPrefs(), TopSitesFactory::GetForProfile(profile), 124 profile->GetPrefs(), TopSitesFactory::GetForProfile(profile),
119 SuggestionsServiceFactory::GetForProfile(profile), 125 SuggestionsServiceFactory::GetForProfile(profile),
120 #if defined(OS_ANDROID) 126 #if defined(OS_ANDROID)
121 ChromePopularSitesFactory::NewForProfile(profile), 127 ChromePopularSitesFactory::NewForProfile(profile),
122 #else 128 #else
123 nullptr, 129 nullptr,
124 #endif 130 #endif
125 base::MakeUnique<ntp_tiles::IconCacherImpl>( 131 base::MakeUnique<ntp_tiles::IconCacherImpl>(
126 FaviconServiceFactory::GetForProfile( 132 FaviconServiceFactory::GetForProfile(
127 profile, ServiceAccessType::IMPLICIT_ACCESS), 133 profile, ServiceAccessType::IMPLICIT_ACCESS),
128 LargeIconServiceFactory::GetForBrowserContext(profile), 134 LargeIconServiceFactory::GetForBrowserContext(profile),
129 base::MakeUnique<image_fetcher::ImageFetcherImpl>( 135 base::MakeUnique<image_fetcher::ImageFetcherImpl>(
130 base::MakeUnique<suggestions::ImageDecoderImpl>(), 136 base::MakeUnique<suggestions::ImageDecoderImpl>(),
131 profile->GetRequestContext())), 137 profile->GetRequestContext())),
132 base::MakeUnique<SupervisorBridge>(profile)); 138 #if BUILDFLAG(ENABLE_SUPERVISED_USERS)
139 base::MakeUnique<SupervisorBridge>(profile)
140 #else
141 nullptr
142 #endif
143 );
133 } 144 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698