Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: chrome/browser/autofill/autofill_download.cc

Issue 11230060: Adding commandline switch and user pref for autofill server url. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changing include after rebasing Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <ostream> 8 #include <ostream>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/prefs/public/pref_service_base.h" 12 #include "base/prefs/public/pref_service_base.h"
13 #include "base/rand_util.h" 13 #include "base/rand_util.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "chrome/browser/autofill/autofill_download_url.h"
16 #include "chrome/browser/autofill/autofill_metrics.h" 17 #include "chrome/browser/autofill/autofill_metrics.h"
17 #include "chrome/browser/autofill/autofill_xml_parser.h" 18 #include "chrome/browser/autofill/autofill_xml_parser.h"
18 #include "chrome/browser/autofill/form_structure.h" 19 #include "chrome/browser/autofill/form_structure.h"
19 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
20 #include "content/public/browser/browser_context.h" 21 #include "content/public/browser/browser_context.h"
21 #include "googleurl/src/gurl.h" 22 #include "googleurl/src/gurl.h"
22 #include "net/base/load_flags.h" 23 #include "net/base/load_flags.h"
23 #include "net/http/http_response_headers.h" 24 #include "net/http/http_response_headers.h"
24 #include "net/url_request/url_fetcher.h" 25 #include "net/url_request/url_fetcher.h"
25 #include "third_party/libjingle/source/talk/xmllite/xmlparser.h" 26 #include "third_party/libjingle/source/talk/xmllite/xmlparser.h"
26 27
27 using content::BrowserContext; 28 using content::BrowserContext;
28 29
29 namespace { 30 namespace {
30 const char kAutofillQueryServerRequestUrl[] =
31 "https://clients1.google.com/tbproxy/af/query?client=";
32 const char kAutofillUploadServerRequestUrl[] =
33 "https://clients1.google.com/tbproxy/af/upload?client=";
34 const char kAutofillQueryServerNameStartInHeader[] = "GFE/"; 31 const char kAutofillQueryServerNameStartInHeader[] = "GFE/";
35 32
36 #if defined(GOOGLE_CHROME_BUILD)
37 const char kClientName[] = "Google Chrome";
38 #else
39 const char kClientName[] = "Chromium";
40 #endif // defined(GOOGLE_CHROME_BUILD)
41
42 const size_t kMaxFormCacheSize = 16; 33 const size_t kMaxFormCacheSize = 16;
43 34
44 // Log the contents of the upload request 35 // Log the contents of the upload request
45 static void LogUploadRequest(const GURL& url, const std::string& signature, 36 static void LogUploadRequest(const GURL& url, const std::string& signature,
46 const std::string& form_xml) { 37 const std::string& form_xml) {
47 VLOG(2) << url; 38 VLOG(2) << url;
48 VLOG(2) << signature; 39 VLOG(2) << signature;
49 VLOG(2) << form_xml; 40 VLOG(2) << form_xml;
50 } 41 }
51 42
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 browser_context_); 163 browser_context_);
173 preferences->SetDouble(prefs::kAutofillNegativeUploadRate, rate); 164 preferences->SetDouble(prefs::kAutofillNegativeUploadRate, rate);
174 } 165 }
175 166
176 bool AutofillDownloadManager::StartRequest( 167 bool AutofillDownloadManager::StartRequest(
177 const std::string& form_xml, 168 const std::string& form_xml,
178 const FormRequestData& request_data) { 169 const FormRequestData& request_data) {
179 net::URLRequestContextGetter* request_context = 170 net::URLRequestContextGetter* request_context =
180 browser_context_->GetRequestContext(); 171 browser_context_->GetRequestContext();
181 DCHECK(request_context); 172 DCHECK(request_context);
182 std::string request_url; 173 GURL request_url;
174 PrefServiceBase* preferences = PrefServiceBase::FromBrowserContext(
175 browser_context_);
176 AutofillDownloadUrl autofill_download_url(preferences);
183 if (request_data.request_type == AutofillDownloadManager::REQUEST_QUERY) 177 if (request_data.request_type == AutofillDownloadManager::REQUEST_QUERY)
184 request_url = kAutofillQueryServerRequestUrl; 178 request_url = autofill_download_url.GetAutofillRequestUrl();
185 else 179 else
186 request_url = kAutofillUploadServerRequestUrl; 180 request_url = autofill_download_url.GetAutofillUploadUrl();
187 request_url += kClientName;
188 181
189 // Id is ignored for regular chrome, in unit test id's for fake fetcher 182 // Id is ignored for regular chrome, in unit test id's for fake fetcher
190 // factory will be 0, 1, 2, ... 183 // factory will be 0, 1, 2, ...
191 net::URLFetcher* fetcher = net::URLFetcher::Create( 184 net::URLFetcher* fetcher = net::URLFetcher::Create(
192 fetcher_id_for_unittest_++, GURL(request_url), net::URLFetcher::POST, 185 fetcher_id_for_unittest_++, request_url, net::URLFetcher::POST,
193 this); 186 this);
194 url_fetchers_[fetcher] = request_data; 187 url_fetchers_[fetcher] = request_data;
195 fetcher->SetAutomaticallyRetryOn5xx(false); 188 fetcher->SetAutomaticallyRetryOn5xx(false);
196 fetcher->SetRequestContext(request_context); 189 fetcher->SetRequestContext(request_context);
197 fetcher->SetUploadData("text/plain", form_xml); 190 fetcher->SetUploadData("text/plain", form_xml);
198 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | 191 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES |
199 net::LOAD_DO_NOT_SEND_COOKIES); 192 net::LOAD_DO_NOT_SEND_COOKIES);
200 fetcher->Start(); 193 fetcher->Start();
201 return true; 194 return true;
202 } 195 }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 SetPositiveUploadRate(new_positive_upload_rate); 319 SetPositiveUploadRate(new_positive_upload_rate);
327 SetNegativeUploadRate(new_negative_upload_rate); 320 SetNegativeUploadRate(new_negative_upload_rate);
328 } 321 }
329 322
330 observer_->OnUploadedPossibleFieldTypes(); 323 observer_->OnUploadedPossibleFieldTypes();
331 } 324 }
332 } 325 }
333 delete it->first; 326 delete it->first;
334 url_fetchers_.erase(it); 327 url_fetchers_.erase(it);
335 } 328 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autofill/autofill_download_url.h » ('j') | chrome/browser/autofill/autofill_download_url.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698