summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r--chrome/browser/autofill/autofill_manager.cc16
-rw-r--r--chrome/browser/autofill/autofill_manager.h12
-rw-r--r--chrome/browser/autofill/personal_data_manager.cc20
-rw-r--r--chrome/browser/autofill/personal_data_manager.h36
4 files changed, 78 insertions, 6 deletions
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index 2a9d3f3..15271f5 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -9,6 +9,8 @@
#include "base/command_line.h"
#include "chrome/browser/autofill/autofill_infobar_delegate.h"
#include "chrome/browser/autofill/form_structure.h"
+#include "chrome/browser/autofill/personal_data_manager.h"
+#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/chrome_switches.h"
#include "webkit/glue/form_field_values.h"
@@ -16,6 +18,7 @@
AutoFillManager::AutoFillManager(TabContents* tab_contents)
: tab_contents_(tab_contents),
infobar_(NULL) {
+ personal_data_ = tab_contents_->profile()->GetPersonalDataManager();
}
AutoFillManager::~AutoFillManager() {
@@ -29,9 +32,14 @@ void AutoFillManager::FormFieldValuesSubmitted(
return;
// Grab a copy of the form data.
- form_structure_.reset(new FormStructure(form));
+ upload_form_structure_.reset(new FormStructure(form));
- if (!form_structure_->IsAutoFillable())
+ if (!upload_form_structure_->IsAutoFillable())
+ return;
+
+ // TODO(jhawkins): Determine possible field types.
+
+ if (!personal_data_->ImportFormData(form_structures_, this))
return;
// Ask the user for permission to save form information.
@@ -46,12 +54,12 @@ void AutoFillManager::SaveFormData() {
void AutoFillManager::UploadFormData() {
std::string xml;
- bool ok = form_structure_->EncodeUploadRequest(false, &xml);
+ bool ok = upload_form_structure_->EncodeUploadRequest(false, &xml);
DCHECK(ok);
// TODO(jhawkins): Initiate the upload request thread.
}
void AutoFillManager::Reset() {
- form_structure_.reset();
+ upload_form_structure_.reset();
}
diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h
index 521d48b..e5b3b58 100644
--- a/chrome/browser/autofill/autofill_manager.h
+++ b/chrome/browser/autofill/autofill_manager.h
@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_
#define CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_
+#include <vector>
+
#include "base/scoped_ptr.h"
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
@@ -14,6 +16,7 @@ class FormFieldValues;
class AutoFillInfoBarDelegate;
class FormStructure;
+class PersonalDataManager;
class TabContents;
// Manages saving and restoring the user's personal information entered into web
@@ -40,10 +43,15 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill {
// The TabContents hosting this AutoFillManager.
TabContents* tab_contents_;
+ // The personal data manager, used to save and load personal data to/from the
+ // web database.
+ PersonalDataManager* personal_data_;
+
// Our copy of the form data.
- scoped_ptr<FormStructure> form_structure_;
+ std::vector<FormStructure*> form_structures_;
+ scoped_ptr<FormStructure> upload_form_structure_;
- // The infobar asking for permission to store form information.
+ // The infobar that asks for permission to store form information.
scoped_ptr<AutoFillInfoBarDelegate> infobar_;
DISALLOW_COPY_AND_ASSIGN(AutoFillManager);
diff --git a/chrome/browser/autofill/personal_data_manager.cc b/chrome/browser/autofill/personal_data_manager.cc
new file mode 100644
index 0000000..8333c699
--- /dev/null
+++ b/chrome/browser/autofill/personal_data_manager.cc
@@ -0,0 +1,20 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/autofill/personal_data_manager.h"
+
+#include "chrome/browser/autofill/autofill_manager.h"
+#include "chrome/browser/autofill/form_structure.h"
+
+PersonalDataManager::~PersonalDataManager() {
+}
+
+bool PersonalDataManager::ImportFormData(
+ const std::vector<FormStructure*>& form_structures,
+ AutoFillManager* autofill_manager) {
+ return true;
+}
+
+PersonalDataManager::PersonalDataManager() {
+}
diff --git a/chrome/browser/autofill/personal_data_manager.h b/chrome/browser/autofill/personal_data_manager.h
new file mode 100644
index 0000000..f8a7b01
--- /dev/null
+++ b/chrome/browser/autofill/personal_data_manager.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_
+#define CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_
+
+#include <vector>
+
+class AutoFillManager;
+class FormStructure;
+
+// Handles loading and saving AutoFill profile information to the web database.
+// This class also stores the profiles loaded from the database for use during
+// AutoFill.
+class PersonalDataManager {
+ public:
+ virtual ~PersonalDataManager();
+
+ // If AutoFill is able to determine the field types of a significant number
+ // of field types that contain information in the FormStructures and the user
+ // has not previously been prompted, the user will be asked if he would like
+ // to import the data. If the user selects yes, a profile will be created
+ // with all of the information from recognized fields.
+ virtual bool ImportFormData(
+ const std::vector<FormStructure*>& form_structures,
+ AutoFillManager* autofill_manager);
+
+ private:
+ // Make sure that only Profile can create an instance of PersonalDataManager.
+ friend class ProfileImpl;
+
+ PersonalDataManager();
+};
+
+#endif // CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_