summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorestade <estade@chromium.org>2014-12-17 17:35:32 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-18 01:35:56 +0000
commitd92bda37560350486049df6aab4567eb4f4c8ec0 (patch)
tree9e76e77011f61fb84d530ff262417daaff629b92 /components
parent461f93fb6561c9d6df54fbcf07d038cc203161b0 (diff)
downloadchromium_src-d92bda37560350486049df6aab4567eb4f4c8ec0.zip
chromium_src-d92bda37560350486049df6aab4567eb4f4c8ec0.tar.gz
chromium_src-d92bda37560350486049df6aab4567eb4f4c8ec0.tar.bz2
Make AutofillMetrics a static-only class.
BUG=439620 TBR=aurimas@chromium.org Review URL: https://codereview.chromium.org/794733003 Cr-Commit-Position: refs/heads/master@{#308913}
Diffstat (limited to 'components')
-rw-r--r--components/autofill/content/browser/wallet/wallet_client_delegate.h2
-rw-r--r--components/autofill/core/browser/autofill_client.h1
-rw-r--r--components/autofill/core/browser/autofill_download_manager.cc5
-rw-r--r--components/autofill/core/browser/autofill_download_manager.h4
-rw-r--r--components/autofill/core/browser/autofill_download_manager_unittest.cc86
-rw-r--r--components/autofill/core/browser/autofill_external_delegate.cc1
-rw-r--r--components/autofill/core/browser/autofill_external_delegate_unittest.cc1
-rw-r--r--components/autofill/core/browser/autofill_manager.cc41
-rw-r--r--components/autofill/core/browser/autofill_manager.h6
-rw-r--r--components/autofill/core/browser/autofill_manager_unittest.cc4
-rw-r--r--components/autofill/core/browser/autofill_metrics.cc57
-rw-r--r--components/autofill/core/browser/autofill_metrics.h48
-rw-r--r--components/autofill/core/browser/form_structure.cc71
-rw-r--r--components/autofill/core/browser/form_structure.h13
-rw-r--r--components/autofill/core/browser/form_structure_unittest.cc92
-rw-r--r--components/autofill/core/browser/personal_data_manager.cc6
-rw-r--r--components/autofill/core/browser/personal_data_manager.h11
-rw-r--r--components/autofill/core/browser/personal_data_manager_unittest.cc88
-rw-r--r--components/password_manager/core/browser/password_generation_manager_unittest.cc12
19 files changed, 228 insertions, 321 deletions
diff --git a/components/autofill/content/browser/wallet/wallet_client_delegate.h b/components/autofill/content/browser/wallet/wallet_client_delegate.h
index 7bb4eb4..c17aa99 100644
--- a/components/autofill/content/browser/wallet/wallet_client_delegate.h
+++ b/components/autofill/content/browser/wallet/wallet_client_delegate.h
@@ -12,8 +12,6 @@
#include "components/autofill/content/browser/wallet/wallet_client.h"
#include "components/autofill/core/browser/autofill_client.h"
-class AutofillMetrics;
-
namespace autofill {
namespace wallet {
diff --git a/components/autofill/core/browser/autofill_client.h b/components/autofill/core/browser/autofill_client.h
index bec688c..6ffcd70 100644
--- a/components/autofill/core/browser/autofill_client.h
+++ b/components/autofill/core/browser/autofill_client.h
@@ -26,7 +26,6 @@ class PrefService;
namespace autofill {
-class AutofillMetrics;
class AutofillPopupDelegate;
class AutofillWebDataService;
class CreditCard;
diff --git a/components/autofill/core/browser/autofill_download_manager.cc b/components/autofill/core/browser/autofill_download_manager.cc
index ba62af5..9331282 100644
--- a/components/autofill/core/browser/autofill_download_manager.cc
+++ b/components/autofill/core/browser/autofill_download_manager.cc
@@ -81,8 +81,7 @@ AutofillDownloadManager::~AutofillDownloadManager() {
}
bool AutofillDownloadManager::StartQueryRequest(
- const std::vector<FormStructure*>& forms,
- const AutofillMetrics& metric_logger) {
+ const std::vector<FormStructure*>& forms) {
if (next_query_request_ > base::Time::Now()) {
// We are in back-off mode: do not do the request.
return false;
@@ -95,7 +94,7 @@ bool AutofillDownloadManager::StartQueryRequest(
}
request_data.request_type = AutofillDownloadManager::REQUEST_QUERY;
- metric_logger.LogServerQueryMetric(AutofillMetrics::QUERY_SENT);
+ AutofillMetrics::LogServerQueryMetric(AutofillMetrics::QUERY_SENT);
std::string query_data;
if (CheckCacheForQueryRequest(request_data.form_signatures, &query_data)) {
diff --git a/components/autofill/core/browser/autofill_download_manager.h b/components/autofill/core/browser/autofill_download_manager.h
index 4f0e2a3..7bfe92f 100644
--- a/components/autofill/core/browser/autofill_download_manager.h
+++ b/components/autofill/core/browser/autofill_download_manager.h
@@ -27,7 +27,6 @@ class URLFetcher;
namespace autofill {
class AutofillDriver;
-class AutofillMetrics;
class FormStructure;
// Handles getting and updating Autofill heuristics.
@@ -68,8 +67,7 @@ class AutofillDownloadManager : public net::URLFetcherDelegate {
// Starts a query request to Autofill servers. The observer is called with the
// list of the fields of all requested forms.
// |forms| - array of forms aggregated in this request.
- bool StartQueryRequest(const std::vector<FormStructure*>& forms,
- const AutofillMetrics& metric_logger);
+ bool StartQueryRequest(const std::vector<FormStructure*>& forms);
// Starts an upload request for the given |form|, unless throttled by the
// server. The probability of the request going over the wire is
diff --git a/components/autofill/core/browser/autofill_download_manager_unittest.cc b/components/autofill/core/browser/autofill_download_manager_unittest.cc
index 5c6268f..1383e1f 100644
--- a/components/autofill/core/browser/autofill_download_manager_unittest.cc
+++ b/components/autofill/core/browser/autofill_download_manager_unittest.cc
@@ -10,6 +10,7 @@
#include "base/prefs/pref_service.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/test/histogram_tester.h"
#include "base/test/test_timeouts.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/autofill_metrics.h"
@@ -30,15 +31,6 @@ namespace autofill {
namespace {
-class MockAutofillMetrics : public AutofillMetrics {
- public:
- MockAutofillMetrics() {}
- MOCK_CONST_METHOD1(LogServerQueryMetric, void(ServerQueryMetric metric));
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MockAutofillMetrics);
-};
-
// Call |fetcher->OnURLFetchComplete()| as the URLFetcher would when
// a response is received. Params allow caller to set fake status.
void FakeOnURLFetchComplete(net::TestURLFetcher* fetcher,
@@ -199,11 +191,11 @@ TEST_F(AutofillDownloadTest, QueryAndUploadTest) {
form_structures.push_back(form_structure);
// Request with id 0.
- MockAutofillMetrics mock_metric_logger;
- EXPECT_CALL(mock_metric_logger,
- LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1);
- EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures.get(),
- mock_metric_logger));
+ base::HistogramTester histogram;
+ EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures.get()));
+ histogram.ExpectUniqueSample("Autofill.ServerQueryResponse",
+ AutofillMetrics::QUERY_SENT, 1);
+
// Set upload to 100% so requests happen.
download_manager_.SetPositiveUploadRate(1.0);
download_manager_.SetNegativeUploadRate(1.0);
@@ -292,12 +284,11 @@ TEST_F(AutofillDownloadTest, QueryAndUploadTest) {
form_structures.push_back(form_structure);
// Request with id 3.
- EXPECT_CALL(mock_metric_logger,
- LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1);
- EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures.get(),
- mock_metric_logger));
+ EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures.get()));
fetcher = factory.GetFetcherByID(3);
ASSERT_TRUE(fetcher);
+ histogram.ExpectUniqueSample("Autofill.ServerQueryResponse",
+ AutofillMetrics::QUERY_SENT, 2);
fetcher->set_backoff_delay(TestTimeouts::action_max_timeout());
FakeOnURLFetchComplete(fetcher, 500, std::string(responses[0]));
@@ -309,12 +300,11 @@ TEST_F(AutofillDownloadTest, QueryAndUploadTest) {
responses_.pop_front();
// Query requests should be ignored for the next 10 seconds.
- EXPECT_CALL(mock_metric_logger,
- LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(0);
- EXPECT_FALSE(download_manager_.StartQueryRequest(form_structures.get(),
- mock_metric_logger));
+ EXPECT_FALSE(download_manager_.StartQueryRequest(form_structures.get()));
fetcher = factory.GetFetcherByID(4);
EXPECT_EQ(NULL, fetcher);
+ histogram.ExpectUniqueSample("Autofill.ServerQueryResponse",
+ AutofillMetrics::QUERY_SENT, 2);
// Set upload required to true so requests happen.
form_structures[0]->upload_required_ = UPLOAD_REQUIRED;
@@ -403,12 +393,12 @@ TEST_F(AutofillDownloadTest, CacheQueryTest) {
"</autofillqueryresponse>",
};
+ base::HistogramTester histogram;
// Request with id 0.
- MockAutofillMetrics mock_metric_logger;
- EXPECT_CALL(mock_metric_logger,
- LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1);
- EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures0.get(),
- mock_metric_logger));
+ EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures0.get()));
+ histogram.ExpectUniqueSample("Autofill.ServerQueryResponse",
+ AutofillMetrics::QUERY_SENT, 1);
+
// No responses yet
EXPECT_EQ(static_cast<size_t>(0), responses_.size());
@@ -421,20 +411,18 @@ TEST_F(AutofillDownloadTest, CacheQueryTest) {
responses_.clear();
// No actual request - should be a cache hit.
- EXPECT_CALL(mock_metric_logger,
- LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1);
- EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures0.get(),
- mock_metric_logger));
+ EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures0.get()));
+ histogram.ExpectUniqueSample("Autofill.ServerQueryResponse",
+ AutofillMetrics::QUERY_SENT, 2);
// Data is available immediately from cache - no over-the-wire trip.
ASSERT_EQ(static_cast<size_t>(1), responses_.size());
EXPECT_EQ(responses[0], responses_.front().response);
responses_.clear();
// Request with id 1.
- EXPECT_CALL(mock_metric_logger,
- LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1);
- EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures1.get(),
- mock_metric_logger));
+ EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures1.get()));
+ histogram.ExpectUniqueSample("Autofill.ServerQueryResponse",
+ AutofillMetrics::QUERY_SENT, 3);
// No responses yet
EXPECT_EQ(static_cast<size_t>(0), responses_.size());
@@ -447,10 +435,9 @@ TEST_F(AutofillDownloadTest, CacheQueryTest) {
responses_.clear();
// Request with id 2.
- EXPECT_CALL(mock_metric_logger,
- LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1);
- EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures2.get(),
- mock_metric_logger));
+ EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures2.get()));
+ histogram.ExpectUniqueSample("Autofill.ServerQueryResponse",
+ AutofillMetrics::QUERY_SENT, 4);
fetcher = factory.GetFetcherByID(2);
ASSERT_TRUE(fetcher);
@@ -461,15 +448,13 @@ TEST_F(AutofillDownloadTest, CacheQueryTest) {
responses_.clear();
// No actual requests - should be a cache hit.
- EXPECT_CALL(mock_metric_logger,
- LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1);
- EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures1.get(),
- mock_metric_logger));
+ EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures1.get()));
+ histogram.ExpectUniqueSample("Autofill.ServerQueryResponse",
+ AutofillMetrics::QUERY_SENT, 5);
- EXPECT_CALL(mock_metric_logger,
- LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1);
- EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures2.get(),
- mock_metric_logger));
+ EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures2.get()));
+ histogram.ExpectUniqueSample("Autofill.ServerQueryResponse",
+ AutofillMetrics::QUERY_SENT, 6);
ASSERT_EQ(static_cast<size_t>(2), responses_.size());
EXPECT_EQ(responses[1], responses_.front().response);
@@ -478,10 +463,9 @@ TEST_F(AutofillDownloadTest, CacheQueryTest) {
// The first structure should've expired.
// Request with id 3.
- EXPECT_CALL(mock_metric_logger,
- LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1);
- EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures0.get(),
- mock_metric_logger));
+ EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures0.get()));
+ histogram.ExpectUniqueSample("Autofill.ServerQueryResponse",
+ AutofillMetrics::QUERY_SENT, 7);
// No responses yet
EXPECT_EQ(static_cast<size_t>(0), responses_.size());
diff --git a/components/autofill/core/browser/autofill_external_delegate.cc b/components/autofill/core/browser/autofill_external_delegate.cc
index 3827800..d058523 100644
--- a/components/autofill/core/browser/autofill_external_delegate.cc
+++ b/components/autofill/core/browser/autofill_external_delegate.cc
@@ -13,6 +13,7 @@
#include "components/autofill/core/browser/autocomplete_history_manager.h"
#include "components/autofill/core/browser/autofill_driver.h"
#include "components/autofill/core/browser/autofill_manager.h"
+#include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/browser/popup_item_ids.h"
#include "components/autofill/core/common/autofill_switches.h"
#include "grit/components_strings.h"
diff --git a/components/autofill/core/browser/autofill_external_delegate_unittest.cc b/components/autofill/core/browser/autofill_external_delegate_unittest.cc
index 6890162..6f907fd 100644
--- a/components/autofill/core/browser/autofill_external_delegate_unittest.cc
+++ b/components/autofill/core/browser/autofill_external_delegate_unittest.cc
@@ -11,6 +11,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/test/histogram_tester.h"
#include "components/autofill/core/browser/autofill_manager.h"
+#include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/browser/popup_item_ids.h"
#include "components/autofill/core/browser/suggestion_test_helpers.h"
#include "components/autofill/core/browser/test_autofill_client.h"
diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc
index ebb899b..8ba36f1 100644
--- a/components/autofill/core/browser/autofill_manager.cc
+++ b/components/autofill/core/browser/autofill_manager.cc
@@ -148,7 +148,6 @@ AutofillManager::AutofillManager(
personal_data_(client->GetPersonalDataManager()),
autocomplete_history_manager_(
new AutocompleteHistoryManager(driver, client)),
- metric_logger_(new AutofillMetrics),
has_logged_autofill_enabled_(false),
has_logged_address_suggestions_count_(false),
did_show_suggestions_(false),
@@ -384,7 +383,7 @@ void AutofillManager::OnFormsSeen(const std::vector<FormData>& forms,
bool enabled = IsAutofillEnabled();
if (!has_logged_autofill_enabled_) {
- metric_logger_->LogIsAutofillEnabledAtPageLoad(enabled);
+ AutofillMetrics::LogIsAutofillEnabledAtPageLoad(enabled);
has_logged_autofill_enabled_ = true;
}
@@ -411,17 +410,17 @@ void AutofillManager::OnTextFieldDidChange(const FormData& form,
if (!user_did_type_) {
user_did_type_ = true;
- metric_logger_->LogUserHappinessMetric(AutofillMetrics::USER_DID_TYPE);
+ AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::USER_DID_TYPE);
}
if (autofill_field->is_autofilled) {
autofill_field->is_autofilled = false;
- metric_logger_->LogUserHappinessMetric(
+ AutofillMetrics::LogUserHappinessMetric(
AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD);
if (!user_did_edit_autofilled_field_) {
user_did_edit_autofilled_field_ = true;
- metric_logger_->LogUserHappinessMetric(
+ AutofillMetrics::LogUserHappinessMetric(
AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD_ONCE);
}
}
@@ -497,7 +496,7 @@ void AutofillManager::OnQueryFormFieldAutofill(int query_id,
// The first time we show suggestions on this page, log the number of
// suggestions shown.
if (!has_logged_address_suggestions_count_ && !section_is_autofilled) {
- metric_logger_->LogAddressSuggestionsCount(suggestions.size());
+ AutofillMetrics::LogAddressSuggestionsCount(suggestions.size());
has_logged_address_suggestions_count_ = true;
}
}
@@ -568,10 +567,10 @@ void AutofillManager::OnDidFillAutofillFormData(const TimeTicks& timestamp) {
if (test_delegate_)
test_delegate_->DidFillFormData();
- metric_logger_->LogUserHappinessMetric(AutofillMetrics::USER_DID_AUTOFILL);
+ AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::USER_DID_AUTOFILL);
if (!user_did_autofill_) {
user_did_autofill_ = true;
- metric_logger_->LogUserHappinessMetric(
+ AutofillMetrics::LogUserHappinessMetric(
AutofillMetrics::USER_DID_AUTOFILL_ONCE);
}
@@ -583,11 +582,11 @@ void AutofillManager::DidShowSuggestions(bool is_new_popup) {
test_delegate_->DidShowSuggestions();
if (is_new_popup) {
- metric_logger_->LogUserHappinessMetric(AutofillMetrics::SUGGESTIONS_SHOWN);
+ AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::SUGGESTIONS_SHOWN);
if (!did_show_suggestions_) {
did_show_suggestions_ = true;
- metric_logger_->LogUserHappinessMetric(
+ AutofillMetrics::LogUserHappinessMetric(
AutofillMetrics::SUGGESTIONS_SHOWN_ONCE);
}
}
@@ -646,9 +645,7 @@ void AutofillManager::OnSetDataList(const std::vector<base::string16>& values,
void AutofillManager::OnLoadedServerPredictions(
const std::string& response_xml) {
// Parse and store the server predictions.
- FormStructure::ParseQueryResponse(response_xml,
- form_structures_.get(),
- *metric_logger_);
+ FormStructure::ParseQueryResponse(response_xml, form_structures_.get());
// Forward form structures to the password generation manager to detect
// account creation forms.
@@ -691,9 +688,7 @@ void AutofillManager::UploadFormDataAsyncCallback(
const TimeTicks& load_time,
const TimeTicks& interaction_time,
const TimeTicks& submission_time) {
- submitted_form->LogQualityMetrics(*metric_logger_,
- load_time,
- interaction_time,
+ submitted_form->LogQualityMetrics(load_time, interaction_time,
submission_time);
if (submitted_form->ShouldBeCrowdsourced())
@@ -789,7 +784,6 @@ AutofillManager::AutofillManager(AutofillDriver* driver,
personal_data_(personal_data),
autocomplete_history_manager_(
new AutocompleteHistoryManager(driver, client)),
- metric_logger_(new AutofillMetrics),
has_logged_autofill_enabled_(false),
has_logged_address_suggestions_count_(false),
did_show_suggestions_(false),
@@ -803,10 +797,6 @@ AutofillManager::AutofillManager(AutofillDriver* driver,
DCHECK(client_);
}
-void AutofillManager::set_metric_logger(const AutofillMetrics* metric_logger) {
- metric_logger_.reset(metric_logger);
-}
-
bool AutofillManager::RefreshDataModels() const {
if (!IsAutofillEnabled())
return false;
@@ -1072,7 +1062,7 @@ bool AutofillManager::UpdateCachedForm(const FormData& live_form,
// Add the new or updated form to our cache.
form_structures_.push_back(new FormStructure(live_form));
*updated_form = *form_structures_.rbegin();
- (*updated_form)->DetermineHeuristicTypes(*metric_logger_);
+ (*updated_form)->DetermineHeuristicTypes();
// If we have cached data, propagate it to the updated form.
if (cached_form) {
@@ -1152,7 +1142,7 @@ void AutofillManager::ParseForms(const std::vector<FormData>& forms) {
if (!form_structure->ShouldBeParsed())
continue;
- form_structure->DetermineHeuristicTypes(*metric_logger_);
+ form_structure->DetermineHeuristicTypes();
if (form_structure->ShouldBeCrowdsourced())
form_structures_.push_back(form_structure.release());
@@ -1162,8 +1152,7 @@ void AutofillManager::ParseForms(const std::vector<FormData>& forms) {
if (!form_structures_.empty() && download_manager_) {
// Query the server if at least one of the forms was parsed.
- download_manager_->StartQueryRequest(form_structures_.get(),
- *metric_logger_);
+ download_manager_->StartQueryRequest(form_structures_.get());
}
for (std::vector<FormStructure*>::const_iterator iter =
@@ -1173,7 +1162,7 @@ void AutofillManager::ParseForms(const std::vector<FormData>& forms) {
}
if (!form_structures_.empty())
- metric_logger_->LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED);
+ AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED);
// For the |non_queryable_forms|, we have all the field type info we're ever
// going to get about them. For the other forms, we'll wait until we get a
diff --git a/components/autofill/core/browser/autofill_manager.h b/components/autofill/core/browser/autofill_manager.h
index 20d2dd3..6fcd73e 100644
--- a/components/autofill/core/browser/autofill_manager.h
+++ b/components/autofill/core/browser/autofill_manager.h
@@ -44,7 +44,6 @@ class AutofillExternalDelegate;
class AutofillField;
class AutofillClient;
class AutofillManagerTestDelegate;
-class AutofillMetrics;
class AutofillProfile;
class AutofillType;
class CreditCard;
@@ -211,9 +210,6 @@ class AutofillManager : public AutofillDownloadManager::Observer {
SuggestionBackendID* cc_backend_id,
SuggestionBackendID* profile_backend_id) const;
- const AutofillMetrics* metric_logger() const { return metric_logger_.get(); }
- void set_metric_logger(const AutofillMetrics* metric_logger);
-
ScopedVector<FormStructure>* form_structures() { return &form_structures_; }
// Exposed for testing.
@@ -327,8 +323,6 @@ class AutofillManager : public AutofillDownloadManager::Observer {
// Handles single-field autocomplete form data.
scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager_;
- // For logging UMA metrics. Overridden by metrics tests.
- scoped_ptr<const AutofillMetrics> metric_logger_;
// Have we logged whether Autofill is enabled for this page load?
bool has_logged_autofill_enabled_;
// Have we logged an address suggestions count metric for this page?
diff --git a/components/autofill/core/browser/autofill_manager_unittest.cc b/components/autofill/core/browser/autofill_manager_unittest.cc
index 33a3b65..a74a13c 100644
--- a/components/autofill/core/browser/autofill_manager_unittest.cc
+++ b/components/autofill/core/browser/autofill_manager_unittest.cc
@@ -21,7 +21,6 @@
#include "base/time/time.h"
#include "components/autofill/core/browser/autocomplete_history_manager.h"
#include "components/autofill/core/browser/autofill_manager.h"
-#include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/browser/autofill_profile.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/credit_card.h"
@@ -2359,8 +2358,7 @@ TEST_F(AutofillManagerTest, FormSubmittedServerTypes) {
// Simulate having seen this form on page load.
// |form_structure| will be owned by |autofill_manager_|.
TestFormStructure* form_structure = new TestFormStructure(form);
- AutofillMetrics metrics_logger; // ignored
- form_structure->DetermineHeuristicTypes(metrics_logger);
+ form_structure->DetermineHeuristicTypes();
// Clear the heuristic types, and instead set the appropriate server types.
std::vector<ServerFieldType> heuristic_types, server_types;
diff --git a/components/autofill/core/browser/autofill_metrics.cc b/components/autofill/core/browser/autofill_metrics.cc
index 8044c32..21ca9f8 100644
--- a/components/autofill/core/browser/autofill_metrics.cc
+++ b/components/autofill/core/browser/autofill_metrics.cc
@@ -259,12 +259,6 @@ void LogTypeQualityMetric(const std::string& base_name,
} // namespace
-AutofillMetrics::AutofillMetrics() {
-}
-
-AutofillMetrics::~AutofillMetrics() {
-}
-
// static
void AutofillMetrics::LogCreditCardInfoBarMetric(InfoBarMetric metric) {
DCHECK_LT(metric, NUM_INFO_BAR_METRICS);
@@ -369,45 +363,49 @@ void AutofillMetrics::LogWalletResponseCode(int response_code) {
UMA_HISTOGRAM_SPARSE_SLOWLY("Wallet.ResponseCode", response_code);
}
+// static
void AutofillMetrics::LogDeveloperEngagementMetric(
- DeveloperEngagementMetric metric) const {
+ DeveloperEngagementMetric metric) {
DCHECK_LT(metric, NUM_DEVELOPER_ENGAGEMENT_METRICS);
UMA_HISTOGRAM_ENUMERATION("Autofill.DeveloperEngagement", metric,
NUM_DEVELOPER_ENGAGEMENT_METRICS);
}
-void AutofillMetrics::LogHeuristicTypePrediction(
- FieldTypeQualityMetric metric,
- ServerFieldType field_type) const {
+// static
+void AutofillMetrics::LogHeuristicTypePrediction(FieldTypeQualityMetric metric,
+ ServerFieldType field_type) {
LogTypeQualityMetric("Autofill.Quality.HeuristicType", metric, field_type);
}
-void AutofillMetrics::LogOverallTypePrediction(
- FieldTypeQualityMetric metric,
- ServerFieldType field_type) const {
+// static
+void AutofillMetrics::LogOverallTypePrediction(FieldTypeQualityMetric metric,
+ ServerFieldType field_type) {
LogTypeQualityMetric("Autofill.Quality.PredictedType", metric, field_type);
}
-void AutofillMetrics::LogServerTypePrediction(
- FieldTypeQualityMetric metric,
- ServerFieldType field_type) const {
+// static
+void AutofillMetrics::LogServerTypePrediction(FieldTypeQualityMetric metric,
+ ServerFieldType field_type) {
LogTypeQualityMetric("Autofill.Quality.ServerType", metric, field_type);
}
-void AutofillMetrics::LogServerQueryMetric(ServerQueryMetric metric) const {
+// static
+void AutofillMetrics::LogServerQueryMetric(ServerQueryMetric metric) {
DCHECK_LT(metric, NUM_SERVER_QUERY_METRICS);
UMA_HISTOGRAM_ENUMERATION("Autofill.ServerQueryResponse", metric,
NUM_SERVER_QUERY_METRICS);
}
-void AutofillMetrics::LogUserHappinessMetric(UserHappinessMetric metric) const {
+// static
+void AutofillMetrics::LogUserHappinessMetric(UserHappinessMetric metric) {
DCHECK_LT(metric, NUM_USER_HAPPINESS_METRICS);
UMA_HISTOGRAM_ENUMERATION("Autofill.UserHappiness", metric,
NUM_USER_HAPPINESS_METRICS);
}
+// static
void AutofillMetrics::LogFormFillDurationFromLoadWithAutofill(
- const base::TimeDelta& duration) const {
+ const base::TimeDelta& duration) {
UMA_HISTOGRAM_CUSTOM_TIMES("Autofill.FillDuration.FromLoad.WithAutofill",
duration,
base::TimeDelta::FromMilliseconds(100),
@@ -415,8 +413,9 @@ void AutofillMetrics::LogFormFillDurationFromLoadWithAutofill(
50);
}
+// static
void AutofillMetrics::LogFormFillDurationFromLoadWithoutAutofill(
- const base::TimeDelta& duration) const {
+ const base::TimeDelta& duration) {
UMA_HISTOGRAM_CUSTOM_TIMES("Autofill.FillDuration.FromLoad.WithoutAutofill",
duration,
base::TimeDelta::FromMilliseconds(100),
@@ -424,8 +423,9 @@ void AutofillMetrics::LogFormFillDurationFromLoadWithoutAutofill(
50);
}
+// static
void AutofillMetrics::LogFormFillDurationFromInteractionWithAutofill(
- const base::TimeDelta& duration) const {
+ const base::TimeDelta& duration) {
UMA_HISTOGRAM_CUSTOM_TIMES(
"Autofill.FillDuration.FromInteraction.WithAutofill",
duration,
@@ -434,8 +434,9 @@ void AutofillMetrics::LogFormFillDurationFromInteractionWithAutofill(
50);
}
+// static
void AutofillMetrics::LogFormFillDurationFromInteractionWithoutAutofill(
- const base::TimeDelta& duration) const {
+ const base::TimeDelta& duration) {
UMA_HISTOGRAM_CUSTOM_TIMES(
"Autofill.FillDuration.FromInteraction.WithoutAutofill",
duration,
@@ -444,19 +445,23 @@ void AutofillMetrics::LogFormFillDurationFromInteractionWithoutAutofill(
50);
}
-void AutofillMetrics::LogIsAutofillEnabledAtStartup(bool enabled) const {
+// static
+void AutofillMetrics::LogIsAutofillEnabledAtStartup(bool enabled) {
UMA_HISTOGRAM_BOOLEAN("Autofill.IsEnabled.Startup", enabled);
}
-void AutofillMetrics::LogIsAutofillEnabledAtPageLoad(bool enabled) const {
+// static
+void AutofillMetrics::LogIsAutofillEnabledAtPageLoad(bool enabled) {
UMA_HISTOGRAM_BOOLEAN("Autofill.IsEnabled.PageLoad", enabled);
}
-void AutofillMetrics::LogStoredProfileCount(size_t num_profiles) const {
+// static
+void AutofillMetrics::LogStoredProfileCount(size_t num_profiles) {
UMA_HISTOGRAM_COUNTS("Autofill.StoredProfileCount", num_profiles);
}
-void AutofillMetrics::LogAddressSuggestionsCount(size_t num_suggestions) const {
+// static
+void AutofillMetrics::LogAddressSuggestionsCount(size_t num_suggestions) {
UMA_HISTOGRAM_COUNTS("Autofill.AddressSuggestionsCount", num_suggestions);
}
diff --git a/components/autofill/core/browser/autofill_metrics.h b/components/autofill/core/browser/autofill_metrics.h
index f1c60d2..92539ba 100644
--- a/components/autofill/core/browser/autofill_metrics.h
+++ b/components/autofill/core/browser/autofill_metrics.h
@@ -318,25 +318,21 @@ class AutofillMetrics {
NUM_WALLET_REQUIRED_ACTIONS
};
- AutofillMetrics();
- virtual ~AutofillMetrics();
-
static void LogCreditCardInfoBarMetric(InfoBarMetric metric);
static void LogScanCreditCardPromptMetric(ScanCreditCardPromptMetric metric);
- virtual void LogDeveloperEngagementMetric(
- DeveloperEngagementMetric metric) const;
+ static void LogDeveloperEngagementMetric(DeveloperEngagementMetric metric);
- virtual void LogHeuristicTypePrediction(FieldTypeQualityMetric metric,
- ServerFieldType field_type) const;
- virtual void LogOverallTypePrediction(FieldTypeQualityMetric metric,
- ServerFieldType field_type) const;
- virtual void LogServerTypePrediction(FieldTypeQualityMetric metric,
- ServerFieldType field_type) const;
+ static void LogHeuristicTypePrediction(FieldTypeQualityMetric metric,
+ ServerFieldType field_type);
+ static void LogOverallTypePrediction(FieldTypeQualityMetric metric,
+ ServerFieldType field_type);
+ static void LogServerTypePrediction(FieldTypeQualityMetric metric,
+ ServerFieldType field_type);
- virtual void LogServerQueryMetric(ServerQueryMetric metric) const;
+ static void LogServerQueryMetric(ServerQueryMetric metric);
- virtual void LogUserHappinessMetric(UserHappinessMetric metric) const;
+ static void LogUserHappinessMetric(UserHappinessMetric metric);
// Logs |state| to the dismissal states histogram.
static void LogDialogDismissalState(DialogDismissalState state);
@@ -385,42 +381,42 @@ class AutofillMetrics {
// This should be called when a form that has been Autofilled is submitted.
// |duration| should be the time elapsed between form load and submission.
- virtual void LogFormFillDurationFromLoadWithAutofill(
- const base::TimeDelta& duration) const;
+ static void LogFormFillDurationFromLoadWithAutofill(
+ const base::TimeDelta& duration);
// This should be called when a fillable form that has not been Autofilled is
// submitted. |duration| should be the time elapsed between form load and
// submission.
- virtual void LogFormFillDurationFromLoadWithoutAutofill(
- const base::TimeDelta& duration) const;
+ static void LogFormFillDurationFromLoadWithoutAutofill(
+ const base::TimeDelta& duration);
// This should be called when a form that has been Autofilled is submitted.
// |duration| should be the time elapsed between the initial form interaction
// and submission.
- virtual void LogFormFillDurationFromInteractionWithAutofill(
- const base::TimeDelta& duration) const;
+ static void LogFormFillDurationFromInteractionWithAutofill(
+ const base::TimeDelta& duration);
// This should be called when a fillable form that has not been Autofilled is
// submitted. |duration| should be the time elapsed between the initial form
// interaction and submission.
- virtual void LogFormFillDurationFromInteractionWithoutAutofill(
- const base::TimeDelta& duration) const;
+ static void LogFormFillDurationFromInteractionWithoutAutofill(
+ const base::TimeDelta& duration);
// This should be called each time a page containing forms is loaded.
- virtual void LogIsAutofillEnabledAtPageLoad(bool enabled) const;
+ static void LogIsAutofillEnabledAtPageLoad(bool enabled);
// This should be called each time a new profile is launched.
- virtual void LogIsAutofillEnabledAtStartup(bool enabled) const;
+ static void LogIsAutofillEnabledAtStartup(bool enabled);
// This should be called each time a new profile is launched.
- virtual void LogStoredProfileCount(size_t num_profiles) const;
+ static void LogStoredProfileCount(size_t num_profiles);
// Log the number of Autofill suggestions presented to the user when filling a
// form.
- virtual void LogAddressSuggestionsCount(size_t num_suggestions) const;
+ static void LogAddressSuggestionsCount(size_t num_suggestions);
private:
- DISALLOW_COPY_AND_ASSIGN(AutofillMetrics);
+ DISALLOW_IMPLICIT_CONSTRUCTORS(AutofillMetrics);
};
} // namespace autofill
diff --git a/components/autofill/core/browser/form_structure.cc b/components/autofill/core/browser/form_structure.cc
index daaad18..b5cfd5e 100644
--- a/components/autofill/core/browser/form_structure.cc
+++ b/components/autofill/core/browser/form_structure.cc
@@ -386,8 +386,7 @@ FormStructure::FormStructure(const FormData& form)
FormStructure::~FormStructure() {}
-void FormStructure::DetermineHeuristicTypes(
- const AutofillMetrics& metric_logger) {
+void FormStructure::DetermineHeuristicTypes() {
// First, try to detect field types based on each field's |autocomplete|
// attribute value. If there is at least one form field that specifies an
// autocomplete type hint, don't try to apply other heuristics to match fields
@@ -412,10 +411,10 @@ void FormStructure::DetermineHeuristicTypes(
IdentifySections(has_author_specified_sections);
if (IsAutofillable()) {
- metric_logger.LogDeveloperEngagementMetric(
+ AutofillMetrics::LogDeveloperEngagementMetric(
AutofillMetrics::FILLABLE_FORM_PARSED);
if (has_author_specified_types_) {
- metric_logger.LogDeveloperEngagementMetric(
+ AutofillMetrics::LogDeveloperEngagementMetric(
AutofillMetrics::FILLABLE_FORM_CONTAINS_TYPE_HINTS);
}
}
@@ -546,9 +545,9 @@ bool FormStructure::EncodeQueryRequest(
// static
void FormStructure::ParseQueryResponse(
const std::string& response_xml,
- const std::vector<FormStructure*>& forms,
- const AutofillMetrics& metric_logger) {
- metric_logger.LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_RECEIVED);
+ const std::vector<FormStructure*>& forms) {
+ AutofillMetrics::LogServerQueryMetric(
+ AutofillMetrics::QUERY_RESPONSE_RECEIVED);
// Parse the field types from the server response to the query.
std::vector<AutofillServerFieldInfo> field_infos;
@@ -560,7 +559,7 @@ void FormStructure::ParseQueryResponse(
if (!parse_handler.succeeded())
return;
- metric_logger.LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_PARSED);
+ AutofillMetrics::LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_PARSED);
bool heuristics_detected_fillable_field = false;
bool query_response_overrode_heuristics = false;
@@ -620,7 +619,7 @@ void FormStructure::ParseQueryResponse(
} else {
metric = AutofillMetrics::QUERY_RESPONSE_MATCHED_LOCAL_HEURISTICS;
}
- metric_logger.LogServerQueryMetric(metric);
+ AutofillMetrics::LogServerQueryMetric(metric);
}
// static
@@ -760,7 +759,6 @@ void FormStructure::UpdateFromCache(const FormStructure& cached_form) {
}
void FormStructure::LogQualityMetrics(
- const AutofillMetrics& metric_logger,
const base::TimeTicks& load_time,
const base::TimeTicks& interaction_time,
const base::TimeTicks& submission_time) const {
@@ -819,51 +817,51 @@ void FormStructure::LogQualityMetrics(
// Log heuristic, server, and overall type quality metrics, independently of
// whether the field was autofilled.
if (heuristic_type == UNKNOWN_TYPE) {
- metric_logger.LogHeuristicTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
- field_type);
+ AutofillMetrics::LogHeuristicTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
+ field_type);
} else if (field_types.count(heuristic_type)) {
- metric_logger.LogHeuristicTypePrediction(AutofillMetrics::TYPE_MATCH,
- field_type);
+ AutofillMetrics::LogHeuristicTypePrediction(AutofillMetrics::TYPE_MATCH,
+ field_type);
} else {
- metric_logger.LogHeuristicTypePrediction(AutofillMetrics::TYPE_MISMATCH,
- field_type);
+ AutofillMetrics::LogHeuristicTypePrediction(
+ AutofillMetrics::TYPE_MISMATCH, field_type);
}
if (server_type == NO_SERVER_DATA) {
- metric_logger.LogServerTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
- field_type);
+ AutofillMetrics::LogServerTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
+ field_type);
} else if (field_types.count(server_type)) {
- metric_logger.LogServerTypePrediction(AutofillMetrics::TYPE_MATCH,
- field_type);
+ AutofillMetrics::LogServerTypePrediction(AutofillMetrics::TYPE_MATCH,
+ field_type);
} else {
- metric_logger.LogServerTypePrediction(AutofillMetrics::TYPE_MISMATCH,
- field_type);
+ AutofillMetrics::LogServerTypePrediction(AutofillMetrics::TYPE_MISMATCH,
+ field_type);
}
if (predicted_type == UNKNOWN_TYPE) {
- metric_logger.LogOverallTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
- field_type);
+ AutofillMetrics::LogOverallTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
+ field_type);
} else if (field_types.count(predicted_type)) {
- metric_logger.LogOverallTypePrediction(AutofillMetrics::TYPE_MATCH,
- field_type);
+ AutofillMetrics::LogOverallTypePrediction(AutofillMetrics::TYPE_MATCH,
+ field_type);
} else {
- metric_logger.LogOverallTypePrediction(AutofillMetrics::TYPE_MISMATCH,
- field_type);
+ AutofillMetrics::LogOverallTypePrediction(AutofillMetrics::TYPE_MISMATCH,
+ field_type);
}
}
if (num_detected_field_types < kRequiredAutofillFields) {
- metric_logger.LogUserHappinessMetric(
+ AutofillMetrics::LogUserHappinessMetric(
AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM);
} else {
if (did_autofill_all_possible_fields) {
- metric_logger.LogUserHappinessMetric(
+ AutofillMetrics::LogUserHappinessMetric(
AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_ALL);
} else if (did_autofill_some_possible_fields) {
- metric_logger.LogUserHappinessMetric(
+ AutofillMetrics::LogUserHappinessMetric(
AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_SOME);
} else {
- metric_logger.LogUserHappinessMetric(
+ AutofillMetrics::LogUserHappinessMetric(
AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_NONE);
}
@@ -877,9 +875,9 @@ void FormStructure::LogQualityMetrics(
DCHECK(submission_time > load_time);
base::TimeDelta elapsed = submission_time - load_time;
if (did_autofill_some_possible_fields)
- metric_logger.LogFormFillDurationFromLoadWithAutofill(elapsed);
+ AutofillMetrics::LogFormFillDurationFromLoadWithAutofill(elapsed);
else
- metric_logger.LogFormFillDurationFromLoadWithoutAutofill(elapsed);
+ AutofillMetrics::LogFormFillDurationFromLoadWithoutAutofill(elapsed);
}
// The |interaction_time| might be unset, in the case that the user
@@ -889,9 +887,10 @@ void FormStructure::LogQualityMetrics(
DCHECK(submission_time > interaction_time);
base::TimeDelta elapsed = submission_time - interaction_time;
if (did_autofill_some_possible_fields) {
- metric_logger.LogFormFillDurationFromInteractionWithAutofill(elapsed);
+ AutofillMetrics::LogFormFillDurationFromInteractionWithAutofill(
+ elapsed);
} else {
- metric_logger.LogFormFillDurationFromInteractionWithoutAutofill(
+ AutofillMetrics::LogFormFillDurationFromInteractionWithoutAutofill(
elapsed);
}
}
diff --git a/components/autofill/core/browser/form_structure.h b/components/autofill/core/browser/form_structure.h
index d2bdb7e..e936210 100644
--- a/components/autofill/core/browser/form_structure.h
+++ b/components/autofill/core/browser/form_structure.h
@@ -36,8 +36,6 @@ class XmlElement;
namespace autofill {
-class AutofillMetrics;
-
struct FormData;
struct FormDataPredictions;
@@ -50,7 +48,7 @@ class FormStructure {
// Runs several heuristics against the form fields to determine their possible
// types.
- void DetermineHeuristicTypes(const AutofillMetrics& metric_logger);
+ void DetermineHeuristicTypes();
// Encodes the XML upload request from this FormStructure.
bool EncodeUploadRequest(const ServerFieldTypeSet& available_field_types,
@@ -75,10 +73,8 @@ class FormStructure {
// Parses the field types from the server query response. |forms| must be the
// same as the one passed to EncodeQueryRequest when constructing the query.
- static void ParseQueryResponse(
- const std::string& response_xml,
- const std::vector<FormStructure*>& forms,
- const AutofillMetrics& metric_logger);
+ static void ParseQueryResponse(const std::string& response_xml,
+ const std::vector<FormStructure*>& forms);
// Fills |forms| with the details from the given |form_structures| and their
// fields' predicted types.
@@ -120,8 +116,7 @@ class FormStructure {
// set for each field. |interaction_time| should be a timestamp corresponding
// to the user's first interaction with the form. |submission_time| should be
// a timestamp corresponding to the form's submission.
- void LogQualityMetrics(const AutofillMetrics& metric_logger,
- const base::TimeTicks& load_time,
+ void LogQualityMetrics(const base::TimeTicks& load_time,
const base::TimeTicks& interaction_time,
const base::TimeTicks& submission_time) const;
diff --git a/components/autofill/core/browser/form_structure_unittest.cc b/components/autofill/core/browser/form_structure_unittest.cc
index e897d05..4ad21eb 100644
--- a/components/autofill/core/browser/form_structure_unittest.cc
+++ b/components/autofill/core/browser/form_structure_unittest.cc
@@ -8,7 +8,6 @@
#include "base/memory/scoped_ptr.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
-#include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/common/autofill_switches.h"
#include "components/autofill/core/common/form_data.h"
#include "components/autofill/core/common/form_field_data.h"
@@ -18,19 +17,6 @@
using base::ASCIIToUTF16;
namespace autofill {
-namespace {
-
-// Unlike the base AutofillMetrics, exposes copy and assignment constructors,
-// which are handy for briefer test code. The AutofillMetrics class is
-// stateless, so this is safe.
-class TestAutofillMetrics : public AutofillMetrics {
- public:
- TestAutofillMetrics() {}
- ~TestAutofillMetrics() override {}
-};
-
-} // anonymous namespace
-
namespace content {
@@ -120,7 +106,7 @@ TEST(FormStructureTest, AutofillCount) {
// Only text and select fields that are heuristically matched are counted.
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_EQ(1U, form_structure->autofill_count());
// Add a field with should_autocomplete=false. This should not be considered a
@@ -132,14 +118,14 @@ TEST(FormStructureTest, AutofillCount) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_EQ(2U, form_structure->autofill_count());
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kRespectAutocompleteOffForAutofill);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_EQ(1U, form_structure->autofill_count());
}
@@ -174,7 +160,7 @@ TEST(FormStructureTest, IsAutofillable) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_FALSE(form_structure->IsAutofillable());
// We now have three text fields, but only two auto-fillable fields.
@@ -189,7 +175,7 @@ TEST(FormStructureTest, IsAutofillable) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_FALSE(form_structure->IsAutofillable());
// We now have three auto-fillable fields.
@@ -199,19 +185,19 @@ TEST(FormStructureTest, IsAutofillable) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_TRUE(form_structure->IsAutofillable());
// The target cannot include http(s)://*/search...
form.action = GURL("http://google.com/search?q=hello");
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_FALSE(form_structure->IsAutofillable());
// But search can be in the URL.
form.action = GURL("http://search.com/?q=hello");
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_TRUE(form_structure->IsAutofillable());
}
@@ -337,7 +323,7 @@ TEST(FormStructureTest, HeuristicsContactInfo) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_TRUE(form_structure->IsAutofillable());
// Expect the correct number of fields.
@@ -387,7 +373,7 @@ TEST(FormStructureTest, HeuristicsAutocompleteAttribute) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_TRUE(form_structure->IsAutofillable());
// Expect the correct number of fields.
@@ -427,7 +413,7 @@ TEST(FormStructureTest, HeuristicsAutocompleteAttributePhoneTypes) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_TRUE(form_structure->IsAutofillable());
// Expect the correct number of fields.
@@ -467,7 +453,7 @@ TEST(FormStructureTest, AutocompleteAttributeOverridesOtherHeuristics) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_TRUE(form_structure->IsAutofillable());
EXPECT_TRUE(form_structure->ShouldBeCrowdsourced());
@@ -481,7 +467,7 @@ TEST(FormStructureTest, AutocompleteAttributeOverridesOtherHeuristics) {
// Now update the first form field to include an 'autocomplete' attribute.
form.fields.front().autocomplete_attribute = "x-other";
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_FALSE(form_structure->IsAutofillable());
EXPECT_FALSE(form_structure->ShouldBeCrowdsourced());
@@ -523,7 +509,7 @@ TEST(FormStructureTest, PasswordFormShouldBeCrowdsourced) {
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
EXPECT_TRUE(form_structure.ShouldBeCrowdsourced());
}
@@ -574,7 +560,7 @@ TEST(FormStructureTest, HeuristicsAutocompleteAttributeWithSections) {
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
EXPECT_TRUE(form_structure.IsAutofillable());
// Expect the correct number of fields.
@@ -618,7 +604,7 @@ TEST(FormStructureTest, HeuristicsAutocompleteAttributeWithSectionsDegenerate) {
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
// Expect the correct number of fields.
ASSERT_EQ(6U, form_structure.field_count());
@@ -647,7 +633,7 @@ TEST(FormStructureTest, HeuristicsAutocompleteAttributeWithSectionsRepeated) {
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
// Expect the correct number of fields.
ASSERT_EQ(2U, form_structure.field_count());
@@ -684,7 +670,7 @@ TEST(FormStructureTest, HeuristicsDontOverrideAutocompleteAttributeSections) {
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
// Expect the correct number of fields.
ASSERT_EQ(4U, form_structure.field_count());
@@ -748,7 +734,7 @@ TEST(FormStructureTest, HeuristicsSample8) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(10U, form_structure->field_count());
ASSERT_EQ(9U, form_structure->autofill_count());
@@ -814,7 +800,7 @@ TEST(FormStructureTest, HeuristicsSample6) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(7U, form_structure->field_count());
ASSERT_EQ(6U, form_structure->autofill_count());
@@ -879,7 +865,7 @@ TEST(FormStructureTest, HeuristicsLabelsOnly) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(8U, form_structure->field_count());
ASSERT_EQ(7U, form_structure->autofill_count());
@@ -936,7 +922,7 @@ TEST(FormStructureTest, HeuristicsCreditCardInfo) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(6U, form_structure->field_count());
ASSERT_EQ(5U, form_structure->autofill_count());
@@ -996,7 +982,7 @@ TEST(FormStructureTest, HeuristicsCreditCardInfoWithUnknownCardField) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(7U, form_structure->field_count());
ASSERT_EQ(5U, form_structure->autofill_count());
@@ -1043,7 +1029,7 @@ TEST(FormStructureTest, ThreeAddressLines) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(4U, form_structure->field_count());
ASSERT_EQ(4U, form_structure->autofill_count());
@@ -1083,7 +1069,7 @@ TEST(FormStructureTest, SurplusAddressLinesIgnored) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
ASSERT_EQ(4U, form_structure->field_count());
ASSERT_EQ(3U, form_structure->autofill_count());
@@ -1126,7 +1112,7 @@ TEST(FormStructureTest, ThreeAddressLinesExpedia) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(4U, form_structure->field_count());
EXPECT_EQ(4U, form_structure->autofill_count());
@@ -1164,7 +1150,7 @@ TEST(FormStructureTest, TwoAddressLinesEbay) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(3U, form_structure->field_count());
ASSERT_EQ(3U, form_structure->autofill_count());
@@ -1197,7 +1183,7 @@ TEST(FormStructureTest, HeuristicsStateWithProvince) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(3U, form_structure->field_count());
ASSERT_EQ(3U, form_structure->autofill_count());
@@ -1263,7 +1249,7 @@ TEST(FormStructureTest, HeuristicsWithBilling) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(11U, form_structure->field_count());
ASSERT_EQ(11U, form_structure->autofill_count());
@@ -1312,7 +1298,7 @@ TEST(FormStructureTest, ThreePartPhoneNumber) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_TRUE(form_structure->IsAutofillable());
ASSERT_EQ(4U, form_structure->field_count());
ASSERT_EQ(3U, form_structure->autofill_count());
@@ -1357,7 +1343,7 @@ TEST(FormStructureTest, HeuristicsInfernoCC) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_TRUE(form_structure->IsAutofillable());
// Expect the correct number of fields.
@@ -1409,7 +1395,7 @@ TEST(FormStructureTest, CVCCodeClash) {
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
EXPECT_TRUE(form_structure->IsAutofillable());
// Expect the correct number of fields.
@@ -1570,7 +1556,7 @@ TEST(FormStructureTest, EncodeUploadRequest) {
std::vector<ServerFieldTypeSet> possible_field_types;
FormData form;
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
FormFieldData field;
field.form_control_type = "text";
@@ -1727,7 +1713,7 @@ TEST(FormStructureTest, EncodeFieldAssignments) {
std::vector<ServerFieldTypeSet> possible_field_types;
FormData form;
form_structure.reset(new FormStructure(form));
- form_structure->DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure->DetermineHeuristicTypes();
FormFieldData field;
field.form_control_type = "text";
@@ -2432,9 +2418,7 @@ TEST(FormStructureTest, ParseQueryResponse) {
"<field autofilltype=\"0\" />"
"</autofillqueryresponse>";
- FormStructure::ParseQueryResponse(response,
- forms.get(),
- TestAutofillMetrics());
+ FormStructure::ParseQueryResponse(response, forms.get());
EXPECT_EQ(7, forms[0]->field(0)->server_type());
EXPECT_EQ(30, forms[0]->field(1)->server_type());
@@ -2461,7 +2445,7 @@ TEST(FormStructureTest, ParseQueryResponseAuthorDefinedTypes) {
ScopedVector<FormStructure> forms;
forms.push_back(new FormStructure(form));
- forms.front()->DetermineHeuristicTypes(TestAutofillMetrics());
+ forms.front()->DetermineHeuristicTypes();
std::string response =
"<autofillqueryresponse>"
@@ -2469,9 +2453,7 @@ TEST(FormStructureTest, ParseQueryResponseAuthorDefinedTypes) {
"<field autofilltype=\"76\" />"
"</autofillqueryresponse>";
- FormStructure::ParseQueryResponse(response,
- forms.get(),
- TestAutofillMetrics());
+ FormStructure::ParseQueryResponse(response, forms.get());
EXPECT_EQ(NO_SERVER_DATA, forms[0]->field(0)->server_type());
EXPECT_EQ(76, forms[0]->field(1)->server_type());
diff --git a/components/autofill/core/browser/personal_data_manager.cc b/components/autofill/core/browser/personal_data_manager.cc
index 5fd2da7..9fc0b63 100644
--- a/components/autofill/core/browser/personal_data_manager.cc
+++ b/components/autofill/core/browser/personal_data_manager.cc
@@ -19,6 +19,7 @@
#include "components/autofill/core/browser/autofill-inl.h"
#include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/autofill_field.h"
+#include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/browser/form_structure.h"
#include "components/autofill/core/browser/personal_data_manager_observer.h"
#include "components/autofill/core/browser/phone_number.h"
@@ -152,7 +153,6 @@ PersonalDataManager::PersonalDataManager(const std::string& app_locale)
pending_profiles_query_(0),
pending_creditcards_query_(0),
app_locale_(app_locale),
- metric_logger_(new AutofillMetrics),
pref_service_(NULL),
is_off_the_record_(false),
has_logged_profile_count_(false) {}
@@ -165,7 +165,7 @@ void PersonalDataManager::Init(scoped_refptr<AutofillWebDataService> database,
is_off_the_record_ = is_off_the_record;
if (!is_off_the_record_)
- metric_logger_->LogIsAutofillEnabledAtStartup(IsAutofillEnabled());
+ AutofillMetrics::LogIsAutofillEnabledAtStartup(IsAutofillEnabled());
// WebDataService may not be available in tests.
if (!database_.get())
@@ -1037,7 +1037,7 @@ std::string PersonalDataManager::SaveImportedCreditCard(
void PersonalDataManager::LogProfileCount() const {
if (!has_logged_profile_count_) {
- metric_logger_->LogStoredProfileCount(web_profiles_.size());
+ AutofillMetrics::LogStoredProfileCount(web_profiles_.size());
has_logged_profile_count_ = true;
}
}
diff --git a/components/autofill/core/browser/personal_data_manager.h b/components/autofill/core/browser/personal_data_manager.h
index 10900e0..2f6b926 100644
--- a/components/autofill/core/browser/personal_data_manager.h
+++ b/components/autofill/core/browser/personal_data_manager.h
@@ -14,7 +14,6 @@
#include "base/observer_list.h"
#include "base/prefs/pref_member.h"
#include "base/strings/string16.h"
-#include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/browser/autofill_profile.h"
#include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/field_types.h"
@@ -286,17 +285,10 @@ class PersonalDataManager : public KeyedService,
// this class and must outlive |this|.
void SetPrefService(PrefService* pref_service);
- // For tests.
- const AutofillMetrics* metric_logger() const { return metric_logger_.get(); }
-
void set_database(scoped_refptr<AutofillWebDataService> database) {
database_ = database;
}
- void set_metric_logger(const AutofillMetrics* metric_logger) {
- metric_logger_.reset(metric_logger);
- }
-
// The backing database that this PersonalDataManager uses.
scoped_refptr<AutofillWebDataService> database_;
@@ -345,9 +337,6 @@ class PersonalDataManager : public KeyedService,
// The default country code for new addresses.
mutable std::string default_country_code_;
- // For logging UMA metrics. Overridden by metrics tests.
- scoped_ptr<const AutofillMetrics> metric_logger_;
-
// The PrefService that this instance uses. Must outlive this instance.
PrefService* pref_service_;
diff --git a/components/autofill/core/browser/personal_data_manager_unittest.cc b/components/autofill/core/browser/personal_data_manager_unittest.cc
index a5415ce..98f04a7 100644
--- a/components/autofill/core/browser/personal_data_manager_unittest.cc
+++ b/components/autofill/core/browser/personal_data_manager_unittest.cc
@@ -14,7 +14,6 @@
#include "base/prefs/pref_service.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/waitable_event.h"
-#include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/browser/autofill_profile.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/form_structure.h"
@@ -48,15 +47,6 @@ class PersonalDataLoadedObserverMock : public PersonalDataManagerObserver {
MOCK_METHOD0(OnPersonalDataChanged, void());
};
-// Unlike the base AutofillMetrics, exposes copy and assignment constructors,
-// which are handy for briefer test code. The AutofillMetrics class is
-// stateless, so this is safe.
-class TestAutofillMetrics : public AutofillMetrics {
- public:
- TestAutofillMetrics() {}
- ~TestAutofillMetrics() override {}
-};
-
template <typename T>
bool CompareElements(T* a, T* b) {
return a->Compare(*b) < 0;
@@ -611,7 +601,7 @@ TEST_F(PersonalDataManagerTest, ImportFormData) {
test::CreateTestFormField("Zip:", "zip", "94102", "text", &field);
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure,
&imported_credit_card));
@@ -652,7 +642,7 @@ TEST_F(PersonalDataManagerTest, ImportFormDataBadEmail) {
test::CreateTestFormField("Zip:", "zip", "94102", "text", &field);
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_FALSE(personal_data_->ImportFormData(form_structure,
&imported_credit_card));
@@ -685,7 +675,7 @@ TEST_F(PersonalDataManagerTest, ImportFormDataTwoEmails) {
"Confirm email:", "confirm_email", "example@example.com", "text", &field);
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure,
&imported_credit_card));
@@ -716,7 +706,7 @@ TEST_F(PersonalDataManagerTest, ImportFormDataTwoDifferentEmails) {
"Email:", "email2", "example2@example.com", "text", &field);
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_FALSE(personal_data_->ImportFormData(form_structure,
&imported_credit_card));
@@ -737,7 +727,7 @@ TEST_F(PersonalDataManagerTest, ImportFormDataNotEnoughFilledFields) {
"Card number:", "card_number", "4111 1111 1111 1111", "text", &field);
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_FALSE(personal_data_->ImportFormData(form_structure,
&imported_credit_card));
@@ -768,7 +758,7 @@ TEST_F(PersonalDataManagerTest, ImportFormMinimumAddressUSA) {
test::CreateTestFormField("Country:", "country", "USA", "text", &field);
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure,
&imported_credit_card));
@@ -795,7 +785,7 @@ TEST_F(PersonalDataManagerTest, ImportFormMinimumAddressGB) {
"Country:", "country", "United Kingdom", "text", &field);
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure,
&imported_credit_card));
@@ -817,7 +807,7 @@ TEST_F(PersonalDataManagerTest, ImportFormMinimumAddressGI) {
test::CreateTestFormField("Country:", "country", "Gibraltar", "text", &field);
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure,
&imported_credit_card));
@@ -856,7 +846,7 @@ TEST_F(PersonalDataManagerTest, ImportPhoneNumberSplitAcrossMultipleFields) {
test::CreateTestFormField("Zip:", "zip", "94102", "text", &field);
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure,
&imported_credit_card));
@@ -903,7 +893,7 @@ TEST_F(PersonalDataManagerTest, ImportFormDataMultilineAddress) {
test::CreateTestFormField("Zip:", "zip", "94102", "text", &field);
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure,
&imported_credit_card));
@@ -983,7 +973,7 @@ TEST_F(PersonalDataManagerTest, AggregateTwoDifferentProfiles) {
form1.fields.push_back(field);
FormStructure form_structure1(form1);
- form_structure1.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure1.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure1,
&imported_credit_card));
@@ -1024,7 +1014,7 @@ TEST_F(PersonalDataManagerTest, AggregateTwoDifferentProfiles) {
form2.fields.push_back(field);
FormStructure form_structure2(form2);
- form_structure2.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure2.DetermineHeuristicTypes();
EXPECT_TRUE(personal_data_->ImportFormData(form_structure2,
&imported_credit_card));
ASSERT_FALSE(imported_credit_card);
@@ -1067,7 +1057,7 @@ TEST_F(PersonalDataManagerTest, AggregateTwoProfilesWithMultiValue) {
form1.fields.push_back(field);
FormStructure form_structure1(form1);
- form_structure1.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure1.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure1,
&imported_credit_card));
@@ -1107,7 +1097,7 @@ TEST_F(PersonalDataManagerTest, AggregateTwoProfilesWithMultiValue) {
form2.fields.push_back(field);
FormStructure form_structure2(form2);
- form_structure2.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure2.DetermineHeuristicTypes();
EXPECT_TRUE(personal_data_->ImportFormData(form_structure2,
&imported_credit_card));
ASSERT_FALSE(imported_credit_card);
@@ -1164,7 +1154,7 @@ TEST_F(PersonalDataManagerTest, AggregateSameProfileWithConflict) {
form1.fields.push_back(field);
FormStructure form_structure1(form1);
- form_structure1.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure1.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure1,
&imported_credit_card));
@@ -1215,7 +1205,7 @@ TEST_F(PersonalDataManagerTest, AggregateSameProfileWithConflict) {
form2.fields.push_back(field);
FormStructure form_structure2(form2);
- form_structure2.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure2.DetermineHeuristicTypes();
EXPECT_TRUE(personal_data_->ImportFormData(form_structure2,
&imported_credit_card));
ASSERT_FALSE(imported_credit_card);
@@ -1257,7 +1247,7 @@ TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) {
form1.fields.push_back(field);
FormStructure form_structure1(form1);
- form_structure1.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure1.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure1,
&imported_credit_card));
@@ -1298,7 +1288,7 @@ TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) {
form2.fields.push_back(field);
FormStructure form_structure2(form2);
- form_structure2.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure2.DetermineHeuristicTypes();
EXPECT_TRUE(personal_data_->ImportFormData(form_structure2,
&imported_credit_card));
ASSERT_FALSE(imported_credit_card);
@@ -1344,7 +1334,7 @@ TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInNew) {
form1.fields.push_back(field);
FormStructure form_structure1(form1);
- form_structure1.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure1.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure1,
&imported_credit_card));
@@ -1386,7 +1376,7 @@ TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInNew) {
form2.fields.push_back(field);
FormStructure form_structure2(form2);
- form_structure2.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure2.DetermineHeuristicTypes();
EXPECT_TRUE(personal_data_->ImportFormData(form_structure2,
&imported_credit_card));
ASSERT_FALSE(imported_credit_card);
@@ -1425,7 +1415,7 @@ TEST_F(PersonalDataManagerTest, AggregateProfileWithInsufficientAddress) {
form1.fields.push_back(field);
FormStructure form_structure1(form1);
- form_structure1.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure1.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_FALSE(personal_data_->ImportFormData(form_structure1,
&imported_credit_card));
@@ -1479,7 +1469,7 @@ TEST_F(PersonalDataManagerTest, AggregateExistingAuxiliaryProfile) {
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure,
&imported_credit_card));
@@ -1512,7 +1502,7 @@ TEST_F(PersonalDataManagerTest, AggregateTwoDifferentCreditCards) {
form1.fields.push_back(field);
FormStructure form_structure1(form1);
- form_structure1.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure1.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure1,
&imported_credit_card));
@@ -1545,7 +1535,7 @@ TEST_F(PersonalDataManagerTest, AggregateTwoDifferentCreditCards) {
form2.fields.push_back(field);
FormStructure form_structure2(form2);
- form_structure2.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure2.DetermineHeuristicTypes();
EXPECT_TRUE(personal_data_->ImportFormData(form_structure2,
&imported_credit_card));
ASSERT_TRUE(imported_credit_card);
@@ -1581,7 +1571,7 @@ TEST_F(PersonalDataManagerTest, AggregateInvalidCreditCard) {
form1.fields.push_back(field);
FormStructure form_structure1(form1);
- form_structure1.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure1.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure1,
&imported_credit_card));
@@ -1614,7 +1604,7 @@ TEST_F(PersonalDataManagerTest, AggregateInvalidCreditCard) {
form2.fields.push_back(field);
FormStructure form_structure2(form2);
- form_structure2.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure2.DetermineHeuristicTypes();
EXPECT_FALSE(personal_data_->ImportFormData(form_structure2,
&imported_credit_card));
ASSERT_FALSE(imported_credit_card);
@@ -1645,7 +1635,7 @@ TEST_F(PersonalDataManagerTest, AggregateSameCreditCardWithConflict) {
form1.fields.push_back(field);
FormStructure form_structure1(form1);
- form_structure1.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure1.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure1,
&imported_credit_card));
@@ -1679,7 +1669,7 @@ TEST_F(PersonalDataManagerTest, AggregateSameCreditCardWithConflict) {
form2.fields.push_back(field);
FormStructure form_structure2(form2);
- form_structure2.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure2.DetermineHeuristicTypes();
EXPECT_TRUE(personal_data_->ImportFormData(form_structure2,
&imported_credit_card));
EXPECT_FALSE(imported_credit_card);
@@ -1716,7 +1706,7 @@ TEST_F(PersonalDataManagerTest, AggregateEmptyCreditCardWithConflict) {
form1.fields.push_back(field);
FormStructure form_structure1(form1);
- form_structure1.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure1.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure1,
&imported_credit_card));
@@ -1746,7 +1736,7 @@ TEST_F(PersonalDataManagerTest, AggregateEmptyCreditCardWithConflict) {
form2.fields.push_back(field);
FormStructure form_structure2(form2);
- form_structure2.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure2.DetermineHeuristicTypes();
EXPECT_FALSE(personal_data_->ImportFormData(form_structure2,
&imported_credit_card));
EXPECT_FALSE(imported_credit_card);
@@ -1781,7 +1771,7 @@ TEST_F(PersonalDataManagerTest, AggregateCreditCardWithMissingInfoInNew) {
form1.fields.push_back(field);
FormStructure form_structure1(form1);
- form_structure1.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure1.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure1,
&imported_credit_card));
@@ -1813,7 +1803,7 @@ TEST_F(PersonalDataManagerTest, AggregateCreditCardWithMissingInfoInNew) {
form2.fields.push_back(field);
FormStructure form_structure2(form2);
- form_structure2.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure2.DetermineHeuristicTypes();
EXPECT_TRUE(personal_data_->ImportFormData(form_structure2,
&imported_credit_card));
EXPECT_FALSE(imported_credit_card);
@@ -1841,7 +1831,7 @@ TEST_F(PersonalDataManagerTest, AggregateCreditCardWithMissingInfoInNew) {
// Note missing expiration month and year..
FormStructure form_structure3(form3);
- form_structure3.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure3.DetermineHeuristicTypes();
EXPECT_FALSE(personal_data_->ImportFormData(form_structure3,
&imported_credit_card));
ASSERT_FALSE(imported_credit_card);
@@ -1893,7 +1883,7 @@ TEST_F(PersonalDataManagerTest, AggregateCreditCardWithMissingInfoInOld) {
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure,
&imported_credit_card));
@@ -1948,7 +1938,7 @@ TEST_F(PersonalDataManagerTest, AggregateSameCreditCardWithSeparators) {
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure,
&imported_credit_card));
@@ -2006,7 +1996,7 @@ TEST_F(PersonalDataManagerTest, AggregateExistingVerifiedProfileWithConflict) {
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure,
&imported_credit_card));
@@ -2056,7 +2046,7 @@ TEST_F(PersonalDataManagerTest,
form.fields.push_back(field);
FormStructure form_structure(form);
- form_structure.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure,
&imported_credit_card));
@@ -2348,7 +2338,7 @@ TEST_F(PersonalDataManagerTest, CaseInsensitiveMultiValueAggregation) {
form1.fields.push_back(field);
FormStructure form_structure1(form1);
- form_structure1.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure1.DetermineHeuristicTypes();
scoped_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(personal_data_->ImportFormData(form_structure1,
&imported_credit_card));
@@ -2402,7 +2392,7 @@ TEST_F(PersonalDataManagerTest, CaseInsensitiveMultiValueAggregation) {
form2.fields.push_back(field);
FormStructure form_structure2(form2);
- form_structure2.DetermineHeuristicTypes(TestAutofillMetrics());
+ form_structure2.DetermineHeuristicTypes();
EXPECT_TRUE(personal_data_->ImportFormData(form_structure2,
&imported_credit_card));
ASSERT_FALSE(imported_credit_card);
diff --git a/components/password_manager/core/browser/password_generation_manager_unittest.cc b/components/password_manager/core/browser/password_generation_manager_unittest.cc
index 4969752..d951968 100644
--- a/components/password_manager/core/browser/password_generation_manager_unittest.cc
+++ b/components/password_manager/core/browser/password_generation_manager_unittest.cc
@@ -97,15 +97,6 @@ class TestPasswordManagerClient : public StubPasswordManagerClient {
bool is_off_the_record_;
};
-// Unlike the base AutofillMetrics, exposes copy and assignment constructors,
-// which are handy for briefer test code. The AutofillMetrics class is
-// stateless, so this is safe.
-class TestAutofillMetrics : public autofill::AutofillMetrics {
- public:
- TestAutofillMetrics() {}
- ~TestAutofillMetrics() override {}
-};
-
} // anonymous namespace
class PasswordGenerationManagerTest : public testing::Test {
@@ -201,8 +192,7 @@ TEST_F(PasswordGenerationManagerTest, DetectAccountCreationForms) {
"<field autofilltype=\"76\" />"
"<field autofilltype=\"75\" />"
"</autofillqueryresponse>";
- autofill::FormStructure::ParseQueryResponse(
- kServerResponse, forms, TestAutofillMetrics());
+ autofill::FormStructure::ParseQueryResponse(kServerResponse, forms);
DetectAccountCreationForms(forms);
EXPECT_EQ(1u, GetTestDriver()->GetFoundAccountCreationForms().size());