[email protected] | ac84431b | 2011-09-27 17:26:11 | [diff] [blame] | 1 | // Copyright (c) 2011 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_EXTENSIONS_EXTENSION_TAB_UTIL_H__ |
| 6 | #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H__ |
| 7 | #pragma once |
| 8 | |
| 9 | #include <string> |
| 10 | |
| 11 | class Browser; |
| 12 | class Profile; |
| 13 | class TabContents; |
| 14 | class TabContentsWrapper; |
| 15 | class TabStripModel; |
| 16 | |
| 17 | namespace base { |
| 18 | class DictionaryValue; |
| 19 | class ListValue; |
| 20 | } |
| 21 | |
[email protected] | 26b5e32 | 2011-12-23 01:36:47 | [diff] [blame] | 22 | namespace content { |
| 23 | class WebContents; |
| 24 | } |
| 25 | |
[email protected] | ac84431b | 2011-09-27 17:26:11 | [diff] [blame] | 26 | // Provides various utility functions that help manipulate tabs. |
| 27 | class ExtensionTabUtil { |
| 28 | public: |
| 29 | static int GetWindowId(const Browser* browser); |
[email protected] | 8c3495c | 2011-09-28 03:32:30 | [diff] [blame] | 30 | static int GetWindowIdOfTabStripModel(const TabStripModel* tab_strip_model); |
[email protected] | 26b5e32 | 2011-12-23 01:36:47 | [diff] [blame] | 31 | static int GetTabId(const content::WebContents* web_contents); |
[email protected] | ac84431b | 2011-09-27 17:26:11 | [diff] [blame] | 32 | static bool GetTabIdFromArgument(const base::ListValue &args, |
| 33 | int argument_index, |
| 34 | int *tab_id, std::string* error_message); |
| 35 | static std::string GetTabStatusText(bool is_loading); |
[email protected] | ea049a0 | 2011-12-25 21:37:09 | [diff] [blame^] | 36 | static int GetWindowIdOfTab(const content::WebContents* web_contents); |
[email protected] | 8c3495c | 2011-09-28 03:32:30 | [diff] [blame] | 37 | static std::string GetWindowTypeText(const Browser* browser); |
[email protected] | 541e3ee | 2011-11-22 01:31:10 | [diff] [blame] | 38 | static std::string GetWindowShowStateText(const Browser* browser); |
[email protected] | ac84431b | 2011-09-27 17:26:11 | [diff] [blame] | 39 | static base::ListValue* CreateTabList(const Browser* browser); |
| 40 | static base::DictionaryValue* CreateTabValue( |
[email protected] | ea049a0 | 2011-12-25 21:37:09 | [diff] [blame^] | 41 | const content::WebContents* web_contents); |
| 42 | static base::DictionaryValue* CreateTabValue( |
| 43 | const content::WebContents* web_contents, |
| 44 | TabStripModel* tab_strip, |
| 45 | int tab_index); |
[email protected] | ac84431b | 2011-09-27 17:26:11 | [diff] [blame] | 46 | // Create a tab value, overriding its kSelectedKey to the provided boolean. |
| 47 | static base::DictionaryValue* CreateTabValueActive( |
[email protected] | ea049a0 | 2011-12-25 21:37:09 | [diff] [blame^] | 48 | const content::WebContents* web_contents, |
[email protected] | ac84431b | 2011-09-27 17:26:11 | [diff] [blame] | 49 | bool active); |
| 50 | static base::DictionaryValue* CreateWindowValue(const Browser* browser, |
| 51 | bool populate_tabs); |
[email protected] | ea049a0 | 2011-12-25 21:37:09 | [diff] [blame^] | 52 | // Gets the |tab_strip_model| and |tab_index| for the given |web_contents|. |
| 53 | static bool GetTabStripModel(const content::WebContents* web_contents, |
[email protected] | ac84431b | 2011-09-27 17:26:11 | [diff] [blame] | 54 | TabStripModel** tab_strip_model, |
| 55 | int* tab_index); |
| 56 | static bool GetDefaultTab(Browser* browser, |
| 57 | TabContentsWrapper** contents, |
| 58 | int* tab_id); |
| 59 | // Any out parameter (|browser|, |tab_strip|, |contents|, & |tab_index|) may |
| 60 | // be NULL and will not be set within the function. |
| 61 | static bool GetTabById(int tab_id, Profile* profile, bool incognito_enabled, |
| 62 | Browser** browser, |
| 63 | TabStripModel** tab_strip, |
| 64 | TabContentsWrapper** contents, |
| 65 | int* tab_index); |
| 66 | }; |
| 67 | |
| 68 | #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H__ |