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