Index: chrome/browser/engagement/important_sites_util.h |
diff --git a/chrome/browser/engagement/important_sites_util.h b/chrome/browser/engagement/important_sites_util.h |
index 364da285f30c9036214524bce3d0bdab493af516..d32cd448d01c3c2b172f41d0196cc6bd9e7ff853 100644 |
--- a/chrome/browser/engagement/important_sites_util.h |
+++ b/chrome/browser/engagement/important_sites_util.h |
@@ -8,22 +8,40 @@ |
#include <string> |
#include <vector> |
+#include "base/callback.h" |
#include "base/macros.h" |
#include "url/gurl.h" |
class Profile; |
+namespace content { |
+class DOMStorageContext; |
+} |
+ |
+namespace storage { |
+class QuotaManager; |
+} |
+ |
namespace user_prefs { |
class PrefRegistrySyncable; |
} |
+// Helper methods for important sites. |
+// All methods should be used on the UI thread. |
class ImportantSitesUtil { |
public: |
+#if defined(OS_ANDROID) |
+ static const int kMaxImportantSites = 5; |
+#else |
+ static const int kMaxImportantSites = 10; |
+#endif |
+ |
struct ImportantDomainInfo { |
std::string registerable_domain; |
GURL example_origin; |
double engagement_score = 0; |
int32_t reason_bitfield = 0; |
+ int64_t usage = 0; |
}; |
// Do not change the values here, as they are used for UMA histograms. |
@@ -36,6 +54,9 @@ class ImportantSitesUtil { |
REASON_BOUNDARY |
}; |
+ using UsageCallback = |
+ base::Callback<void(std::vector<ImportantDomainInfo> sites)>; |
+ |
static bool IsDialogDisabled(Profile* profile); |
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
@@ -50,6 +71,14 @@ class ImportantSitesUtil { |
Profile* profile, |
size_t max_results); |
+ // Populates the ImportantDomainInfo::usage field of each site with the amount |
+ // of localstorage and quota bytes used. The |sites| vector with populated |
+ // usage fields is returned by |callback|. |
+ static void PopulateUsage(storage::QuotaManager* quota_manager, |
+ content::DOMStorageContext* dom_storage, |
+ std::vector<ImportantDomainInfo> sites, |
+ UsageCallback callback); |
+ |
// Record the sites that the user chose to blacklist from clearing (in the |
// Clear Browsing Dialog) and the sites they ignored. The blacklisted sites |
// are NOT cleared as they are 'blacklisted' from the clear operation. |