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

Unified Diff: chrome/browser/extensions/app_process_apitest.cc

Issue 10702029: Move tab functions off Browser into browser_tabstrip and browser_tabrestore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 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
Index: chrome/browser/extensions/app_process_apitest.cc
===================================================================
--- chrome/browser/extensions/app_process_apitest.cc (revision 145001)
+++ chrome/browser/extensions/app_process_apitest.cc (working copy)
@@ -11,6 +11,7 @@
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/common/chrome_notification_types.h"
@@ -81,8 +82,8 @@
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
LOG(INFO) << "Nav 1.";
EXPECT_TRUE(process_map->Contains(
- browser()->GetWebContentsAt(1)->GetRenderProcessHost()->GetID()));
- EXPECT_FALSE(browser()->GetWebContentsAt(1)->GetWebUI());
+ chrome::GetWebContentsAt(browser(), 1)->GetRenderProcessHost()->GetID()));
+ EXPECT_FALSE(chrome::GetWebContentsAt(browser(), 1)->GetWebUI());
ui_test_utils::WindowedNotificationObserver tab_added_observer(
chrome::NOTIFICATION_TAB_ADDED,
@@ -94,16 +95,16 @@
base_url.Resolve("path2/empty.html"));
LOG(INFO) << "Nav 2.";
EXPECT_TRUE(process_map->Contains(
- browser()->GetWebContentsAt(2)->GetRenderProcessHost()->GetID()));
- EXPECT_FALSE(browser()->GetWebContentsAt(2)->GetWebUI());
+ chrome::GetWebContentsAt(browser(), 2)->GetRenderProcessHost()->GetID()));
+ EXPECT_FALSE(chrome::GetWebContentsAt(browser(), 2)->GetWebUI());
// We should have opened 2 new extension tabs. Including the original blank
// tab, we now have 3 tabs. The two app tabs should not be in the same
// process, since they do not have the background permission. (Thus, we
// want to separate them to improve responsiveness.)
ASSERT_EQ(3, browser()->tab_count());
- WebContents* tab1 = browser()->GetWebContentsAt(1);
- WebContents* tab2 = browser()->GetWebContentsAt(2);
+ WebContents* tab1 = chrome::GetWebContentsAt(browser(), 1);
+ WebContents* tab2 = chrome::GetWebContentsAt(browser(), 2);
EXPECT_NE(tab1->GetRenderProcessHost(), tab2->GetRenderProcessHost());
// Opening tabs with window.open should keep the page in the opener's
@@ -141,16 +142,16 @@
browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
EXPECT_TRUE(process_map->Contains(
- browser()->GetWebContentsAt(1)->GetRenderProcessHost()->GetID()));
- EXPECT_FALSE(browser()->GetWebContentsAt(1)->GetWebUI());
+ chrome::GetWebContentsAt(browser(), 1)->GetRenderProcessHost()->GetID()));
+ EXPECT_FALSE(chrome::GetWebContentsAt(browser(), 1)->GetWebUI());
LOG(INFO) << "Nav 1.";
ui_test_utils::NavigateToURLWithDisposition(
browser(), base_url.Resolve("path2/empty.html"), NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
EXPECT_TRUE(process_map->Contains(
- browser()->GetWebContentsAt(2)->GetRenderProcessHost()->GetID()));
- EXPECT_FALSE(browser()->GetWebContentsAt(2)->GetWebUI());
+ chrome::GetWebContentsAt(browser(), 2)->GetRenderProcessHost()->GetID()));
+ EXPECT_FALSE(chrome::GetWebContentsAt(browser(), 2)->GetWebUI());
LOG(INFO) << "Nav 2.";
ui_test_utils::WindowedNotificationObserver tab_added_observer(
@@ -162,20 +163,20 @@
ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path3/empty.html"));
LOG(INFO) << "Nav 3.";
EXPECT_FALSE(process_map->Contains(
- browser()->GetWebContentsAt(3)->GetRenderProcessHost()->GetID()));
- EXPECT_FALSE(browser()->GetWebContentsAt(3)->GetWebUI());
+ chrome::GetWebContentsAt(browser(), 3)->GetRenderProcessHost()->GetID()));
+ EXPECT_FALSE(chrome::GetWebContentsAt(browser(), 3)->GetWebUI());
// We should have opened 3 new extension tabs. Including the original blank
// tab, we now have 4 tabs. Because the app_process app has the background
// permission, all of its instances are in the same process. Thus two tabs
// should be part of the extension app and grouped in the same process.
ASSERT_EQ(4, browser()->tab_count());
- WebContents* tab = browser()->GetWebContentsAt(1);
+ WebContents* tab = chrome::GetWebContentsAt(browser(), 1);
EXPECT_EQ(tab->GetRenderProcessHost(),
- browser()->GetWebContentsAt(2)->GetRenderProcessHost());
+ chrome::GetWebContentsAt(browser(), 2)->GetRenderProcessHost());
EXPECT_NE(tab->GetRenderProcessHost(),
- browser()->GetWebContentsAt(3)->GetRenderProcessHost());
+ chrome::GetWebContentsAt(browser(), 3)->GetRenderProcessHost());
// Now let's do the same using window.open. The same should happen.
ASSERT_EQ(1u, browser::GetBrowserCount(browser()->profile()));
@@ -195,24 +196,24 @@
// extent. They should switch processes.
const GURL& app_url(base_url.Resolve("path1/empty.html"));
const GURL& non_app_url(base_url.Resolve("path3/empty.html"));
- NavigateInRenderer(browser()->GetWebContentsAt(2), non_app_url);
+ NavigateInRenderer(chrome::GetWebContentsAt(browser(), 2), non_app_url);
LOG(INFO) << "NavigateTabHelper 1.";
- NavigateInRenderer(browser()->GetWebContentsAt(3), app_url);
+ NavigateInRenderer(chrome::GetWebContentsAt(browser(), 3), app_url);
LOG(INFO) << "NavigateTabHelper 2.";
EXPECT_NE(tab->GetRenderProcessHost(),
- browser()->GetWebContentsAt(2)->GetRenderProcessHost());
+ chrome::GetWebContentsAt(browser(), 2)->GetRenderProcessHost());
EXPECT_EQ(tab->GetRenderProcessHost(),
- browser()->GetWebContentsAt(3)->GetRenderProcessHost());
+ chrome::GetWebContentsAt(browser(), 3)->GetRenderProcessHost());
// If one of the popup tabs navigates back to the app, window.opener should
// be valid.
- NavigateInRenderer(browser()->GetWebContentsAt(6), app_url);
+ NavigateInRenderer(chrome::GetWebContentsAt(browser(), 6), app_url);
LOG(INFO) << "NavigateTabHelper 3.";
EXPECT_EQ(tab->GetRenderProcessHost(),
- browser()->GetWebContentsAt(6)->GetRenderProcessHost());
+ chrome::GetWebContentsAt(browser(), 6)->GetRenderProcessHost());
bool windowOpenerValid = false;
ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
- browser()->GetWebContentsAt(6)->GetRenderViewHost(), L"",
+ chrome::GetWebContentsAt(browser(), 6)->GetRenderViewHost(), L"",
L"window.domAutomationController.send(window.opener != null)",
&windowOpenerValid));
ASSERT_TRUE(windowOpenerValid);
@@ -262,8 +263,8 @@
browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
EXPECT_FALSE(process_map->Contains(
- browser()->GetWebContentsAt(1)->GetRenderProcessHost()->GetID()));
- EXPECT_FALSE(browser()->GetWebContentsAt(1)->GetWebUI());
+ chrome::GetWebContentsAt(browser(), 1)->GetRenderProcessHost()->GetID()));
+ EXPECT_FALSE(chrome::GetWebContentsAt(browser(), 1)->GetWebUI());
ui_test_utils::WindowedNotificationObserver tab_added_observer(
chrome::NOTIFICATION_TAB_ADDED,
@@ -272,16 +273,16 @@
tab_added_observer.Wait();
ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html"));
EXPECT_FALSE(process_map->Contains(
- browser()->GetWebContentsAt(2)->GetRenderProcessHost()->GetID()));
- EXPECT_FALSE(browser()->GetWebContentsAt(2)->GetWebUI());
+ chrome::GetWebContentsAt(browser(), 2)->GetRenderProcessHost()->GetID()));
+ EXPECT_FALSE(chrome::GetWebContentsAt(browser(), 2)->GetWebUI());
// We should have opened 2 new bookmark app tabs. Including the original blank
// tab, we now have 3 tabs. Because normal pages use the
// process-per-site-instance model, each should be in its own process.
ASSERT_EQ(3, browser()->tab_count());
- WebContents* tab = browser()->GetWebContentsAt(1);
+ WebContents* tab = chrome::GetWebContentsAt(browser(), 1);
EXPECT_NE(tab->GetRenderProcessHost(),
- browser()->GetWebContentsAt(2)->GetRenderProcessHost());
+ chrome::GetWebContentsAt(browser(), 2)->GetRenderProcessHost());
// Now let's do the same using window.open. The same should happen.
ASSERT_EQ(1u, browser::GetBrowserCount(browser()->profile()));
@@ -292,13 +293,14 @@
// extent. Neither navigation should switch processes.
const GURL& app_url(base_url.Resolve("path1/empty.html"));
const GURL& non_app_url(base_url.Resolve("path3/empty.html"));
- RenderViewHost* host2 = browser()->GetWebContentsAt(2)->GetRenderViewHost();
- NavigateInRenderer(browser()->GetWebContentsAt(2), non_app_url);
+ RenderViewHost* host2 =
+ chrome::GetWebContentsAt(browser(), 2)->GetRenderViewHost();
+ NavigateInRenderer(chrome::GetWebContentsAt(browser(), 2), non_app_url);
EXPECT_EQ(host2->GetProcess(),
- browser()->GetWebContentsAt(2)->GetRenderProcessHost());
- NavigateInRenderer(browser()->GetWebContentsAt(2), app_url);
+ chrome::GetWebContentsAt(browser(), 2)->GetRenderProcessHost());
+ NavigateInRenderer(chrome::GetWebContentsAt(browser(), 2), app_url);
EXPECT_EQ(host2->GetProcess(),
- browser()->GetWebContentsAt(2)->GetRenderProcessHost());
+ chrome::GetWebContentsAt(browser(), 2)->GetRenderProcessHost());
}
// Tests that app process switching works properly in the following scenario:
@@ -336,10 +338,10 @@
// process.
ASSERT_EQ(3, browser()->tab_count());
EXPECT_EQ("/files/extensions/api_test/app_process/path1/empty.html",
- browser()->GetWebContentsAt(2)->GetController().
+ chrome::GetWebContentsAt(browser(), 2)->GetController().
GetLastCommittedEntry()->GetURL().path());
- EXPECT_EQ(browser()->GetWebContentsAt(1)->GetRenderProcessHost(),
- browser()->GetWebContentsAt(2)->GetRenderProcessHost());
+ EXPECT_EQ(chrome::GetWebContentsAt(browser(), 1)->GetRenderProcessHost(),
+ chrome::GetWebContentsAt(browser(), 2)->GetRenderProcessHost());
}
// Ensure that reloading a URL after installing or uninstalling it as an app
@@ -364,7 +366,7 @@
// Load an app URL before loading the app.
ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html"));
- WebContents* contents = browser()->GetWebContentsAt(0);
+ WebContents* contents = chrome::GetWebContentsAt(browser(), 0);
EXPECT_FALSE(process_map->Contains(
contents->GetRenderProcessHost()->GetID()));
@@ -387,7 +389,7 @@
ui_test_utils::WindowedNotificationObserver reload_observer(
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
- &browser()->GetActiveWebContents()->GetController()));
+ &chrome::GetActiveWebContents(browser())->GetController()));
chrome::Reload(browser(), CURRENT_TAB);
reload_observer.Wait();
EXPECT_TRUE(process_map->Contains(
@@ -398,7 +400,7 @@
ui_test_utils::WindowedNotificationObserver reload_observer2(
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
- &browser()->GetActiveWebContents()->GetController()));
+ &chrome::GetActiveWebContents(browser())->GetController()));
chrome::Reload(browser(), CURRENT_TAB);
reload_observer2.Wait();
EXPECT_FALSE(process_map->Contains(
@@ -409,7 +411,7 @@
ui_test_utils::WindowedNotificationObserver js_reload_observer(
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
- &browser()->GetActiveWebContents()->GetController()));
+ &chrome::GetActiveWebContents(browser())->GetController()));
ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(contents->GetRenderViewHost(),
L"", L"location.reload();"));
js_reload_observer.Wait();
@@ -421,7 +423,7 @@
ui_test_utils::WindowedNotificationObserver js_reload_observer2(
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
- &browser()->GetActiveWebContents()->GetController()));
+ &chrome::GetActiveWebContents(browser())->GetController()));
ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(contents->GetRenderViewHost(),
L"", L"location = location;"));
js_reload_observer2.Wait();
@@ -454,7 +456,7 @@
ui_test_utils::NavigateToURL(browser(),
base_url.Resolve("path3/container.html"));
EXPECT_FALSE(process_map->Contains(
- browser()->GetWebContentsAt(0)->GetRenderProcessHost()->GetID()));
+ chrome::GetWebContentsAt(browser(), 0)->GetRenderProcessHost()->GetID()));
popup_observer.Wait();
// Popup window should be in the app's process.
@@ -499,7 +501,7 @@
// App has loaded, and chrome.app.isInstalled should be true.
bool is_installed = false;
ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
- browser()->GetActiveWebContents()->GetRenderViewHost(), L"",
+ chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"",
L"window.domAutomationController.send(chrome.app.isInstalled)",
&is_installed));
ASSERT_TRUE(is_installed);
@@ -532,7 +534,7 @@
ui_test_utils::NavigateToURL(browser(),
base_url.Resolve("path1/container.html"));
content::RenderProcessHost* process =
- browser()->GetWebContentsAt(0)->GetRenderProcessHost();
+ chrome::GetWebContentsAt(browser(), 0)->GetRenderProcessHost();
EXPECT_TRUE(process_map->Contains(process->GetID()));
// Wait for popup window to appear.
@@ -563,7 +565,7 @@
// Load the app, chrome.app.isInstalled should be true.
ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html"));
- WebContents* contents = browser()->GetWebContentsAt(0);
+ WebContents* contents = chrome::GetWebContentsAt(browser(), 0);
EXPECT_TRUE(process_map->Contains(
contents->GetRenderProcessHost()->GetID()));
bool is_installed = false;
@@ -574,11 +576,11 @@
ASSERT_TRUE(is_installed);
// Crash the tab and reload it, chrome.app.isInstalled should still be true.
- ui_test_utils::CrashTab(browser()->GetActiveWebContents());
+ ui_test_utils::CrashTab(chrome::GetActiveWebContents(browser()));
ui_test_utils::WindowedNotificationObserver observer(
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
- &browser()->GetActiveWebContents()->GetController()));
+ &chrome::GetActiveWebContents(browser())->GetController()));
chrome::Reload(browser(), CURRENT_TAB);
observer.Wait();
ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
« no previous file with comments | « chrome/browser/extensions/api/web_request/web_request_apitest.cc ('k') | chrome/browser/extensions/browser_action_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698