summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/app_process_apitest.cc
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-09 21:30:47 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-09 21:30:47 +0000
commiteab29435d72de0fbcf3e5e1502b1677e7969cb30 (patch)
tree2e50a6a30ba7e91a2e2316b83d8fda5845238d41 /chrome/browser/extensions/app_process_apitest.cc
parent8e6e93688b5f67d3fe508b4c538ff13ae2694226 (diff)
downloadchromium_src-eab29435d72de0fbcf3e5e1502b1677e7969cb30.zip
chromium_src-eab29435d72de0fbcf3e5e1502b1677e7969cb30.tar.gz
chromium_src-eab29435d72de0fbcf3e5e1502b1677e7969cb30.tar.bz2
convert NOTIFICATION_RENDER_VIEW_HOST_CREATED usage to callbacks
BUG=170921 Review URL: https://codereview.chromium.org/13875002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193217 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/app_process_apitest.cc')
-rw-r--r--chrome/browser/extensions/app_process_apitest.cc37
1 files changed, 23 insertions, 14 deletions
diff --git a/chrome/browser/extensions/app_process_apitest.cc b/chrome/browser/extensions/app_process_apitest.cc
index 39fc84f..4b7f53f 100644
--- a/chrome/browser/extensions/app_process_apitest.cc
+++ b/chrome/browser/extensions/app_process_apitest.cc
@@ -527,6 +527,15 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, ReloadIntoAppProcessWithJavaScript) {
contents->GetRenderProcessHost()->GetID()));
}
+namespace {
+
+void RenderViewHostCreated(std::vector<content::RenderViewHost*>* rvh_vector,
+ content::RenderViewHost* rvh) {
+ rvh_vector->push_back(rvh);
+}
+
+} // namespace
+
// Tests that if we have a non-app process (path3/container.html) that has an
// iframe with a URL in the app's extent (path1/iframe.html), then opening a
// link from that iframe to a new window to a URL in the app's extent (path1/
@@ -546,19 +555,20 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromIframe) {
LoadExtension(test_data_dir_.AppendASCII("app_process"));
ASSERT_TRUE(app);
- content::WindowedNotificationObserver popup_observer(
- content::NOTIFICATION_RENDER_VIEW_HOST_CREATED,
- content::NotificationService::AllSources());
+ std::vector<content::RenderViewHost*> rvh_vector;
+ content::RenderViewHost::CreatedCallback rvh_callback(
+ base::Bind(&RenderViewHostCreated, &rvh_vector));
+ content::RenderViewHost::AddCreatedCallback(rvh_callback);
ui_test_utils::NavigateToURL(browser(),
base_url.Resolve("path3/container.html"));
+ content::RenderViewHost::RemoveCreatedCallback(rvh_callback);
EXPECT_FALSE(process_map->Contains(
browser()->tab_strip_model()->GetWebContentsAt(0)->
GetRenderProcessHost()->GetID()));
- popup_observer.Wait();
// Popup window should be in the app's process.
- RenderViewHost* popup_host =
- content::Source<RenderViewHost>(popup_observer.source()).ptr();
+ ASSERT_EQ(3U, rvh_vector.size());
+ RenderViewHost* popup_host = rvh_vector[2];
EXPECT_TRUE(process_map->Contains(popup_host->GetProcess()->GetID()));
}
@@ -657,21 +667,20 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, OpenWebPopupFromWebIframe) {
LoadExtension(test_data_dir_.AppendASCII("app_process"));
ASSERT_TRUE(app);
- content::WindowedNotificationObserver popup_observer(
- content::NOTIFICATION_RENDER_VIEW_HOST_CREATED,
- content::NotificationService::AllSources());
+ std::vector<content::RenderViewHost*> rvh_vector;
+ content::RenderViewHost::CreatedCallback rvh_callback(
+ base::Bind(&RenderViewHostCreated, &rvh_vector));
+ content::RenderViewHost::AddCreatedCallback(rvh_callback);
ui_test_utils::NavigateToURL(browser(),
base_url.Resolve("path1/container.html"));
+ content::RenderViewHost::RemoveCreatedCallback(rvh_callback);
content::RenderProcessHost* process =
browser()->tab_strip_model()->GetWebContentsAt(0)->GetRenderProcessHost();
EXPECT_TRUE(process_map->Contains(process->GetID()));
- // Wait for popup window to appear.
- popup_observer.Wait();
-
// Popup window should be in the app's process.
- RenderViewHost* popup_host =
- content::Source<RenderViewHost>(popup_observer.source()).ptr();
+ ASSERT_EQ(2U, rvh_vector.size());
+ RenderViewHost* popup_host = rvh_vector[1];
EXPECT_EQ(process, popup_host->GetProcess());
}