Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/autofill/autofill_download_url.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/string_util.h" | |
| 9 #include "chrome/browser/api/prefs/pref_service_base.h" | |
| 10 #include "chrome/common/chrome_switches.h" | |
| 11 #include "chrome/common/pref_names.h" | |
| 12 #include "googleurl/src/gurl.h" | |
| 13 | |
| 14 const char kDefaultAutofillServiceUrl[] = "https://clients1.google.com/tbproxy/a f/"; | |
|
Albert Bodenhamer
2012/10/23 23:34:17
80 chars.
ahutter
2012/10/24 17:33:45
Done.
| |
| 15 | |
| 16 #if defined(GOOGLE_CHROME_BUILD) | |
| 17 const char kClientName[] = "Google Chrome"; | |
| 18 #else | |
| 19 const char kClientName[] = "Chromium"; | |
| 20 #endif // defined(GOOGLE_CHROME_BUILD) | |
| 21 | |
| 22 void AutofillDownloadUrl::RegisterPreferences() { | |
| 23 DCHECK(pref_service_); | |
| 24 if (pref_service_->FindPreference(prefs::kAutofillServiceUrl)) | |
| 25 return; | |
| 26 pref_service_->RegisterStringPref(prefs::kAutofillServiceUrl, | |
| 27 kDefaultAutofillServiceUrl); | |
| 28 } | |
| 29 | |
| 30 std::string AutofillDownloadUrl::GetBaseAutofillUrl() { | |
| 31 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 32 std::string baseAutoFillServiceUrl = command_line.GetSwitchValueASCII( | |
|
Ilya Sherman
2012/10/23 23:45:13
nit: "AutoFill" -> "Autofill"
ahutter
2012/10/24 17:33:45
Done.
| |
| 33 switches::kAutofillServiceUrl); | |
| 34 if (ContainsOnlyWhitespaceASCII(baseAutoFillServiceUrl)) | |
| 35 baseAutoFillServiceUrl = | |
| 36 pref_service_->GetString(prefs::kAutofillServiceUrl); | |
| 37 | |
| 38 return baseAutoFillServiceUrl; | |
| 39 } | |
| 40 | |
| 41 GURL AutofillDownloadUrl::GetAutofillRequestUrl() { | |
| 42 DCHECK(pref_service_); | |
| 43 RegisterPreferences(); | |
| 44 | |
| 45 std::string baseAutoFillServiceUrl = GetBaseAutofillUrl(); | |
| 46 return GURL(baseAutoFillServiceUrl + "query?client=" + kClientName); | |
| 47 } | |
| 48 | |
| 49 GURL AutofillDownloadUrl::GetAutofillUploadUrl() { | |
| 50 DCHECK(pref_service_); | |
| 51 RegisterPreferences(); | |
| 52 | |
| 53 std::string baseAutoFillServiceUrl = GetBaseAutofillUrl(); | |
| 54 return GURL(baseAutoFillServiceUrl + "upload?client=" + kClientName); | |
| 55 } | |
| OLD | NEW |