Commit d04d6346 authored by Anne Lim's avatar Anne Lim Committed by Commit Bot

[AF][Traffic Light] Moved strike_database files to components

Moved strike_database files from chrome/browser/autofill to
components/autofill/browser.

Bug: 884717
Change-Id: If6f7d6b59edd35d727ebcf70537a216a54b37de0
Reviewed-on: https://chromium-review.googlesource.com/1241937
Commit-Queue: Anne Lim <annelim@google.com>
Reviewed-by: default avatarMathieu Perreault <mathp@chromium.org>
Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Reviewed-by: default avatarJared Saul <jsaul@google.com>
Cr-Commit-Position: refs/heads/master@{#594315}
parent 0465ccf6
......@@ -111,10 +111,6 @@ jumbo_split_static_library("browser") {
"autofill/personal_data_manager_factory.h",
"autofill/risk_util.cc",
"autofill/risk_util.h",
"autofill/strike_database.cc",
"autofill/strike_database.h",
"autofill/test_strike_database.cc",
"autofill/test_strike_database.h",
"autofill/validation_rules_storage_factory.cc",
"autofill/validation_rules_storage_factory.h",
"background_fetch/background_fetch_delegate_factory.cc",
......@@ -1701,7 +1697,6 @@ jumbo_split_static_library("browser") {
"//chrome:strings",
"//chrome/app/resources:platform_locale_settings",
"//chrome/app/theme:theme_resources",
"//chrome/browser/autofill:strike_data",
"//chrome/browser/devtools",
"//chrome/browser/media:media_engagement_preload_proto",
"//chrome/browser/media:mojo_bindings",
......
# Copyright 2018 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.
import("//third_party/protobuf/proto_library.gni")
proto_library("strike_data") {
sources = [
"strike_data.proto",
]
}
......@@ -2359,7 +2359,6 @@ test("unit_tests") {
"../browser/autocomplete/chrome_autocomplete_scheme_classifier_unittest.cc",
"../browser/autocomplete/search_provider_unittest.cc",
"../browser/autocomplete/shortcuts_provider_extension_unittest.cc",
"../browser/autofill/strike_database_unittest.cc",
"../browser/background_sync/background_sync_controller_impl_unittest.cc",
"../browser/background_sync/background_sync_permission_context_unittest.cc",
"../browser/banners/app_banner_settings_helper_unittest.cc",
......
......@@ -156,6 +156,8 @@ jumbo_static_library("browser") {
"search_field.h",
"state_names.cc",
"state_names.h",
"strike_database.cc",
"strike_database.h",
"subkey_requester.cc",
"subkey_requester.h",
"suggestion.cc",
......@@ -262,6 +264,7 @@ jumbo_static_library("browser") {
"//components/data_use_measurement/core",
"//components/infobars/core",
"//components/keyed_service/core",
"//components/leveldb_proto:leveldb_proto",
"//components/os_crypt",
"//components/pref_registry",
"//components/prefs",
......@@ -339,6 +342,8 @@ jumbo_static_library("test_support") {
"test_personal_data_manager.h",
"test_region_data_loader.cc",
"test_region_data_loader.h",
"test_strike_database.cc",
"test_strike_database.h",
"test_sync_service.cc",
"test_sync_service.h",
"webdata/autofill_sync_bridge_test_util.cc",
......@@ -480,6 +485,7 @@ source_set("unit_tests") {
"rationalization_util_unittest.cc",
"region_combobox_model_unittest.cc",
"search_field_unittest.cc",
"strike_database_unittest.cc",
"subkey_requester_unittest.cc",
"ui/card_unmask_prompt_controller_impl_unittest.cc",
"validation_unittest.cc",
......
......@@ -3,6 +3,7 @@ include_rules = [
"+components/grit/components_scaled_resources.h",
"+components/infobars/core",
"+components/keyed_service/core",
"+components/leveldb_proto",
"+components/metrics",
"+components/policy",
"+components/security_state",
......
......@@ -10,5 +10,6 @@ fuzzable_proto_library("proto") {
"password_requirements.proto",
"password_requirements_shard.proto",
"server.proto",
"strike_data.proto",
]
}
......@@ -2,11 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/autofill/strike_database.h"
#include "components/autofill/core/browser/strike_database.h"
#include <string>
#include <utility>
#include <vector>
#include "base/task/post_task.h"
#include "base/time/time.h"
#include "chrome/browser/autofill/strike_data.pb.h"
#include "components/autofill/core/browser/proto/strike_data.pb.h"
#include "components/leveldb_proto/proto_database_impl.h"
namespace autofill {
......
......@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_AUTOFILL_STRIKE_DATABASE_H_
#define CHROME_BROWSER_AUTOFILL_STRIKE_DATABASE_H_
#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_STRIKE_DATABASE_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_STRIKE_DATABASE_H_
#include <memory>
#include <string>
#include "base/callback_forward.h"
#include "base/memory/weak_ptr.h"
......@@ -32,7 +33,7 @@ class StrikeDatabase {
using StrikeDataProto = leveldb_proto::ProtoDatabase<StrikeData>;
StrikeDatabase(const base::FilePath& database_dir);
explicit StrikeDatabase(const base::FilePath& database_dir);
~StrikeDatabase();
// Passes the number of strikes for |key| to |outer_callback|. In the case
......@@ -90,4 +91,4 @@ class StrikeDatabase {
} // namespace autofill
#endif // CHROME_BROWSER_AUTOFILL_STRIKE_DATABASE_H_
#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_STRIKE_DATABASE_H_
......@@ -2,25 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/autofill/strike_database.h"
#include "components/autofill/core/browser/strike_database.h"
#include <utility>
#include <vector>
#include "base/files/scoped_temp_dir.h"
#include "base/run_loop.h"
#include "base/test/scoped_task_environment.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/autofill/strike_data.pb.h"
#include "chrome/browser/autofill/test_strike_database.h"
#include "chrome/test/base/testing_profile.h"
#include "components/leveldb_proto/proto_database.h"
#include "components/leveldb_proto/proto_database_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "components/autofill/core/browser/proto/strike_data.pb.h"
#include "components/autofill/core/browser/test_strike_database.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace autofill {
class StrikeDatabaseTest : public ::testing::Test {
public:
StrikeDatabaseTest()
: db_(profile_.GetPath().Append(FILE_PATH_LITERAL("StrikeDatabase"))) {}
StrikeDatabaseTest() : db_(InitFilePath()) {}
void AddEntries(
std::vector<std::pair<std::string, StrikeData>> entries_to_add) {
......@@ -79,10 +78,17 @@ class StrikeDatabaseTest : public ::testing::Test {
}
private:
static const base::FilePath InitFilePath() {
base::ScopedTempDir temp_dir_;
EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
const base::FilePath file_path =
temp_dir_.GetPath().AppendASCII("StrikeDatabaseTest");
return file_path;
}
int num_strikes_;
content::TestBrowserThreadBundle thread_bundle_;
base::test::ScopedTaskEnvironment scoped_task_environment_;
std::unique_ptr<StrikeData> strike_data_;
TestingProfile profile_;
TestStrikeDatabase db_;
};
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/autofill/test_strike_database.h"
#include "components/autofill/core/browser/test_strike_database.h"
#include "chrome/browser/autofill/strike_data.pb.h"
#include "components/autofill/core/browser/proto/strike_data.pb.h"
namespace autofill {
......
......@@ -2,16 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_AUTOFILL_TEST_STRIKE_DATABASE_H_
#define CHROME_BROWSER_AUTOFILL_TEST_STRIKE_DATABASE_H_
#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_STRIKE_DATABASE_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_STRIKE_DATABASE_H_
#include "chrome/browser/autofill/strike_database.h"
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "components/autofill/core/browser/strike_database.h"
namespace autofill {
class TestStrikeDatabase : public StrikeDatabase {
public:
TestStrikeDatabase(const base::FilePath& database_dir);
explicit TestStrikeDatabase(const base::FilePath& database_dir);
void AddEntries(
std::vector<std::pair<std::string, StrikeData>> entries_to_add,
......@@ -20,4 +25,4 @@ class TestStrikeDatabase : public StrikeDatabase {
} // namespace autofill
#endif // CHROME_BROWSER_AUTOFILL_TEST_STRIKE_DATABASE_H_
#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_STRIKE_DATABASE_H_
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