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

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, test split up, cleanup 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
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 const std::vector<std::pair<GURL, double>>& sorted_new_origins, 77 const std::vector<std::pair<GURL, double>>& sorted_new_origins,
78 size_t max_important_domains, 78 size_t max_important_domains,
79 std::vector<std::string>* final_list) { 79 std::vector<std::string>* final_list) {
80 for (const auto& pair : sorted_new_origins) { 80 for (const auto& pair : sorted_new_origins) {
81 if (final_list->size() >= max_important_domains) 81 if (final_list->size() >= max_important_domains)
82 return; 82 return;
83 std::string registerable_domain = 83 std::string registerable_domain =
84 net::registry_controlled_domains::GetDomainAndRegistry( 84 net::registry_controlled_domains::GetDomainAndRegistry(
85 pair.first, 85 pair.first,
86 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); 86 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
87 if (registerable_domain.empty() && pair.first.HostIsIPAddress())
88 registerable_domain = pair.first.host();
87 // Just iterate to find, as we assume our size is small. 89 // Just iterate to find, as we assume our size is small.
88 if (std::find(final_list->begin(), final_list->end(), 90 if (std::find(final_list->begin(), final_list->end(),
89 registerable_domain) == final_list->end()) { 91 registerable_domain) == final_list->end()) {
90 final_list->push_back(registerable_domain); 92 final_list->push_back(registerable_domain);
91 } 93 }
92 } 94 }
93 } 95 }
94 96
95 } // namespace 97 } // namespace
96 98
(...skipping 21 matching lines...) Expand all
118 // Otherwise we can add a set later. 120 // Otherwise we can add a set later.
119 std::vector<std::string> final_list; 121 std::vector<std::string> final_list;
120 // We start with notifications. 122 // We start with notifications.
121 FillTopRegisterableDomains(sorted_notification_origins, max_results, 123 FillTopRegisterableDomains(sorted_notification_origins, max_results,
122 &final_list); 124 &final_list);
123 // And now we fill the rest with high engagement sites. 125 // And now we fill the rest with high engagement sites.
124 FillTopRegisterableDomains(sorted_engagement_origins, max_results, 126 FillTopRegisterableDomains(sorted_engagement_origins, max_results,
125 &final_list); 127 &final_list);
126 return final_list; 128 return final_list;
127 } 129 }
130
131 void ImportantSitesUtil::MarkOriginAsImportantForTesting(Profile* profile,
132 const GURL& origin) {
133 // First get data from site engagement.
134 SiteEngagementService* site_engagement_service =
135 SiteEngagementService::Get(profile);
136 site_engagement_service->ResetScoreForURL(
137 origin, SiteEngagementScore::GetMediumEngagementBoundary());
138 DCHECK(site_engagement_service->IsEngagementAtLeast(
139 origin, SiteEngagementService::ENGAGEMENT_LEVEL_MEDIUM));
140 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698