summaryrefslogtreecommitdiffstats
path: root/chrome/common/net/url_util.h
diff options
context:
space:
mode:
authorgroby@chromium.org <groby@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-09 22:34:36 +0000
committergroby@chromium.org <groby@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-09 22:34:36 +0000
commit06305964e02af11bda4699175340ffec2f784f6b (patch)
treebb565cff1a2e9218ca85b98d953f1a1b2ab070b6 /chrome/common/net/url_util.h
parent3ebf7d606bfd9d3d90c34542db5a370340af63b8 (diff)
downloadchromium_src-06305964e02af11bda4699175340ffec2f784f6b.zip
chromium_src-06305964e02af11bda4699175340ffec2f784f6b.tar.gz
chromium_src-06305964e02af11bda4699175340ffec2f784f6b.tar.bz2
Moved url_utils from chrome/browser/net to chrome/common/net.
There is an upcoming CL that needs those functions from chrome/common/extensions. TBR=satorux@chromium.org, pkasting@chromium.org BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/10384086 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136154 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/net/url_util.h')
-rw-r--r--chrome/common/net/url_util.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/chrome/common/net/url_util.h b/chrome/common/net/url_util.h
new file mode 100644
index 0000000..c801d40
--- /dev/null
+++ b/chrome/common/net/url_util.h
@@ -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.
+
+#ifndef CHROME_COMMON_NET_URL_UTIL_H_
+#define CHROME_COMMON_NET_URL_UTIL_H_
+#pragma once
+
+#include <string>
+
+class GURL;
+
+namespace ui {
+class Clipboard;
+}
+
+namespace chrome_common_net {
+
+// Writes a string representation of |url| to the system clipboard.
+void WriteURLToClipboard(const GURL& url,
+ const std::string& languages,
+ ui::Clipboard *clipboard);
+
+// 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"
+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"
+GURL AppendOrReplaceQueryParameter(const GURL& url,
+ const std::string& name,
+ const std::string& value);
+
+} // namespace chrome_common_net
+
+#endif // CHROME_COMMON_NET_URL_UTIL_H_