Commit 1c55ded3 authored by John Lee's avatar John Lee Committed by Commit Bot

Copy Link To Text: Surround selected text with quotes

Bug: 1105862
Change-Id: Ia3b9cb7d06a88005321806c78f1dbcf93d4ba544
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2438929Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: John Lee <johntlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812888}
parent c2b4106d
...@@ -79,7 +79,8 @@ void CopyLinkToTextMenuObserver::OnGeneratedSelector( ...@@ -79,7 +79,8 @@ void CopyLinkToTextMenuObserver::OnGeneratedSelector(
std::string url = url_.spec(); std::string url = url_.spec();
if (!selector.empty()) if (!selector.empty())
url += kTextFragmentUrlClassifier + selector; url += kTextFragmentUrlClassifier + selector;
scw.WriteText(selected_text_ + base::UTF8ToUTF16("\n" + url)); scw.WriteText(base::UTF8ToUTF16("\"") + selected_text_ +
base::UTF8ToUTF16("\"\n" + url));
} }
void CopyLinkToTextMenuObserver::OverrideGeneratedSelectorForTesting( void CopyLinkToTextMenuObserver::OverrideGeneratedSelectorForTesting(
......
...@@ -77,8 +77,8 @@ IN_PROC_BROWSER_TEST_F(CopyLinkToTextMenuObserverTest, CopiesLinkToText) { ...@@ -77,8 +77,8 @@ IN_PROC_BROWSER_TEST_F(CopyLinkToTextMenuObserverTest, CopiesLinkToText) {
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
base::string16 text; base::string16 text;
clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, nullptr, &text); clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, nullptr, &text);
EXPECT_EQ( EXPECT_EQ(base::UTF8ToUTF16(
base::UTF8ToUTF16("hello world\nhttp://foo.com/#:~:text=hello%20world"), "\"hello world\"\nhttp://foo.com/#:~:text=hello%20world"),
text); text);
} }
...@@ -95,5 +95,5 @@ IN_PROC_BROWSER_TEST_F(CopyLinkToTextMenuObserverTest, ...@@ -95,5 +95,5 @@ IN_PROC_BROWSER_TEST_F(CopyLinkToTextMenuObserverTest,
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
base::string16 text; base::string16 text;
clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, nullptr, &text); clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, nullptr, &text);
EXPECT_EQ(base::UTF8ToUTF16("hello world\nhttp://foo.com/"), text); EXPECT_EQ(base::UTF8ToUTF16("\"hello world\"\nhttp://foo.com/"), text);
} }
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