diff options
author | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-02 23:52:39 +0000 |
---|---|---|
committer | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-02 23:52:39 +0000 |
commit | 80742f2ffeb9e90cd85cbee27acb9f924ffebd16 (patch) | |
tree | 42db07c98e10243ef214946d75554b4fa27e09b2 /chrome/browser/autofill | |
parent | 9ca846258555296ddbd0c61277f9e602d1f5393f (diff) | |
download | chromium_src-80742f2ffeb9e90cd85cbee27acb9f924ffebd16.zip chromium_src-80742f2ffeb9e90cd85cbee27acb9f924ffebd16.tar.gz chromium_src-80742f2ffeb9e90cd85cbee27acb9f924ffebd16.tar.bz2 |
Add support for the "uploadrequired" attribute for Autofill query responses
BUG=84693
TEST=unit_tests --gtest_filter=AutofillDownloadTest.QueryAndUploadTest
Review URL: http://codereview.chromium.org/6969090
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87729 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r-- | chrome/browser/autofill/autofill_download.cc | 4 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_download_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_manager.cc | 3 | ||||
-rw-r--r-- | chrome/browser/autofill/form_structure.cc | 8 | ||||
-rw-r--r-- | chrome/browser/autofill/form_structure.h | 9 |
5 files changed, 18 insertions, 10 deletions
diff --git a/chrome/browser/autofill/autofill_download.cc b/chrome/browser/autofill/autofill_download.cc index 5d1699a..546379e5 100644 --- a/chrome/browser/autofill/autofill_download.cc +++ b/chrome/browser/autofill/autofill_download.cc @@ -113,7 +113,9 @@ bool AutofillDownloadManager::StartUploadRequest( // Flip a coin to see if we should upload this form. double upload_rate = form_was_autofilled ? GetPositiveUploadRate() : GetNegativeUploadRate(); - if (base::RandDouble() > upload_rate) { + if (form.upload_required() == UPLOAD_NOT_REQUIRED || + (form.upload_required() == USE_UPLOAD_RATES && + base::RandDouble() > upload_rate)) { VLOG(1) << "AutofillDownloadManager: Upload request is ignored."; // If we ever need notification that upload was skipped, add it here. return false; diff --git a/chrome/browser/autofill/autofill_download_unittest.cc b/chrome/browser/autofill/autofill_download_unittest.cc index 2806a85..c616249 100644 --- a/chrome/browser/autofill/autofill_download_unittest.cc +++ b/chrome/browser/autofill/autofill_download_unittest.cc @@ -339,8 +339,8 @@ TEST_F(AutofillDownloadTest, QueryAndUploadTest) { fetcher = factory.GetFetcherByID(4); EXPECT_EQ(NULL, fetcher); - // Set upload to 100% so requests happen. - helper.download_manager.SetPositiveUploadRate(1.0); + // Set upload required to true so requests happen. + form_structures[0]->upload_required_ = UPLOAD_REQUIRED; // Request with id 4. EXPECT_TRUE(helper.download_manager.StartUploadRequest(*(form_structures[0]), true, diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index ea2aacf..2c0d965 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -626,11 +626,8 @@ void AutofillManager::OnDidShowAutofillSuggestions() { void AutofillManager::OnLoadedAutofillHeuristics( const std::string& heuristic_xml) { - // TODO(jhawkins): Store |upload_required| in the AutofillManager. - UploadRequired upload_required; FormStructure::ParseQueryResponse(heuristic_xml, form_structures_.get(), - &upload_required, *metric_logger_); } diff --git a/chrome/browser/autofill/form_structure.cc b/chrome/browser/autofill/form_structure.cc index 2841710..5f5146e 100644 --- a/chrome/browser/autofill/form_structure.cc +++ b/chrome/browser/autofill/form_structure.cc @@ -84,7 +84,8 @@ FormStructure::FormStructure(const FormData& form) : form_name_(form.name), source_url_(form.origin), target_url_(form.action), - autofill_count_(0) { + autofill_count_(0), + upload_required_(USE_UPLOAD_RATES) { // Copy the form fields. std::vector<webkit_glue::FormField>::const_iterator field; for (field = form.fields.begin(); @@ -236,14 +237,14 @@ bool FormStructure::EncodeQueryRequest(const ScopedVector<FormStructure>& forms, // static void FormStructure::ParseQueryResponse(const std::string& response_xml, const std::vector<FormStructure*>& forms, - UploadRequired* upload_required, const AutofillMetrics& metric_logger) { metric_logger.LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_RECEIVED); // Parse the field types from the server response to the query. std::vector<AutofillFieldType> field_types; + UploadRequired upload_required; std::string experiment_id; - AutofillQueryXmlParser parse_handler(&field_types, upload_required, + AutofillQueryXmlParser parse_handler(&field_types, &upload_required, &experiment_id); buzz::XmlParser parser(&parse_handler); parser.Parse(response_xml.c_str(), response_xml.length(), true); @@ -260,6 +261,7 @@ void FormStructure::ParseQueryResponse(const std::string& response_xml, for (std::vector<FormStructure*>::const_iterator iter = forms.begin(); iter != forms.end(); ++iter) { FormStructure* form = *iter; + form->upload_required_ = upload_required; form->server_experiment_id_ = experiment_id; for (std::vector<AutofillField*>::iterator field = form->fields_.begin(); diff --git a/chrome/browser/autofill/form_structure.h b/chrome/browser/autofill/form_structure.h index 95b8661..0d8ddd7 100644 --- a/chrome/browser/autofill/form_structure.h +++ b/chrome/browser/autofill/form_structure.h @@ -9,6 +9,7 @@ #include <string> #include <vector> +#include "base/gtest_prod_util.h" #include "base/memory/scoped_vector.h" #include "chrome/browser/autofill/autofill_field.h" #include "chrome/browser/autofill/autofill_type.h" @@ -62,7 +63,6 @@ class FormStructure { // same as the one passed to EncodeQueryRequest when constructing the query. static void ParseQueryResponse(const std::string& response_xml, const std::vector<FormStructure*>& forms, - UploadRequired* upload_required, const AutofillMetrics& metric_logger); // The unique signature for this form, composed of the target url domain, @@ -112,6 +112,8 @@ class FormStructure { const GURL& source_url() const { return source_url_; } + UploadRequired upload_required() const { return upload_required_; } + virtual std::string server_experiment_id() const; bool operator==(const webkit_glue::FormData& form) const; @@ -123,6 +125,7 @@ class FormStructure { private: friend class FormStructureTest; + FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest); // 64-bit hash of the string - used in FormSignature and unit-tests. static std::string Hash64Bit(const std::string& str); @@ -156,6 +159,10 @@ class FormStructure { // character. E.g.: "&form_input1_name&form_input2_name&...&form_inputN_name" std::string form_signature_field_names_; + // Whether the server expects us to always upload, never upload, or default + // to the stored upload rates. + UploadRequired upload_required_; + // The server experiment corresponding to the server types returned for this // form. std::string server_experiment_id_; |