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

Unified Diff: chrome/browser/autofill/autofill_manager.cc

Issue 541001: Add two AutoFill prefs. autofill.infobar_shown is true if the autofill infob... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/autofill/autofill_manager.h ('k') | chrome/browser/browser_prefs.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/autofill_manager.cc
===================================================================
--- chrome/browser/autofill/autofill_manager.cc (revision 35750)
+++ chrome/browser/autofill/autofill_manager.cc (working copy)
@@ -13,6 +13,8 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/pref_service.h"
#include "webkit/glue/form_field_values.h"
AutoFillManager::AutoFillManager(TabContents* tab_contents)
@@ -24,6 +26,12 @@
AutoFillManager::~AutoFillManager() {
}
+// static
+void AutoFillManager::RegisterUserPrefs(PrefService* prefs) {
+ prefs->RegisterBooleanPref(prefs::kAutoFillInfoBarShown, false);
+ prefs->RegisterBooleanPref(prefs::kAutoFillEnabled, false);
+}
+
void AutoFillManager::FormFieldValuesSubmitted(
const webkit_glue::FormFieldValues& form) {
// TODO(jhawkins): Remove this switch when AutoFill++ is fully implemented.
@@ -40,11 +48,15 @@
// Determine the possible field types.
DeterminePossibleFieldTypes(upload_form_structure_.get());
- if (!personal_data_->ImportFormData(form_structures_, this))
- return;
-
- // Ask the user for permission to save form information.
- infobar_.reset(new AutoFillInfoBarDelegate(tab_contents_, this));
+ PrefService* prefs = tab_contents_->profile()->GetPrefs();
+ bool autofill_enabled = prefs->GetBoolean(prefs::kAutoFillEnabled);
+ bool infobar_shown = prefs->GetBoolean(prefs::kAutoFillInfoBarShown);
+ if (!infobar_shown) {
+ // Ask the user for permission to save form information.
+ infobar_.reset(new AutoFillInfoBarDelegate(tab_contents_, this));
+ } else if (autofill_enabled) {
+ HandleSubmit();
+ }
}
void AutoFillManager::DeterminePossibleFieldTypes(
@@ -61,9 +73,25 @@
}
}
-void AutoFillManager::SaveFormData() {
+void AutoFillManager::HandleSubmit() {
+ // If there wasn't enough data to import then we don't want to send an upload
+ // to the server.
+ if (!personal_data_->ImportFormData(form_structures_, this))
+ return;
+
UploadFormData();
+}
+void AutoFillManager::OnInfoBarAccepted() {
+ PrefService* prefs = tab_contents_->profile()->GetPrefs();
+ prefs->SetBoolean(prefs::kAutoFillEnabled, true);
+
+ // TODO(jhawkins): AutoFillDialog
+
+ HandleSubmit();
+}
+
+void AutoFillManager::SaveFormData() {
// TODO(jhawkins): Save the form data to the web database.
}
« no previous file with comments | « chrome/browser/autofill/autofill_manager.h ('k') | chrome/browser/browser_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698