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

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

Issue 306053008: Rename AutofillManagerDelegate to AutofillClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 6 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"
11 #include "components/autofill/core/common/form_data.h" 11 #include "components/autofill/core/common/form_data.h"
12 #include "content/public/browser/render_view_host.h" 12 #include "content/public/browser/render_view_host.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "third_party/WebKit/public/web/WebFormElement.h" 14 #include "third_party/WebKit/public/web/WebFormElement.h"
15 #include "url/gurl.h" 15 #include "url/gurl.h"
16 16
17 namespace autofill { 17 namespace autofill {
18 18
19 namespace { 19 namespace {
20 20
21 blink::WebFormElement::AutocompleteResult ToWebkitAutocompleteResult( 21 blink::WebFormElement::AutocompleteResult ToWebkitAutocompleteResult(
22 AutofillManagerDelegate::RequestAutocompleteResult result) { 22 AutofillClient::RequestAutocompleteResult result) {
23 switch(result) { 23 switch(result) {
24 case AutofillManagerDelegate::AutocompleteResultSuccess: 24 case AutofillClient::AutocompleteResultSuccess:
25 return blink::WebFormElement::AutocompleteResultSuccess; 25 return blink::WebFormElement::AutocompleteResultSuccess;
26 case AutofillManagerDelegate::AutocompleteResultErrorDisabled: 26 case AutofillClient::AutocompleteResultErrorDisabled:
27 return blink::WebFormElement::AutocompleteResultErrorDisabled; 27 return blink::WebFormElement::AutocompleteResultErrorDisabled;
28 case AutofillManagerDelegate::AutocompleteResultErrorCancel: 28 case AutofillClient::AutocompleteResultErrorCancel:
29 return blink::WebFormElement::AutocompleteResultErrorCancel; 29 return blink::WebFormElement::AutocompleteResultErrorCancel;
30 case AutofillManagerDelegate::AutocompleteResultErrorInvalid: 30 case AutofillClient::AutocompleteResultErrorInvalid:
31 return blink::WebFormElement::AutocompleteResultErrorInvalid; 31 return blink::WebFormElement::AutocompleteResultErrorInvalid;
32 } 32 }
33 33
34 NOTREACHED(); 34 NOTREACHED();
35 return blink::WebFormElement::AutocompleteResultErrorDisabled; 35 return blink::WebFormElement::AutocompleteResultErrorDisabled;
36 } 36 }
37 37
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(
49 const FormData& form, 49 const FormData& form,
50 const GURL& frame_url) { 50 const GURL& frame_url) {
51 if (!IsValidFormData(form)) 51 if (!IsValidFormData(form))
52 return; 52 return;
53 53
54 AutofillManagerDelegate::ResultCallback callback = 54 AutofillClient::ResultCallback callback =
55 base::Bind(&RequestAutocompleteManager::ReturnAutocompleteResult, 55 base::Bind(&RequestAutocompleteManager::ReturnAutocompleteResult,
56 weak_ptr_factory_.GetWeakPtr()); 56 weak_ptr_factory_.GetWeakPtr());
57 ShowRequestAutocompleteDialog(form, frame_url, callback); 57 ShowRequestAutocompleteDialog(form, frame_url, callback);
58 } 58 }
59 59
60 void RequestAutocompleteManager::OnCancelRequestAutocomplete() { 60 void RequestAutocompleteManager::OnCancelRequestAutocomplete() {
61 autofill_driver_->autofill_manager()->delegate()-> 61 autofill_driver_->autofill_manager()->client()
62 HideRequestAutocompleteDialog(); 62 ->HideRequestAutocompleteDialog();
63 } 63 }
64 64
65 void RequestAutocompleteManager::ReturnAutocompleteResult( 65 void RequestAutocompleteManager::ReturnAutocompleteResult(
66 AutofillManagerDelegate::RequestAutocompleteResult result, 66 AutofillClient::RequestAutocompleteResult result,
67 const base::string16& debug_message, 67 const base::string16& debug_message,
68 const FormStructure* form_structure) { 68 const FormStructure* form_structure) {
69 // autofill_driver_->GetWebContents() will be NULL when the interactive 69 // autofill_driver_->GetWebContents() will be NULL when the interactive
70 // autocomplete is closed due to a tab or browser window closing. 70 // autocomplete is closed due to a tab or browser window closing.
71 if (!autofill_driver_->GetWebContents()) 71 if (!autofill_driver_->GetWebContents())
72 return; 72 return;
73 73
74 content::RenderViewHost* host = 74 content::RenderViewHost* host =
75 autofill_driver_->GetWebContents()->GetRenderViewHost(); 75 autofill_driver_->GetWebContents()->GetRenderViewHost();
76 if (!host) 76 if (!host)
(...skipping 11 matching lines...) Expand all
88 host->Send(new AutofillMsg_RequestAutocompleteResult( 88 host->Send(new AutofillMsg_RequestAutocompleteResult(
89 host->GetRoutingID(), 89 host->GetRoutingID(),
90 ToWebkitAutocompleteResult(result), 90 ToWebkitAutocompleteResult(result),
91 debug_message, 91 debug_message,
92 form_data)); 92 form_data));
93 } 93 }
94 94
95 void RequestAutocompleteManager::ShowRequestAutocompleteDialog( 95 void RequestAutocompleteManager::ShowRequestAutocompleteDialog(
96 const FormData& form, 96 const FormData& form,
97 const GURL& source_url, 97 const GURL& source_url,
98 const AutofillManagerDelegate::ResultCallback& callback) { 98 const AutofillClient::ResultCallback& callback) {
99 AutofillManagerDelegate* delegate = 99 AutofillClient* client = autofill_driver_->autofill_manager()->client();
100 autofill_driver_->autofill_manager()->delegate(); 100 client->ShowRequestAutocompleteDialog(form, source_url, callback);
101 delegate->ShowRequestAutocompleteDialog(form, source_url, callback);
102 } 101 }
103 102
104 } // namespace autofill 103 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698