Commit e46aa311 authored by Vaclav Brozek's avatar Vaclav Brozek Committed by Commit Bot

Synchronise flags for sync password reuse detection

There are two flags guarding support for detecting sync password
reuse:
(1) password_reuse_detection_support in
    components/password_manager/core/browser/BUILD.gn, and
(2) SYNC_PASSWORD_REUSE_DETECTION_ENABLED in
    components/password_manager/core/browser/password_reuse_defines.h

Those got out of sync, with the former excluding Android and the
latter not. This can cause compilation errors.

Furthermore, at some places, direct mentions of OS_* macros are used
instead of SYNC_PASSWORD_REUSE_DETECTION_ENABLED. This breaks
compilation if SYNC_PASSWORD_REUSE_DETECTION_ENABLED is changed.

Therefore this CL defines (2) by (1) and abolishes
password_reuse_defines.h completely. It also replaces OS_* macros
with SYNC_PASSWORD_REUSE_DETECTION_ENABLED as appropriate.
Finally, it adds "// nogncheck" to conditional #includes which
would otherwise cause troubles, following the guidance of [1],
and also adds a missing #include, which was found when switching
password_reuse_detection_support to exclude Linux instead.

[1] https://chromium.googlesource.com/chromium/src/+/eca97f87e275a7c9c5b7f13a65ff8635f0821d46/tools/gn/docs/reference.md#controlling-includes-individually

