| Index: content/public/test/browser_test_utils.cc
|
| diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc
|
| index 857542c67d9b670ea2e3512568ec42dbc0abe9dc..2c1907b24c52f5d5b83402dd3566ec84d2803aef 100644
|
| --- a/content/public/test/browser_test_utils.cc
|
| +++ b/content/public/test/browser_test_utils.cc
|
| @@ -1507,4 +1507,35 @@ void BrowserTestClipboardScope::SetText(const std::string& text) {
|
| clipboard_writer.WriteText(base::ASCIIToUTF16(text));
|
| }
|
|
|
| +class FrameFocusedObserver::FrameTreeNodeObserverImpl
|
| + : public FrameTreeNode::Observer {
|
| + public:
|
| + explicit FrameTreeNodeObserverImpl(FrameTreeNode* owner)
|
| + : owner_(owner), message_loop_runner_(new MessageLoopRunner) {
|
| + owner->AddObserver(this);
|
| + }
|
| + ~FrameTreeNodeObserverImpl() override { owner_->RemoveObserver(this); }
|
| +
|
| + void Run() { message_loop_runner_->Run(); }
|
| +
|
| + void OnFrameTreeNodeFocused(FrameTreeNode* node) override {
|
| + if (node == owner_)
|
| + message_loop_runner_->Quit();
|
| + }
|
| +
|
| + private:
|
| + FrameTreeNode* owner_;
|
| + scoped_refptr<MessageLoopRunner> message_loop_runner_;
|
| +};
|
| +
|
| +FrameFocusedObserver::FrameFocusedObserver(RenderFrameHost* owner_host)
|
| + : impl_(new FrameTreeNodeObserverImpl(
|
| + static_cast<RenderFrameHostImpl*>(owner_host)->frame_tree_node())) {}
|
| +
|
| +FrameFocusedObserver::~FrameFocusedObserver() {}
|
| +
|
| +void FrameFocusedObserver::Wait() {
|
| + impl_->Run();
|
| +}
|
| +
|
| } // namespace content
|
|
|