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