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

Side by Side Diff: components/autofill/content/browser/request_autocomplete_manager.cc

Issue 796493004: Remove FrameDetached and FrameWillClose listeners from AutofillAgent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix init order Created 5 years, 11 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 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/content/browser/request_autocomplete_manager.h" 5 #include "components/autofill/content/browser/request_autocomplete_manager.h"
6 6
7 #include "components/autofill/content/browser/content_autofill_driver.h" 7 #include "components/autofill/content/browser/content_autofill_driver.h"
8 #include "components/autofill/content/common/autofill_messages.h" 8 #include "components/autofill/content/common/autofill_messages.h"
9 #include "components/autofill/core/browser/form_structure.h" 9 #include "components/autofill/core/browser/form_structure.h"
10 #include "components/autofill/core/common/autofill_data_validation.h" 10 #include "components/autofill/core/common/autofill_data_validation.h"
(...skipping 27 matching lines...) Expand all
38 } // namespace 38 } // namespace
39 39
40 RequestAutocompleteManager::RequestAutocompleteManager( 40 RequestAutocompleteManager::RequestAutocompleteManager(
41 ContentAutofillDriver* autofill_driver) 41 ContentAutofillDriver* autofill_driver)
42 : autofill_driver_(autofill_driver), weak_ptr_factory_(this) { 42 : autofill_driver_(autofill_driver), weak_ptr_factory_(this) {
43 DCHECK(autofill_driver_); 43 DCHECK(autofill_driver_);
44 } 44 }
45 45
46 RequestAutocompleteManager::~RequestAutocompleteManager() {} 46 RequestAutocompleteManager::~RequestAutocompleteManager() {}
47 47
48 void RequestAutocompleteManager::OnRequestAutocomplete( 48 void RequestAutocompleteManager::OnRequestAutocomplete(const FormData& form) {
49 const FormData& form,
50 const GURL& frame_url) {
51 if (!IsValidFormData(form)) 49 if (!IsValidFormData(form))
52 return; 50 return;
53 51
54 AutofillClient::ResultCallback callback = 52 AutofillClient::ResultCallback callback =
55 base::Bind(&RequestAutocompleteManager::ReturnAutocompleteResult, 53 base::Bind(&RequestAutocompleteManager::ReturnAutocompleteResult,
56 weak_ptr_factory_.GetWeakPtr()); 54 weak_ptr_factory_.GetWeakPtr());
57 ShowRequestAutocompleteDialog(form, frame_url, callback); 55 ShowRequestAutocompleteDialog(form, callback);
58 }
59
60 void RequestAutocompleteManager::OnCancelRequestAutocomplete() {
61 autofill_driver_->autofill_manager()->client()
62 ->HideRequestAutocompleteDialog();
63 } 56 }
64 57
65 void RequestAutocompleteManager::ReturnAutocompleteResult( 58 void RequestAutocompleteManager::ReturnAutocompleteResult(
66 AutofillClient::RequestAutocompleteResult result, 59 AutofillClient::RequestAutocompleteResult result,
67 const base::string16& debug_message, 60 const base::string16& debug_message,
68 const FormStructure* form_structure) { 61 const FormStructure* form_structure) {
69 content::RenderFrameHost* host = autofill_driver_->render_frame_host(); 62 content::RenderFrameHost* host = autofill_driver_->render_frame_host();
70 if (!host) 63 if (!host)
71 return; 64 return;
72 65
73 FormData form_data; 66 FormData form_data;
74 if (form_structure) { 67 if (form_structure) {
75 form_data = form_structure->ToFormData(); 68 form_data = form_structure->ToFormData();
76 for (size_t i = 0; i < form_data.fields.size(); ++i) { 69 for (size_t i = 0; i < form_data.fields.size(); ++i) {
77 if(!form_data.fields[i].value.empty()) 70 if(!form_data.fields[i].value.empty())
78 form_data.fields[i].is_autofilled = true; 71 form_data.fields[i].is_autofilled = true;
79 } 72 }
80 } 73 }
81 74
82 host->Send(new AutofillMsg_RequestAutocompleteResult( 75 host->Send(new AutofillMsg_RequestAutocompleteResult(
83 host->GetRoutingID(), 76 host->GetRoutingID(),
84 ToWebkitAutocompleteResult(result), 77 ToWebkitAutocompleteResult(result),
85 debug_message, 78 debug_message,
86 form_data)); 79 form_data));
87 } 80 }
88 81
89 void RequestAutocompleteManager::ShowRequestAutocompleteDialog( 82 void RequestAutocompleteManager::ShowRequestAutocompleteDialog(
90 const FormData& form, 83 const FormData& form,
91 const GURL& source_url,
92 const AutofillClient::ResultCallback& callback) { 84 const AutofillClient::ResultCallback& callback) {
93 AutofillClient* client = autofill_driver_->autofill_manager()->client(); 85 AutofillClient* client = autofill_driver_->autofill_manager()->client();
94 client->ShowRequestAutocompleteDialog(form, source_url, callback); 86 client->ShowRequestAutocompleteDialog(
87 form, autofill_driver_->render_frame_host(), callback);
95 } 88 }
96 89
97 } // namespace autofill 90 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698