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

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

Issue 9600038: Add Password Autofill Manager to New Autofill (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "content/public/browser/render_view_host.h" 50 #include "content/public/browser/render_view_host.h"
51 #include "content/public/browser/web_contents.h" 51 #include "content/public/browser/web_contents.h"
52 #include "googleurl/src/gurl.h" 52 #include "googleurl/src/gurl.h"
53 #include "grit/generated_resources.h" 53 #include "grit/generated_resources.h"
54 #include "ipc/ipc_message_macros.h" 54 #include "ipc/ipc_message_macros.h"
55 #include "ui/base/l10n/l10n_util.h" 55 #include "ui/base/l10n/l10n_util.h"
56 #include "ui/gfx/rect.h" 56 #include "ui/gfx/rect.h"
57 #include "webkit/forms/form_data.h" 57 #include "webkit/forms/form_data.h"
58 #include "webkit/forms/form_data_predictions.h" 58 #include "webkit/forms/form_data_predictions.h"
59 #include "webkit/forms/form_field.h" 59 #include "webkit/forms/form_field.h"
60 #include "webkit/forms/password_form_dom_manager.h"
60 61
61 using base::TimeTicks; 62 using base::TimeTicks;
62 using content::BrowserThread; 63 using content::BrowserThread;
63 using content::RenderViewHost; 64 using content::RenderViewHost;
64 using switches::kEnableAutofillFeedback; 65 using switches::kEnableAutofillFeedback;
65 using webkit::forms::FormData; 66 using webkit::forms::FormData;
66 using webkit::forms::FormDataPredictions; 67 using webkit::forms::FormDataPredictions;
67 using webkit::forms::FormField; 68 using webkit::forms::FormField;
68 69
69 namespace { 70 namespace {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 kAutofillNegativeUploadRateDefaultValue, 289 kAutofillNegativeUploadRateDefaultValue,
289 PrefService::UNSYNCABLE_PREF); 290 PrefService::UNSYNCABLE_PREF);
290 } 291 }
291 292
292 void AutofillManager::DidNavigateMainFrame( 293 void AutofillManager::DidNavigateMainFrame(
293 const content::LoadCommittedDetails& details, 294 const content::LoadCommittedDetails& details,
294 const content::FrameNavigateParams& params) { 295 const content::FrameNavigateParams& params) {
295 Reset(); 296 Reset();
296 } 297 }
297 298
299 bool AutofillManager::HasExternalDelegate() {
300 return external_delegate_ != NULL;
301 }
302
298 bool AutofillManager::OnMessageReceived(const IPC::Message& message) { 303 bool AutofillManager::OnMessageReceived(const IPC::Message& message) {
299 bool handled = true; 304 bool handled = true;
300 IPC_BEGIN_MESSAGE_MAP(AutofillManager, message) 305 IPC_BEGIN_MESSAGE_MAP(AutofillManager, message)
301 IPC_MESSAGE_HANDLER(AutofillHostMsg_FormsSeen, OnFormsSeen) 306 IPC_MESSAGE_HANDLER(AutofillHostMsg_FormsSeen, OnFormsSeen)
302 IPC_MESSAGE_HANDLER(AutofillHostMsg_FormSubmitted, OnFormSubmitted) 307 IPC_MESSAGE_HANDLER(AutofillHostMsg_FormSubmitted, OnFormSubmitted)
303 IPC_MESSAGE_HANDLER(AutofillHostMsg_TextFieldDidChange, 308 IPC_MESSAGE_HANDLER(AutofillHostMsg_TextFieldDidChange,
304 OnTextFieldDidChange) 309 OnTextFieldDidChange)
305 IPC_MESSAGE_HANDLER(AutofillHostMsg_QueryFormFieldAutofill, 310 IPC_MESSAGE_HANDLER(AutofillHostMsg_QueryFormFieldAutofill,
306 OnQueryFormFieldAutofill) 311 OnQueryFormFieldAutofill)
307 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowAutofillDialog, 312 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowAutofillDialog,
308 OnShowAutofillDialog) 313 OnShowAutofillDialog)
309 IPC_MESSAGE_HANDLER(AutofillHostMsg_FillAutofillFormData, 314 IPC_MESSAGE_HANDLER(AutofillHostMsg_FillAutofillFormData,
310 OnFillAutofillFormData) 315 OnFillAutofillFormData)
311 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidPreviewAutofillFormData, 316 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidPreviewAutofillFormData,
312 OnDidPreviewAutofillFormData) 317 OnDidPreviewAutofillFormData)
313 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidFillAutofillFormData, 318 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidFillAutofillFormData,
314 OnDidFillAutofillFormData) 319 OnDidFillAutofillFormData)
315 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidShowAutofillSuggestions, 320 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidShowAutofillSuggestions,
316 OnDidShowAutofillSuggestions) 321 OnDidShowAutofillSuggestions)
317 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidEndTextFieldEditing, 322 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidEndTextFieldEditing,
318 OnDidEndTextFieldEditing) 323 OnDidEndTextFieldEditing)
319 IPC_MESSAGE_HANDLER(AutofillHostMsg_HideAutofillPopup, 324 IPC_MESSAGE_HANDLER(AutofillHostMsg_HideAutofillPopup,
320 OnHideAutofillPopup) 325 OnHideAutofillPopup)
326 IPC_MESSAGE_HANDLER(AutofillHostMsg_AddPasswordFormMapping,
327 OnAddPasswordFormMapping)
321 IPC_MESSAGE_UNHANDLED(handled = false) 328 IPC_MESSAGE_UNHANDLED(handled = false)
322 IPC_END_MESSAGE_MAP() 329 IPC_END_MESSAGE_MAP()
323 330
324 return handled; 331 return handled;
325 } 332 }
326 333
327 bool AutofillManager::OnFormSubmitted(const FormData& form, 334 bool AutofillManager::OnFormSubmitted(const FormData& form,
328 const TimeTicks& timestamp) { 335 const TimeTicks& timestamp) {
329 // Let AutoComplete know as well. 336 // Let AutoComplete know as well.
330 tab_contents_wrapper_->autocomplete_history_manager()->OnFormSubmitted(form); 337 tab_contents_wrapper_->autocomplete_history_manager()->OnFormSubmitted(form);
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 AutofillMetrics::SUGGESTIONS_SHOWN_ONCE); 691 AutofillMetrics::SUGGESTIONS_SHOWN_ONCE);
685 } 692 }
686 } 693 }
687 } 694 }
688 695
689 void AutofillManager::OnHideAutofillPopup() { 696 void AutofillManager::OnHideAutofillPopup() {
690 if (external_delegate_) 697 if (external_delegate_)
691 external_delegate_->HideAutofillPopup(); 698 external_delegate_->HideAutofillPopup();
692 } 699 }
693 700
701 void AutofillManager::OnAddPasswordFormMapping(
702 const webkit::forms::FormField& form,
703 const webkit::forms::PasswordFormFillData& fill_data) {
704 if (external_delegate_)
705 external_delegate_->AddPasswordFormMapping(form, fill_data);
706 }
707
708
694 void AutofillManager::OnLoadedServerPredictions( 709 void AutofillManager::OnLoadedServerPredictions(
695 const std::string& response_xml) { 710 const std::string& response_xml) {
696 // Parse and store the server predictions. 711 // Parse and store the server predictions.
697 FormStructure::ParseQueryResponse(response_xml, 712 FormStructure::ParseQueryResponse(response_xml,
698 form_structures_.get(), 713 form_structures_.get(),
699 *metric_logger_); 714 *metric_logger_);
700 715
701 // If the corresponding flag is set, annotate forms with the predicted types. 716 // If the corresponding flag is set, annotate forms with the predicted types.
702 SendAutofillTypePredictions(form_structures_.get()); 717 SendAutofillTypePredictions(form_structures_.get());
703 } 718 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 void AutofillManager::Reset() { 807 void AutofillManager::Reset() {
793 form_structures_.reset(); 808 form_structures_.reset();
794 has_logged_autofill_enabled_ = false; 809 has_logged_autofill_enabled_ = false;
795 has_logged_address_suggestions_count_ = false; 810 has_logged_address_suggestions_count_ = false;
796 did_show_suggestions_ = false; 811 did_show_suggestions_ = false;
797 user_did_type_ = false; 812 user_did_type_ = false;
798 user_did_autofill_ = false; 813 user_did_autofill_ = false;
799 user_did_edit_autofilled_field_ = false; 814 user_did_edit_autofilled_field_ = false;
800 forms_loaded_timestamp_ = TimeTicks(); 815 forms_loaded_timestamp_ = TimeTicks();
801 initial_interaction_timestamp_ = TimeTicks(); 816 initial_interaction_timestamp_ = TimeTicks();
817
818 if (external_delegate_)
819 external_delegate_->Reset();
802 } 820 }
803 821
804 AutofillManager::AutofillManager(TabContentsWrapper* tab_contents, 822 AutofillManager::AutofillManager(TabContentsWrapper* tab_contents,
805 PersonalDataManager* personal_data) 823 PersonalDataManager* personal_data)
806 : content::WebContentsObserver(tab_contents->web_contents()), 824 : content::WebContentsObserver(tab_contents->web_contents()),
807 tab_contents_wrapper_(tab_contents), 825 tab_contents_wrapper_(tab_contents),
808 personal_data_(personal_data), 826 personal_data_(personal_data),
809 download_manager_(tab_contents->profile(), this), 827 download_manager_(tab_contents->profile(), this),
810 disable_download_manager_requests_(true), 828 disable_download_manager_requests_(true),
811 metric_logger_(new AutofillMetrics), 829 metric_logger_(new AutofillMetrics),
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 *profile_guid = IDToGUID(profile_id); 1319 *profile_guid = IDToGUID(profile_id);
1302 } 1320 }
1303 1321
1304 void AutofillManager::UpdateInitialInteractionTimestamp( 1322 void AutofillManager::UpdateInitialInteractionTimestamp(
1305 const TimeTicks& interaction_timestamp) { 1323 const TimeTicks& interaction_timestamp) {
1306 if (initial_interaction_timestamp_.is_null() || 1324 if (initial_interaction_timestamp_.is_null() ||
1307 interaction_timestamp < initial_interaction_timestamp_) { 1325 interaction_timestamp < initial_interaction_timestamp_) {
1308 initial_interaction_timestamp_ = interaction_timestamp; 1326 initial_interaction_timestamp_ = interaction_timestamp;
1309 } 1327 }
1310 } 1328 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698