OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/net/browser_url_util.h" |
| 6 |
| 7 #include "app/clipboard/scoped_clipboard_writer.h" |
| 8 #include "base/string_util.h" |
| 9 #include "googleurl/src/gurl.h" |
| 10 #include "net/base/net_util.h" |
| 11 |
| 12 namespace chrome_browser_net { |
| 13 |
| 14 void WriteURLToClipboard(const GURL& url, |
| 15 const std::wstring& languages, |
| 16 Clipboard *clipboard) { |
| 17 if (url.is_empty() || !url.is_valid() || !clipboard) |
| 18 return; |
| 19 |
| 20 // Unescaping path and query is not a good idea because other applications |
| 21 // may not encode non-ASCII characters in UTF-8. See crbug.com/2820. |
| 22 string16 text = WideToUTF16(net::FormatUrl(url, languages, false, |
| 23 UnescapeRule::NONE, NULL, NULL)); |
| 24 |
| 25 ScopedClipboardWriter scw(clipboard); |
| 26 scw.WriteURL(text); |
| 27 } |
| 28 |
| 29 } // namespace chrome_browser_net |
OLD | NEW |