Commit 22983e53 authored by John Lee's avatar John Lee Committed by Commit Bot

Copy Link to Text: Only copy the URL to the clipboard

After user feedback and UX discussion, the menu item will now only copy
the URL to the selected text to the clipboard instead of copying a quote
of the selected text.

Bug: 1137934
Change-Id: I9b51d70e649de973d34644a294980cd7bccc1658
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2553031Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: John Lee <johntlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830259}
parent 6ae1e213
......@@ -112,8 +112,7 @@ void CopyLinkToTextMenuObserver::OnGeneratedSelector(
std::string url = url_.spec();
if (!selector.empty())
url += kTextFragmentUrlClassifier + selector;
scw.WriteText(base::UTF8ToUTF16("\"") + selected_text_ +
base::UTF8ToUTF16("\"\n" + url));
scw.WriteText(base::UTF8ToUTF16(url));
}
void CopyLinkToTextMenuObserver::OverrideGeneratedSelectorForTesting(
......
......@@ -91,9 +91,7 @@ IN_PROC_BROWSER_TEST_F(CopyLinkToTextMenuObserverTest, CopiesLinkToText) {
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
base::string16 text;
clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, nullptr, &text);
EXPECT_EQ(base::UTF8ToUTF16(
"\"hello world\"\nhttp://foo.com/#:~:text=hello%20world"),
text);
EXPECT_EQ(base::UTF8ToUTF16("http://foo.com/#:~:text=hello%20world"), text);
}
IN_PROC_BROWSER_TEST_F(CopyLinkToTextMenuObserverTest,
......@@ -109,7 +107,7 @@ IN_PROC_BROWSER_TEST_F(CopyLinkToTextMenuObserverTest,
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
base::string16 text;
clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, nullptr, &text);
EXPECT_EQ(base::UTF8ToUTF16("\"hello world\"\nhttp://foo.com/"), text);
EXPECT_EQ(base::UTF8ToUTF16("http://foo.com/"), text);
}
IN_PROC_BROWSER_TEST_F(CopyLinkToTextMenuObserverTest, ReplacesRefInURL) {
......@@ -124,8 +122,7 @@ IN_PROC_BROWSER_TEST_F(CopyLinkToTextMenuObserverTest, ReplacesRefInURL) {
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
base::string16 text;
clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, nullptr, &text);
EXPECT_EQ(base::UTF8ToUTF16("\"hello world\"\nhttp://foo.com/#:~:text=hello"),
text);
EXPECT_EQ(base::UTF8ToUTF16("http://foo.com/#:~:text=hello"), text);
}
// crbug.com/1139864
......@@ -155,7 +152,7 @@ IN_PROC_BROWSER_TEST_F(CopyLinkToTextMenuObserverTest,
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
base::string16 text;
clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, nullptr, &text);
EXPECT_EQ(base::UTF8ToUTF16("\"hello world\"\n" + main_url.spec()), text);
EXPECT_EQ(base::UTF8ToUTF16(main_url.spec()), text);
}
IN_PROC_BROWSER_TEST_F(CopyLinkToTextMenuObserverTest, HiddenForExtensions) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment