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

Side by Side Diff: components/autofill/core/browser/autocomplete_history_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/core/browser/autocomplete_history_manager.h" 5 #include "components/autofill/core/browser/autocomplete_history_manager.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "components/autofill/core/browser/autofill_client.h"
12 #include "components/autofill/core/browser/autofill_driver.h" 13 #include "components/autofill/core/browser/autofill_driver.h"
13 #include "components/autofill/core/browser/autofill_external_delegate.h" 14 #include "components/autofill/core/browser/autofill_external_delegate.h"
14 #include "components/autofill/core/browser/autofill_manager_delegate.h"
15 #include "components/autofill/core/browser/validation.h" 15 #include "components/autofill/core/browser/validation.h"
16 #include "components/autofill/core/common/autofill_pref_names.h" 16 #include "components/autofill/core/common/autofill_pref_names.h"
17 #include "components/autofill/core/common/form_data.h" 17 #include "components/autofill/core/common/form_data.h"
18 18
19 namespace autofill { 19 namespace autofill {
20 namespace { 20 namespace {
21 21
22 // Limit on the number of suggestions to appear in the pop-up menu under an 22 // Limit on the number of suggestions to appear in the pop-up menu under an
23 // text input element in a form. 23 // text input element in a form.
24 const int kMaxAutocompleteMenuItems = 6; 24 const int kMaxAutocompleteMenuItems = 6;
25 25
26 bool IsTextField(const FormFieldData& field) { 26 bool IsTextField(const FormFieldData& field) {
27 return 27 return
28 field.form_control_type == "text" || 28 field.form_control_type == "text" ||
29 field.form_control_type == "search" || 29 field.form_control_type == "search" ||
30 field.form_control_type == "tel" || 30 field.form_control_type == "tel" ||
31 field.form_control_type == "url" || 31 field.form_control_type == "url" ||
32 field.form_control_type == "email"; 32 field.form_control_type == "email";
33 } 33 }
34 34
35 } // namespace 35 } // namespace
36 36
37 AutocompleteHistoryManager::AutocompleteHistoryManager( 37 AutocompleteHistoryManager::AutocompleteHistoryManager(
38 AutofillDriver* driver, 38 AutofillDriver* driver,
39 AutofillManagerDelegate* manager_delegate) 39 AutofillClient* autofill_client)
40 : driver_(driver), 40 : driver_(driver),
41 database_(manager_delegate->GetDatabase()), 41 database_(autofill_client->GetDatabase()),
42 pending_query_handle_(0), 42 pending_query_handle_(0),
43 query_id_(0), 43 query_id_(0),
44 external_delegate_(NULL), 44 external_delegate_(NULL),
45 manager_delegate_(manager_delegate) { 45 autofill_client_(autofill_client) {
46 DCHECK(manager_delegate_); 46 DCHECK(autofill_client_);
47 } 47 }
48 48
49 AutocompleteHistoryManager::~AutocompleteHistoryManager() { 49 AutocompleteHistoryManager::~AutocompleteHistoryManager() {
50 CancelPendingQuery(); 50 CancelPendingQuery();
51 } 51 }
52 52
53 void AutocompleteHistoryManager::OnWebDataServiceRequestDone( 53 void AutocompleteHistoryManager::OnWebDataServiceRequestDone(
54 WebDataServiceBase::Handle h, 54 WebDataServiceBase::Handle h,
55 const WDTypedResult* result) { 55 const WDTypedResult* result) {
56 DCHECK(pending_query_handle_); 56 DCHECK(pending_query_handle_);
57 pending_query_handle_ = 0; 57 pending_query_handle_ = 0;
58 58
59 if (!manager_delegate_->IsAutocompleteEnabled()) { 59 if (!autofill_client_->IsAutocompleteEnabled()) {
60 SendSuggestions(NULL); 60 SendSuggestions(NULL);
61 return; 61 return;
62 } 62 }
63 63
64 DCHECK(result); 64 DCHECK(result);
65 // Returning early here if |result| is NULL. We've seen this happen on 65 // Returning early here if |result| is NULL. We've seen this happen on
66 // Linux due to NFS dismounting and causing sql failures. 66 // Linux due to NFS dismounting and causing sql failures.
67 // See http://crbug.com/68783. 67 // See http://crbug.com/68783.
68 if (!result) { 68 if (!result) {
69 SendSuggestions(NULL); 69 SendSuggestions(NULL);
(...skipping 16 matching lines...) Expand all
86 const std::vector<base::string16>& autofill_labels, 86 const std::vector<base::string16>& autofill_labels,
87 const std::vector<base::string16>& autofill_icons, 87 const std::vector<base::string16>& autofill_icons,
88 const std::vector<int>& autofill_unique_ids) { 88 const std::vector<int>& autofill_unique_ids) {
89 CancelPendingQuery(); 89 CancelPendingQuery();
90 90
91 query_id_ = query_id; 91 query_id_ = query_id;
92 autofill_values_ = autofill_values; 92 autofill_values_ = autofill_values;
93 autofill_labels_ = autofill_labels; 93 autofill_labels_ = autofill_labels;
94 autofill_icons_ = autofill_icons; 94 autofill_icons_ = autofill_icons;
95 autofill_unique_ids_ = autofill_unique_ids; 95 autofill_unique_ids_ = autofill_unique_ids;
96 if (!manager_delegate_->IsAutocompleteEnabled() || 96 if (!autofill_client_->IsAutocompleteEnabled() ||
97 form_control_type == "textarea") { 97 form_control_type == "textarea") {
98 SendSuggestions(NULL); 98 SendSuggestions(NULL);
99 return; 99 return;
100 } 100 }
101 101
102 if (database_.get()) { 102 if (database_.get()) {
103 pending_query_handle_ = database_->GetFormValuesForElementName( 103 pending_query_handle_ = database_->GetFormValuesForElementName(
104 name, prefix, kMaxAutocompleteMenuItems, this); 104 name, prefix, kMaxAutocompleteMenuItems, this);
105 } 105 }
106 } 106 }
107 107
108 void AutocompleteHistoryManager::OnFormSubmitted(const FormData& form) { 108 void AutocompleteHistoryManager::OnFormSubmitted(const FormData& form) {
109 if (!manager_delegate_->IsAutocompleteEnabled()) 109 if (!autofill_client_->IsAutocompleteEnabled())
110 return; 110 return;
111 111
112 if (driver_->IsOffTheRecord()) 112 if (driver_->IsOffTheRecord())
113 return; 113 return;
114 114
115 // Don't save data that was submitted through JavaScript. 115 // Don't save data that was submitted through JavaScript.
116 if (!form.user_submitted) 116 if (!form.user_submitted)
117 return; 117 return;
118 118
119 // We put the following restriction on stored FormFields: 119 // We put the following restriction on stored FormFields:
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 autofill_unique_ids_); 188 autofill_unique_ids_);
189 189
190 query_id_ = 0; 190 query_id_ = 0;
191 autofill_values_.clear(); 191 autofill_values_.clear();
192 autofill_labels_.clear(); 192 autofill_labels_.clear();
193 autofill_icons_.clear(); 193 autofill_icons_.clear();
194 autofill_unique_ids_.clear(); 194 autofill_unique_ids_.clear();
195 } 195 }
196 196
197 } // namespace autofill 197 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698