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

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

Issue 196283013: Make to call WebContentsImpl::RenderViewCreated() when we create child window. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: remove "ax_event_notification_details.h" in web_contents_impl.h Created 6 years, 7 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/content_browser_test_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/content_browser_test_utils.cc
===================================================================
--- content/public/test/content_browser_test_utils.cc (revision 270988)
+++ content/public/test/content_browser_test_utils.cc (working copy)
@@ -8,6 +8,7 @@
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/run_loop.h"
+#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/web_contents.h"
@@ -91,4 +92,57 @@
runner_->QuitClosure().Run();
}
+class RenderViewCreatedObserver : public WebContentsObserver {
+ public:
+ RenderViewCreatedObserver(WebContents* web_contents)
+ : WebContentsObserver(web_contents),
+ render_view_created_called_(false) {
+ }
+
+ // WebContentsObserver:
+ virtual void RenderViewCreated(RenderViewHost* rvh) OVERRIDE {
+ render_view_created_called_ = true;
+ }
+
+ bool render_view_created_called_;
+};
+
+WebContentsAddedObserver::WebContentsAddedObserver()
+ : web_contents_created_callback_(
+ base::Bind(
+ &WebContentsAddedObserver::WebContentsCreated,
+ base::Unretained(this))),
+ web_contents_(NULL) {
+ WebContentsImpl::AddCreatedCallback(web_contents_created_callback_);
+}
+
+WebContentsAddedObserver::~WebContentsAddedObserver() {
+ WebContentsImpl::RemoveCreatedCallback(web_contents_created_callback_);
+}
+
+void WebContentsAddedObserver::WebContentsCreated(WebContents* web_contents) {
+ DCHECK(!web_contents_);
+ web_contents_ = web_contents;
+ child_observer_.reset(new RenderViewCreatedObserver(web_contents));
+
+ if (runner_.get())
+ runner_->QuitClosure().Run();
+}
+
+WebContents* WebContentsAddedObserver::GetWebContents() {
+ if (web_contents_)
+ return web_contents_;
+
+ runner_ = new MessageLoopRunner();
+ runner_->Run();
+ return web_contents_;
+}
+
+bool WebContentsAddedObserver::RenderViewCreatedCalled() {
+ if (child_observer_)
+ return child_observer_->render_view_created_called_;
+
+ return false;
+}
+
} // namespace content
« no previous file with comments | « content/public/test/content_browser_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698