summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/browser_url_util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/net/browser_url_util.cc')
-rw-r--r--chrome/browser/net/browser_url_util.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/chrome/browser/net/browser_url_util.cc b/chrome/browser/net/browser_url_util.cc
new file mode 100644
index 0000000..7688051
--- /dev/null
+++ b/chrome/browser/net/browser_url_util.cc
@@ -0,0 +1,29 @@
+// Copyright (c) 2009 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/net/browser_url_util.h"
+
+#include "app/clipboard/scoped_clipboard_writer.h"
+#include "base/string_util.h"
+#include "googleurl/src/gurl.h"
+#include "net/base/net_util.h"
+
+namespace chrome_browser_net {
+
+void WriteURLToClipboard(const GURL& url,
+ const std::wstring& languages,
+ Clipboard *clipboard) {
+ if (url.is_empty() || !url.is_valid() || !clipboard)
+ return;
+
+ // Unescaping path and query is not a good idea because other applications
+ // may not encode non-ASCII characters in UTF-8. See crbug.com/2820.
+ string16 text = WideToUTF16(net::FormatUrl(url, languages, false,
+ UnescapeRule::NONE, NULL, NULL));
+
+ ScopedClipboardWriter scw(clipboard);
+ scw.WriteURL(text);
+}
+
+} // namespace chrome_browser_net