google_apis: Move AppendQueryParameter() etc. from common/net/url_util.h to
net/base/url_util.h
Which removes one more dependency on chrome/common/
BUG=146989
TEST=net_unittests --gtest_filter=UrlUtilTest*
[email protected],[email protected]
[email protected]
Review URL: https://chromiumcodereview.appspot.com/12069004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179902 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/net/base/url_util.h b/net/base/url_util.h
new file mode 100644
index 0000000..5d5e58b
--- /dev/null
+++ b/net/base/url_util.h
@@ -0,0 +1,56 @@
+// Copyright 2013 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.
+
+#ifndef NET_BASE_URL_UTIL_H_
+#define NET_BASE_URL_UTIL_H_
+
+#include <string>
+
+#include "net/base/net_export.h"
+
+class GURL;
+
+namespace net {
+
+// Returns a new GURL by appending the given query parameter name and the
+// value. Unsafe characters in the name and the value are escaped like
+// %XX%XX. The original query component is preserved if it's present.
+//
+// Examples:
+//
+// AppendQueryParameter(GURL("http://example.com"), "name", "value").spec()
+// => "http://example.com?name=value"
+// AppendQueryParameter(GURL("http://example.com?x=y"), "name", "value").spec()
+// => "http://example.com?x=y&name=value"
+NET_EXPORT GURL AppendQueryParameter(const GURL& url,
+ const std::string& name,
+ const std::string& value);
+
+// Returns a new GURL by appending or replacing the given query parameter name
+// and the value. If |name| appears more than once, only the first name-value
+// pair is replaced. Unsafe characters in the name and the value are escaped
+// like %XX%XX. The original query component is preserved if it's present.
+//
+// Examples:
+//
+// AppendOrReplaceQueryParameter(
+// GURL("http://example.com"), "name", "new").spec()
+// => "http://example.com?name=value"
+// AppendOrReplaceQueryParameter(
+// GURL("http://example.com?x=y&name=old"), "name", "new").spec()
+// => "http://example.com?x=y&name=new"
+NET_EXPORT GURL AppendOrReplaceQueryParameter(const GURL& url,
+ const std::string& name,
+ const std::string& value);
+
+// Looks for |search_key| in the query portion of |url|. Returns true if the
+// key is found and sets |out_value| to the unescaped value for the key.
+// Returns false if the key is not found.
+NET_EXPORT bool GetValueForKeyInQuery(const GURL& url,
+ const std::string& search_key,
+ std::string* out_value);
+
+} // namespace net
+
+#endif // NET_BASE_URL_UTIL_H_