Bug: 706392
Change-Id: I40113777be9440faccb4e80fbca2a3571e2f6110
Reviewed-on: https://chromium-review.googlesource.com/1252585Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Commit-Queue: Vaclav Brozek <vabr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595441}
parent d1d33c00
......@@ -28,7 +28,6 @@
#include "components/password_manager/core/browser/login_database.h"
#include "components/password_manager/core/browser/password_manager_constants.h"
#include "components/password_manager/core/browser/password_manager_util.h"
#include "components/password_manager/core/browser/password_reuse_defines.h"
#include "components/password_manager/core/browser/password_store.h"
#include "components/password_manager/core/browser/password_store_default.h"
#include "components/password_manager/core/browser/password_store_factory_util.h"
......
......@@ -13,6 +13,12 @@ if (is_android) {
# TODO(crbug.com/706392): Fix password reuse detection for Android.
password_reuse_detection_support = !is_android && !is_ios
config("password_reuse_detection_config") {
if (password_reuse_detection_support) {
defines = [ "SYNC_PASSWORD_REUSE_DETECTION_ENABLED" ]
}
}
jumbo_static_library("browser") {
sources = [
"android_affiliation/affiliated_match_helper.cc",
......@@ -128,7 +134,6 @@ jumbo_static_library("browser") {
"password_manager_util.h",
"password_requirements_service.cc",
"password_requirements_service.h",
"password_reuse_defines.h",
"password_store.cc",
"password_store.h",
"password_store_change.cc",
......@@ -163,6 +168,8 @@ jumbo_static_library("browser") {
"votes_uploader.h",
]
all_dependent_configs = [ ":password_reuse_detection_config" ]
if (password_reuse_detection_support) {
sources += [
"password_reuse_detection_manager.cc",
......
......@@ -32,7 +32,6 @@
#include "components/password_manager/core/browser/password_manager_driver.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "components/password_manager/core/browser/password_manager_util.h"
#include "components/password_manager/core/browser/password_reuse_defines.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/password_manager/core/common/password_manager_pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
......
......@@ -12,6 +12,7 @@
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/credentials_filter.h"
#include "components/password_manager/core/browser/hsts_query.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "components/password_manager/core/browser/password_store.h"
#include "net/cert/cert_status_flags.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
......
......@@ -10,7 +10,6 @@
#include <string>
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/password_reuse_defines.h"
#include "components/password_manager/core/common/credential_manager_types.h"
namespace password_manager {
......
......@@ -106,8 +106,7 @@ MockPasswordStoreObserver::MockPasswordStoreObserver() {}
MockPasswordStoreObserver::~MockPasswordStoreObserver() {}
// TODO(crbug.com/706392): Fix password reuse detection for Android.
#if !defined(OS_ANDROID) && !defined(OS_IOS)
#if defined(SYNC_PASSWORD_REUSE_DETECTION_ENABLED)
MockPasswordReuseDetectorConsumer::MockPasswordReuseDetectorConsumer() {}
MockPasswordReuseDetectorConsumer::~MockPasswordReuseDetectorConsumer() {}
......
......@@ -14,6 +14,11 @@
#include "components/password_manager/core/browser/password_store.h"
#include "testing/gmock/include/gmock/gmock.h"
#if defined(SYNC_PASSWORD_REUSE_DETECTION_ENABLED)
#include "components/password_manager/core/browser/password_hash_data.h" // nogncheck
#include "components/password_manager/core/browser/password_reuse_detector_consumer.h" // nogncheck
#endif
namespace password_manager {
// This template allows creating methods with signature conforming to
......@@ -80,8 +85,7 @@ class MockPasswordStoreObserver : public PasswordStore::Observer {
MOCK_METHOD1(OnLoginsChanged, void(const PasswordStoreChangeList& changes));
};
// TODO(crbug.com/706392): Fix password reuse detection for Android.
#if !defined(OS_ANDROID) && !defined(OS_IOS)
#if defined(SYNC_PASSWORD_REUSE_DETECTION_ENABLED)
class MockPasswordReuseDetectorConsumer : public PasswordReuseDetectorConsumer {
public:
MockPasswordReuseDetectorConsumer();
......
......@@ -26,7 +26,6 @@
#include "components/password_manager/core/browser/new_password_form_manager.h"
#include "components/password_manager/core/browser/password_autofill_manager.h"
#include "components/password_manager/core/browser/password_manager_driver.h"
#include "components/password_manager/core/browser/password_reuse_defines.h"
#include "components/password_manager/core/browser/password_store.h"
#include "components/password_manager/core/browser/statistics_table.h"
#include "components/password_manager/core/browser/stub_credentials_filter.h"
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_REUSE_DEFINES_H_
#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_REUSE_DEFINES_H_
#if defined(OS_WIN) || (defined(OS_MACOSX) && !defined(OS_IOS)) || \
defined(OS_LINUX) || defined(OS_CHROMEOS)
// Enable the detection when the sync password is typed not on the sync domain.
#define SYNC_PASSWORD_REUSE_DETECTION_ENABLED
#endif
#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_REUSE_DEFINES_H_
......@@ -23,7 +23,6 @@
#include "components/password_manager/core/browser/android_affiliation/affiliated_match_helper.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "components/password_manager/core/browser/password_manager_util.h"
#include "components/password_manager/core/browser/password_reuse_defines.h"
#include "components/password_manager/core/browser/password_store_consumer.h"
#include "components/password_manager/core/browser/password_syncable_service.h"
#include "components/password_manager/core/browser/statistics_table.h"
......
......@@ -18,7 +18,6 @@
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/keyed_service/core/refcounted_keyed_service.h"
#include "components/password_manager/core/browser/password_reuse_defines.h"
#include "components/password_manager/core/browser/password_store_change.h"
#include "components/password_manager/core/browser/password_store_sync.h"
#include "components/sync/model/syncable_service.h"
......
......@@ -16,7 +16,6 @@
#include "base/synchronization/waitable_event.h"
#include "base/test/scoped_task_environment.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/os_crypt/os_crypt_mocker.h"
#include "components/password_manager/core/browser/android_affiliation/affiliated_match_helper.h"
#include "components/password_manager/core/browser/android_affiliation/affiliation_service.h"
......@@ -871,8 +870,7 @@ TEST_F(PasswordStoreTest, GetLoginsForSameOrganizationName) {
store->ShutdownOnUIThread();
}
// TODO(crbug.com/706392): Fix password reuse detection for Android.
#if !defined(OS_ANDROID) && !defined(OS_IOS)
#if defined(SYNC_PASSWORD_REUSE_DETECTION_ENABLED)
TEST_F(PasswordStoreTest, CheckPasswordReuse) {
static constexpr PasswordFormData kTestCredentials[] = {
{PasswordForm::SCHEME_HTML, "https://www.google.com",
......@@ -918,9 +916,7 @@ TEST_F(PasswordStoreTest, CheckPasswordReuse) {
store->ShutdownOnUIThread();
}
#endif
#if defined(SYNC_PASSWORD_REUSE_DETECTION_ENABLED)
TEST_F(PasswordStoreTest, SavingClearingProtectedPassword) {
scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault(
std::make_unique<LoginDatabase>(test_login_db_file_path())));
......
......@@ -7,7 +7,6 @@
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/password_reuse_defines.h"
#include "google_apis/gaia/gaia_auth_util.h"
#include "google_apis/gaia/gaia_urls.h"
#include "url/origin.h"
......
......@@ -9,15 +9,14 @@
#include "base/stl_util.h"
#include "build/build_config.h"
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/password_reuse_defines.h"
#include "components/password_manager/sync/browser/sync_username_test_base.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/testing_pref_service.h"
#include "testing/gtest/include/gtest/gtest.h"
#if !defined(OS_IOS)
#include "components/safe_browsing/common/safe_browsing_prefs.h"
#endif // !OS_IOS
#if defined(SYNC_PASSWORD_REUSE_DETECTION_ENABLED)
#include "components/safe_browsing/common/safe_browsing_prefs.h" // nogncheck
#endif // SYNC_PASSWORD_REUSE_DETECTION_ENABLED
using autofill::PasswordForm;
......
......@@ -31,11 +31,13 @@
#include "components/password_manager/sync/browser/sync_username_test_base.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/testing_pref_service.h"
#include "components/safe_browsing/common/safe_browsing_prefs.h"
#include "components/safe_browsing/features.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(SYNC_PASSWORD_REUSE_DETECTION_ENABLED)
#include "components/safe_browsing/common/safe_browsing_prefs.h" // nogncheck
#endif // SYNC_PASSWORD_REUSE_DETECTION_ENABLED
using autofill::PasswordForm;
namespace password_manager {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment