Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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* field_trial = base::FeatureList::GetFieldTrial( | |
| 320 request_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE | |
| 321 ? kLowReputationPinging | |
| 322 : kProtectedPasswordEntryPinging); | |
| 323 if (field_trial) { | |
| 324 user_population->set_finch_active_group(field_trial->trial_name() + "|" + | |
|
Nathan Parker
2017/05/05 20:58:22
Would it be useful to know the group name for both
Jialiu Lin
2017/05/05 22:19:32
SG. Changed to a repeated field.
| |
| 325 field_trial->group_name()); | |
| 326 } | |
| 327 } | |
| 328 | |
| 303 void PasswordProtectionService::OnMatchCsdWhiteListResult( | 329 void PasswordProtectionService::OnMatchCsdWhiteListResult( |
| 304 const bool* match_whitelist) { | 330 const bool* match_whitelist) { |
| 305 UMA_HISTOGRAM_BOOLEAN( | 331 UMA_HISTOGRAM_BOOLEAN( |
| 306 "PasswordManager.PasswordReuse.MainFrameMatchCsdWhitelist", | 332 "PasswordManager.PasswordReuse.MainFrameMatchCsdWhitelist", |
| 307 *match_whitelist); | 333 *match_whitelist); |
| 308 } | 334 } |
| 309 | 335 |
| 310 void PasswordProtectionService::OnURLsDeleted( | 336 void PasswordProtectionService::OnURLsDeleted( |
| 311 history::HistoryService* history_service, | 337 history::HistoryService* history_service, |
| 312 bool all_history, | 338 bool all_history, |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 const std::vector<char> verdict_blob(serialized_proto.begin(), | 472 const std::vector<char> verdict_blob(serialized_proto.begin(), |
| 447 serialized_proto.end()); | 473 serialized_proto.end()); |
| 448 std::unique_ptr<base::Value> binary_value = | 474 std::unique_ptr<base::Value> binary_value = |
| 449 base::MakeUnique<base::Value>(verdict_blob); | 475 base::MakeUnique<base::Value>(verdict_blob); |
| 450 DCHECK_EQ(base::Value::Type::BINARY, binary_value->type()); | 476 DCHECK_EQ(base::Value::Type::BINARY, binary_value->type()); |
| 451 result->Set(kVerdictProto, std::move(binary_value)); | 477 result->Set(kVerdictProto, std::move(binary_value)); |
| 452 return result; | 478 return result; |
| 453 } | 479 } |
| 454 | 480 |
| 455 } // namespace safe_browsing | 481 } // namespace safe_browsing |
| OLD | NEW |