Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef COMPONENTS_NTP_TILES_MOST_VISITED_SITES_H_ | 5 #ifndef COMPONENTS_NTP_TILES_MOST_VISITED_SITES_H_ |
| 6 #define COMPONENTS_NTP_TILES_MOST_VISITED_SITES_H_ | 6 #define COMPONENTS_NTP_TILES_MOST_VISITED_SITES_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 void Refresh(); | 112 void Refresh(); |
| 113 | 113 |
| 114 void AddOrRemoveBlacklistedUrl(const GURL& url, bool add_url); | 114 void AddOrRemoveBlacklistedUrl(const GURL& url, bool add_url); |
| 115 void ClearBlacklistedUrls(); | 115 void ClearBlacklistedUrls(); |
| 116 | 116 |
| 117 // MostVisitedSitesSupervisor::Observer implementation. | 117 // MostVisitedSitesSupervisor::Observer implementation. |
| 118 void OnBlockedSitesChanged() override; | 118 void OnBlockedSitesChanged() override; |
| 119 | 119 |
| 120 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 120 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 121 | 121 |
| 122 // Workhorse for SaveNewTiles. Implemented as a separate static and public | |
| 123 // method for ease of testing. | |
| 124 static NTPTilesVector MergeTiles(NTPTilesVector personal_tiles, | |
| 125 NTPTilesVector whitelist_tiles, | |
| 126 NTPTilesVector popular_tiles); | |
|
Marc Treib
2016/12/13 16:44:15
I generally prefer "friend class ...Test" over exp
mastiz
2016/12/14 08:54:27
Yes, my preferences are: public API if not too ugl
Marc Treib
2016/12/14 09:27:34
Well, this exposes less internals to the test, but
mastiz
2016/12/14 09:40:29
This is a good topic to bring up to our testing di
| |
| 127 | |
| 122 private: | 128 private: |
| 123 friend class MostVisitedSitesTest; | |
| 124 | |
| 125 void BuildCurrentTiles(); | 129 void BuildCurrentTiles(); |
| 126 | 130 |
| 127 // Initialize the query to Top Sites. Called if the SuggestionsService | 131 // Initialize the query to Top Sites. Called if the SuggestionsService |
| 128 // returned no data. | 132 // returned no data. |
| 129 void InitiateTopSitesQuery(); | 133 void InitiateTopSitesQuery(); |
| 130 | 134 |
| 131 // If there's a whitelist entry point for the URL, return the large icon path. | 135 // If there's a whitelist entry point for the URL, return the large icon path. |
| 132 base::FilePath GetWhitelistLargeIconPath(const GURL& url); | 136 base::FilePath GetWhitelistLargeIconPath(const GURL& url); |
| 133 | 137 |
| 134 // Callback for when data is available from TopSites. | 138 // Callback for when data is available from TopSites. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 146 | 150 |
| 147 // Takes the personal and whitelist tiles and creates popular tiles if | 151 // Takes the personal and whitelist tiles and creates popular tiles if |
| 148 // necessary. | 152 // necessary. |
| 149 NTPTilesVector CreatePopularSitesTiles(const NTPTilesVector& personal_tiles, | 153 NTPTilesVector CreatePopularSitesTiles(const NTPTilesVector& personal_tiles, |
| 150 const NTPTilesVector& whitelist_tiles); | 154 const NTPTilesVector& whitelist_tiles); |
| 151 | 155 |
| 152 // Takes the personal tiles, creates and merges in whitelist and popular tiles | 156 // Takes the personal tiles, creates and merges in whitelist and popular tiles |
| 153 // if appropriate, and saves the new tiles. | 157 // if appropriate, and saves the new tiles. |
| 154 void SaveNewTiles(NTPTilesVector personal_tiles); | 158 void SaveNewTiles(NTPTilesVector personal_tiles); |
| 155 | 159 |
| 156 // Workhorse for SaveNewTiles above. Implemented as a separate static method | |
| 157 // for ease of testing. | |
| 158 static NTPTilesVector MergeTiles(NTPTilesVector personal_tiles, | |
| 159 NTPTilesVector whitelist_tiles, | |
| 160 NTPTilesVector popular_tiles); | |
| 161 | |
| 162 // Notifies the observer about the availability of tiles. | 160 // Notifies the observer about the availability of tiles. |
| 163 // Also records impressions UMA if not done already. | 161 // Also records impressions UMA if not done already. |
| 164 void NotifyMostVisitedURLsObserver(); | 162 void NotifyMostVisitedURLsObserver(); |
| 165 | 163 |
| 166 void OnPopularSitesAvailable(bool success); | 164 void OnPopularSitesAvailable(bool success); |
| 167 | 165 |
| 168 void OnIconMadeAvailable(const GURL& site_url, bool newly_available); | 166 void OnIconMadeAvailable(const GURL& site_url, bool newly_available); |
| 169 | 167 |
| 170 // history::TopSitesObserver implementation. | 168 // history::TopSitesObserver implementation. |
| 171 void TopSitesLoaded(history::TopSites* top_sites) override; | 169 void TopSitesLoaded(history::TopSites* top_sites) override; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 198 | 196 |
| 199 // For callbacks may be run after destruction. | 197 // For callbacks may be run after destruction. |
| 200 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_; | 198 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_; |
| 201 | 199 |
| 202 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); | 200 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); |
| 203 }; | 201 }; |
| 204 | 202 |
| 205 } // namespace ntp_tiles | 203 } // namespace ntp_tiles |
| 206 | 204 |
| 207 #endif // COMPONENTS_NTP_TILES_MOST_VISITED_SITES_H_ | 205 #endif // COMPONENTS_NTP_TILES_MOST_VISITED_SITES_H_ |
| OLD | NEW |