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

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

Issue 229723002: Better error reasons for rAc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 11 matching lines...) Expand all
22 } 22 }
23 23
24 RequestAutocompleteManager::~RequestAutocompleteManager() {} 24 RequestAutocompleteManager::~RequestAutocompleteManager() {}
25 25
26 void RequestAutocompleteManager::OnRequestAutocomplete( 26 void RequestAutocompleteManager::OnRequestAutocomplete(
27 const FormData& form, 27 const FormData& form,
28 const GURL& frame_url) { 28 const GURL& frame_url) {
29 if (!IsValidFormData(form)) 29 if (!IsValidFormData(form))
30 return; 30 return;
31 31
32 base::Callback<void(const FormStructure*)> callback = 32 AutofillManagerDelegate::ResultCallback callback =
33 base::Bind(&RequestAutocompleteManager::ReturnAutocompleteData, 33 base::Bind(&RequestAutocompleteManager::ReturnAutocompleteResult,
34 weak_ptr_factory_.GetWeakPtr()); 34 weak_ptr_factory_.GetWeakPtr());
35 ShowRequestAutocompleteDialog(form, frame_url, callback); 35 ShowRequestAutocompleteDialog(form, frame_url, callback);
36 } 36 }
37 37
38 void RequestAutocompleteManager::OnCancelRequestAutocomplete() { 38 void RequestAutocompleteManager::OnCancelRequestAutocomplete() {
39 autofill_driver_->autofill_manager()->delegate()-> 39 autofill_driver_->autofill_manager()->delegate()->
40 HideRequestAutocompleteDialog(); 40 HideRequestAutocompleteDialog();
41 } 41 }
42 42
43 void RequestAutocompleteManager::ReturnAutocompleteResult( 43 void RequestAutocompleteManager::ReturnAutocompleteResult(
44 blink::WebFormElement::AutocompleteResult result, 44 blink::WebFormElement::AutocompleteResult result,
45 const FormData& form_data) { 45 const FormStructure* form_structure) {
46 // autofill_driver_->GetWebContents() will be NULL when the interactive 46 // autofill_driver_->GetWebContents() will be NULL when the interactive
47 // autocomplete is closed due to a tab or browser window closing. 47 // autocomplete is closed due to a tab or browser window closing.
48 if (!autofill_driver_->GetWebContents()) 48 if (!autofill_driver_->GetWebContents())
49 return; 49 return;
50 50
51 content::RenderViewHost* host = 51 content::RenderViewHost* host =
52 autofill_driver_->GetWebContents()->GetRenderViewHost(); 52 autofill_driver_->GetWebContents()->GetRenderViewHost();
53 if (!host) 53 if (!host)
54 return; 54 return;
55 55
56 host->Send(new AutofillMsg_RequestAutocompleteResult(host->GetRoutingID(), 56 host->Send(new AutofillMsg_RequestAutocompleteResult(
57 result, 57 host->GetRoutingID(),
58 form_data)); 58 result,
59 } 59 form_structure ? form_structure->ToFormData() : FormData()));
60
61 void RequestAutocompleteManager::ReturnAutocompleteData(
62 const FormStructure* result) {
63 if (!result) {
64 ReturnAutocompleteResult(
65 blink::WebFormElement::AutocompleteResultErrorCancel, FormData());
66 } else {
67 ReturnAutocompleteResult(blink::WebFormElement::AutocompleteResultSuccess,
68 result->ToFormData());
69 }
70 } 60 }
71 61
72 void RequestAutocompleteManager::ShowRequestAutocompleteDialog( 62 void RequestAutocompleteManager::ShowRequestAutocompleteDialog(
73 const FormData& form, 63 const FormData& form,
74 const GURL& source_url, 64 const GURL& source_url,
75 const base::Callback<void(const FormStructure*)>& callback) { 65 const AutofillManagerDelegate::ResultCallback& callback) {
76 AutofillManagerDelegate* delegate = 66 AutofillManagerDelegate* delegate =
77 autofill_driver_->autofill_manager()->delegate(); 67 autofill_driver_->autofill_manager()->delegate();
78 delegate->ShowRequestAutocompleteDialog(form, source_url, callback); 68 delegate->ShowRequestAutocompleteDialog(form, source_url, callback);
79 } 69 }
80 70
81 } // namespace autofill 71 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698