summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-05 15:58:55 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-05 15:58:55 +0000
commitcecc93a46dd560fe4157af3d098092eb395324d3 (patch)
tree18e511cec0772c03f0109bb8a24bd9ad95a4e3fd /chrome/browser
parent07efbd20cead99d9b46df250e6e562bf1696cd4b (diff)
downloadchromium_src-cecc93a46dd560fe4157af3d098092eb395324d3.zip
chromium_src-cecc93a46dd560fe4157af3d098092eb395324d3.tar.gz
chromium_src-cecc93a46dd560fe4157af3d098092eb395324d3.tar.bz2
Replace Browser::AddTabWithURL(...) with:
- Browser::AddSelectedTabWithURL(const GURL& url, PageTransition::Type transition) -> A good many callsites just wanted a way to open a tab somewhere and select it. - Browser::AddTabWithURL(AddTabWithURLParams* params) -> For the callsites with specialized needs, this new signature allows the parameter set to change as features are added without having to update a bunch of callers every time. BUG=none TEST=existing unit tests Review URL: http://codereview.chromium.org/3599006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61517 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/autocomplete/autocomplete_browsertest.cc9
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc9
-rw-r--r--chrome/browser/browser.cc175
-rw-r--r--chrome/browser/browser.h71
-rw-r--r--chrome/browser/browser_browsertest.cc42
-rw-r--r--chrome/browser/browser_focus_uitest.cc23
-rw-r--r--chrome/browser/browser_init.cc11
-rw-r--r--chrome/browser/chromeos/tab_closeable_state_watcher_browsertest.cc6
-rw-r--r--chrome/browser/cocoa/applescript/window_applescript.mm35
-rw-r--r--chrome/browser/cocoa/tab_strip_controller.mm12
-rw-r--r--chrome/browser/dom_ui/filebrowse_ui.cc25
-rw-r--r--chrome/browser/dom_ui/html_dialog_tab_contents_delegate.cc9
-rw-r--r--chrome/browser/dom_ui/mediaplayer_ui.cc12
-rw-r--r--chrome/browser/extensions/extension_install_ui.cc4
-rw-r--r--chrome/browser/extensions/extension_tabs_module.cc13
-rw-r--r--chrome/browser/find_bar_host_browsertest.cc39
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc8
-rw-r--r--chrome/browser/importer/importer.cc10
-rw-r--r--chrome/browser/platform_util_chromeos.cc8
-rw-r--r--chrome/browser/sessions/session_restore.cc6
-rw-r--r--chrome/browser/sessions/session_restore_browsertest.cc15
-rw-r--r--chrome/browser/ssl/ssl_browser_tests.cc26
-rw-r--r--chrome/browser/task_manager/task_manager_browsertest.cc15
-rw-r--r--chrome/browser/translate/translate_manager.cc6
-rw-r--r--chrome/browser/views/app_launcher.cc5
-rw-r--r--chrome/browser/views/find_bar_host_interactive_uitest.cc8
26 files changed, 281 insertions, 321 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_browsertest.cc b/chrome/browser/autocomplete/autocomplete_browsertest.cc
index 744db3e..0fcd9a8 100644
--- a/chrome/browser/autocomplete/autocomplete_browsertest.cc
+++ b/chrome/browser/autocomplete/autocomplete_browsertest.cc
@@ -147,11 +147,10 @@ IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, TabAwayRevertSelect) {
EXPECT_EQ(UTF8ToWide(chrome::kAboutBlankURL),
location_bar->location_entry()->GetText());
location_bar->location_entry()->SetUserText(L"");
- Browser* browser_used = NULL;
- browser()->AddTabWithURL(
- GURL(chrome::kAboutBlankURL), GURL(), PageTransition::START_PAGE,
- -1, TabStripModel::ADD_SELECTED, NULL, std::string(), &browser_used);
- EXPECT_EQ(browser(), browser_used);
+ Browser::AddTabWithURLParams params(GURL(chrome::kAboutBlankURL),
+ PageTransition::START_PAGE);
+ browser()->AddTabWithURL(&params);
+ EXPECT_EQ(browser(), params.target);
ui_test_utils::WaitForNavigation(
&browser()->GetSelectedTabContents()->controller());
EXPECT_EQ(UTF8ToWide(chrome::kAboutBlankURL),
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 7184780..b0c2df5 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -492,12 +492,11 @@ void TestingAutomationProvider::AppendTab(int handle, const GURL& url,
if (browser_tracker_->ContainsHandle(handle)) {
Browser* browser = browser_tracker_->GetResource(handle);
observer = AddTabStripObserver(browser, reply_message);
- TabContents* tab_contents = browser->AddTabWithURL(
- url, GURL(), PageTransition::TYPED, -1, TabStripModel::ADD_SELECTED,
- NULL, std::string(), &browser);
- if (tab_contents) {
+ TabContents* contents =
+ browser->AddSelectedTabWithURL(url, PageTransition::TYPED);
+ if (contents) {
append_tab_response =
- GetIndexForNavigationController(&tab_contents->controller(), browser);
+ GetIndexForNavigationController(&contents->controller(), browser);
}
}
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 01e70c3..ad3c3e7 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -453,15 +453,9 @@ void Browser::OpenWindowWithRestoredTabs(Profile* profile) {
// static
void Browser::OpenURLOffTheRecord(Profile* profile, const GURL& url) {
- Profile* off_the_record_profile = profile->GetOffTheRecordProfile();
- Browser* browser = BrowserList::FindBrowserWithType(
- off_the_record_profile, TYPE_NORMAL, false);
- if (!browser)
- browser = Browser::Create(off_the_record_profile);
- // TODO(eroman): should we have referrer here?
- browser->AddTabWithURL(
- url, GURL(), PageTransition::LINK, -1, TabStripModel::ADD_SELECTED, NULL,
- std::string(), &browser);
+ Browser* browser = GetOrCreateTabbedBrowser(
+ profile->GetOffTheRecordProfile());
+ browser->AddSelectedTabWithURL(url, PageTransition::LINK);
browser->window()->Show();
}
@@ -496,10 +490,10 @@ TabContents* Browser::OpenApplication(
case extension_misc::LAUNCH_WINDOW:
case extension_misc::LAUNCH_PANEL:
tab = Browser::OpenApplicationWindow(profile, extension, container,
- GURL(), NULL);
+ GURL());
break;
case extension_misc::LAUNCH_TAB: {
- tab = Browser::OpenApplicationTab(profile, extension, NULL);
+ tab = Browser::OpenApplicationTab(profile, extension);
break;
}
default:
@@ -514,8 +508,7 @@ TabContents* Browser::OpenApplicationWindow(
Profile* profile,
Extension* extension,
extension_misc::LaunchContainer container,
- const GURL& url_input,
- Browser** browser) {
+ const GURL& url_input) {
GURL url;
if (!url_input.is_empty()) {
if (extension)
@@ -531,19 +524,17 @@ TabContents* Browser::OpenApplicationWindow(
RegisterAppPrefs(app_name);
bool as_panel = extension && (container == extension_misc::LAUNCH_PANEL);
- Browser* local_browser = Browser::CreateForApp(app_name, extension, profile,
- as_panel);
- TabContents* tab_contents = local_browser->AddTabWithURL(
- url, GURL(), PageTransition::START_PAGE, -1, TabStripModel::ADD_SELECTED,
- NULL, std::string(), &local_browser);
-
- tab_contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
- tab_contents->render_view_host()->SyncRendererPrefs();
- local_browser->window()->Show();
+ Browser* browser = Browser::CreateForApp(app_name, extension, profile,
+ as_panel);
+ TabContents* contents =
+ browser->AddSelectedTabWithURL(url, PageTransition::START_PAGE);
+ contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
+ contents->render_view_host()->SyncRendererPrefs();
+ browser->window()->Show();
// TODO(jcampan): http://crbug.com/8123 we should not need to set the initial
// focus explicitly.
- tab_contents->view()->SetInitialFocus();
+ contents->view()->SetInitialFocus();
if (!as_panel) {
// Set UPDATE_SHORTCUT as the pending web app action. This action is picked
@@ -552,30 +543,25 @@ TabContents* Browser::OpenApplicationWindow(
// OnDidGetApplicationInfo, which calls
// web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as
// pending web app action.
- local_browser->pending_web_app_action_ = UPDATE_SHORTCUT;
+ browser->pending_web_app_action_ = UPDATE_SHORTCUT;
}
- if (browser)
- *browser = local_browser;
-
- return tab_contents;
+ return contents;
}
// static
-TabContents* Browser::OpenApplicationWindow(Profile* profile,
- GURL& url, Browser** browser) {
+TabContents* Browser::OpenApplicationWindow(Profile* profile, GURL& url) {
return OpenApplicationWindow(profile, NULL, extension_misc::LAUNCH_WINDOW,
- url, browser);
+ url);
}
// static
TabContents* Browser::OpenApplicationTab(Profile* profile,
- Extension* extension,
- Browser** browser) {
- Browser* local_browser = BrowserList::GetLastActiveWithProfile(profile);
- TabContents* tab_contents = NULL;
- if (!local_browser || local_browser->type() != Browser::TYPE_NORMAL)
- return tab_contents;
+ Extension* extension) {
+ Browser* browser = BrowserList::GetLastActiveWithProfile(profile);
+ TabContents* contents = NULL;
+ if (!browser || browser->type() != Browser::TYPE_NORMAL)
+ return contents;
// Check the prefs for overridden mode.
ExtensionsService* extensions_service = profile->GetExtensionsService();
@@ -589,12 +575,14 @@ TabContents* Browser::OpenApplicationTab(Profile* profile,
// TODO(erikkay): START_PAGE doesn't seem like the right transition in all
// cases.
- tab_contents = local_browser->AddTabWithURL(extension->GetFullLaunchURL(),
- GURL(), PageTransition::START_PAGE, -1, add_type, NULL, "", browser);
+ AddTabWithURLParams params(extension->GetFullLaunchURL(),
+ PageTransition::START_PAGE);
+ params.add_types = add_type;
+ contents = browser->AddTabWithURL(&params);
if (launch_type == ExtensionPrefs::LAUNCH_FULLSCREEN)
- local_browser->window()->SetFullscreen(true);
+ browser->window()->SetFullscreen(true);
- return tab_contents;
+ return contents;
}
// static
@@ -874,48 +862,57 @@ int Browser::GetIndexForInsertionDuringRestore(int relative_index) {
TabStripModel::INSERT_AFTER) ? tab_count() : relative_index;
}
-TabContents* Browser::AddTabWithURL(const GURL& url,
- const GURL& referrer,
- PageTransition::Type transition,
- int index,
- int add_types,
- SiteInstance* instance,
- const std::string& extension_app_id,
- Browser** browser_used) {
+TabContents* Browser::AddSelectedTabWithURL(const GURL& url,
+ PageTransition::Type transition) {
+ AddTabWithURLParams params(url, transition);
+ return AddTabWithURL(&params);
+}
+
+Browser::AddTabWithURLParams::AddTabWithURLParams(
+ const GURL& a_url,
+ PageTransition::Type a_transition)
+ : url(a_url),
+ transition(a_transition),
+ index(-1),
+ add_types(TabStripModel::ADD_SELECTED),
+ instance(NULL),
+ target(NULL) {
+}
+
+Browser::AddTabWithURLParams::~AddTabWithURLParams() {
+}
+
+TabContents* Browser::AddTabWithURL(AddTabWithURLParams* params) {
TabContents* contents = NULL;
if (CanSupportWindowFeature(FEATURE_TABSTRIP) || tabstrip_model()->empty()) {
- GURL url_to_load = url;
+ GURL url_to_load = params->url;
if (url_to_load.is_empty())
url_to_load = GetHomePage();
- contents = CreateTabContentsForURL(url_to_load, referrer, profile_,
- transition, false, instance);
- contents->SetExtensionAppById(extension_app_id);
- tab_handler_->GetTabStripModel()->AddTabContents(contents, index,
- transition, add_types);
+ contents = CreateTabContentsForURL(url_to_load, params->referrer, profile_,
+ params->transition, false,
+ params->instance);
+ contents->SetExtensionAppById(params->extension_app_id);
+ tab_handler_->GetTabStripModel()->AddTabContents(contents, params->index,
+ params->transition,
+ params->add_types);
// TODO(sky): figure out why this is needed. Without it we seem to get
// failures in startup tests.
// By default, content believes it is not hidden. When adding contents
// in the background, tell it that it's hidden.
- if ((add_types & TabStripModel::ADD_SELECTED) == 0) {
+ if ((params->add_types & TabStripModel::ADD_SELECTED) == 0) {
// TabStripModel::AddTabContents invokes HideContents if not foreground.
contents->WasHidden();
}
-
- if (browser_used)
- *browser_used = this;
+ params->target = this;
} else {
// We're in an app window or a popup window. Find an existing browser to
// open this URL in, creating one if none exists.
- Browser* b = BrowserList::FindBrowserWithFeature(profile_,
- FEATURE_TABSTRIP);
- if (!b)
- b = Browser::Create(profile_);
- contents = b->AddTabWithURL(url, referrer, transition, index, add_types,
- instance, extension_app_id, &b);
- b->window()->Show();
-
- if (browser_used)
- *browser_used = b;
+ Browser* browser =
+ BrowserList::FindBrowserWithFeature(profile_, FEATURE_TABSTRIP);
+ if (!browser)
+ browser = Browser::Create(profile_);
+ contents = browser->AddTabWithURL(params);
+ DCHECK(params->target);
}
return contents;
}
@@ -1049,8 +1046,7 @@ void Browser::ShowSingletonTab(const GURL& url) {
}
// Otherwise, just create a new tab.
- AddTabWithURL(url, GURL(), PageTransition::AUTO_BOOKMARK, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(), NULL);
+ AddSelectedTabWithURL(url, PageTransition::AUTO_BOOKMARK);
}
void Browser::UpdateCommandsForFullscreenMode(bool is_fullscreen) {
@@ -1805,8 +1801,7 @@ void Browser::ShowOptionsTab(const std::string& sub_page) {
}
// No options tab found, so create a new one.
- AddTabWithURL(url, GURL(), PageTransition::AUTO_BOOKMARK, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(), NULL);
+ AddSelectedTabWithURL(url, PageTransition::AUTO_BOOKMARK);
}
void Browser::OpenClearBrowsingDataDialog() {
@@ -1887,8 +1882,7 @@ void Browser::OpenUpdateChromeDialog() {
void Browser::OpenHelpTab() {
GURL help_url = google_util::AppendGoogleLocaleParam(GURL(kHelpContentUrl));
- AddTabWithURL(help_url, GURL(), PageTransition::AUTO_BOOKMARK, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(), NULL);
+ AddSelectedTabWithURL(help_url, PageTransition::AUTO_BOOKMARK);
}
void Browser::OpenThemeGalleryTabAndActivate() {
@@ -2314,12 +2308,13 @@ TabContents* Browser::AddBlankTabAt(int index, bool foreground) {
// TabContents, but we want to include the time it takes to create the
// TabContents object too.
base::TimeTicks new_tab_start_time = base::TimeTicks::Now();
- TabContents* tab_contents = AddTabWithURL(
- GURL(chrome::kChromeUINewTabURL), GURL(), PageTransition::TYPED, index,
- foreground ? TabStripModel::ADD_SELECTED : TabStripModel::ADD_NONE, NULL,
- std::string(), NULL);
- tab_contents->set_new_tab_start_time(new_tab_start_time);
- return tab_contents;
+ AddTabWithURLParams params(GURL(chrome::kChromeUINewTabURL),
+ PageTransition::TYPED);
+ params.add_types =
+ foreground ? TabStripModel::ADD_SELECTED : TabStripModel::ADD_NONE;
+ TabContents* contents = AddTabWithURL(&params);
+ contents->set_new_tab_start_time(new_tab_start_time);
+ return contents;
}
Browser* Browser::CreateNewStripWithContents(TabContents* detached_contents,
@@ -3965,10 +3960,12 @@ void Browser::OpenURLAtIndex(TabContents* source,
return;
} else if (disposition == NEW_WINDOW) {
Browser* browser = Browser::Create(profile_);
- new_contents = browser->AddTabWithURL(
- url, referrer, transition, index,
- TabStripModel::ADD_SELECTED | add_types, instance, std::string(),
- &browser);
+ AddTabWithURLParams params(url, transition);
+ params.referrer = referrer;
+ params.index = index;
+ params.add_types = TabStripModel::ADD_SELECTED | add_types;
+ params.instance = instance;
+ new_contents = browser->AddTabWithURL(&params);
browser->window()->Show();
} else if ((disposition == CURRENT_TAB) && current_tab) {
tab_handler_->GetTabStripModel()->TabNavigating(current_tab, transition);
@@ -4002,8 +3999,12 @@ void Browser::OpenURLAtIndex(TabContents* source,
} else if (disposition != SUPPRESS_OPEN) {
if (disposition != NEW_BACKGROUND_TAB)
add_types |= TabStripModel::ADD_SELECTED;
- new_contents = AddTabWithURL(url, referrer, transition, index, add_types,
- instance, std::string(), NULL);
+ AddTabWithURLParams params(url, transition);
+ params.referrer = referrer;
+ params.index = index;
+ params.add_types = add_types;
+ params.instance = instance;
+ new_contents = AddTabWithURL(&params);
}
if (disposition != NEW_BACKGROUND_TAB && source_tab_was_frontmost &&
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 9b29b87..59049c5 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -122,6 +122,8 @@ class Browser : public TabHandlerDelegate,
// Creates a new browser of the given |type| and for the given |profile|. The
// Browser has a NULL window after its construction, CreateBrowserWindow must
// be called after configuration for window() to be valid.
+ // Avoid using this constructor directly if you can use one of the Create*()
+ // methods below. This applies to almost all non-testing code.
Browser(Type type, Profile* profile);
virtual ~Browser();
@@ -235,29 +237,19 @@ class Browser : public TabHandlerDelegate,
// app panel window, otherwise it will be opened as as either
// Browser::Type::APP a.k.a. "thin frame" (if |extension| is NULL) or
// Browser::Type::EXTENSION_APP (if |extension| is non-NULL).
- // Returns the browser hosting for the TabContents via optional parameter,
- // |browser|.
static TabContents* OpenApplicationWindow(
Profile* profile,
Extension* extension,
extension_misc::LaunchContainer container,
- const GURL& url,
- Browser** browser);
+ const GURL& url);
// Open an application for |extension| in a new application window or panel.
- // Returns the browser hosting the TabContents via optional parameter,
- // |browser|.
- static TabContents* OpenApplicationWindow(Profile* profile,
- GURL& url,
- Browser** browser);
+ static TabContents* OpenApplicationWindow(Profile* profile, GURL& url);
// Open an application for |extension| in a new application tab. Returns
// NULL if there are no appropriate existing browser windows for |profile|.
- // Returns the browser hosting the TabContents via optional parameter,
- // |browser|.
static TabContents* OpenApplicationTab(Profile* profile,
- Extension* extension,
- Browser** browser);
+ Extension* extension);
// Opens a new window and opens the bookmark manager.
static void OpenBookmarkManagerWindow(Profile* profile);
@@ -337,21 +329,44 @@ class Browser : public TabHandlerDelegate,
// command line this is invoked three times with the values 0, 1 and 2.
int GetIndexForInsertionDuringRestore(int relative_index);
- // Adds a new tab at the specified index. |add_types| is a bitmask of the
- // values defined by TabStripModel::AddTabTypes; see it for details. If
- // |instance| is not null, its process will be used to render the tab. If
- // |extension_app_id| is non-empty the new tab is an app tab.
- // The returned tab may be hosted in a different browser. |browser_used|
- // will be assigned the browser that satisfied the add tab request.
- // |browser_used| may be passed
- TabContents* AddTabWithURL(const GURL& url,
- const GURL& referrer,
- PageTransition::Type transition,
- int index,
- int add_types,
- SiteInstance* instance,
- const std::string& extension_app_id,
- Browser** browser_used);
+ // Adds a selected tab with the specified URL and transition, returns the
+ // created TabContents.
+ TabContents* AddSelectedTabWithURL(const GURL& url,
+ PageTransition::Type transition);
+
+ // Parameters for AddTabWithURL.
+ struct AddTabWithURLParams {
+ AddTabWithURLParams(const GURL& a_url, PageTransition::Type a_transition);
+ ~AddTabWithURLParams();
+
+ // Basic configuration.
+ GURL url;
+ GURL referrer;
+ PageTransition::Type transition;
+
+ // The index to open the tab at. This could be ignored by the tabstrip
+ // depending on the combination of |add_types| specified.
+ int index;
+
+ // A bitmask of values defined in TabStripModel::AddTabTypes.
+ // The default is ADD_SELECTED.
+ int add_types;
+
+ // If non-NULL, used to render the tab.
+ SiteInstance* instance;
+
+ // If non-empty, the new tab is an app tab.
+ std::string extension_app_id;
+
+ // The browser where the tab was added.
+ Browser* target;
+
+ private:
+ AddTabWithURLParams();
+ };
+
+ // Adds a tab to the browser (or another) and returns the created TabContents.
+ TabContents* AddTabWithURL(AddTabWithURLParams* params);
// Add a new tab, given a TabContents. A TabContents appropriate to
// display the last committed entry is created and returned.
diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc
index 572355a..ecf2692 100644
--- a/chrome/browser/browser_browsertest.cc
+++ b/chrome/browser/browser_browsertest.cc
@@ -204,11 +204,10 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_JavascriptAlertActivatesTab) {
GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
FilePath(kTitle1File)));
ui_test_utils::NavigateToURL(browser(), url);
- Browser* browser_used = NULL;
- browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, 0,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- &browser_used);
- EXPECT_EQ(browser(), browser_used);
+ Browser::AddTabWithURLParams params(url, PageTransition::TYPED);
+ params.index = 0;
+ browser()->AddTabWithURL(&params);
+ EXPECT_EQ(browser(), params.target);
EXPECT_EQ(2, browser()->tab_count());
EXPECT_EQ(0, browser()->selected_index());
TabContents* second_tab = browser()->GetTabContentsAt(1);
@@ -233,11 +232,10 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, ThirtyFourTabs) {
// There is one initial tab.
for (int ix = 0; ix != 33; ++ix) {
- Browser* browser_used = NULL;
- browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, 0,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- &browser_used);
- EXPECT_EQ(browser(), browser_used);
+ Browser::AddTabWithURLParams params(url, PageTransition::TYPED);
+ params.index = 0;
+ browser()->AddTabWithURL(&params);
+ EXPECT_EQ(browser(), params.target);
}
EXPECT_EQ(34, browser()->tab_count());
@@ -606,11 +604,9 @@ IN_PROC_BROWSER_TEST_F(BrowserTest2, NoTabsInPopups) {
EXPECT_EQ(1, popup_browser->tab_count());
// Now try opening another tab in the popup browser.
- Browser* browser_used = NULL;
- popup_browser->AddTabWithURL(
- GURL(chrome::kAboutBlankURL), GURL(), PageTransition::TYPED, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(), &browser_used);
- EXPECT_EQ(popup_browser, browser_used);
+ AddTabWithURLParams params1(url, PageTransition::TYPED);
+ popup_browser->AddTabWithURL(&params1);
+ EXPECT_EQ(popup_browser, params1.target);
// The popup should still only have one tab.
EXPECT_EQ(1, popup_browser->tab_count());
@@ -625,10 +621,10 @@ IN_PROC_BROWSER_TEST_F(BrowserTest2, NoTabsInPopups) {
EXPECT_EQ(1, app_browser->tab_count());
// Now try opening another tab in the app browser.
- app_browser->AddTabWithURL(
- GURL(chrome::kAboutBlankURL), GURL(), PageTransition::TYPED, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(), &browser_used);
- EXPECT_EQ(app_browser, browser_used);
+ AddTabWithURLParams params2(GURL(chrome::kAboutBlankURL),
+ PageTransition::TYPED);
+ app_browser->AddTabWithURL(&params2);
+ EXPECT_EQ(app_browser, params2.target);
// The popup should still only have one tab.
EXPECT_EQ(1, app_browser->tab_count());
@@ -643,10 +639,10 @@ IN_PROC_BROWSER_TEST_F(BrowserTest2, NoTabsInPopups) {
EXPECT_EQ(1, app_popup_browser->tab_count());
// Now try opening another tab in the app popup browser.
- app_popup_browser->AddTabWithURL(
- GURL(chrome::kAboutBlankURL), GURL(), PageTransition::TYPED, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(), &browser_used);
- EXPECT_EQ(app_popup_browser, browser_used);
+ AddTabWithURLParams params3(GURL(chrome::kAboutBlankURL),
+ PageTransition::TYPED);
+ app_popup_browser->AddTabWithURL(&params3);
+ EXPECT_EQ(app_popup_browser, params3.target);
// The popup should still only have one tab.
EXPECT_EQ(1, app_popup_browser->tab_count());
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index 90a3b19..43b18ec 100644
--- a/chrome/browser/browser_focus_uitest.cc
+++ b/chrome/browser/browser_focus_uitest.cc
@@ -20,6 +20,7 @@
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/view_ids.h"
#include "chrome/common/chrome_paths.h"
+#include "chrome/common/url_constants.h"
#include "chrome/test/in_process_browser_test.h"
#include "chrome/test/ui_test_utils.h"
#include "net/test/test_server.h"
@@ -217,11 +218,9 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabsRememberFocus) {
// Create several tabs.
for (int i = 0; i < 4; ++i) {
- Browser* browser_used = NULL;
- browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- &browser_used);
- EXPECT_EQ(browser(), browser_used);
+ Browser::AddTabWithURLParams params(url, PageTransition::TYPED);
+ browser()->AddTabWithURL(&params);
+ EXPECT_EQ(browser(), params.target);
}
// Alternate focus for the tab.
@@ -297,11 +296,9 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_TabsRememberFocusFindInPage) {
browser()->FocusLocationBar();
// Create a 2nd tab.
- Browser* browser_used = NULL;
- browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- &browser_used);
- EXPECT_EQ(browser(), browser_used);
+ Browser::AddTabWithURLParams params(url, PageTransition::TYPED);
+ browser()->AddTabWithURL(&params);
+ EXPECT_EQ(browser(), params.target);
// Focus should be on the recently opened tab page.
ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
@@ -733,10 +730,8 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FLAKY_TabInitialFocus) {
ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
// Open about:blank, focus should be on the location bar.
- browser()->AddTabWithURL(GURL("about:blank"), GURL(), PageTransition::LINK,
- -1, TabStripModel::ADD_SELECTED, NULL,
- std::string(),
- NULL);
+ browser()->AddSelectedTabWithURL(GURL(chrome::kAboutBlankURL),
+ PageTransition::LINK);
ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
}
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 3e7e440..9f8b171 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -613,7 +613,7 @@ bool BrowserInit::LaunchWithProfile::OpenApplicationWindow(Profile* profile) {
ChildProcessSecurityPolicy::GetInstance();
if (policy->IsWebSafeScheme(url.scheme()) ||
url.SchemeIs(chrome::kFileScheme)) {
- Browser::OpenApplicationWindow(profile, url, NULL);
+ Browser::OpenApplicationWindow(profile, url);
return true;
}
}
@@ -757,9 +757,12 @@ Browser* BrowserInit::LaunchWithProfile::OpenTabsInBrowser(
add_types |= TabStripModel::ADD_PINNED;
int index = browser->GetIndexForInsertionDuringRestore(i);
- TabContents* tab = browser->AddTabWithURL(
- tabs[i].url, GURL(), PageTransition::START_PAGE, index, add_types, NULL,
- tabs[i].app_id, NULL);
+ Browser::AddTabWithURLParams params(tabs[i].url,
+ PageTransition::START_PAGE);
+ params.index = index;
+ params.add_types = add_types;
+ params.extension_app_id = tabs[i].app_id;
+ TabContents* tab = browser->AddTabWithURL(&params);
if (profile_ && first_tab && process_startup) {
AddCrashedInfoBarIfNecessary(tab);
diff --git a/chrome/browser/chromeos/tab_closeable_state_watcher_browsertest.cc b/chrome/browser/chromeos/tab_closeable_state_watcher_browsertest.cc
index ea49119..211c3bdb 100644
--- a/chrome/browser/chromeos/tab_closeable_state_watcher_browsertest.cc
+++ b/chrome/browser/chromeos/tab_closeable_state_watcher_browsertest.cc
@@ -37,9 +37,9 @@ class TabCloseableStateWatcherTest : public InProcessBrowserTest {
protected:
// Wrapper for Browser::AddTabWithURL
void AddTabWithURL(Browser* browser, const GURL& url) {
- browser->AddTabWithURL(url, GURL(), PageTransition::TYPED, 0,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- &browser);
+ Browser::AddTabWithURLParams params(url, PageTransition::TYPED);
+ params.index = 0;
+ browser->AddTabWithURL(&params);
// Wait for page to finish loading.
ui_test_utils::WaitForNavigation(
&browser->GetSelectedTabContents()->controller());
diff --git a/chrome/browser/cocoa/applescript/window_applescript.mm b/chrome/browser/cocoa/applescript/window_applescript.mm
index 624f9be..c51e9d8 100644
--- a/chrome/browser/cocoa/applescript/window_applescript.mm
+++ b/chrome/browser/cocoa/applescript/window_applescript.mm
@@ -169,18 +169,12 @@
// Set how long it takes a tab to be created.
base::TimeTicks newTabStartTime = base::TimeTicks::Now();
- TabContents* tabContents = browser_->AddTabWithURL(
- GURL(chrome::kChromeUINewTabURL),
- GURL(),
- PageTransition::TYPED,
- -1, // To indicate tab is inserted at end.
- TabStripModel::ADD_SELECTED,
- NULL,
- std::string(),
- NULL);
- tabContents->set_new_tab_start_time(newTabStartTime);
+ TabContents* contents =
+ browser_->AddSelectedTabWithURL(GURL(chrome::kChromeUINewTabURL),
+ PageTransition::TYPED);
+ contents->set_new_tab_start_time(newTabStartTime);
- [aTab setTabContent:tabContents];
+ [aTab setTabContent:contents];
}
- (void)insertInTabs:(TabAppleScript*)aTab atIndex:(int)index {
@@ -191,18 +185,13 @@
// Set how long it takes a tab to be created.
base::TimeTicks newTabStartTime = base::TimeTicks::Now();
- TabContents* tabContents = browser_->AddTabWithURL(
- GURL(chrome::kChromeUINewTabURL),
- GURL(),
- PageTransition::TYPED,
- index,
- TabStripModel::ADD_SELECTED,
- NULL,
- std::string(),
- NULL);
- tabContents->set_new_tab_start_time(newTabStartTime);
-
- [aTab setTabContent:tabContents];
+ Browser::AddTabWithURLParams params(GURL(chrome::kChromeUINewTabURL),
+ PageTransition::TYPED);
+ params.index = index;
+ TabContents* contents = browser_->AddTabWithURL(&params);
+ contents->set_new_tab_start_time(newTabStartTime);
+
+ [aTab setTabContent:contents];
}
- (void)removeFromTabsAtIndex:(int)index {
diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm
index 3c0e819..148071e 100644
--- a/chrome/browser/cocoa/tab_strip_controller.mm
+++ b/chrome/browser/cocoa/tab_strip_controller.mm
@@ -1676,14 +1676,16 @@ private:
// Either insert a new tab or open in a current tab.
switch (disposition) {
- case NEW_FOREGROUND_TAB:
+ case NEW_FOREGROUND_TAB: {
UserMetrics::RecordAction(UserMetricsAction("Tab_DropURLBetweenTabs"),
browser_->profile());
- browser_->AddTabWithURL(url, GURL(), PageTransition::TYPED, index,
- TabStripModel::ADD_SELECTED |
- TabStripModel::ADD_FORCE_INDEX,
- NULL, std::string(), NULL);
+ Browser::AddTabWithURLParams params(url, PageTransition::TYPED);
+ params.index = index;
+ params.add_types =
+ TabStripModel::ADD_SELECTED | TabStripModel::ADD_FORCE_INDEX;
+ browser_->AddTabWithURL(&params);
break;
+ }
case CURRENT_TAB:
UserMetrics::RecordAction(UserMetricsAction("Tab_DropURLOnTab"),
browser_->profile());
diff --git a/chrome/browser/dom_ui/filebrowse_ui.cc b/chrome/browser/dom_ui/filebrowse_ui.cc
index 4d93086..c8fb9ce 100644
--- a/chrome/browser/dom_ui/filebrowse_ui.cc
+++ b/chrome/browser/dom_ui/filebrowse_ui.cc
@@ -696,15 +696,14 @@ void FilebrowseHandler::OpenNewWindow(const ListValue* args, bool popup) {
Browser* browser = popup ?
Browser::CreateForType(Browser::TYPE_APP_PANEL, profile_) :
BrowserList::GetLastActive();
- browser->AddTabWithURL(GURL(url), GURL(), PageTransition::LINK, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- &browser);
+ Browser::AddTabWithURLParams params(GURL(url), PageTransition::LINK);
+ browser->AddTabWithURL(&params);
if (popup) {
// TODO(dhg): Remove these from being hardcoded. Allow javascript
// to specify.
- browser->window()->SetBounds(gfx::Rect(0, 0, 400, 300));
+ params.target->window()->SetBounds(gfx::Rect(0, 0, 400, 300));
}
- browser->window()->Show();
+ params.target->window()->Show();
}
void FilebrowseHandler::SendPicasawebRequest() {
@@ -1062,16 +1061,14 @@ Browser* FileBrowseUI::OpenPopup(Profile* profile,
url.append(hashArgument);
}
- browser->AddTabWithURL(
- GURL(url), GURL(), PageTransition::LINK, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- &browser);
- browser->window()->SetBounds(gfx::Rect(kPopupLeft,
- kPopupTop,
- width,
- height));
+ Browser::AddTabWithURLParams params(GURL(url), PageTransition::LINK);
+ browser->AddTabWithURL(&params);
+ params.target->window()->SetBounds(gfx::Rect(kPopupLeft,
+ kPopupTop,
+ width,
+ height));
- browser->window()->Show();
+ params.target->window()->Show();
} else {
browser->window()->Show();
}
diff --git a/chrome/browser/dom_ui/html_dialog_tab_contents_delegate.cc b/chrome/browser/dom_ui/html_dialog_tab_contents_delegate.cc
index 0230f88..1c9c5bb 100644
--- a/chrome/browser/dom_ui/html_dialog_tab_contents_delegate.cc
+++ b/chrome/browser/dom_ui/html_dialog_tab_contents_delegate.cc
@@ -41,13 +41,10 @@ void HtmlDialogTabContentsDelegate::OpenURLFromTab(
// open it in the current frame. Code adapted from
// Browser::OpenURLFromTab() with disposition == NEW_WINDOW.
Browser* browser = CreateBrowser();
- TabContents* new_contents =
- browser->AddTabWithURL(url, referrer, transition, -1,
- TabStripModel::ADD_SELECTED, NULL,
- std::string(), &browser);
- DCHECK(new_contents);
+ Browser::AddTabWithURLParams params(url, transition);
+ params.referrer = referrer;
+ browser->AddTabWithURL(&params);
browser->window()->Show();
- new_contents->Focus();
}
}
diff --git a/chrome/browser/dom_ui/mediaplayer_ui.cc b/chrome/browser/dom_ui/mediaplayer_ui.cc
index e545da0..61631a2 100644
--- a/chrome/browser/dom_ui/mediaplayer_ui.cc
+++ b/chrome/browser/dom_ui/mediaplayer_ui.cc
@@ -498,10 +498,8 @@ void MediaPlayer::PopupPlaylist(Browser* creator) {
Profile* profile = BrowserList::GetLastActive()->profile();
playlist_browser_ = Browser::CreateForType(Browser::TYPE_APP_PANEL,
profile);
- playlist_browser_->AddTabWithURL(
- GURL(kMediaplayerPlaylistURL), GURL(), PageTransition::LINK,
- -1, TabStripModel::ADD_SELECTED, NULL, std::string(),
- &playlist_browser_);
+ playlist_browser_->AddSelectedTabWithURL(GURL(kMediaplayerPlaylistURL),
+ PageTransition::LINK);
playlist_browser_->window()->SetBounds(gfx::Rect(kPopupLeft,
kPopupTop,
kPopupWidth,
@@ -532,10 +530,8 @@ void MediaPlayer::PopupMediaPlayer(Browser* creator) {
view->SetCreatorView(creatorview);
}
#endif
- mediaplayer_browser_->AddTabWithURL(
- GURL(kMediaplayerURL), GURL(), PageTransition::LINK,
- -1, TabStripModel::ADD_SELECTED, NULL, std::string(),
- &mediaplayer_browser_);
+ mediaplayer_browser_->AddSelectedTabWithURL(GURL(kMediaplayerURL),
+ PageTransition::LINK);
mediaplayer_browser_->window()->SetBounds(gfx::Rect(kPopupLeft,
kPopupTop,
kPopupWidth,
diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc
index 857b4e8..b6ef578 100644
--- a/chrome/browser/extensions/extension_install_ui.cc
+++ b/chrome/browser/extensions/extension_install_ui.cc
@@ -148,9 +148,7 @@ void ExtensionInstallUI::OnInstallSuccess(Extension* extension) {
std::string url(chrome::kChromeUINewTabURL);
url += "/#";
url += hash_params;
- browser->AddTabWithURL(GURL(url), GURL(), PageTransition::TYPED, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- NULL);
+ browser->AddSelectedTabWithURL(GURL(url), PageTransition::TYPED);
}
return;
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
index 8e04e19..a81de9d 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -384,11 +384,8 @@ bool CreateWindowFunction::RunImpl() {
}
}
- Browser* new_window = new Browser(window_type, window_profile);
- new_window->CreateBrowserWindow();
- new_window->AddTabWithURL(url, GURL(), PageTransition::LINK, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- &new_window);
+ Browser* new_window = Browser::CreateForType(window_type, window_profile);
+ new_window->AddSelectedTabWithURL(url, PageTransition::LINK);
if (window_type & Browser::TYPE_POPUP)
new_window->window()->SetBounds(popup_bounds);
else
@@ -597,8 +594,10 @@ bool CreateTabFunction::RunImpl() {
int add_types = selected ? TabStripModel::ADD_SELECTED :
TabStripModel::ADD_NONE;
add_types |= TabStripModel::ADD_FORCE_INDEX;
- TabContents* contents = browser->AddTabWithURL(url, GURL(),
- PageTransition::LINK, index, add_types, NULL, std::string(), &browser);
+ Browser::AddTabWithURLParams params(url, PageTransition::LINK);
+ params.index = index;
+ params.add_types = add_types;
+ TabContents* contents = browser->AddTabWithURL(&params);
index = browser->tabstrip_model()->GetIndexOfTabContents(contents);
if (selected)
diff --git a/chrome/browser/find_bar_host_browsertest.cc b/chrome/browser/find_bar_host_browsertest.cc
index 22a1c26..62bae77 100644
--- a/chrome/browser/find_bar_host_browsertest.cc
+++ b/chrome/browser/find_bar_host_browsertest.cc
@@ -823,11 +823,9 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PreferPreviousSearch) {
EXPECT_EQ(1, FindInPageWchar(tab1, L"Default", kFwd, kIgnoreCase, &ordinal));
// Create a second tab.
- Browser* browser_used = NULL;
- browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- &browser_used);
- EXPECT_EQ(browser(), browser_used);
+ Browser::AddTabWithURLParams params(url, PageTransition::TYPED);
+ browser()->AddTabWithURL(&params);
+ EXPECT_EQ(browser(), params.target);
browser()->SelectTabContentsAt(1, false);
TabContents* tab2 = browser()->GetSelectedTabContents();
EXPECT_NE(tab1, tab2);
@@ -901,11 +899,9 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulateInNewTab) {
EXPECT_EQ(1, FindInPageWchar(tab1, L"page", kFwd, kIgnoreCase, &ordinal));
// Now create a second tab and load the same page.
- Browser* browser_used = NULL;
- browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- &browser_used);
- EXPECT_EQ(browser(), browser_used);
+ Browser::AddTabWithURLParams params(url, PageTransition::TYPED);
+ browser()->AddTabWithURL(&params);
+ EXPECT_EQ(browser(), params.target);
browser()->SelectTabContentsAt(1, false);
TabContents* tab2 = browser()->GetSelectedTabContents();
EXPECT_NE(tab1, tab2);
@@ -948,11 +944,9 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulatePreserveLast) {
FindBarController::kKeepSelection);
// Now create a second tab and load the same page.
- Browser* browser_used = NULL;
- browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- &browser_used);
- EXPECT_EQ(browser(), browser_used);
+ Browser::AddTabWithURLParams params(url, PageTransition::TYPED);
+ browser()->AddTabWithURL(&params);
+ EXPECT_EQ(browser(), params.target);
browser()->SelectTabContentsAt(1, false);
TabContents* tab2 = browser()->GetSelectedTabContents();
EXPECT_NE(tab1, tab2);
@@ -1024,11 +1018,9 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_NoIncognitoPrepopulate) {
// Open a new incognito window and navigate to the same page.
Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile();
Browser* incognito_browser = Browser::Create(incognito_profile);
- Browser* browser_used = NULL;
- incognito_browser->AddTabWithURL(url, GURL(), PageTransition::START_PAGE, -1,
- TabStripModel::ADD_SELECTED, NULL,
- std::string(), &browser_used);
- EXPECT_EQ(incognito_browser, browser_used);
+ Browser::AddTabWithURLParams params1(url, PageTransition::START_PAGE);
+ incognito_browser->AddTabWithURL(&params1);
+ EXPECT_EQ(incognito_browser, params1.target);
ui_test_utils::WaitForNavigation(
&incognito_browser->GetSelectedTabContents()->controller());
incognito_browser->window()->Show();
@@ -1048,10 +1040,9 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_NoIncognitoPrepopulate) {
FindBarController::kKeepSelection);
// Now open a new tab in the original (non-incognito) browser.
- browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- &browser_used);
- EXPECT_EQ(browser(), browser_used);
+ Browser::AddTabWithURLParams params2(url, PageTransition::TYPED);
+ browser()->AddTabWithURL(&params2);
+ EXPECT_EQ(browser(), params2.target);
browser()->SelectTabContentsAt(1, false);
TabContents* tab2 = browser()->GetSelectedTabContents();
EXPECT_NE(tab1, tab2);
diff --git a/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc b/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc
index 46d38c8..f3bffa2 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc
+++ b/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc
@@ -35,12 +35,10 @@ IN_PROC_BROWSER_TEST_F(BookmarkBarGtkBrowserTest, FindBarTest) {
browser()->Find();
// Create new tab with an arbitrary URL.
- Browser* browser_used = NULL;
GURL url = test_server()->GetURL(kSimplePage);
- browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- &browser_used);
- EXPECT_EQ(browser(), browser_used);
+ Browser::AddTabWithURLParams params(url, PageTransition::TYPED);
+ browser()->AddTabWithURL(&params);
+ EXPECT_EQ(browser(), params.target);
// Switch back to the NTP with the active findbar.
browser()->SelectTabContentsAt(1, false);
diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc
index 2ca7425..88f4491 100644
--- a/chrome/browser/importer/importer.cc
+++ b/chrome/browser/importer/importer.cc
@@ -200,12 +200,12 @@ void ImporterHost::StartImportSettings(
MB_OK | MB_TOPMOST);
GURL url("https://www.google.com/accounts/ServiceLogin");
- BrowsingInstance* instance = new BrowsingInstance(writer_->profile());
- SiteInstance* site = instance->GetSiteInstanceForURL(url);
Browser* browser = BrowserList::GetLastActive();
- browser->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1,
- TabStripModel::ADD_SELECTED, site, std::string(),
- NULL);
+ Browser::AddTabWithURLParams params(url, PageTransition::TYPED);
+ // BrowsingInstance is refcounted.
+ BrowsingInstance* instance = new BrowsingInstance(writer_->profile());
+ params.instance = instance->GetSiteInstanceForURL(url);
+ browser->AddTabWithURL(&params);
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
this, &ImporterHost::OnLockViewEnd, false));
diff --git a/chrome/browser/platform_util_chromeos.cc b/chrome/browser/platform_util_chromeos.cc
index 2d70ef3..229563b 100644
--- a/chrome/browser/platform_util_chromeos.cc
+++ b/chrome/browser/platform_util_chromeos.cc
@@ -79,9 +79,7 @@ void OpenItem(const FilePath& full_path) {
return;
}
Browser* browser = BrowserList::GetLastActive();
- browser->AddTabWithURL(
- GURL(path), GURL(), PageTransition::LINK, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(), NULL);
+ browser->AddSelectedTabWithURL(GURL(path), PageTransition::LINK);
return;
}
if (ext == ".avi" ||
@@ -112,9 +110,7 @@ void OpenItem(const FilePath& full_path) {
static void OpenURL(const std::string& url) {
Browser* browser = BrowserList::GetLastActive();
- browser->AddTabWithURL(
- GURL(url), GURL(), PageTransition::LINK, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(), NULL);
+ browser->AddSelectedTabWithURL(GURL(url), PageTransition::LINK);
}
void OpenExternal(const GURL& url) {
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc
index e0b49cd..46047a6 100644
--- a/chrome/browser/sessions/session_restore.cc
+++ b/chrome/browser/sessions/session_restore.cc
@@ -551,8 +551,10 @@ class SessionRestoreImpl : public NotificationObserver {
if (i == 0)
add_types |= TabStripModel::ADD_SELECTED;
int index = browser->GetIndexForInsertionDuringRestore(i);
- browser->AddTabWithURL(urls[i], GURL(), PageTransition::START_PAGE, index,
- add_types, NULL, std::string(), NULL);
+ Browser::AddTabWithURLParams params(urls[i], PageTransition::START_PAGE);
+ params.index = index;
+ params.add_types = add_types;
+ browser->AddTabWithURL(&params);
}
}
diff --git a/chrome/browser/sessions/session_restore_browsertest.cc b/chrome/browser/sessions/session_restore_browsertest.cc
index 19cf744..8bc0c2d 100644
--- a/chrome/browser/sessions/session_restore_browsertest.cc
+++ b/chrome/browser/sessions/session_restore_browsertest.cc
@@ -76,18 +76,15 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreIndividualTabFromWindow) {
FilePath(FILE_PATH_LITERAL("title3.html"))));
// Add and navigate three tabs.
- Browser* browser_used = NULL;
ui_test_utils::NavigateToURL(browser(), url1);
- browser()->AddTabWithURL(url2, GURL(), PageTransition::LINK, 1,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- &browser_used);
- EXPECT_EQ(browser(), browser_used);
+ Browser::AddTabWithURLParams params1(url2, PageTransition::LINK);
+ browser()->AddTabWithURL(&params1);
+ EXPECT_EQ(browser(), params1.target);
ui_test_utils::WaitForNavigationInCurrentTab(browser());
- browser()->AddTabWithURL(url3, GURL(), PageTransition::LINK, 2,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- &browser_used);
- EXPECT_EQ(browser(), browser_used);
+ Browser::AddTabWithURLParams params2(url3, PageTransition::LINK);
+ browser()->AddTabWithURL(&params2);
+ EXPECT_EQ(browser(), params2.target);
ui_test_utils::WaitForNavigationInCurrentTab(browser());
TabRestoreService* service = browser()->profile()->GetTabRestoreService();
diff --git a/chrome/browser/ssl/ssl_browser_tests.cc b/chrome/browser/ssl/ssl_browser_tests.cc
index a897e1b..aad8854 100644
--- a/chrome/browser/ssl/ssl_browser_tests.cc
+++ b/chrome/browser/ssl/ssl_browser_tests.cc
@@ -329,9 +329,8 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSErrorWithNoNavEntry) {
ASSERT_TRUE(https_server_expired_.Start());
GURL url = https_server_expired_.GetURL("files/ssl/google.htm");
- TabContents* tab2 = browser()->AddTabWithURL(
- url, GURL(), PageTransition::TYPED, -1, TabStripModel::ADD_SELECTED, NULL,
- std::string(), NULL);
+ TabContents* tab2 =
+ browser()->AddSelectedTabWithURL(url, PageTransition::TYPED);
ui_test_utils::WaitForLoadStop(&(tab2->controller()));
// Verify our assumption that there was no prior navigation.
@@ -450,9 +449,10 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysInsecureContentTwoTabs) {
// Create a new tab.
GURL url = https_server_.GetURL(
"files/ssl/page_displays_insecure_content.html");
- TabContents* tab2 = browser()->AddTabWithURL(url, GURL(),
- PageTransition::TYPED, 0, TabStripModel::ADD_SELECTED,
- tab1->GetSiteInstance(), std::string(), NULL);
+ Browser::AddTabWithURLParams params(url, PageTransition::TYPED);
+ params.index = 0;
+ params.instance = tab1->GetSiteInstance();
+ TabContents* tab2 = browser()->AddTabWithURL(&params);
ui_test_utils::WaitForNavigation(&(tab2->controller()));
// The new tab has insecure content.
@@ -480,9 +480,9 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestRunsInsecureContentTwoTabs) {
// Create a new tab.
GURL url =
https_server_.GetURL("files/ssl/page_runs_insecure_content.html");
- TabContents* tab2 = browser()->AddTabWithURL(url, GURL(),
- PageTransition::TYPED, 0, TabStripModel::ADD_SELECTED,
- tab1->GetSiteInstance(), std::string(), NULL);
+ Browser::AddTabWithURLParams params(url, PageTransition::TYPED);
+ params.instance = tab1->GetSiteInstance();
+ TabContents* tab2 = browser()->AddTabWithURL(&params);
ui_test_utils::WaitForNavigation(&(tab2->controller()));
// The new tab has insecure content.
@@ -623,15 +623,13 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestCloseTabWithUnsafePopup) {
// Let's add another tab to make sure the browser does not exit when we close
// the first tab.
- Browser* browser_used = NULL;
GURL url = test_server()->GetURL("files/ssl/google.html");
- TabContents* tab2 = browser()->AddTabWithURL(
- url, GURL(), PageTransition::TYPED, 0, TabStripModel::ADD_SELECTED, NULL,
- std::string(), &browser_used);
+ Browser::AddTabWithURLParams params(url, PageTransition::TYPED);
+ TabContents* tab2 = browser()->AddTabWithURL(&params);
ui_test_utils::WaitForNavigation(&(tab2->controller()));
// Ensure that the tab was created in the correct browser.
- EXPECT_EQ(browser(), browser_used);
+ EXPECT_EQ(browser(), params.target);
// Close the first tab.
browser()->CloseTabContents(tab1);
diff --git a/chrome/browser/task_manager/task_manager_browsertest.cc b/chrome/browser/task_manager/task_manager_browsertest.cc
index bce58f6..6544f2f 100644
--- a/chrome/browser/task_manager/task_manager_browsertest.cc
+++ b/chrome/browser/task_manager/task_manager_browsertest.cc
@@ -102,11 +102,10 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeTabContentsChanges) {
// Open a new tab and make sure we notice that.
GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
FilePath(kTitle1File)));
- Browser* browser_used = NULL;
- browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, 0,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- &browser_used);
- EXPECT_EQ(browser(), browser_used);
+ Browser::AddTabWithURLParams params(url, PageTransition::TYPED);
+ params.index = 0;
+ browser()->AddTabWithURL(&params);
+ EXPECT_EQ(browser(), params.target);
WaitForResourceChange(3);
// Close the tab and verify that we notice.
@@ -250,9 +249,9 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest,
// Open a new tab and make sure we notice that.
GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
FilePath(kTitle1File)));
- browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, 0,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- NULL);
+ Browser::AddTabWithURLParams params(url, PageTransition::TYPED);
+ params.index = 0;
+ browser()->AddTabWithURL(&params);
WaitForResourceChange(3);
// Check that we get some value for the cache columns.
diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc
index 1c70dd4..8c43916 100644
--- a/chrome/browser/translate/translate_manager.cc
+++ b/chrome/browser/translate/translate_manager.cc
@@ -479,10 +479,8 @@ void TranslateManager::ReportLanguageDetectionError(TabContents* tab_contents) {
NOTREACHED();
return;
}
- browser->AddTabWithURL(GURL(report_error_url), GURL(),
- PageTransition::AUTO_BOOKMARK, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- NULL);
+ browser->AddSelectedTabWithURL(GURL(report_error_url),
+ PageTransition::AUTO_BOOKMARK);
}
void TranslateManager::DoTranslatePage(TabContents* tab,
diff --git a/chrome/browser/views/app_launcher.cc b/chrome/browser/views/app_launcher.cc
index c011d87..6c5a635 100644
--- a/chrome/browser/views/app_launcher.cc
+++ b/chrome/browser/views/app_launcher.cc
@@ -363,10 +363,7 @@ void AppLauncher::InfoBubbleClosing(InfoBubble* info_bubble,
void AppLauncher::AddTabWithURL(const GURL& url,
PageTransition::Type transition) {
- browser_->AddTabWithURL(
- url, GURL(), transition, -1,
- TabStripModel::ADD_SELECTED | TabStripModel::ADD_FORCE_INDEX, NULL,
- std::string(), NULL);
+ browser_->AddSelectedTabWithURL(url, transition);
}
void AppLauncher::Resize(const gfx::Size& contents_size) {
diff --git a/chrome/browser/views/find_bar_host_interactive_uitest.cc b/chrome/browser/views/find_bar_host_interactive_uitest.cc
index d0b5e2e..9c2750e 100644
--- a/chrome/browser/views/find_bar_host_interactive_uitest.cc
+++ b/chrome/browser/views/find_bar_host_interactive_uitest.cc
@@ -50,11 +50,9 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) {
browser()->Find();
// Open another tab (tab B).
- Browser* browser_used = NULL;
- browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1,
- TabStripModel::ADD_SELECTED, NULL, std::string(),
- &browser_used);
- EXPECT_EQ(browser(), browser_used);
+ Browser::AddTabWithURLParams params(url, PageTransition::TYPED);
+ browser()->AddTabWithURL(&params);
+ EXPECT_EQ(browser(), params.target);
browser()->Find();
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),