| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/net/url_util.h" | 5 #include "chrome/common/net/url_util.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "content/public/common/url_constants.h" | |
| 9 #include "net/base/escape.h" | 8 #include "net/base/escape.h" |
| 10 #include "net/base/net_util.h" | 9 #include "net/base/net_util.h" |
| 11 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 10 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 12 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 12 #include "url/url_constants.h" |
| 13 | 13 |
| 14 namespace chrome_common_net { | 14 namespace chrome_common_net { |
| 15 | 15 |
| 16 void WriteURLToClipboard(const GURL& url, | 16 void WriteURLToClipboard(const GURL& url, |
| 17 const std::string& languages, | 17 const std::string& languages, |
| 18 ui::Clipboard *clipboard) { | 18 ui::Clipboard *clipboard) { |
| 19 if (url.is_empty() || !url.is_valid() || !clipboard) | 19 if (url.is_empty() || !url.is_valid() || !clipboard) |
| 20 return; | 20 return; |
| 21 | 21 |
| 22 // Unescaping path and query is not a good idea because other applications | 22 // Unescaping path and query is not a good idea because other applications |
| 23 // may not encode non-ASCII characters in UTF-8. See crbug.com/2820. | 23 // may not encode non-ASCII characters in UTF-8. See crbug.com/2820. |
| 24 base::string16 text = url.SchemeIs(content::kMailToScheme) ? | 24 base::string16 text = url.SchemeIs(url::kMailToScheme) ? |
| 25 base::ASCIIToUTF16(url.path()) : | 25 base::ASCIIToUTF16(url.path()) : |
| 26 net::FormatUrl(url, languages, net::kFormatUrlOmitNothing, | 26 net::FormatUrl(url, languages, net::kFormatUrlOmitNothing, |
| 27 net::UnescapeRule::NONE, NULL, NULL, NULL); | 27 net::UnescapeRule::NONE, NULL, NULL, NULL); |
| 28 | 28 |
| 29 ui::ScopedClipboardWriter scw(clipboard, ui::CLIPBOARD_TYPE_COPY_PASTE); | 29 ui::ScopedClipboardWriter scw(clipboard, ui::CLIPBOARD_TYPE_COPY_PASTE); |
| 30 scw.WriteURL(text); | 30 scw.WriteURL(text); |
| 31 } | 31 } |
| 32 | 32 |
| 33 } // namespace chrome_common_net | 33 } // namespace chrome_common_net |
| OLD | NEW |