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

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

Issue 279001: Move autofill related WebView{Delegate} methods into the WebKit API.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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
« no previous file with comments | « chrome/browser/autofill_manager.h ('k') | chrome/browser/renderer_host/render_view_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_manager.h" 5 #include "chrome/browser/autofill_manager.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/browser/profile.h" 8 #include "chrome/browser/profile.h"
9 #include "chrome/browser/tab_contents/tab_contents.h" 9 #include "chrome/browser/tab_contents/tab_contents.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
11 #include "chrome/common/pref_service.h" 11 #include "chrome/common/pref_service.h"
12 #include "webkit/glue/autofill_form.h" 12 #include "webkit/glue/autofill_form.h"
13 13
14 // Limit on the number of suggestions to appear in the pop-up menu under an 14 // Limit on the number of suggestions to appear in the pop-up menu under an
15 // text input element in a form. 15 // text input element in a form.
16 static const int kMaxAutofillMenuItems = 6; 16 static const int kMaxAutofillMenuItems = 6;
17 17
18 // static 18 // static
19 void AutofillManager::RegisterUserPrefs(PrefService* prefs) { 19 void AutofillManager::RegisterUserPrefs(PrefService* prefs) {
20 prefs->RegisterBooleanPref(prefs::kFormAutofillEnabled, true); 20 prefs->RegisterBooleanPref(prefs::kFormAutofillEnabled, true);
21 } 21 }
22 22
23 AutofillManager::AutofillManager(TabContents* tab_contents) 23 AutofillManager::AutofillManager(TabContents* tab_contents)
24 : tab_contents_(tab_contents), 24 : tab_contents_(tab_contents),
25 pending_query_handle_(0), 25 pending_query_handle_(0),
26 request_id_(0) { 26 query_id_(0) {
27 form_autofill_enabled_.Init(prefs::kFormAutofillEnabled, 27 form_autofill_enabled_.Init(prefs::kFormAutofillEnabled,
28 profile()->GetPrefs(), NULL); 28 profile()->GetPrefs(), NULL);
29 } 29 }
30 30
31 AutofillManager::~AutofillManager() { 31 AutofillManager::~AutofillManager() {
32 CancelPendingQuery(); 32 CancelPendingQuery();
33 } 33 }
34 34
35 void AutofillManager::CancelPendingQuery() { 35 void AutofillManager::CancelPendingQuery() {
36 if (pending_query_handle_) { 36 if (pending_query_handle_) {
(...skipping 11 matching lines...) Expand all
48 48
49 Profile* AutofillManager::profile() { 49 Profile* AutofillManager::profile() {
50 return tab_contents_->profile(); 50 return tab_contents_->profile();
51 } 51 }
52 52
53 void AutofillManager::AutofillFormSubmitted( 53 void AutofillManager::AutofillFormSubmitted(
54 const webkit_glue::AutofillForm& form) { 54 const webkit_glue::AutofillForm& form) {
55 StoreFormEntriesInWebDatabase(form); 55 StoreFormEntriesInWebDatabase(form);
56 } 56 }
57 57
58 bool AutofillManager::GetAutofillSuggestions(int request_id, 58 bool AutofillManager::GetAutofillSuggestions(int query_id,
59 const std::wstring& name, 59 const string16& name,
60 const std::wstring& prefix) { 60 const string16& prefix) {
61 if (!*form_autofill_enabled_) 61 if (!*form_autofill_enabled_)
62 return false; 62 return false;
63 63
64 WebDataService* web_data_service = 64 WebDataService* web_data_service =
65 profile()->GetWebDataService(Profile::EXPLICIT_ACCESS); 65 profile()->GetWebDataService(Profile::EXPLICIT_ACCESS);
66 if (!web_data_service) { 66 if (!web_data_service) {
67 NOTREACHED(); 67 NOTREACHED();
68 return false; 68 return false;
69 } 69 }
70 70
71 CancelPendingQuery(); 71 CancelPendingQuery();
72 72
73 request_id_ = request_id; 73 query_id_ = query_id;
74 74
75 pending_query_handle_ = web_data_service->GetFormValuesForElementName( 75 pending_query_handle_ = web_data_service->GetFormValuesForElementName(
76 name, prefix, kMaxAutofillMenuItems, this); 76 name, prefix, kMaxAutofillMenuItems, this);
77 return true; 77 return true;
78 } 78 }
79 79
80 void AutofillManager::RemoveAutofillEntry(const std::wstring& name, 80 void AutofillManager::RemoveAutofillEntry(const string16& name,
81 const std::wstring& value) { 81 const string16& value) {
82 WebDataService* web_data_service = 82 WebDataService* web_data_service =
83 profile()->GetWebDataService(Profile::EXPLICIT_ACCESS); 83 profile()->GetWebDataService(Profile::EXPLICIT_ACCESS);
84 if (!web_data_service) { 84 if (!web_data_service) {
85 NOTREACHED(); 85 NOTREACHED();
86 return; 86 return;
87 } 87 }
88 88
89 web_data_service->RemoveFormValueForElementName(name, value); 89 web_data_service->RemoveFormValueForElementName(name, value);
90 } 90 }
91 91
(...skipping 21 matching lines...) Expand all
113 profile()->GetWebDataService(Profile::EXPLICIT_ACCESS)-> 113 profile()->GetWebDataService(Profile::EXPLICIT_ACCESS)->
114 AddAutofillFormElements(form.elements); 114 AddAutofillFormElements(form.elements);
115 } 115 }
116 116
117 void AutofillManager::SendSuggestions(const WDTypedResult* result) { 117 void AutofillManager::SendSuggestions(const WDTypedResult* result) {
118 RenderViewHost* host = tab_contents_->render_view_host(); 118 RenderViewHost* host = tab_contents_->render_view_host();
119 if (!host) 119 if (!host)
120 return; 120 return;
121 if (result) { 121 if (result) {
122 DCHECK(result->GetType() == AUTOFILL_VALUE_RESULT); 122 DCHECK(result->GetType() == AUTOFILL_VALUE_RESULT);
123 const WDResult<std::vector<std::wstring> >* autofill_result = 123 const WDResult<std::vector<string16> >* autofill_result =
124 static_cast<const WDResult<std::vector<std::wstring> >*>(result); 124 static_cast<const WDResult<std::vector<string16> >*>(result);
125 host->AutofillSuggestionsReturned( 125 host->AutofillSuggestionsReturned(
126 request_id_, autofill_result->GetValue(), -1); 126 query_id_, autofill_result->GetValue(), -1);
127 } else { 127 } else {
128 host->AutofillSuggestionsReturned( 128 host->AutofillSuggestionsReturned(
129 request_id_, std::vector<std::wstring>(), -1); 129 query_id_, std::vector<string16>(), -1);
130 } 130 }
131 } 131 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill_manager.h ('k') | chrome/browser/renderer_host/render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698