| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/autofill/autofill_download.h" | 5 #include "chrome/browser/autofill/autofill_download.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 next_query_request_(base::Time::Now()), | 47 next_query_request_(base::Time::Now()), |
| 48 next_upload_request_(base::Time::Now()), | 48 next_upload_request_(base::Time::Now()), |
| 49 positive_upload_rate_(0), | 49 positive_upload_rate_(0), |
| 50 negative_upload_rate_(0), | 50 negative_upload_rate_(0), |
| 51 fetcher_id_for_unittest_(0), | 51 fetcher_id_for_unittest_(0), |
| 52 is_testing_(false) { | 52 is_testing_(false) { |
| 53 // |profile_| could be NULL in some unit-tests. | 53 // |profile_| could be NULL in some unit-tests. |
| 54 if (profile_) { | 54 if (profile_) { |
| 55 PrefService* preferences = profile_->GetPrefs(); | 55 PrefService* preferences = profile_->GetPrefs(); |
| 56 positive_upload_rate_ = | 56 positive_upload_rate_ = |
| 57 preferences->GetReal(prefs::kAutoFillPositiveUploadRate); | 57 preferences->GetDouble(prefs::kAutoFillPositiveUploadRate); |
| 58 negative_upload_rate_ = | 58 negative_upload_rate_ = |
| 59 preferences->GetReal(prefs::kAutoFillNegativeUploadRate); | 59 preferences->GetDouble(prefs::kAutoFillNegativeUploadRate); |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 | 62 |
| 63 AutoFillDownloadManager::~AutoFillDownloadManager() { | 63 AutoFillDownloadManager::~AutoFillDownloadManager() { |
| 64 STLDeleteContainerPairFirstPointers(url_fetchers_.begin(), | 64 STLDeleteContainerPairFirstPointers(url_fetchers_.begin(), |
| 65 url_fetchers_.end()); | 65 url_fetchers_.end()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void AutoFillDownloadManager::SetObserver( | 68 void AutoFillDownloadManager::SetObserver( |
| 69 AutoFillDownloadManager::Observer *observer) { | 69 AutoFillDownloadManager::Observer *observer) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 158 } |
| 159 | 159 |
| 160 void AutoFillDownloadManager::SetPositiveUploadRate(double rate) { | 160 void AutoFillDownloadManager::SetPositiveUploadRate(double rate) { |
| 161 if (rate == positive_upload_rate_) | 161 if (rate == positive_upload_rate_) |
| 162 return; | 162 return; |
| 163 positive_upload_rate_ = rate; | 163 positive_upload_rate_ = rate; |
| 164 DCHECK_GE(rate, 0.0); | 164 DCHECK_GE(rate, 0.0); |
| 165 DCHECK_LE(rate, 1.0); | 165 DCHECK_LE(rate, 1.0); |
| 166 DCHECK(profile_); | 166 DCHECK(profile_); |
| 167 PrefService* preferences = profile_->GetPrefs(); | 167 PrefService* preferences = profile_->GetPrefs(); |
| 168 preferences->SetReal(prefs::kAutoFillPositiveUploadRate, rate); | 168 preferences->SetDouble(prefs::kAutoFillPositiveUploadRate, rate); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void AutoFillDownloadManager::SetNegativeUploadRate(double rate) { | 171 void AutoFillDownloadManager::SetNegativeUploadRate(double rate) { |
| 172 if (rate == negative_upload_rate_) | 172 if (rate == negative_upload_rate_) |
| 173 return; | 173 return; |
| 174 negative_upload_rate_ = rate; | 174 negative_upload_rate_ = rate; |
| 175 DCHECK_GE(rate, 0.0); | 175 DCHECK_GE(rate, 0.0); |
| 176 DCHECK_LE(rate, 1.0); | 176 DCHECK_LE(rate, 1.0); |
| 177 DCHECK(profile_); | 177 DCHECK(profile_); |
| 178 PrefService* preferences = profile_->GetPrefs(); | 178 PrefService* preferences = profile_->GetPrefs(); |
| 179 preferences->SetReal(prefs::kAutoFillNegativeUploadRate, rate); | 179 preferences->SetDouble(prefs::kAutoFillNegativeUploadRate, rate); |
| 180 } | 180 } |
| 181 | 181 |
| 182 bool AutoFillDownloadManager::StartRequest( | 182 bool AutoFillDownloadManager::StartRequest( |
| 183 const std::string& form_xml, | 183 const std::string& form_xml, |
| 184 const FormRequestData& request_data) { | 184 const FormRequestData& request_data) { |
| 185 std::string request_url; | 185 std::string request_url; |
| 186 if (request_data.request_type == AutoFillDownloadManager::REQUEST_QUERY) | 186 if (request_data.request_type == AutoFillDownloadManager::REQUEST_QUERY) |
| 187 request_url = AUTO_FILL_QUERY_SERVER_REQUEST_URL; | 187 request_url = AUTO_FILL_QUERY_SERVER_REQUEST_URL; |
| 188 else | 188 else |
| 189 request_url = AUTO_FILL_UPLOAD_SERVER_REQUEST_URL; | 189 request_url = AUTO_FILL_UPLOAD_SERVER_REQUEST_URL; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 SetNegativeUploadRate(new_negative_upload_rate); | 338 SetNegativeUploadRate(new_negative_upload_rate); |
| 339 } | 339 } |
| 340 | 340 |
| 341 if (observer_) | 341 if (observer_) |
| 342 observer_->OnUploadedAutoFillHeuristics(it->second.form_signatures[0]); | 342 observer_->OnUploadedAutoFillHeuristics(it->second.form_signatures[0]); |
| 343 } | 343 } |
| 344 } | 344 } |
| 345 delete it->first; | 345 delete it->first; |
| 346 url_fetchers_.erase(it); | 346 url_fetchers_.erase(it); |
| 347 } | 347 } |
| OLD | NEW |