Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Unified Diff: components/autofill/core/browser/personal_data_manager_mac.mm

Issue 212233002: [Autofill] Add metrics to determine whether the system AddressBook is accessible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix a typo Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/personal_data_manager_mac.mm
diff --git a/components/autofill/core/browser/personal_data_manager_mac.mm b/components/autofill/core/browser/personal_data_manager_mac.mm
index 834a1151461fad4a6781501ea86c6507b22508b7..745a60e6b99ce914b4adb2717f9138f7d183f683 100644
--- a/components/autofill/core/browser/personal_data_manager_mac.mm
+++ b/components/autofill/core/browser/personal_data_manager_mac.mm
@@ -14,12 +14,15 @@
#import "base/mac/scoped_nsexception_enabler.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
+#include "base/metrics/histogram.h"
+#include "base/prefs/pref_service.h"
#include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h"
#include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/autofill_profile.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/phone_number.h"
+#include "components/autofill/core/common/autofill_pref_names.h"
#include "grit/component_strings.h"
#include "ui/base/l10n/l10n_util_mac.h"
@@ -46,7 +49,8 @@ class AuxiliaryProfilesImpl {
virtual ~AuxiliaryProfilesImpl() {}
// Import the "me" card from the Mac Address Book and fill in |profiles_|.
- void GetAddressBookMeCard(const std::string& app_locale);
+ void GetAddressBookMeCard(const std::string& app_locale,
+ PrefService* pref_service);
private:
void GetAddressBookNames(ABPerson* me,
@@ -73,8 +77,8 @@ class AuxiliaryProfilesImpl {
// from the active user's address book. It looks for the user address
// information and translates it to the internal list of |AutofillProfile| data
// structures.
-void AuxiliaryProfilesImpl::GetAddressBookMeCard(
- const std::string& app_locale) {
+void AuxiliaryProfilesImpl::GetAddressBookMeCard(const std::string& app_locale,
+ PrefService* pref_service) {
profiles_.clear();
// +[ABAddressBook sharedAddressBook] throws an exception internally in
@@ -85,6 +89,13 @@ void AuxiliaryProfilesImpl::GetAddressBookMeCard(
ABAddressBook* addressBook = base::mac::RunBlockIgnoringExceptions(^{
return [ABAddressBook sharedAddressBook];
});
+ UMA_HISTOGRAM_BOOLEAN("Autofill.AddressBookAvailable", addressBook != nil);
+ if (!pref_service->GetBoolean(prefs::kAutofillAuxiliaryProfilesQueried)) {
+ pref_service->SetBoolean(prefs::kAutofillAuxiliaryProfilesQueried, true);
+ UMA_HISTOGRAM_BOOLEAN("Autofill.AddressBookAvailableOnFirstAttempt",
+ addressBook != nil);
+ }
+
ABPerson* me = [addressBook me];
if (!me)
return;
@@ -267,7 +278,7 @@ void AuxiliaryProfilesImpl::GetAddressBookPhoneNumbers(
// Populate |auxiliary_profiles_| with the Address Book data.
void PersonalDataManager::LoadAuxiliaryProfiles() const {
AuxiliaryProfilesImpl impl(&auxiliary_profiles_);
- impl.GetAddressBookMeCard(app_locale_);
+ impl.GetAddressBookMeCard(app_locale_, pref_service_);
}
} // namespace autofill
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | components/autofill/core/common/autofill_pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698