Chromium Code Reviews| Index: chrome/browser/autofill/autofill_download_url.cc |
| diff --git a/chrome/browser/autofill/autofill_download_url.cc b/chrome/browser/autofill/autofill_download_url.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7d7cd52445d4fc81be1ad9b54c08a1fb964b9bad |
| --- /dev/null |
| +++ b/chrome/browser/autofill/autofill_download_url.cc |
| @@ -0,0 +1,57 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/autofill/autofill_download_url.h" |
| + |
| +#include "base/command_line.h" |
| +#include "base/prefs/public/pref_service_base.h" |
| +#include "base/string_util.h" |
| +#include "chrome/common/chrome_switches.h" |
| +#include "chrome/common/pref_names.h" |
| +#include "googleurl/src/gurl.h" |
| + |
| +const char kDefaultAutofillServiceUrl[] = |
| + "https://clients1.google.com/tbproxy/af/"; |
| + |
| +#if defined(GOOGLE_CHROME_BUILD) |
| +const char kClientName[] = "Google Chrome"; |
| +#else |
| +const char kClientName[] = "Chromium"; |
| +#endif // defined(GOOGLE_CHROME_BUILD) |
| + |
| +void AutofillDownloadUrl::RegisterPreferences() { |
| + DCHECK(pref_service_); |
| + if (pref_service_->FindPreference(prefs::kAutofillServiceUrl)) |
| + return; |
|
Ilya Sherman
2012/10/25 22:52:02
nit: Does anything actually go wrong if we remove
|
| + pref_service_->RegisterStringPref(prefs::kAutofillServiceUrl, |
| + kDefaultAutofillServiceUrl); |
|
Ilya Sherman
2012/10/25 22:52:02
It looks like the default value is the only value
ahutter
2012/10/25 23:56:03
Removed.
|
| +} |
| + |
| +std::string AutofillDownloadUrl::GetBaseAutofillUrl() { |
| + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| + std::string baseAutofillServiceUrl = command_line.GetSwitchValueASCII( |
| + switches::kAutofillServiceUrl); |
| + if (ContainsOnlyWhitespaceASCII(baseAutofillServiceUrl)) |
|
Ilya Sherman
2012/10/25 22:52:02
Optional nit: Can we just check for baseAutofillSe
ahutter
2012/10/25 23:56:03
Done.
|
| + baseAutofillServiceUrl = |
| + pref_service_->GetString(prefs::kAutofillServiceUrl); |
|
Ilya Sherman
2012/10/25 22:52:02
nit: Please add curly braces to this if-stmt, sinc
|
| + |
| + return baseAutofillServiceUrl; |
| +} |
| + |
| +GURL AutofillDownloadUrl::GetAutofillRequestUrl() { |
| + DCHECK(pref_service_); |
| + RegisterPreferences(); |
| + |
| + std::string baseAutofillServiceUrl = GetBaseAutofillUrl(); |
| + return GURL(baseAutofillServiceUrl + "query?client=" + kClientName); |
| +} |
| + |
| +GURL AutofillDownloadUrl::GetAutofillUploadUrl() { |
| + DCHECK(pref_service_); |
| + RegisterPreferences(); |
| + |
| + std::string baseAutofillServiceUrl = GetBaseAutofillUrl(); |
| + return GURL(baseAutofillServiceUrl + "upload?client=" + kClientName); |
| +} |
| + |