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

Side by Side Diff: content/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: 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/test/content_browser_test_utils.h" 5 #include "content/test/content_browser_test_utils.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "content/browser/web_contents/web_contents_impl.h"
11 #include "content/public/browser/navigation_controller.h" 12 #include "content/public/browser/navigation_controller.h"
12 #include "content/public/browser/notification_source.h" 13 #include "content/public/browser/notification_source.h"
13 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
14 #include "content/public/common/content_paths.h" 15 #include "content/public/common/content_paths.h"
15 #include "content/public/test/browser_test_utils.h" 16 #include "content/public/test/browser_test_utils.h"
16 #include "content/public/test/test_navigation_observer.h" 17 #include "content/public/test/test_navigation_observer.h"
17 #include "content/public/test/test_utils.h" 18 #include "content/public/test/test_utils.h"
18 #include "content/shell/browser/shell.h" 19 #include "content/shell/browser/shell.h"
19 #include "content/shell/browser/shell_javascript_dialog_manager.h" 20 #include "content/shell/browser/shell_javascript_dialog_manager.h"
20 #include "net/base/net_util.h" 21 #include "net/base/net_util.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 return shell_; 76 return shell_;
76 } 77 }
77 78
78 void ShellAddedObserver::ShellCreated(Shell* shell) { 79 void ShellAddedObserver::ShellCreated(Shell* shell) {
79 DCHECK(!shell_); 80 DCHECK(!shell_);
80 shell_ = shell; 81 shell_ = shell;
81 if (runner_.get()) 82 if (runner_.get())
82 runner_->QuitClosure().Run(); 83 runner_->QuitClosure().Run();
83 } 84 }
84 85
86 class RenderViewCreatedObserver : public WebContentsObserver {
87 public:
88 RenderViewCreatedObserver(WebContents* web_contents)
89 : WebContentsObserver(web_contents),
90 render_view_created_called_(false) {
91 }
92
93 // WebContentsObserver:
94 virtual void RenderViewCreated(RenderViewHost* rvh) OVERRIDE {
95 render_view_created_called_ = true;
96 }
97
98 bool render_view_created_called_;
99 };
100
101 WebContentsAddedObserver::WebContentsAddedObserver()
102 : web_contents_(NULL) ,
103 child_observer_(NULL) ,
104 web_contents_created_callback_(
105 base::Bind(
106 &WebContentsAddedObserver::WebContentsCreated,
107 base::Unretained(this))) {
108 WebContentsImpl::AddCreatedCallback(web_contents_created_callback_);
109 }
110
111 WebContentsAddedObserver::~WebContentsAddedObserver() {
112 WebContentsImpl::RemoveCreatedCallback(web_contents_created_callback_);
113 }
114
115 void WebContentsAddedObserver::WebContentsCreated(WebContents* web_contents) {
116 DCHECK(!web_contents_);
117 web_contents_ = web_contents;
118 child_observer_ = new RenderViewCreatedObserver(web_contents);
119
120 if (runner_.get())
121 runner_->QuitClosure().Run();
122 }
123
124 WebContents* WebContentsAddedObserver::GetWebContents() {
125 if (web_contents_)
126 return web_contents_;
127
128 runner_ = new MessageLoopRunner();
129 runner_->Run();
130 return web_contents_;
131 }
132
133 bool WebContentsAddedObserver::RenderViewCreatedCalled() {
134 if (child_observer_)
135 return child_observer_->render_view_created_called_;
136
137 return false;
138 }
139
85 } // namespace content 140 } // namespace content
OLDNEW
« content/test/content_browser_test_utils.h ('K') | « content/test/content_browser_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698