| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 #include "chrome/common/pref_names.h" | 50 #include "chrome/common/pref_names.h" |
| 51 #include "chrome/common/url_constants.h" | 51 #include "chrome/common/url_constants.h" |
| 52 #include "content/public/browser/browser_thread.h" | 52 #include "content/public/browser/browser_thread.h" |
| 53 #include "content/public/browser/notification_service.h" | 53 #include "content/public/browser/notification_service.h" |
| 54 #include "content/public/browser/notification_source.h" | 54 #include "content/public/browser/notification_source.h" |
| 55 #include "content/public/browser/render_view_host.h" | 55 #include "content/public/browser/render_view_host.h" |
| 56 #include "content/public/browser/web_contents.h" | 56 #include "content/public/browser/web_contents.h" |
| 57 #include "googleurl/src/gurl.h" | 57 #include "googleurl/src/gurl.h" |
| 58 #include "grit/generated_resources.h" | 58 #include "grit/generated_resources.h" |
| 59 #include "ipc/ipc_message_macros.h" | 59 #include "ipc/ipc_message_macros.h" |
| 60 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" |
| 60 #include "ui/base/l10n/l10n_util.h" | 61 #include "ui/base/l10n/l10n_util.h" |
| 61 #include "ui/gfx/rect.h" | 62 #include "ui/gfx/rect.h" |
| 62 #include "webkit/forms/form_data.h" | 63 #include "webkit/forms/form_data.h" |
| 63 #include "webkit/forms/form_data_predictions.h" | 64 #include "webkit/forms/form_data_predictions.h" |
| 64 #include "webkit/forms/form_field.h" | 65 #include "webkit/forms/form_field.h" |
| 65 #include "webkit/forms/password_form_dom_manager.h" | 66 #include "webkit/forms/password_form_dom_manager.h" |
| 66 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" | |
| 67 | 67 |
| 68 using base::TimeTicks; | 68 using base::TimeTicks; |
| 69 using content::BrowserThread; | 69 using content::BrowserThread; |
| 70 using content::RenderViewHost; | 70 using content::RenderViewHost; |
| 71 using switches::kEnableAutofillFeedback; | 71 using switches::kEnableAutofillFeedback; |
| 72 using webkit::forms::FormData; | 72 using webkit::forms::FormData; |
| 73 using webkit::forms::FormDataPredictions; | 73 using webkit::forms::FormDataPredictions; |
| 74 using webkit::forms::FormField; | 74 using webkit::forms::FormField; |
| 75 | 75 |
| 76 namespace { | 76 namespace { |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 void AutofillManager::OnShowPasswordGenerationPopup(const gfx::Rect& bounds) { | 690 void AutofillManager::OnShowPasswordGenerationPopup(const gfx::Rect& bounds) { |
| 691 #if defined(OS_ANDROID) | 691 #if defined(OS_ANDROID) |
| 692 NOTIMPLEMENTED(); | 692 NOTIMPLEMENTED(); |
| 693 #else | 693 #else |
| 694 Browser* browser = BrowserList::GetLastActiveWithProfile( | 694 Browser* browser = BrowserList::GetLastActiveWithProfile( |
| 695 Profile::FromBrowserContext(web_contents()->GetBrowserContext())); | 695 Profile::FromBrowserContext(web_contents()->GetBrowserContext())); |
| 696 browser->window()->ShowPasswordGenerationBubble(bounds); | 696 browser->window()->ShowPasswordGenerationBubble(bounds); |
| 697 #endif // #if defined(OS_ANDROID) | 697 #endif // #if defined(OS_ANDROID) |
| 698 } | 698 } |
| 699 | 699 |
| 700 void AutofillManager::RemoveAutofillProfileOrCreditCard(int unique_id) { |
| 701 const std::vector<AutofillProfile*>& profiles = personal_data_->profiles(); |
| 702 const std::vector<CreditCard*>& credit_cards = personal_data_->credit_cards(); |
| 703 const AutofillProfile* profile = NULL; |
| 704 const CreditCard* credit_card = NULL; |
| 705 size_t variant = 0; |
| 706 if (!GetProfileOrCreditCard(unique_id, profiles, credit_cards, &profile, |
| 707 &credit_card, &variant)) { |
| 708 NOTREACHED(); |
| 709 return; |
| 710 } |
| 711 |
| 712 // TODO(csharp): If we are dealing with a variant only the variant should |
| 713 // be deleted, instead of doing nothing. |
| 714 // http://crbug.com/124211 |
| 715 if (variant != 0) |
| 716 return; |
| 717 |
| 718 if (profile) |
| 719 personal_data_->RemoveProfile(profile->guid()); |
| 720 else |
| 721 personal_data_->RemoveCreditCard(credit_card->guid()); |
| 722 } |
| 723 |
| 700 void AutofillManager::OnAddPasswordFormMapping( | 724 void AutofillManager::OnAddPasswordFormMapping( |
| 701 const webkit::forms::FormField& form, | 725 const webkit::forms::FormField& form, |
| 702 const webkit::forms::PasswordFormFillData& fill_data) { | 726 const webkit::forms::PasswordFormFillData& fill_data) { |
| 703 if (external_delegate_) | 727 if (external_delegate_) |
| 704 external_delegate_->AddPasswordFormMapping(form, fill_data); | 728 external_delegate_->AddPasswordFormMapping(form, fill_data); |
| 705 } | 729 } |
| 706 | 730 |
| 707 void AutofillManager::OnShowPasswordSuggestions( | 731 void AutofillManager::OnShowPasswordSuggestions( |
| 708 const webkit::forms::FormField& field, | 732 const webkit::forms::FormField& field, |
| 709 const gfx::Rect& bounds, | 733 const gfx::Rect& bounds, |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1327 *profile_guid = IDToGUID(profile_id); | 1351 *profile_guid = IDToGUID(profile_id); |
| 1328 } | 1352 } |
| 1329 | 1353 |
| 1330 void AutofillManager::UpdateInitialInteractionTimestamp( | 1354 void AutofillManager::UpdateInitialInteractionTimestamp( |
| 1331 const TimeTicks& interaction_timestamp) { | 1355 const TimeTicks& interaction_timestamp) { |
| 1332 if (initial_interaction_timestamp_.is_null() || | 1356 if (initial_interaction_timestamp_.is_null() || |
| 1333 interaction_timestamp < initial_interaction_timestamp_) { | 1357 interaction_timestamp < initial_interaction_timestamp_) { |
| 1334 initial_interaction_timestamp_ = interaction_timestamp; | 1358 initial_interaction_timestamp_ = interaction_timestamp; |
| 1335 } | 1359 } |
| 1336 } | 1360 } |
| OLD | NEW |