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

Side by Side Diff: components/autofill/core/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: add a check that disappeared during a merge. 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 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/autofill_manager.h" 5 #include "components/autofill/core/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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 181
182 AutofillManager::AutofillManager( 182 AutofillManager::AutofillManager(
183 AutofillDriver* driver, 183 AutofillDriver* driver,
184 autofill::AutofillManagerDelegate* delegate, 184 autofill::AutofillManagerDelegate* delegate,
185 const std::string& app_locale, 185 const std::string& app_locale,
186 AutofillDownloadManagerState enable_download_manager) 186 AutofillDownloadManagerState enable_download_manager)
187 : driver_(driver), 187 : driver_(driver),
188 manager_delegate_(delegate), 188 manager_delegate_(delegate),
189 app_locale_(app_locale), 189 app_locale_(app_locale),
190 personal_data_(delegate->GetPersonalDataManager()), 190 personal_data_(delegate->GetPersonalDataManager()),
191 autocomplete_history_manager_(driver), 191 autocomplete_history_manager_(
192 new AutocompleteHistoryManager(driver, delegate)),
192 autocheckout_manager_(this), 193 autocheckout_manager_(this),
193 metric_logger_(new AutofillMetrics), 194 metric_logger_(new AutofillMetrics),
194 has_logged_autofill_enabled_(false), 195 has_logged_autofill_enabled_(false),
195 has_logged_address_suggestions_count_(false), 196 has_logged_address_suggestions_count_(false),
196 did_show_suggestions_(false), 197 did_show_suggestions_(false),
197 user_did_type_(false), 198 user_did_type_(false),
198 user_did_autofill_(false), 199 user_did_autofill_(false),
199 user_did_edit_autofilled_field_(false), 200 user_did_edit_autofilled_field_(false),
200 external_delegate_(NULL), 201 external_delegate_(NULL),
201 test_delegate_(NULL), 202 test_delegate_(NULL),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 prefs::kAutofillNegativeUploadRate, 236 prefs::kAutofillNegativeUploadRate,
236 kAutofillNegativeUploadRateDefaultValue, 237 kAutofillNegativeUploadRateDefaultValue,
237 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 238 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
238 } 239 }
239 240
240 void AutofillManager::SetExternalDelegate(AutofillExternalDelegate* delegate) { 241 void AutofillManager::SetExternalDelegate(AutofillExternalDelegate* delegate) {
241 // TODO(jrg): consider passing delegate into the ctor. That won't 242 // TODO(jrg): consider passing delegate into the ctor. That won't
242 // work if the delegate has a pointer to the AutofillManager, but 243 // work if the delegate has a pointer to the AutofillManager, but
243 // future directions may not need such a pointer. 244 // future directions may not need such a pointer.
244 external_delegate_ = delegate; 245 external_delegate_ = delegate;
245 autocomplete_history_manager_.SetExternalDelegate(delegate); 246 autocomplete_history_manager_->SetExternalDelegate(delegate);
246 } 247 }
247 248
248 bool AutofillManager::IsNativeUiEnabled() { 249 bool AutofillManager::IsNativeUiEnabled() {
249 return external_delegate_ != NULL; 250 return external_delegate_ != NULL;
250 } 251 }
251 252
252 bool AutofillManager::OnFormSubmitted(const FormData& form, 253 bool AutofillManager::OnFormSubmitted(const FormData& form,
253 const TimeTicks& timestamp) { 254 const TimeTicks& timestamp) {
254 // Let AutoComplete know as well. 255 // Let Autocomplete know as well.
255 autocomplete_history_manager_.OnFormSubmitted(form); 256 autocomplete_history_manager_->OnFormSubmitted(form);
256 257
257 if (!IsAutofillEnabled()) 258 if (!IsAutofillEnabled())
258 return false; 259 return false;
259 260
260 if (driver_->GetWebContents()->GetBrowserContext()->IsOffTheRecord()) 261 if (driver_->GetWebContents()->GetBrowserContext()->IsOffTheRecord())
261 return false; 262 return false;
262 263
263 // Don't save data that was submitted through JavaScript. 264 // Don't save data that was submitted through JavaScript.
264 if (!form.user_submitted) 265 if (!form.user_submitted)
265 return false; 266 return false;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 metric_logger_->LogAddressSuggestionsCount(values.size()); 480 metric_logger_->LogAddressSuggestionsCount(values.size());
480 has_logged_address_suggestions_count_ = true; 481 has_logged_address_suggestions_count_ = true;
481 } 482 }
482 } 483 }
483 } 484 }
484 } 485 }
485 486
486 // Add the results from AutoComplete. They come back asynchronously, so we 487 // Add the results from AutoComplete. They come back asynchronously, so we
487 // hand off what we generated and they will send the results back to the 488 // hand off what we generated and they will send the results back to the
488 // renderer. 489 // renderer.
489 autocomplete_history_manager_.OnGetAutocompleteSuggestions( 490 autocomplete_history_manager_->OnGetAutocompleteSuggestions(
490 query_id, field.name, field.value, values, labels, icons, unique_ids); 491 query_id, field.name, field.value, values, labels, icons, unique_ids);
491 } 492 }
492 493
493 void AutofillManager::OnFillAutofillFormData(int query_id, 494 void AutofillManager::OnFillAutofillFormData(int query_id,
494 const FormData& form, 495 const FormData& form,
495 const FormFieldData& field, 496 const FormFieldData& field,
496 int unique_id) { 497 int unique_id) {
497 RenderViewHost* host = NULL; 498 RenderViewHost* host = NULL;
498 const AutofillDataModel* data_model = NULL; 499 const AutofillDataModel* data_model = NULL;
499 size_t variant = 0; 500 size_t variant = 0;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 // be deleted, instead of doing nothing. 634 // be deleted, instead of doing nothing.
634 // http://crbug.com/124211 635 // http://crbug.com/124211
635 if (variant != 0) 636 if (variant != 0)
636 return; 637 return;
637 638
638 personal_data_->RemoveByGUID(data_model->guid()); 639 personal_data_->RemoveByGUID(data_model->guid());
639 } 640 }
640 641
641 void AutofillManager::RemoveAutocompleteEntry(const base::string16& name, 642 void AutofillManager::RemoveAutocompleteEntry(const base::string16& name,
642 const base::string16& value) { 643 const base::string16& value) {
643 autocomplete_history_manager_.OnRemoveAutocompleteEntry(name, value); 644 autocomplete_history_manager_->OnRemoveAutocompleteEntry(name, value);
644 } 645 }
645 646
646 content::WebContents* AutofillManager::GetWebContents() const { 647 content::WebContents* AutofillManager::GetWebContents() const {
647 return driver_->GetWebContents(); 648 return driver_->GetWebContents();
648 } 649 }
649 650
650 const std::vector<FormStructure*>& AutofillManager::GetFormStructures() { 651 const std::vector<FormStructure*>& AutofillManager::GetFormStructures() {
651 return form_structures_.get(); 652 return form_structures_.get();
652 } 653 }
653 654
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 autocheckout_manager_.OnClickFailed(status); 780 autocheckout_manager_.OnClickFailed(status);
780 } 781 }
781 782
782 std::string AutofillManager::GetAutocheckoutURLPrefix() const { 783 std::string AutofillManager::GetAutocheckoutURLPrefix() const {
783 if (!driver_->GetWebContents()) 784 if (!driver_->GetWebContents())
784 return std::string(); 785 return std::string();
785 786
786 autofill::autocheckout::WhitelistManager* whitelist_manager = 787 autofill::autocheckout::WhitelistManager* whitelist_manager =
787 manager_delegate_->GetAutocheckoutWhitelistManager(); 788 manager_delegate_->GetAutocheckoutWhitelistManager();
788 789
789 return whitelist_manager->GetMatchedURLPrefix( 790 return whitelist_manager ? whitelist_manager->GetMatchedURLPrefix(
790 driver_->GetWebContents()->GetURL()); 791 driver_->GetWebContents()->GetURL()) : std::string();
791 } 792 }
792 793
793 bool AutofillManager::IsAutofillEnabled() const { 794 bool AutofillManager::IsAutofillEnabled() const {
794 return manager_delegate_->GetPrefs()->GetBoolean(prefs::kAutofillEnabled); 795 return manager_delegate_->GetPrefs()->GetBoolean(prefs::kAutofillEnabled);
795 } 796 }
796 797
797 void AutofillManager::SendAutofillTypePredictions( 798 void AutofillManager::SendAutofillTypePredictions(
798 const std::vector<FormStructure*>& forms) const { 799 const std::vector<FormStructure*>& forms) const {
799 if (!CommandLine::ForCurrentProcess()->HasSwitch( 800 if (!CommandLine::ForCurrentProcess()->HasSwitch(
800 switches::kShowAutofillTypePredictions)) 801 switches::kShowAutofillTypePredictions))
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 external_delegate_->Reset(); 906 external_delegate_->Reset();
906 } 907 }
907 908
908 AutofillManager::AutofillManager(AutofillDriver* driver, 909 AutofillManager::AutofillManager(AutofillDriver* driver,
909 autofill::AutofillManagerDelegate* delegate, 910 autofill::AutofillManagerDelegate* delegate,
910 PersonalDataManager* personal_data) 911 PersonalDataManager* personal_data)
911 : driver_(driver), 912 : driver_(driver),
912 manager_delegate_(delegate), 913 manager_delegate_(delegate),
913 app_locale_("en-US"), 914 app_locale_("en-US"),
914 personal_data_(personal_data), 915 personal_data_(personal_data),
915 autocomplete_history_manager_(driver), 916 autocomplete_history_manager_(
917 new AutocompleteHistoryManager(driver, delegate)),
916 autocheckout_manager_(this), 918 autocheckout_manager_(this),
917 metric_logger_(new AutofillMetrics), 919 metric_logger_(new AutofillMetrics),
918 has_logged_autofill_enabled_(false), 920 has_logged_autofill_enabled_(false),
919 has_logged_address_suggestions_count_(false), 921 has_logged_address_suggestions_count_(false),
920 did_show_suggestions_(false), 922 did_show_suggestions_(false),
921 user_did_type_(false), 923 user_did_type_(false),
922 user_did_autofill_(false), 924 user_did_autofill_(false),
923 user_did_edit_autofilled_field_(false), 925 user_did_edit_autofilled_field_(false),
924 external_delegate_(NULL), 926 external_delegate_(NULL),
925 test_delegate_(NULL), 927 test_delegate_(NULL),
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 1242
1241 void AutofillManager::UpdateInitialInteractionTimestamp( 1243 void AutofillManager::UpdateInitialInteractionTimestamp(
1242 const TimeTicks& interaction_timestamp) { 1244 const TimeTicks& interaction_timestamp) {
1243 if (initial_interaction_timestamp_.is_null() || 1245 if (initial_interaction_timestamp_.is_null() ||
1244 interaction_timestamp < initial_interaction_timestamp_) { 1246 interaction_timestamp < initial_interaction_timestamp_) {
1245 initial_interaction_timestamp_ = interaction_timestamp; 1247 initial_interaction_timestamp_ = interaction_timestamp;
1246 } 1248 }
1247 } 1249 }
1248 1250
1249 } // namespace autofill 1251 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager.h ('k') | components/autofill/core/browser/autofill_manager_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698