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

Side by Side Diff: components/safe_browsing/password_protection/password_protection_service.cc

Issue 2856033002: Add finch control of user population in low reputation requests (Closed)
Patch Set: rebase Created 3 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "components/safe_browsing/password_protection/password_protection_servi ce.h" 5 #include "components/safe_browsing/password_protection/password_protection_servi ce.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
11 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_split.h" 13 #include "base/strings/string_split.h"
13 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
14 #include "components/content_settings/core/browser/host_content_settings_map.h" 15 #include "components/content_settings/core/browser/host_content_settings_map.h"
15 #include "components/history/core/browser/history_service.h" 16 #include "components/history/core/browser/history_service.h"
16 #include "components/safe_browsing/password_protection/password_protection_reque st.h" 17 #include "components/safe_browsing/password_protection/password_protection_reque st.h"
17 #include "components/safe_browsing_db/database_manager.h" 18 #include "components/safe_browsing_db/database_manager.h"
18 #include "components/safe_browsing_db/v4_protocol_manager_util.h" 19 #include "components/safe_browsing_db/v4_protocol_manager_util.h"
19 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // e.g., "https://www.foo.com:80/bar/test.cgi" -> "http://www.foo.com". 57 // e.g., "https://www.foo.com:80/bar/test.cgi" -> "http://www.foo.com".
57 GURL GetHostNameWithHTTPScheme(const GURL& url) { 58 GURL GetHostNameWithHTTPScheme(const GURL& url) {
58 DCHECK(url.SchemeIsHTTPOrHTTPS()); 59 DCHECK(url.SchemeIsHTTPOrHTTPS());
59 std::string result(url::kHttpScheme); 60 std::string result(url::kHttpScheme);
60 result.append(url::kStandardSchemeSeparator).append(url.HostNoBrackets()); 61 result.append(url::kStandardSchemeSeparator).append(url.HostNoBrackets());
61 return GURL(result); 62 return GURL(result);
62 } 63 }
63 64
64 } // namespace 65 } // namespace
65 66
67 const base::Feature kLowReputationPinging{"LowReputationPinging",
68 base::FEATURE_DISABLED_BY_DEFAULT};
69
70 const base::Feature kProtectedPasswordEntryPinging{
71 "ProtectedPasswordEntryPinging", base::FEATURE_DISABLED_BY_DEFAULT};
72
66 PasswordProtectionService::PasswordProtectionService( 73 PasswordProtectionService::PasswordProtectionService(
67 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager, 74 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager,
68 scoped_refptr<net::URLRequestContextGetter> request_context_getter, 75 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
69 HistoryService* history_service, 76 HistoryService* history_service,
70 HostContentSettingsMap* host_content_settings_map) 77 HostContentSettingsMap* host_content_settings_map)
71 : stored_verdict_count_(-1), 78 : stored_verdict_count_(-1),
72 database_manager_(database_manager), 79 database_manager_(database_manager),
73 request_context_getter_(request_context_getter), 80 request_context_getter_(request_context_getter),
74 history_service_observer_(this), 81 history_service_observer_(this),
75 content_settings_(host_content_settings_map), 82 content_settings_(host_content_settings_map),
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 DCHECK(request); 214 DCHECK(request);
208 request->Start(); 215 request->Start();
209 requests_.insert(std::move(request)); 216 requests_.insert(std::move(request));
210 } 217 }
211 218
212 void PasswordProtectionService::MaybeStartLowReputationRequest( 219 void PasswordProtectionService::MaybeStartLowReputationRequest(
213 const GURL& main_frame_url, 220 const GURL& main_frame_url,
214 const GURL& password_form_action, 221 const GURL& password_form_action,
215 const GURL& password_form_frame_url) { 222 const GURL& password_form_frame_url) {
216 DCHECK_CURRENTLY_ON(BrowserThread::UI); 223 DCHECK_CURRENTLY_ON(BrowserThread::UI);
217 if (!IsPingingEnabled()) 224 if (!IsPingingEnabled(kLowReputationPinging))
218 return; 225 return;
219 226
220 // Skip URLs that we can't get a reliable reputation for. 227 // Skip URLs that we can't get a reliable reputation for.
221 if (!main_frame_url.is_valid() || !main_frame_url.SchemeIsHTTPOrHTTPS()) { 228 if (!main_frame_url.is_valid() || !main_frame_url.SchemeIsHTTPOrHTTPS()) {
222 return; 229 return;
223 } 230 }
224 231
225 StartRequest(main_frame_url, password_form_action, password_form_frame_url, 232 StartRequest(main_frame_url, password_form_action, password_form_frame_url,
226 LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE); 233 LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE);
227 } 234 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 if (verdict_dictionary.get() && !verdict_dictionary->empty()) 300 if (verdict_dictionary.get() && !verdict_dictionary->empty())
294 stored_verdict_count_ += static_cast<int>(verdict_dictionary->size()); 301 stored_verdict_count_ += static_cast<int>(verdict_dictionary->size());
295 } 302 }
296 return stored_verdict_count_; 303 return stored_verdict_count_;
297 } 304 }
298 305
299 int PasswordProtectionService::GetRequestTimeoutInMS() { 306 int PasswordProtectionService::GetRequestTimeoutInMS() {
300 return kRequestTimeoutMs; 307 return kRequestTimeoutMs;
301 } 308 }
302 309
310 void PasswordProtectionService::FillUserPopulation(
311 const LoginReputationClientRequest::TriggerType& request_type,
312 LoginReputationClientRequest* request_proto) {
313 ChromeUserPopulation* user_population = request_proto->mutable_population();
314 user_population->set_user_population(
315 IsExtendedReporting() ? ChromeUserPopulation::EXTENDED_REPORTING
316 : ChromeUserPopulation::SAFE_BROWSING);
317 user_population->set_is_history_sync_enabled(IsHistorySyncEnabled());
318
319 base::FieldTrial* low_reputation_field_trial =
320 base::FeatureList::GetFieldTrial(kLowReputationPinging);
321 if (low_reputation_field_trial) {
322 user_population->add_finch_active_groups(
323 low_reputation_field_trial->trial_name() + "|" +
324 low_reputation_field_trial->group_name());
325 }
326 base::FieldTrial* password_entry_field_trial =
327 base::FeatureList::GetFieldTrial(kProtectedPasswordEntryPinging);
328 if (password_entry_field_trial) {
329 user_population->add_finch_active_groups(
330 low_reputation_field_trial->trial_name() + "|" +
331 low_reputation_field_trial->group_name());
332 }
333 }
334
303 void PasswordProtectionService::OnMatchCsdWhiteListResult( 335 void PasswordProtectionService::OnMatchCsdWhiteListResult(
304 const bool* match_whitelist) { 336 const bool* match_whitelist) {
305 UMA_HISTOGRAM_BOOLEAN( 337 UMA_HISTOGRAM_BOOLEAN(
306 "PasswordManager.PasswordReuse.MainFrameMatchCsdWhitelist", 338 "PasswordManager.PasswordReuse.MainFrameMatchCsdWhitelist",
307 *match_whitelist); 339 *match_whitelist);
308 } 340 }
309 341
310 void PasswordProtectionService::OnURLsDeleted( 342 void PasswordProtectionService::OnURLsDeleted(
311 history::HistoryService* history_service, 343 history::HistoryService* history_service,
312 bool all_history, 344 bool all_history,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 const std::vector<char> verdict_blob(serialized_proto.begin(), 478 const std::vector<char> verdict_blob(serialized_proto.begin(),
447 serialized_proto.end()); 479 serialized_proto.end());
448 std::unique_ptr<base::Value> binary_value = 480 std::unique_ptr<base::Value> binary_value =
449 base::MakeUnique<base::Value>(verdict_blob); 481 base::MakeUnique<base::Value>(verdict_blob);
450 DCHECK_EQ(base::Value::Type::BINARY, binary_value->type()); 482 DCHECK_EQ(base::Value::Type::BINARY, binary_value->type());
451 result->Set(kVerdictProto, std::move(binary_value)); 483 result->Set(kVerdictProto, std::move(binary_value));
452 return result; 484 return result;
453 } 485 }
454 486
455 } // namespace safe_browsing 487 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698