Commit 0455af94 authored by Robert Sesek's avatar Robert Sesek Committed by Commit Bot

mac: Fix "Use Selection for Find" / Cmd+E.

In 1e1812f8, the ClipboardHost was
moved to the frame's interface broker. But the implementation of
CopyToFindPboard() was still attempting to get the ClipboardHost via
the process's interface broker, which no longer provides it.

Test: Added RenderFrameHostImplBrowserMacTest.CopyToFindPasteboard
Bug: 1045982
Change-Id: I7f26f27c20dd96475ae416c9b7c34f79941082be
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2031672Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737122}
parent a0663b42
...@@ -8,7 +8,7 @@ include_rules = [ ...@@ -8,7 +8,7 @@ include_rules = [
] ]
specific_include_rules = { specific_include_rules = {
".*_(unit|browser)test\.cc": [ ".*_(unit|browser)test\.(cc|mm)": [
"+content/browser/web_contents", "+content/browser/web_contents",
"+content/public/browser/web_contents.h", "+content/public/browser/web_contents.h",
"+content/public/browser/web_contents_delegate.h", "+content/public/browser/web_contents_delegate.h",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "base/mac/scoped_nsobject.h"
#include "base/run_loop.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/shell/browser/shell.h"
#include "testing/gtest_mac.h"
#include "ui/base/cocoa/find_pasteboard.h"
#include "url/gurl.h"
namespace content {
using RenderFrameHostImplBrowserMacTest = ContentBrowserTest;
IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserMacTest,
CopyToFindPasteboard) {
WebContents* web_contents = shell()->web_contents();
GURL url("data:text/html,Hello world");
ASSERT_TRUE(NavigateToURL(web_contents, url));
FindPasteboard* pboard = [FindPasteboard sharedInstance];
base::scoped_nsobject<NSString> original_pboard_text(
[[pboard findText] copy]);
[pboard setFindText:@"test"];
EXPECT_NSEQ(@"test", [pboard findText]);
auto* rfhi = static_cast<RenderFrameHostImpl*>(web_contents->GetMainFrame());
auto* input_handler = rfhi->GetFrameInputHandler();
input_handler->SelectAll();
input_handler->CopyToFindPboard();
base::RunLoop loop;
__block base::OnceClosure quit_closure = loop.QuitClosure();
NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
id notification_handle =
[center addObserverForName:kFindPasteboardChangedNotification
object:pboard
queue:nil
usingBlock:^(NSNotification*) {
std::move(quit_closure).Run();
}];
loop.Run();
[center removeObserver:notification_handle];
EXPECT_NSEQ(@"Hello world", [pboard findText]);
[pboard setFindText:original_pboard_text];
}
} // namespace content
...@@ -2457,8 +2457,7 @@ void RenderFrameImpl::OnCopyToFindPboard() { ...@@ -2457,8 +2457,7 @@ void RenderFrameImpl::OnCopyToFindPboard() {
// than the |OnCopy()| case. // than the |OnCopy()| case.
if (frame_->HasSelection()) { if (frame_->HasSelection()) {
if (!clipboard_host_) { if (!clipboard_host_) {
auto* platform = RenderThreadImpl::current_blink_platform_impl(); GetBrowserInterfaceBroker()->GetInterface(
platform->GetBrowserInterfaceBroker()->GetInterface(
clipboard_host_.BindNewPipeAndPassReceiver()); clipboard_host_.BindNewPipeAndPassReceiver());
clipboard_host_.set_disconnect_handler(base::BindOnce( clipboard_host_.set_disconnect_handler(base::BindOnce(
&RenderFrameImpl::OnClipboardHostError, base::Unretained(this))); &RenderFrameImpl::OnClipboardHostError, base::Unretained(this)));
......
...@@ -879,6 +879,7 @@ test("content_browsertests") { ...@@ -879,6 +879,7 @@ test("content_browsertests") {
"../browser/frame_host/navigation_request_browsertest.cc", "../browser/frame_host/navigation_request_browsertest.cc",
"../browser/frame_host/render_document_host_browsertest.cc", "../browser/frame_host/render_document_host_browsertest.cc",
"../browser/frame_host/render_frame_host_impl_browsertest.cc", "../browser/frame_host/render_frame_host_impl_browsertest.cc",
"../browser/frame_host/render_frame_host_impl_mac_browsertest.mm",
"../browser/frame_host/render_frame_host_manager_browsertest.cc", "../browser/frame_host/render_frame_host_manager_browsertest.cc",
"../browser/frame_host/render_frame_message_filter_browsertest.cc", "../browser/frame_host/render_frame_message_filter_browsertest.cc",
"../browser/frame_host/sec_fetch_browsertest.cc", "../browser/frame_host/sec_fetch_browsertest.cc",
......
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