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

Side by Side Diff: components/autofill/browser/autofill_manager.cc

Issue 15097004: Enable Autocomplete feature for chromium webview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@setSaveFormData2
Patch Set: rebased for IPC changes Created 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/autofill_manager.h" 5 #include "components/autofill/browser/autofill_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
185 AutofillManager::AutofillManager( 185 AutofillManager::AutofillManager(
186 AutofillDriver* driver, 186 AutofillDriver* driver,
187 autofill::AutofillManagerDelegate* delegate, 187 autofill::AutofillManagerDelegate* delegate,
188 const std::string& app_locale, 188 const std::string& app_locale,
189 AutofillDownloadManagerState enable_download_manager) 189 AutofillDownloadManagerState enable_download_manager)
190 : driver_(driver), 190 : driver_(driver),
191 manager_delegate_(delegate), 191 manager_delegate_(delegate),
192 app_locale_(app_locale), 192 app_locale_(app_locale),
193 personal_data_(delegate->GetPersonalDataManager()), 193 personal_data_(delegate->GetPersonalDataManager()),
194 autocomplete_history_manager_(driver),
195 autocheckout_manager_(this), 194 autocheckout_manager_(this),
196 metric_logger_(new AutofillMetrics), 195 metric_logger_(new AutofillMetrics),
197 has_logged_autofill_enabled_(false), 196 has_logged_autofill_enabled_(false),
198 has_logged_address_suggestions_count_(false), 197 has_logged_address_suggestions_count_(false),
199 did_show_suggestions_(false), 198 did_show_suggestions_(false),
200 user_did_type_(false), 199 user_did_type_(false),
201 user_did_autofill_(false), 200 user_did_autofill_(false),
202 user_did_edit_autofilled_field_(false), 201 user_did_edit_autofilled_field_(false),
203 external_delegate_(NULL), 202 external_delegate_(NULL),
204 test_delegate_(NULL), 203 test_delegate_(NULL),
205 weak_ptr_factory_(this) { 204 weak_ptr_factory_(this) {
205 autocomplete_history_manager_.reset(
206 new AutocompleteHistoryManager(driver,delegate));
Ilya Sherman 2013/06/19 00:38:27 nit: Please include a space after the comma.
Ilya Sherman 2013/06/19 00:38:27 nit: Why did this get moved out of the initializer
sgurun-gerrit only 2013/06/19 17:56:23 Done.
sgurun-gerrit only 2013/06/19 17:56:23 Done.
206 if (enable_download_manager == ENABLE_AUTOFILL_DOWNLOAD_MANAGER) { 207 if (enable_download_manager == ENABLE_AUTOFILL_DOWNLOAD_MANAGER) {
207 download_manager_.reset( 208 download_manager_.reset(
208 new AutofillDownloadManager( 209 new AutofillDownloadManager(
209 driver->GetWebContents()->GetBrowserContext(), this)); 210 driver->GetWebContents()->GetBrowserContext(), this));
210 } 211 }
211 } 212 }
212 213
213 AutofillManager::~AutofillManager() {} 214 AutofillManager::~AutofillManager() {}
214 215
215 // static 216 // static
(...skipping 29 matching lines...) Expand all
245 const content::FrameNavigateParams& params) { 246 const content::FrameNavigateParams& params) {
246 if (details.is_navigation_to_different_page()) 247 if (details.is_navigation_to_different_page())
247 Reset(); 248 Reset();
248 } 249 }
249 250
250 void AutofillManager::SetExternalDelegate(AutofillExternalDelegate* delegate) { 251 void AutofillManager::SetExternalDelegate(AutofillExternalDelegate* delegate) {
251 // TODO(jrg): consider passing delegate into the ctor. That won't 252 // TODO(jrg): consider passing delegate into the ctor. That won't
252 // work if the delegate has a pointer to the AutofillManager, but 253 // work if the delegate has a pointer to the AutofillManager, but
253 // future directions may not need such a pointer. 254 // future directions may not need such a pointer.
254 external_delegate_ = delegate; 255 external_delegate_ = delegate;
255 autocomplete_history_manager_.SetExternalDelegate(delegate); 256 autocomplete_history_manager_->SetExternalDelegate(delegate);
256 } 257 }
257 258
258 bool AutofillManager::IsNativeUiEnabled() { 259 bool AutofillManager::IsNativeUiEnabled() {
259 return external_delegate_ != NULL; 260 return external_delegate_ != NULL;
260 } 261 }
261 262
262 bool AutofillManager::OnMessageReceived(const IPC::Message& message) { 263 bool AutofillManager::OnMessageReceived(const IPC::Message& message) {
263 bool handled = true; 264 bool handled = true;
264 IPC_BEGIN_MESSAGE_MAP(AutofillManager, message) 265 IPC_BEGIN_MESSAGE_MAP(AutofillManager, message)
265 IPC_MESSAGE_HANDLER(AutofillHostMsg_FormsSeen, OnFormsSeen) 266 IPC_MESSAGE_HANDLER(AutofillHostMsg_FormsSeen, OnFormsSeen)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 IPC_MESSAGE_HANDLER(AutofillHostMsg_RemoveAutocompleteEntry, 298 IPC_MESSAGE_HANDLER(AutofillHostMsg_RemoveAutocompleteEntry,
298 RemoveAutocompleteEntry) 299 RemoveAutocompleteEntry)
299 IPC_MESSAGE_UNHANDLED(handled = false) 300 IPC_MESSAGE_UNHANDLED(handled = false)
300 IPC_END_MESSAGE_MAP() 301 IPC_END_MESSAGE_MAP()
301 302
302 return handled; 303 return handled;
303 } 304 }
304 305
305 bool AutofillManager::OnFormSubmitted(const FormData& form, 306 bool AutofillManager::OnFormSubmitted(const FormData& form,
306 const TimeTicks& timestamp) { 307 const TimeTicks& timestamp) {
307 // Let AutoComplete know as well. 308 // Let Autocomplete know as well.
308 autocomplete_history_manager_.OnFormSubmitted(form); 309 autocomplete_history_manager_->OnFormSubmitted(form);
309 310
310 if (!IsAutofillEnabled()) 311 if (!IsAutofillEnabled())
311 return false; 312 return false;
312 313
313 if (driver_->GetWebContents()->GetBrowserContext()->IsOffTheRecord()) 314 if (driver_->GetWebContents()->GetBrowserContext()->IsOffTheRecord())
314 return false; 315 return false;
315 316
316 // Don't save data that was submitted through JavaScript. 317 // Don't save data that was submitted through JavaScript.
317 if (!form.user_submitted) 318 if (!form.user_submitted)
318 return false; 319 return false;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 metric_logger_->LogAddressSuggestionsCount(values.size()); 533 metric_logger_->LogAddressSuggestionsCount(values.size());
533 has_logged_address_suggestions_count_ = true; 534 has_logged_address_suggestions_count_ = true;
534 } 535 }
535 } 536 }
536 } 537 }
537 } 538 }
538 539
539 // Add the results from AutoComplete. They come back asynchronously, so we 540 // Add the results from AutoComplete. They come back asynchronously, so we
540 // hand off what we generated and they will send the results back to the 541 // hand off what we generated and they will send the results back to the
541 // renderer. 542 // renderer.
542 autocomplete_history_manager_.OnGetAutocompleteSuggestions( 543 autocomplete_history_manager_->OnGetAutocompleteSuggestions(
543 query_id, field.name, field.value, values, labels, icons, unique_ids); 544 query_id, field.name, field.value, values, labels, icons, unique_ids);
544 } 545 }
545 546
546 void AutofillManager::OnFillAutofillFormData(int query_id, 547 void AutofillManager::OnFillAutofillFormData(int query_id,
547 const FormData& form, 548 const FormData& form,
548 const FormFieldData& field, 549 const FormFieldData& field,
549 int unique_id) { 550 int unique_id) {
550 RenderViewHost* host = NULL; 551 RenderViewHost* host = NULL;
551 const AutofillDataModel* data_model = NULL; 552 const AutofillDataModel* data_model = NULL;
552 size_t variant = 0; 553 size_t variant = 0;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 // be deleted, instead of doing nothing. 687 // be deleted, instead of doing nothing.
687 // http://crbug.com/124211 688 // http://crbug.com/124211
688 if (variant != 0) 689 if (variant != 0)
689 return; 690 return;
690 691
691 personal_data_->RemoveByGUID(data_model->guid()); 692 personal_data_->RemoveByGUID(data_model->guid());
692 } 693 }
693 694
694 void AutofillManager::RemoveAutocompleteEntry(const base::string16& name, 695 void AutofillManager::RemoveAutocompleteEntry(const base::string16& name,
695 const base::string16& value) { 696 const base::string16& value) {
696 autocomplete_history_manager_.OnRemoveAutocompleteEntry(name, value); 697 autocomplete_history_manager_->OnRemoveAutocompleteEntry(name, value);
697 } 698 }
698 699
699 content::WebContents* AutofillManager::GetWebContents() const { 700 content::WebContents* AutofillManager::GetWebContents() const {
700 return driver_->GetWebContents(); 701 return driver_->GetWebContents();
701 } 702 }
702 703
703 const std::vector<FormStructure*>& AutofillManager::GetFormStructures() { 704 const std::vector<FormStructure*>& AutofillManager::GetFormStructures() {
704 return form_structures_.get(); 705 return form_structures_.get();
705 } 706 }
706 707
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 external_delegate_->Reset(); 959 external_delegate_->Reset();
959 } 960 }
960 961
961 AutofillManager::AutofillManager(AutofillDriver* driver, 962 AutofillManager::AutofillManager(AutofillDriver* driver,
962 autofill::AutofillManagerDelegate* delegate, 963 autofill::AutofillManagerDelegate* delegate,
963 PersonalDataManager* personal_data) 964 PersonalDataManager* personal_data)
964 : driver_(driver), 965 : driver_(driver),
965 manager_delegate_(delegate), 966 manager_delegate_(delegate),
966 app_locale_("en-US"), 967 app_locale_("en-US"),
967 personal_data_(personal_data), 968 personal_data_(personal_data),
968 autocomplete_history_manager_(driver),
969 autocheckout_manager_(this), 969 autocheckout_manager_(this),
970 metric_logger_(new AutofillMetrics), 970 metric_logger_(new AutofillMetrics),
971 has_logged_autofill_enabled_(false), 971 has_logged_autofill_enabled_(false),
972 has_logged_address_suggestions_count_(false), 972 has_logged_address_suggestions_count_(false),
973 did_show_suggestions_(false), 973 did_show_suggestions_(false),
974 user_did_type_(false), 974 user_did_type_(false),
975 user_did_autofill_(false), 975 user_did_autofill_(false),
976 user_did_edit_autofilled_field_(false), 976 user_did_edit_autofilled_field_(false),
977 external_delegate_(NULL), 977 external_delegate_(NULL),
978 test_delegate_(NULL), 978 test_delegate_(NULL),
979 weak_ptr_factory_(this) { 979 weak_ptr_factory_(this) {
980 autocomplete_history_manager_.reset(
981 new AutocompleteHistoryManager(driver, delegate));
Ilya Sherman 2013/06/19 00:38:27 nit: Why did this get moved out of the initializer
sgurun-gerrit only 2013/06/19 17:56:23 Done.
980 DCHECK(driver_); 982 DCHECK(driver_);
981 DCHECK(driver_->GetWebContents()); 983 DCHECK(driver_->GetWebContents());
982 DCHECK(manager_delegate_); 984 DCHECK(manager_delegate_);
983 } 985 }
984 986
985 void AutofillManager::set_metric_logger(const AutofillMetrics* metric_logger) { 987 void AutofillManager::set_metric_logger(const AutofillMetrics* metric_logger) {
986 metric_logger_.reset(metric_logger); 988 metric_logger_.reset(metric_logger);
987 } 989 }
988 990
989 bool AutofillManager::GetHost(RenderViewHost** host) const { 991 bool AutofillManager::GetHost(RenderViewHost** host) const {
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 1295
1294 void AutofillManager::UpdateInitialInteractionTimestamp( 1296 void AutofillManager::UpdateInitialInteractionTimestamp(
1295 const TimeTicks& interaction_timestamp) { 1297 const TimeTicks& interaction_timestamp) {
1296 if (initial_interaction_timestamp_.is_null() || 1298 if (initial_interaction_timestamp_.is_null() ||
1297 interaction_timestamp < initial_interaction_timestamp_) { 1299 interaction_timestamp < initial_interaction_timestamp_) {
1298 initial_interaction_timestamp_ = interaction_timestamp; 1300 initial_interaction_timestamp_ = interaction_timestamp;
1299 } 1301 }
1300 } 1302 }
1301 1303
1302 } // namespace autofill 1304 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698