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

Side by Side Diff: chrome/browser/autofill/autofill_manager.cc

Issue 10073018: Add Delete Support to New Autofill UI (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 8 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 unified diff | Download patch
OLDNEW
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "chrome/common/pref_names.h" 49 #include "chrome/common/pref_names.h"
50 #include "chrome/common/url_constants.h" 50 #include "chrome/common/url_constants.h"
51 #include "content/public/browser/browser_thread.h" 51 #include "content/public/browser/browser_thread.h"
52 #include "content/public/browser/notification_service.h" 52 #include "content/public/browser/notification_service.h"
53 #include "content/public/browser/notification_source.h" 53 #include "content/public/browser/notification_source.h"
54 #include "content/public/browser/render_view_host.h" 54 #include "content/public/browser/render_view_host.h"
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 "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h"
59 #include "ui/base/l10n/l10n_util.h" 60 #include "ui/base/l10n/l10n_util.h"
60 #include "ui/gfx/rect.h" 61 #include "ui/gfx/rect.h"
61 #include "webkit/forms/form_data.h" 62 #include "webkit/forms/form_data.h"
62 #include "webkit/forms/form_data_predictions.h" 63 #include "webkit/forms/form_data_predictions.h"
63 #include "webkit/forms/form_field.h" 64 #include "webkit/forms/form_field.h"
64 #include "webkit/forms/password_form_dom_manager.h" 65 #include "webkit/forms/password_form_dom_manager.h"
65 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h"
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
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, instead of doing nothing.
706 // http://crbug.com/124211
707 if (variant != 0)
708 return;
709
710 if (profile)
711 personal_data_->RemoveProfile(profile->guid());
712 else
713 personal_data_->RemoveCreditCard(credit_card->guid());
714 }
715
692 void AutofillManager::OnAddPasswordFormMapping( 716 void AutofillManager::OnAddPasswordFormMapping(
693 const webkit::forms::FormField& form, 717 const webkit::forms::FormField& form,
694 const webkit::forms::PasswordFormFillData& fill_data) { 718 const webkit::forms::PasswordFormFillData& fill_data) {
695 if (external_delegate_) 719 if (external_delegate_)
696 external_delegate_->AddPasswordFormMapping(form, fill_data); 720 external_delegate_->AddPasswordFormMapping(form, fill_data);
697 } 721 }
698 722
699 void AutofillManager::OnShowPasswordSuggestions( 723 void AutofillManager::OnShowPasswordSuggestions(
700 const webkit::forms::FormField& field, 724 const webkit::forms::FormField& field,
701 const gfx::Rect& bounds, 725 const gfx::Rect& bounds,
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 *profile_guid = IDToGUID(profile_id); 1343 *profile_guid = IDToGUID(profile_id);
1320 } 1344 }
1321 1345
1322 void AutofillManager::UpdateInitialInteractionTimestamp( 1346 void AutofillManager::UpdateInitialInteractionTimestamp(
1323 const TimeTicks& interaction_timestamp) { 1347 const TimeTicks& interaction_timestamp) {
1324 if (initial_interaction_timestamp_.is_null() || 1348 if (initial_interaction_timestamp_.is_null() ||
1325 interaction_timestamp < initial_interaction_timestamp_) { 1349 interaction_timestamp < initial_interaction_timestamp_) {
1326 initial_interaction_timestamp_ = interaction_timestamp; 1350 initial_interaction_timestamp_ = interaction_timestamp;
1327 } 1351 }
1328 } 1352 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698