blob: b5e8262cffd2777c6461cfb11b8836db8fb9b595 [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2012 The Chromium Authors
[email protected]5d9cace72012-06-21 16:07:122// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_UI_SINGLETON_TABS_H_
6#define CHROME_BROWSER_UI_SINGLETON_TABS_H_
[email protected]5d9cace72012-06-21 16:07:127
thestige80821242015-09-30 23:46:088#include "chrome/browser/ui/browser_navigator_params.h"
9
[email protected]5d9cace72012-06-21 16:07:1210class Browser;
11class GURL;
12
[email protected]5d9cace72012-06-21 16:07:1213// Methods for opening "singleton tabs". Tabs are guaranteed unique by varying
14// metrics within a particular Browser window.
15
[email protected]5d9cace72012-06-21 16:07:1216// Core singleton tab API:
17
Georg Neisb037e3372023-06-20 01:44:5618// Shows a given a URL. If a tab with the same URL (ignoring the ref) is already
19// visible in this browser, it becomes selected. Otherwise a new tab is created.
[email protected]5d9cace72012-06-21 16:07:1220void ShowSingletonTab(Browser* browser, const GURL& url);
21
Georg Neisb037e3372023-06-20 01:44:5622// Like above, but uses the last active tabbed browser or creates a new one if
23// possible.
24void ShowSingletonTab(Profile* profile, const GURL& url);
25
26// Like ShowSingletonTab, but if the current tab is the new tab page or
[email protected]5d9cace72012-06-21 16:07:1227// about:blank, then overwrite it with the passed contents.
Georg Neisb037e3372023-06-20 01:44:5628void ShowSingletonTabOverwritingNTP(
29 Profile* profile,
30 const GURL& url,
31 NavigateParams::PathBehavior path_behavior = NavigateParams::RESPECT);
32void ShowSingletonTabOverwritingNTP(
33 Browser* browser,
34 const GURL& url,
35 NavigateParams::PathBehavior path_behavior = NavigateParams::RESPECT);
36void ShowSingletonTabOverwritingNTP(NavigateParams* params);
[email protected]5d9cace72012-06-21 16:07:1237
38// Creates a NavigateParams struct for a singleton tab navigation.
[email protected]78e2edc2012-07-01 23:32:2839NavigateParams GetSingletonTabNavigateParams(Browser* browser, const GURL& url);
[email protected]5d9cace72012-06-21 16:07:1240
Kevin Baileyc8f9ef322018-01-05 17:19:5541// If the given navigational URL is already open in |browser|, return
42// the tab and tab index for it. Otherwise, returns -1.
43int GetIndexOfExistingTab(Browser* browser, const NavigateParams& params);
[email protected]5d9cace72012-06-21 16:07:1244
Kevin Bailey29343422019-10-04 00:22:5145// This simply calls GetIndexOfExistingTab() for each browser that
46// matches the passed |profile|, and returns the first found tab.
47std::pair<Browser*, int> GetIndexAndBrowserOfExistingTab(
48 Profile* profile,
49 const NavigateParams& params);
50
[email protected]5d9cace72012-06-21 16:07:1251#endif // CHROME_BROWSER_UI_SINGLETON_TABS_H_