Commit 614a7d91 authored by Anne Lim's avatar Anne Lim Committed by Commit Bot

Added AutofillStrikeDatabase Framework

Added skeleton framework for AutofillStrikeDatabase.
It will be used to store data about the number of times a user
refuses to save their info.

Bug: 884817

Change-Id: Iaffac0ab45785e4c0ff261ecb9bbde31e270e00a
Reviewed-on: https://chromium-review.googlesource.com/1228774Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Reviewed-by: default avatarJared Saul <jsaul@google.com>
Commit-Queue: Anne Lim <annelim@google.com>
Cr-Commit-Position: refs/heads/master@{#592047}
parent f6e13edc
...@@ -111,6 +111,8 @@ jumbo_split_static_library("browser") { ...@@ -111,6 +111,8 @@ jumbo_split_static_library("browser") {
"autofill/personal_data_manager_factory.h", "autofill/personal_data_manager_factory.h",
"autofill/risk_util.cc", "autofill/risk_util.cc",
"autofill/risk_util.h", "autofill/risk_util.h",
"autofill/strike_database.cc",
"autofill/strike_database.h",
"autofill/validation_rules_storage_factory.cc", "autofill/validation_rules_storage_factory.cc",
"autofill/validation_rules_storage_factory.h", "autofill/validation_rules_storage_factory.h",
"background_fetch/background_fetch_delegate_factory.cc", "background_fetch/background_fetch_delegate_factory.cc",
...@@ -1695,6 +1697,7 @@ jumbo_split_static_library("browser") { ...@@ -1695,6 +1697,7 @@ jumbo_split_static_library("browser") {
"//chrome:strings", "//chrome:strings",
"//chrome/app/resources:platform_locale_settings", "//chrome/app/resources:platform_locale_settings",
"//chrome/app/theme:theme_resources", "//chrome/app/theme:theme_resources",
"//chrome/browser/autofill:strike_data",
"//chrome/browser/devtools", "//chrome/browser/devtools",
"//chrome/browser/media:media_engagement_preload_proto", "//chrome/browser/media:media_engagement_preload_proto",
"//chrome/browser/media:mojo_bindings", "//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",
]
}
// 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.
syntax = "proto2";
package autofill;
option optimize_for = LITE_RUNTIME;
message StrikeData {
// Total number of strikes thus far.
optional int32 num_strikes = 1;
// Timestamp of when a strike was last added or removed
// for this entry. Can be used to expire strikes later.
optional int64 last_update_timestamp = 2;
}
// 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.
#include "chrome/browser/autofill/strike_database.h"
#include "base/task/post_task.h"
#include "chrome/browser/autofill/strike_data.pb.h"
#include "components/leveldb_proto/proto_database_impl.h"
namespace autofill {
namespace {
const char kDatabaseClientName[] = "StrikeService";
} // namespace
StrikeDatabase::StrikeDatabase(const base::FilePath& database_dir)
: db_(std::make_unique<leveldb_proto::ProtoDatabaseImpl<StrikeData>>(
base::CreateSequencedTaskRunnerWithTraits(
{base::MayBlock(), base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}))),
weak_ptr_factory_(this) {
db_->Init(kDatabaseClientName, database_dir,
leveldb_proto::CreateSimpleOptions(),
base::BindRepeating(&StrikeDatabase::OnDatabaseInit,
weak_ptr_factory_.GetWeakPtr()));
}
StrikeDatabase::~StrikeDatabase() {}
void StrikeDatabase::OnDatabaseInit(bool success) {}
} // namespace autofill
// 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.
#ifndef CHROME_BROWSER_AUTOFILL_STRIKE_DATABASE_H_
#define CHROME_BROWSER_AUTOFILL_STRIKE_DATABASE_H_
#include <memory>
#include "base/callback_forward.h"
#include "base/memory/weak_ptr.h"
#include "components/leveldb_proto/proto_database.h"
namespace autofill {
class StrikeData;
// Manages data on whether different Autofill opportunities should be offered to
// the user. Projects can earn strikes in a number of ways; for instance, if a
// user ignores or declines a prompt, or if a user accepts a prompt but the task
// fails.
class StrikeDatabase {
public:
StrikeDatabase(const base::FilePath& database_dir);
~StrikeDatabase();
private:
void OnDatabaseInit(bool success);
std::unique_ptr<leveldb_proto::ProtoDatabase<StrikeData>> db_;
base::WeakPtrFactory<StrikeDatabase> weak_ptr_factory_;
};
} // namespace autofill
#endif // CHROME_BROWSER_AUTOFILL_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