summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-01 21:42:14 +0000
committerericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-01 21:42:14 +0000
commit0c4c3884b89e0c5fb3adbbb0f3cdf092cda84a10 (patch)
treee942cc54be97b815ae60fdd7bbd65a2aa624d843 /net
parent2ef2712ec860306a843c0e18afbdc339da4917cd (diff)
downloadchromium_src-0c4c3884b89e0c5fb3adbbb0f3cdf092cda84a10.zip
chromium_src-0c4c3884b89e0c5fb3adbbb0f3cdf092cda84a10.tar.gz
chromium_src-0c4c3884b89e0c5fb3adbbb0f3cdf092cda84a10.tar.bz2
The "Copy URL" link is always greyed out in the Chrome menu on popups [crbug.com/13488].
This turns out to be because it was never implemented. Tested manually on Windows; I'll test on Linux before submitting. BUG=13488 TEST=Tested manually on Windows and added a unit test for the new Clipboard function. Review URL: http://codereview.chromium.org/210042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27772 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/net_util.cc18
-rw-r--r--net/base/net_util.h6
2 files changed, 24 insertions, 0 deletions
diff --git a/net/base/net_util.cc b/net/base/net_util.cc
index b8c8add..51cfdf7 100644
--- a/net/base/net_util.cc
+++ b/net/base/net_util.cc
@@ -33,6 +33,7 @@
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/path_service.h"
+#include "base/scoped_clipboard_writer.h"
#include "base/singleton.h"
#include "base/stl_util-inl.h"
#include "base/string_escape.h"
@@ -1330,6 +1331,23 @@ std::wstring FormatUrl(const GURL& url,
return url_string;
}
+void WriteURLToClipboard(const GURL& url,
+ const std::wstring& languages,
+ Clipboard *clipboard) {
+ if (url.is_empty() || !url.is_valid() || !clipboard)
+ return;
+
+ string16 text =
+ // 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.
+ WideToUTF16(FormatUrl(url, languages, false, UnescapeRule::NONE, NULL,
+ NULL));
+
+ ScopedClipboardWriter scw(clipboard);
+ scw.WriteURL(text);
+}
+
GURL SimplifyUrlForRequest(const GURL& url) {
DCHECK(url.is_valid());
GURL::Replacements replacements;
diff --git a/net/base/net_util.h b/net/base/net_util.h
index 4d7e0aa..7d6cf81 100644
--- a/net/base/net_util.h
+++ b/net/base/net_util.h
@@ -19,6 +19,7 @@
#include "net/base/escape.h"
struct addrinfo;
+class Clipboard;
class FilePath;
class GURL;
@@ -239,6 +240,11 @@ inline std::wstring FormatUrl(const GURL& url, const std::wstring& languages) {
return FormatUrl(url, languages, true, UnescapeRule::SPACES, NULL, NULL);
}
+// Writes a string representation of |url| to the system clipboard.
+void WriteURLToClipboard(const GURL& url,
+ const std::wstring& languages,
+ Clipboard *clipboard);
+
// Strip the portions of |url| that aren't core to the network request.
// - user name / password
// - reference section