[email protected] | 5d9cace7 | 2012-06-21 16:07:12 | [diff] [blame] | 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 |
| 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] | 5d9cace7 | 2012-06-21 16:07:12 | [diff] [blame] | 7 | |
thestig | e8082124 | 2015-09-30 23:46:08 | [diff] [blame] | 8 | #include "chrome/browser/ui/browser_navigator_params.h" |
| 9 | |
[email protected] | 5d9cace7 | 2012-06-21 16:07:12 | [diff] [blame] | 10 | class Browser; |
| 11 | class GURL; |
| 12 | |
[email protected] | 5d9cace7 | 2012-06-21 16:07:12 | [diff] [blame] | 13 | // Methods for opening "singleton tabs". Tabs are guaranteed unique by varying |
| 14 | // metrics within a particular Browser window. |
| 15 | |
[email protected] | 5d9cace7 | 2012-06-21 16:07:12 | [diff] [blame] | 16 | // Core singleton tab API: |
| 17 | |
| 18 | // Show a given a URL. If a tab with the same URL (ignoring the ref) is |
| 19 | // already visible in this browser, it becomes selected. Otherwise a new tab |
| 20 | // is created. |
| 21 | void ShowSingletonTab(Browser* browser, const GURL& url); |
| 22 | |
| 23 | // Same as ShowSingletonTab, but does not ignore ref. |
| 24 | void ShowSingletonTabRespectRef(Browser* browser, const GURL& url); |
| 25 | |
| 26 | // As ShowSingletonTab, but if the current tab is the new tab page or |
| 27 | // about:blank, then overwrite it with the passed contents. |
erikchen | 38fa402 | 2018-04-26 20:37:52 | [diff] [blame] | 28 | void ShowSingletonTabOverwritingNTP(Browser* browser, NavigateParams params); |
[email protected] | 5d9cace7 | 2012-06-21 16:07:12 | [diff] [blame] | 29 | |
| 30 | // Creates a NavigateParams struct for a singleton tab navigation. |
[email protected] | 78e2edc | 2012-07-01 23:32:28 | [diff] [blame] | 31 | NavigateParams GetSingletonTabNavigateParams(Browser* browser, const GURL& url); |
[email protected] | 5d9cace7 | 2012-06-21 16:07:12 | [diff] [blame] | 32 | |
Kevin Bailey | c8f9ef32 | 2018-01-05 17:19:55 | [diff] [blame] | 33 | // If the given navigational URL is already open in |browser|, return |
| 34 | // the tab and tab index for it. Otherwise, returns -1. |
| 35 | int GetIndexOfExistingTab(Browser* browser, const NavigateParams& params); |
[email protected] | 5d9cace7 | 2012-06-21 16:07:12 | [diff] [blame] | 36 | |
Kevin Bailey | 2934342 | 2019-10-04 00:22:51 | [diff] [blame^] | 37 | // This simply calls GetIndexOfExistingTab() for each browser that |
| 38 | // matches the passed |profile|, and returns the first found tab. |
| 39 | std::pair<Browser*, int> GetIndexAndBrowserOfExistingTab( |
| 40 | Profile* profile, |
| 41 | const NavigateParams& params); |
| 42 | |
[email protected] | 5d9cace7 | 2012-06-21 16:07:12 | [diff] [blame] | 43 | #endif // CHROME_BROWSER_UI_SINGLETON_TABS_H_ |