OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/autofill/core/browser/personal_data_manager.h" | 5 #include "components/autofill/core/browser/personal_data_manager.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #import <AddressBook/AddressBook.h> | 9 #import <AddressBook/AddressBook.h> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... | |
24 #include "components/autofill/core/browser/form_structure.h" | 24 #include "components/autofill/core/browser/form_structure.h" |
25 #include "components/autofill/core/browser/phone_number.h" | 25 #include "components/autofill/core/browser/phone_number.h" |
26 #include "components/autofill/core/common/autofill_pref_names.h" | 26 #include "components/autofill/core/common/autofill_pref_names.h" |
27 #include "components/autofill/core/common/form_data.h" | 27 #include "components/autofill/core/common/form_data.h" |
28 #include "grit/components_strings.h" | 28 #include "grit/components_strings.h" |
29 #include "ui/base/l10n/l10n_util_mac.h" | 29 #include "ui/base/l10n/l10n_util_mac.h" |
30 | 30 |
31 namespace autofill { | 31 namespace autofill { |
32 namespace { | 32 namespace { |
33 | 33 |
34 // The maximum number of instances when the access Address Book prompt should | |
35 // be shown. | |
36 int kMaxTimesToShowMacAddressBookCount = 5; | |
Evan Stade
2014/09/18 21:26:37
nit: "Times" and "Count" seem redundant
erikchen
2014/09/18 21:55:57
Changed to kMaxTimesToShowMacAddressBook
| |
37 | |
34 // There is an uncommon sequence of events that causes the Address Book | 38 // There is an uncommon sequence of events that causes the Address Book |
35 // permissions dialog to appear more than once for a given install of Chrome. | 39 // permissions dialog to appear more than once for a given install of Chrome. |
36 // 1. Chrome has previously presented the Address Book permissions dialog. | 40 // 1. Chrome has previously presented the Address Book permissions dialog. |
37 // 2. Chrome is launched. | 41 // 2. Chrome is launched. |
38 // 3. Chrome performs an auto-update, and changes its binary. | 42 // 3. Chrome performs an auto-update, and changes its binary. |
39 // 4. Chrome attempts to access the Address Book for the first time since (2). | 43 // 4. Chrome attempts to access the Address Book for the first time since (2). |
40 // This sequence of events is rare because Chrome attempts to acess the Address | 44 // This sequence of events is rare because Chrome attempts to acess the Address |
41 // Book when the user focuses most form fields, so (4) generally occurs before | 45 // Book when the user focuses most form fields, so (4) generally occurs before |
42 // (3). For more details, see http://crbug.com/381763. | 46 // (3). For more details, see http://crbug.com/381763. |
43 // | 47 // |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
367 // Autofill state. | 371 // Autofill state. |
368 if (!web_profiles_.empty()) | 372 if (!web_profiles_.empty()) |
369 return false; | 373 return false; |
370 | 374 |
371 if (!enabled_pref_->GetValue()) | 375 if (!enabled_pref_->GetValue()) |
372 return false; | 376 return false; |
373 | 377 |
374 if (HasPromptedForAccessToAddressBook(pref_service_)) | 378 if (HasPromptedForAccessToAddressBook(pref_service_)) |
375 return false; | 379 return false; |
376 | 380 |
381 if (pref_service_->GetInteger(prefs::kAutofillMacAddressBookShowedCount) >= | |
382 kMaxTimesToShowMacAddressBookCount) | |
Evan Stade
2014/09/18 21:26:37
nit: 4 more indent
erikchen
2014/09/18 21:55:57
Doesn't apply anymore, since conditional fits on a
| |
383 return false; | |
Evan Stade
2014/09/18 21:26:37
nit: curlies
erikchen
2014/09/18 21:55:57
N/A
| |
384 | |
377 switch (type.group()) { | 385 switch (type.group()) { |
378 case ADDRESS_BILLING: | 386 case ADDRESS_BILLING: |
379 case ADDRESS_HOME: | 387 case ADDRESS_HOME: |
380 case EMAIL: | 388 case EMAIL: |
381 case NAME: | 389 case NAME: |
382 case NAME_BILLING: | 390 case NAME_BILLING: |
383 case PHONE_BILLING: | 391 case PHONE_BILLING: |
384 case PHONE_HOME: | 392 case PHONE_HOME: |
385 return true; | 393 return true; |
386 case NO_GROUP: | 394 case NO_GROUP: |
387 case COMPANY: | 395 case COMPANY: |
388 case CREDIT_CARD: | 396 case CREDIT_CARD: |
389 case PASSWORD_FIELD: | 397 case PASSWORD_FIELD: |
390 case TRANSACTION: | 398 case TRANSACTION: |
391 return false; | 399 return false; |
392 } | 400 } |
393 | 401 |
394 return false; | 402 return false; |
395 } | 403 } |
396 | 404 |
405 void PersonalDataManager::ShowedAccessAddressBookPrompt() { | |
406 int count = | |
407 pref_service_->GetInteger(prefs::kAutofillMacAddressBookShowedCount); | |
408 pref_service_->SetInteger(prefs::kAutofillMacAddressBookShowedCount, | |
409 count + 1); | |
410 } | |
411 | |
397 void PersonalDataManager::BinaryChanging() { | 412 void PersonalDataManager::BinaryChanging() { |
398 g_binary_changed = true; | 413 g_binary_changed = true; |
399 } | 414 } |
400 | 415 |
401 } // namespace autofill | 416 } // namespace autofill |
OLD | NEW |