| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 void Refresh(); | 109 void Refresh(); |
| 110 | 110 |
| 111 void AddOrRemoveBlacklistedUrl(const GURL& url, bool add_url); | 111 void AddOrRemoveBlacklistedUrl(const GURL& url, bool add_url); |
| 112 void ClearBlacklistedUrls(); | 112 void ClearBlacklistedUrls(); |
| 113 | 113 |
| 114 // MostVisitedSitesSupervisor::Observer implementation. | 114 // MostVisitedSitesSupervisor::Observer implementation. |
| 115 void OnBlockedSitesChanged() override; | 115 void OnBlockedSitesChanged() override; |
| 116 | 116 |
| 117 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 117 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 118 | 118 |
| 119 // Workhorse for SaveNewTiles. Implemented as a separate static and public |
| 120 // method for ease of testing. |
| 121 static NTPTilesVector MergeTiles(NTPTilesVector personal_tiles, |
| 122 NTPTilesVector whitelist_tiles, |
| 123 NTPTilesVector popular_tiles); |
| 124 |
| 119 private: | 125 private: |
| 120 friend class MostVisitedSitesTest; | |
| 121 | |
| 122 void BuildCurrentTiles(); | 126 void BuildCurrentTiles(); |
| 123 | 127 |
| 124 // Initialize the query to Top Sites. Called if the SuggestionsService | 128 // Initialize the query to Top Sites. Called if the SuggestionsService |
| 125 // returned no data. | 129 // returned no data. |
| 126 void InitiateTopSitesQuery(); | 130 void InitiateTopSitesQuery(); |
| 127 | 131 |
| 128 // If there's a whitelist entry point for the URL, return the large icon path. | 132 // If there's a whitelist entry point for the URL, return the large icon path. |
| 129 base::FilePath GetWhitelistLargeIconPath(const GURL& url); | 133 base::FilePath GetWhitelistLargeIconPath(const GURL& url); |
| 130 | 134 |
| 131 // Callback for when data is available from TopSites. | 135 // Callback for when data is available from TopSites. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 143 | 147 |
| 144 // Takes the personal and whitelist tiles and creates popular tiles if | 148 // Takes the personal and whitelist tiles and creates popular tiles if |
| 145 // necessary. | 149 // necessary. |
| 146 NTPTilesVector CreatePopularSitesTiles(const NTPTilesVector& personal_tiles, | 150 NTPTilesVector CreatePopularSitesTiles(const NTPTilesVector& personal_tiles, |
| 147 const NTPTilesVector& whitelist_tiles); | 151 const NTPTilesVector& whitelist_tiles); |
| 148 | 152 |
| 149 // Takes the personal tiles, creates and merges in whitelist and popular tiles | 153 // Takes the personal tiles, creates and merges in whitelist and popular tiles |
| 150 // if appropriate, and saves the new tiles. | 154 // if appropriate, and saves the new tiles. |
| 151 void SaveNewTiles(NTPTilesVector personal_tiles); | 155 void SaveNewTiles(NTPTilesVector personal_tiles); |
| 152 | 156 |
| 153 // Workhorse for SaveNewTiles above. Implemented as a separate static method | |
| 154 // for ease of testing. | |
| 155 static NTPTilesVector MergeTiles(NTPTilesVector personal_tiles, | |
| 156 NTPTilesVector whitelist_tiles, | |
| 157 NTPTilesVector popular_tiles); | |
| 158 | |
| 159 // Notifies the observer about the availability of tiles. | 157 // Notifies the observer about the availability of tiles. |
| 160 // Also records impressions UMA if not done already. | 158 // Also records impressions UMA if not done already. |
| 161 void NotifyMostVisitedURLsObserver(); | 159 void NotifyMostVisitedURLsObserver(); |
| 162 | 160 |
| 163 void OnPopularSitesAvailable(bool success); | 161 void OnPopularSitesAvailable(bool success); |
| 164 | 162 |
| 165 void OnIconMadeAvailable(const GURL& site_url, bool newly_available); | 163 void OnIconMadeAvailable(const GURL& site_url, bool newly_available); |
| 166 | 164 |
| 167 // history::TopSitesObserver implementation. | 165 // history::TopSitesObserver implementation. |
| 168 void TopSitesLoaded(history::TopSites* top_sites) override; | 166 void TopSitesLoaded(history::TopSites* top_sites) override; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 195 | 193 |
| 196 // For callbacks may be run after destruction. | 194 // For callbacks may be run after destruction. |
| 197 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_; | 195 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_; |
| 198 | 196 |
| 199 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); | 197 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); |
| 200 }; | 198 }; |
| 201 | 199 |
| 202 } // namespace ntp_tiles | 200 } // namespace ntp_tiles |
| 203 | 201 |
| 204 #endif // COMPONENTS_NTP_TILES_MOST_VISITED_SITES_H_ | 202 #endif // COMPONENTS_NTP_TILES_MOST_VISITED_SITES_H_ |
| OLD | NEW |