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

Side by Side Diff: chrome/browser/android/preferences/important_sites_util.cc

Issue 1465363002: [Storage] Android - ManageSpace UI, Important Origins, and CBD Dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 7 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 "chrome/browser/android/preferences/important_sites_util.h" 5 #include "chrome/browser/android/preferences/important_sites_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
11 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 11 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
12 #include "chrome/browser/engagement/site_engagement_score.h"
12 #include "chrome/browser/engagement/site_engagement_service.h" 13 #include "chrome/browser/engagement/site_engagement_service.h"
13 #include "components/content_settings/core/browser/host_content_settings_map.h" 14 #include "components/content_settings/core/browser/host_content_settings_map.h"
14 #include "components/content_settings/core/common/content_settings.h" 15 #include "components/content_settings/core/common/content_settings.h"
15 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 16 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
17 18
18 namespace { 19 namespace {
19 20
20 std::vector<std::pair<GURL, double>> GetSortedTopEngagementOrigins( 21 std::vector<std::pair<GURL, double>> GetSortedTopEngagementOrigins(
21 const SiteEngagementService* site_engagement_service, 22 const SiteEngagementService* site_engagement_service,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 const std::vector<std::pair<GURL, double>>& sorted_new_origins, 78 const std::vector<std::pair<GURL, double>>& sorted_new_origins,
78 size_t max_important_domains, 79 size_t max_important_domains,
79 std::vector<std::string>* final_list) { 80 std::vector<std::string>* final_list) {
80 for (const auto& pair : sorted_new_origins) { 81 for (const auto& pair : sorted_new_origins) {
81 if (final_list->size() >= max_important_domains) 82 if (final_list->size() >= max_important_domains)
82 return; 83 return;
83 std::string registerable_domain = 84 std::string registerable_domain =
84 net::registry_controlled_domains::GetDomainAndRegistry( 85 net::registry_controlled_domains::GetDomainAndRegistry(
85 pair.first, 86 pair.first,
86 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); 87 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
88 if (registerable_domain.empty() && pair.first.HostIsIPAddress())
89 registerable_domain = pair.first.host();
87 // Just iterate to find, as we assume our size is small. 90 // Just iterate to find, as we assume our size is small.
88 if (std::find(final_list->begin(), final_list->end(), 91 if (std::find(final_list->begin(), final_list->end(),
89 registerable_domain) == final_list->end()) { 92 registerable_domain) == final_list->end()) {
90 final_list->push_back(registerable_domain); 93 final_list->push_back(registerable_domain);
91 } 94 }
92 } 95 }
93 } 96 }
94 97
95 } // namespace 98 } // namespace
96 99
(...skipping 21 matching lines...) Expand all
118 // Otherwise we can add a set later. 121 // Otherwise we can add a set later.
119 std::vector<std::string> final_list; 122 std::vector<std::string> final_list;
120 // We start with notifications. 123 // We start with notifications.
121 FillTopRegisterableDomains(sorted_notification_origins, max_results, 124 FillTopRegisterableDomains(sorted_notification_origins, max_results,
122 &final_list); 125 &final_list);
123 // And now we fill the rest with high engagement sites. 126 // And now we fill the rest with high engagement sites.
124 FillTopRegisterableDomains(sorted_engagement_origins, max_results, 127 FillTopRegisterableDomains(sorted_engagement_origins, max_results,
125 &final_list); 128 &final_list);
126 return final_list; 129 return final_list;
127 } 130 }
131
132 void ImportantSitesUtil::MarkOriginAsImportantForTesting(Profile* profile,
133 const GURL& origin) {
134 // First get data from site engagement.
135 SiteEngagementService* site_engagement_service =
136 SiteEngagementService::Get(profile);
137 site_engagement_service->ResetScoreForURL(
138 origin, SiteEngagementScore::GetMediumEngagementBoundary());
139 DCHECK(site_engagement_service->IsEngagementAtLeast(
140 origin, SiteEngagementService::ENGAGEMENT_LEVEL_MEDIUM));
141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698