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

Unified Diff: chrome/browser/autofill/autofill_download_url.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: More fixes from code review Created 8 years, 2 months 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 side-by-side diff with in-line comments
Download patch
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..d8b590bf9ca3ebe8e3b17ddaee9db589d02d35c6
--- /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/string_util.h"
+#include "chrome/browser/api/prefs/pref_service_base.h"
Albert Bodenhamer 2012/10/24 19:51:56 it looks like you should use: #include "chrome/bro
ahutter 2012/10/24 21:29:45 I don't think I can based on the current restricti
Albert Bodenhamer 2012/10/24 21:41:06 The rest of AF is using #include "base/prefs/publi
+#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/";
Albert Bodenhamer 2012/10/24 19:51:56 4 spaces on continuation of a line.
ahutter 2012/10/24 21:29:45 Done.
+
+#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;
+ pref_service_->RegisterStringPref(prefs::kAutofillServiceUrl,
+ kDefaultAutofillServiceUrl);
Albert Bodenhamer 2012/10/24 19:51:56 1 more space on the second line.
ahutter 2012/10/24 21:29:45 Done.
+}
+
+std::string AutofillDownloadUrl::GetBaseAutofillUrl() {
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ std::string baseAutofillServiceUrl = command_line.GetSwitchValueASCII(
+ switches::kAutofillServiceUrl);
+ if (ContainsOnlyWhitespaceASCII(baseAutofillServiceUrl))
+ baseAutofillServiceUrl =
+ pref_service_->GetString(prefs::kAutofillServiceUrl);
+
+ 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);
+}
+

Powered by Google App Engine
This is Rietveld 408576698