| Index: chrome/browser/safe_browsing/chrome_password_protection_service.cc
|
| diff --git a/chrome/browser/safe_browsing/chrome_password_protection_service.cc b/chrome/browser/safe_browsing/chrome_password_protection_service.cc
|
| index f979a75967e0cbe8803a9964087a728f4847f0f4..9c4efee47e7016d45575efe9ec65b1143ebc84ef 100644
|
| --- a/chrome/browser/safe_browsing/chrome_password_protection_service.cc
|
| +++ b/chrome/browser/safe_browsing/chrome_password_protection_service.cc
|
| @@ -5,12 +5,17 @@
|
| #include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
|
|
|
| #include "base/feature_list.h"
|
| +#include "base/metrics/field_trial_params.h"
|
| #include "base/metrics/histogram_macros.h"
|
| #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
|
| #include "chrome/browser/history/history_service_factory.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.h"
|
| #include "chrome/browser/safe_browsing/safe_browsing_service.h"
|
| +#include "chrome/browser/sync/profile_sync_service_factory.h"
|
| +#include "components/browser_sync/profile_sync_service.h"
|
| +#include "components/safe_browsing/password_protection/password_protection_request.h"
|
| +#include "components/safe_browsing_db/database_manager.h"
|
| #include "components/safe_browsing_db/safe_browsing_prefs.h"
|
|
|
| using content::BrowserThread;
|
| @@ -22,9 +27,6 @@ namespace {
|
| const int kPasswordEventAttributionUserGestureLimit = 2;
|
| }
|
|
|
| -const base::Feature kPasswordProtectionPingOnly{
|
| - "PasswordProtectionPingOnly", base::FEATURE_DISABLED_BY_DEFAULT};
|
| -
|
| ChromePasswordProtectionService::ChromePasswordProtectionService(
|
| SafeBrowsingService* sb_service,
|
| Profile* profile)
|
| @@ -41,9 +43,11 @@ ChromePasswordProtectionService::ChromePasswordProtectionService(
|
| }
|
|
|
| ChromePasswordProtectionService::~ChromePasswordProtectionService() {
|
| - UMA_HISTOGRAM_COUNTS_1000(
|
| - "PasswordProtection.NumberOfCachedVerdictBeforeShutdown",
|
| - GetStoredVerdictCount());
|
| + if (content_settings()) {
|
| + UMA_HISTOGRAM_COUNTS_1000(
|
| + "PasswordProtection.NumberOfCachedVerdictBeforeShutdown",
|
| + GetStoredVerdictCount());
|
| + }
|
| }
|
|
|
| void ChromePasswordProtectionService::FillReferrerChain(
|
| @@ -72,8 +76,42 @@ bool ChromePasswordProtectionService::IsIncognito() {
|
| return profile_->IsOffTheRecord();
|
| }
|
|
|
| -bool ChromePasswordProtectionService::IsPingingEnabled() {
|
| - return base::FeatureList::IsEnabled(kPasswordProtectionPingOnly);
|
| +bool ChromePasswordProtectionService::IsPingingEnabled(
|
| + const base::Feature& feature) {
|
| + if (!base::FeatureList::IsEnabled(feature)) {
|
| + return false;
|
| + }
|
| +
|
| + bool allowed_incognito =
|
| + base::GetFieldTrialParamByFeatureAsBool(feature, "incognito", false);
|
| + if (IsIncognito() && !allowed_incognito)
|
| + return false;
|
| +
|
| + bool allowed_all_population =
|
| + base::GetFieldTrialParamByFeatureAsBool(feature, "all_population", false);
|
| + if (!allowed_all_population) {
|
| + bool allowed_extended_reporting = base::GetFieldTrialParamByFeatureAsBool(
|
| + feature, "extended_reporting", false);
|
| + if (IsExtendedReporting() && allowed_extended_reporting)
|
| + return true; // Ping enabled because this user opted in extended
|
| + // reporting.
|
| +
|
| + bool allowed_history_sync =
|
| + base::GetFieldTrialParamByFeatureAsBool(feature, "history_sync", false);
|
| + if (IsHistorySyncEnabled() && allowed_history_sync)
|
| + return true;
|
| + }
|
| +
|
| + return allowed_all_population;
|
| +}
|
| +
|
| +bool ChromePasswordProtectionService::IsHistorySyncEnabled() {
|
| + browser_sync::ProfileSyncService* sync =
|
| + ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
|
| + return sync && sync->IsSyncActive() && !sync->IsLocalSyncEnabled() &&
|
| + sync->GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES);
|
| }
|
|
|
| +ChromePasswordProtectionService::ChromePasswordProtectionService()
|
| + : PasswordProtectionService(nullptr, nullptr, nullptr, nullptr) {}
|
| } // namespace safe_browsing
|
|
|