summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorsgurun@chromium.org <sgurun@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-10 19:06:49 +0000
committersgurun@chromium.org <sgurun@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-10 19:06:49 +0000
commitae1741ecf9602066e83f4e0a4d080ee32c74a6b2 (patch)
treee0a7f35ec2cb77411c88d3cf197e0741eeb1e020 /components
parent0b70dbec6b58a41414033bfc8cfc16c920af2375 (diff)
downloadchromium_src-ae1741ecf9602066e83f4e0a4d080ee32c74a6b2.zip
chromium_src-ae1741ecf9602066e83f4e0a4d080ee32c74a6b2.tar.gz
chromium_src-ae1741ecf9602066e83f4e0a4d080ee32c74a6b2.tar.bz2
Allow disabling autocomplete download manager
BUG=b/6335434 TBR=ben@chromium.org for chrome/browser/ui/browser_tab_contents.cc Review URL: https://chromiumcodereview.appspot.com/14963010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@199516 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r--components/autofill/browser/autocomplete_history_manager_unittest.cc5
-rw-r--r--components/autofill/browser/autofill_manager.cc33
-rw-r--r--components/autofill/browser/autofill_manager.h23
3 files changed, 36 insertions, 25 deletions
diff --git a/components/autofill/browser/autocomplete_history_manager_unittest.cc b/components/autofill/browser/autocomplete_history_manager_unittest.cc
index eb7eb16..6eaf07d 100644
--- a/components/autofill/browser/autocomplete_history_manager_unittest.cc
+++ b/components/autofill/browser/autocomplete_history_manager_unittest.cc
@@ -255,7 +255,10 @@ TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) {
web_contents());
AutofillManager::CreateForWebContentsAndDelegate(
- web_contents(), &manager_delegate, "en-US");
+ web_contents(),
+ &manager_delegate,
+ "en-US",
+ AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER);
MockAutofillExternalDelegate external_delegate(web_contents());
autocomplete_history_manager.SetExternalDelegate(&external_delegate);
diff --git a/components/autofill/browser/autofill_manager.cc b/components/autofill/browser/autofill_manager.cc
index 406daf7..ff16c6b 100644
--- a/components/autofill/browser/autofill_manager.cc
+++ b/components/autofill/browser/autofill_manager.cc
@@ -175,12 +175,15 @@ void DeterminePossibleFieldTypesForUpload(
void AutofillManager::CreateForWebContentsAndDelegate(
content::WebContents* contents,
autofill::AutofillManagerDelegate* delegate,
- const std::string& app_locale) {
+ const std::string& app_locale,
+ AutofillDownloadManagerState enable_download_manager) {
if (FromWebContents(contents))
return;
- contents->SetUserData(kAutofillManagerWebContentsUserDataKey,
- new AutofillManager(contents, delegate, app_locale));
+ contents->SetUserData(
+ kAutofillManagerWebContentsUserDataKey,
+ new AutofillManager(
+ contents, delegate, app_locale, enable_download_manager));
// Trigger the lazy creation of AutocheckoutWhitelistManagerService, and
// schedule a fetch of the Autocheckout whitelist file if it's not already
@@ -196,15 +199,15 @@ AutofillManager* AutofillManager::FromWebContents(
contents->GetUserData(kAutofillManagerWebContentsUserDataKey));
}
-AutofillManager::AutofillManager(content::WebContents* web_contents,
- autofill::AutofillManagerDelegate* delegate,
- const std::string& app_locale)
+AutofillManager::AutofillManager(
+ content::WebContents* web_contents,
+ autofill::AutofillManagerDelegate* delegate,
+ const std::string& app_locale,
+ AutofillDownloadManagerState enable_download_manager)
: content::WebContentsObserver(web_contents),
manager_delegate_(delegate),
app_locale_(app_locale),
personal_data_(delegate->GetPersonalDataManager()),
- download_manager_(web_contents->GetBrowserContext(), this),
- disable_download_manager_requests_(false),
autocomplete_history_manager_(web_contents),
autocheckout_manager_(this),
metric_logger_(new AutofillMetrics),
@@ -217,6 +220,10 @@ AutofillManager::AutofillManager(content::WebContents* web_contents,
external_delegate_(NULL),
test_delegate_(NULL),
weak_ptr_factory_(this) {
+ if (enable_download_manager == ENABLE_AUTOFILL_DOWNLOAD_MANAGER) {
+ download_manager_.reset(
+ new AutofillDownloadManager(web_contents->GetBrowserContext(), this));
+ }
}
AutofillManager::~AutofillManager() {}
@@ -917,7 +924,7 @@ void AutofillManager::UploadFormDataAsyncCallback(
}
void AutofillManager::UploadFormData(const FormStructure& submitted_form) {
- if (disable_download_manager_requests_)
+ if (!download_manager_)
return;
// Check if the form is among the forms that were recently auto-filled.
@@ -934,7 +941,7 @@ void AutofillManager::UploadFormData(const FormStructure& submitted_form) {
FieldTypeSet non_empty_types;
personal_data_->GetNonEmptyTypes(&non_empty_types);
- download_manager_.StartUploadRequest(submitted_form, was_autofilled,
+ download_manager_->StartUploadRequest(submitted_form, was_autofilled,
non_empty_types);
}
@@ -960,8 +967,6 @@ AutofillManager::AutofillManager(content::WebContents* web_contents,
manager_delegate_(delegate),
app_locale_("en-US"),
personal_data_(personal_data),
- download_manager_(web_contents->GetBrowserContext(), this),
- disable_download_manager_requests_(true),
autocomplete_history_manager_(web_contents),
autocheckout_manager_(this),
metric_logger_(new AutofillMetrics),
@@ -1210,9 +1215,9 @@ void AutofillManager::ParseForms(const std::vector<FormData>& forms) {
// terminate Autocheckout and send Autocheckout status.
autocheckout_manager_.OnLoadedPageMetaData(
scoped_ptr<autofill::AutocheckoutPageMetaData>(NULL));
- } else if (!disable_download_manager_requests_) {
+ } else if (download_manager_) {
// Query the server if we have at least one of the forms were parsed.
- download_manager_.StartQueryRequest(form_structures_.get(),
+ download_manager_->StartQueryRequest(form_structures_.get(),
*metric_logger_);
}
diff --git a/components/autofill/browser/autofill_manager.h b/components/autofill/browser/autofill_manager.h
index 5a2b083..9233659 100644
--- a/components/autofill/browser/autofill_manager.h
+++ b/components/autofill/browser/autofill_manager.h
@@ -59,6 +59,7 @@ class PrefRegistrySyncable;
namespace autofill {
class AutofillDataModel;
+class AutofillDownloadManager;
class AutofillExternalDelegate;
class AutofillField;
class AutofillProfile;
@@ -78,10 +79,16 @@ class AutofillManager : public content::WebContentsObserver,
public AutofillDownloadManager::Observer,
public base::SupportsUserData::Data {
public:
+ enum AutofillDownloadManagerState {
+ ENABLE_AUTOFILL_DOWNLOAD_MANAGER,
+ DISABLE_AUTOFILL_DOWNLOAD_MANAGER,
+ };
+
static void CreateForWebContentsAndDelegate(
content::WebContents* contents,
autofill::AutofillManagerDelegate* delegate,
- const std::string& app_locale);
+ const std::string& app_locale,
+ AutofillDownloadManagerState enable_download_manager);
static AutofillManager* FromWebContents(content::WebContents* contents);
// Registers our Enable/Disable Autofill pref.
@@ -141,7 +148,8 @@ class AutofillManager : public content::WebContentsObserver,
// Only test code should subclass AutofillManager.
AutofillManager(content::WebContents* web_contents,
autofill::AutofillManagerDelegate* delegate,
- const std::string& app_locale);
+ const std::string& app_locale,
+ AutofillDownloadManagerState enable_download_manager);
virtual ~AutofillManager();
// Test code should prefer to use this constructor.
@@ -348,14 +356,9 @@ class AutofillManager : public content::WebContentsObserver,
std::list<std::string> autofilled_form_signatures_;
- // Handles queries and uploads to Autofill servers.
- AutofillDownloadManager download_manager_;
-
- // Should be set to true in AutofillManagerTest and other tests, false in
- // AutofillDownloadManagerTest and in non-test environment. Is false by
- // default for the public constructor, and true by default for the test-only
- // constructors.
- bool disable_download_manager_requests_;
+ // Handles queries and uploads to Autofill servers. Will be NULL if
+ // the download manager functionality is disabled.
+ scoped_ptr<AutofillDownloadManager> download_manager_;
// Handles single-field autocomplete form data.
AutocompleteHistoryManager autocomplete_history_manager_;