Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(575)

Unified Diff: content/public/test/browser_test_utils.cc

Issue 1934703002: Fix keyboard focus for OOPIF-<webview>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nasko@ comments. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698