Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/autofill/autofill_manager.h" | 5 #include "chrome/browser/autofill/autofill_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 #include "content/public/browser/web_contents.h" | 55 #include "content/public/browser/web_contents.h" |
| 56 #include "googleurl/src/gurl.h" | 56 #include "googleurl/src/gurl.h" |
| 57 #include "grit/generated_resources.h" | 57 #include "grit/generated_resources.h" |
| 58 #include "ipc/ipc_message_macros.h" | 58 #include "ipc/ipc_message_macros.h" |
| 59 #include "ui/base/l10n/l10n_util.h" | 59 #include "ui/base/l10n/l10n_util.h" |
| 60 #include "ui/gfx/rect.h" | 60 #include "ui/gfx/rect.h" |
| 61 #include "webkit/forms/form_data.h" | 61 #include "webkit/forms/form_data.h" |
| 62 #include "webkit/forms/form_data_predictions.h" | 62 #include "webkit/forms/form_data_predictions.h" |
| 63 #include "webkit/forms/form_field.h" | 63 #include "webkit/forms/form_field.h" |
| 64 #include "webkit/forms/password_form_dom_manager.h" | 64 #include "webkit/forms/password_form_dom_manager.h" |
| 65 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" | 65 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" |
|
Ilya Sherman
2012/04/19 21:01:57
nit: alpha-sort (should come before ui/)
csharp
2012/04/20 15:03:18
Done.
| |
| 66 | 66 |
| 67 using base::TimeTicks; | 67 using base::TimeTicks; |
| 68 using content::BrowserThread; | 68 using content::BrowserThread; |
| 69 using content::RenderViewHost; | 69 using content::RenderViewHost; |
| 70 using switches::kEnableAutofillFeedback; | 70 using switches::kEnableAutofillFeedback; |
| 71 using webkit::forms::FormData; | 71 using webkit::forms::FormData; |
| 72 using webkit::forms::FormDataPredictions; | 72 using webkit::forms::FormDataPredictions; |
| 73 using webkit::forms::FormField; | 73 using webkit::forms::FormField; |
| 74 | 74 |
| 75 namespace { | 75 namespace { |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 682 void AutofillManager::OnShowPasswordGenerationPopup(const gfx::Rect& bounds) { | 682 void AutofillManager::OnShowPasswordGenerationPopup(const gfx::Rect& bounds) { |
| 683 #if defined(OS_ANDROID) | 683 #if defined(OS_ANDROID) |
| 684 NOTIMPLEMENTED(); | 684 NOTIMPLEMENTED(); |
| 685 #else | 685 #else |
| 686 Browser* browser = BrowserList::GetLastActiveWithProfile( | 686 Browser* browser = BrowserList::GetLastActiveWithProfile( |
| 687 Profile::FromBrowserContext(web_contents()->GetBrowserContext())); | 687 Profile::FromBrowserContext(web_contents()->GetBrowserContext())); |
| 688 browser->window()->ShowPasswordGenerationBubble(bounds); | 688 browser->window()->ShowPasswordGenerationBubble(bounds); |
| 689 #endif // #if defined(OS_ANDROID) | 689 #endif // #if defined(OS_ANDROID) |
| 690 } | 690 } |
| 691 | 691 |
| 692 void AutofillManager::RemoveAutofillProfileOrCreditCard(int unique_id) { | |
| 693 const std::vector<AutofillProfile*>& profiles = personal_data_->profiles(); | |
| 694 const std::vector<CreditCard*>& credit_cards = personal_data_->credit_cards(); | |
| 695 const AutofillProfile* profile = NULL; | |
| 696 const CreditCard* credit_card = NULL; | |
| 697 size_t variant = 0; | |
| 698 if (!GetProfileOrCreditCard(unique_id, profiles, credit_cards, &profile, | |
| 699 &credit_card, &variant)) { | |
| 700 NOTREACHED(); | |
| 701 return; | |
| 702 } | |
| 703 | |
| 704 // TODO(csharp): If we are dealing with a variant only the variant should | |
| 705 // be deleted, not the whole profile. | |
| 706 // http://crbug.com/124211 | |
|
Ilya Sherman
2012/04/19 21:01:57
Hmm, this has the potential for accidental data lo
csharp
2012/04/20 15:03:18
Done.
| |
| 707 | |
| 708 if (profile) | |
| 709 personal_data_->RemoveProfile(profile->guid()); | |
| 710 else | |
| 711 personal_data_->RemoveCreditCard(credit_card->guid()); | |
| 712 } | |
| 713 | |
| 692 void AutofillManager::OnAddPasswordFormMapping( | 714 void AutofillManager::OnAddPasswordFormMapping( |
| 693 const webkit::forms::FormField& form, | 715 const webkit::forms::FormField& form, |
| 694 const webkit::forms::PasswordFormFillData& fill_data) { | 716 const webkit::forms::PasswordFormFillData& fill_data) { |
| 695 if (external_delegate_) | 717 if (external_delegate_) |
| 696 external_delegate_->AddPasswordFormMapping(form, fill_data); | 718 external_delegate_->AddPasswordFormMapping(form, fill_data); |
| 697 } | 719 } |
| 698 | 720 |
| 699 void AutofillManager::OnShowPasswordSuggestions( | 721 void AutofillManager::OnShowPasswordSuggestions( |
| 700 const webkit::forms::FormField& field, | 722 const webkit::forms::FormField& field, |
| 701 const gfx::Rect& bounds, | 723 const gfx::Rect& bounds, |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1319 *profile_guid = IDToGUID(profile_id); | 1341 *profile_guid = IDToGUID(profile_id); |
| 1320 } | 1342 } |
| 1321 | 1343 |
| 1322 void AutofillManager::UpdateInitialInteractionTimestamp( | 1344 void AutofillManager::UpdateInitialInteractionTimestamp( |
| 1323 const TimeTicks& interaction_timestamp) { | 1345 const TimeTicks& interaction_timestamp) { |
| 1324 if (initial_interaction_timestamp_.is_null() || | 1346 if (initial_interaction_timestamp_.is_null() || |
| 1325 interaction_timestamp < initial_interaction_timestamp_) { | 1347 interaction_timestamp < initial_interaction_timestamp_) { |
| 1326 initial_interaction_timestamp_ = interaction_timestamp; | 1348 initial_interaction_timestamp_ = interaction_timestamp; |
| 1327 } | 1349 } |
| 1328 } | 1350 } |
| OLD | NEW |