summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-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
-rw-r--r--chrome/browser/automation/automation_profile_impl.h3
-rw-r--r--chrome/browser/profile.cc12
-rw-r--r--chrome/browser/profile.h8
7 files changed, 100 insertions, 7 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_
diff --git a/chrome/browser/automation/automation_profile_impl.h b/chrome/browser/automation/automation_profile_impl.h
index a794c97..ac01b76 100644
--- a/chrome/browser/automation/automation_profile_impl.h
+++ b/chrome/browser/automation/automation_profile_impl.h
@@ -111,6 +111,9 @@ class AutomationProfileImpl : public Profile {
virtual bool HasCreatedDownloadManager() const {
return original_profile_->HasCreatedDownloadManager();
}
+ virtual PersonalDataManager* GetPersonalDataManager() {
+ return original_profile_->GetPersonalDataManager();
+ }
virtual void InitThemes() {
return original_profile_->InitThemes();
}
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index aba64c5..0402b57 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -11,6 +11,7 @@
#include "base/path_service.h"
#include "base/scoped_ptr.h"
#include "base/string_util.h"
+#include "chrome/browser/autofill/personal_data_manager.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_theme_provider.h"
@@ -352,6 +353,10 @@ class OffTheRecordProfileImpl : public Profile,
return (download_manager_.get() != NULL);
}
+ virtual PersonalDataManager* GetPersonalDataManager() {
+ return NULL;
+ }
+
virtual void InitThemes() {
GetOriginalProfile()->InitThemes();
}
@@ -1085,6 +1090,13 @@ bool ProfileImpl::HasCreatedDownloadManager() const {
return created_download_manager_;
}
+PersonalDataManager* ProfileImpl::GetPersonalDataManager() {
+ if (!personal_data_manager_.get()) {
+ personal_data_manager_.reset(new PersonalDataManager);
+ }
+ return personal_data_manager_.get();
+}
+
void ProfileImpl::InitThemes() {
if (!created_theme_provider_) {
#if defined(OS_LINUX)
diff --git a/chrome/browser/profile.h b/chrome/browser/profile.h
index 78d2c9a..b00706d 100644
--- a/chrome/browser/profile.h
+++ b/chrome/browser/profile.h
@@ -41,6 +41,7 @@ class FaviconService;
class HistoryService;
class NavigationController;
class PasswordStore;
+class PersonalDataManager;
class PrefService;
class ProfileSyncService;
class SearchVersusNavigateClassifier;
@@ -236,10 +237,13 @@ class Profile {
// profile.
virtual TemplateURLFetcher* GetTemplateURLFetcher() = 0;
- // Returns the DownloadManager associated with this profile
+ // Returns the DownloadManager associated with this profile.
virtual DownloadManager* GetDownloadManager() = 0;
virtual bool HasCreatedDownloadManager() const = 0;
+ // Returns the PersonalDataManager associated with this profile.
+ virtual PersonalDataManager* GetPersonalDataManager() = 0;
+
// Init our themes system.
virtual void InitThemes() = 0;
@@ -420,6 +424,7 @@ class ProfileImpl : public Profile,
virtual TemplateURLModel* GetTemplateURLModel();
virtual TemplateURLFetcher* GetTemplateURLFetcher();
virtual DownloadManager* GetDownloadManager();
+ virtual PersonalDataManager* GetPersonalDataManager();
virtual void InitThemes();
virtual void SetTheme(Extension* extension);
virtual void SetNativeTheme();
@@ -530,6 +535,7 @@ class ProfileImpl : public Profile,
scoped_ptr<BrowserThemeProvider> theme_provider_;
scoped_refptr<WebKitContext> webkit_context_;
scoped_ptr<DesktopNotificationService> desktop_notification_service_;
+ scoped_ptr<PersonalDataManager> personal_data_manager_;
bool history_service_created_;
bool favicon_service_created_;
bool created_web_data_service_;