blob: 0dd9274b3f83b412c63e3633cade147c7c86aa03 [file] [log] [blame]
[email protected]ac84431b2011-09-27 17:26:111// 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
11class Browser;
12class Profile;
13class TabContents;
14class TabContentsWrapper;
15class TabStripModel;
16
17namespace base {
18class DictionaryValue;
19class ListValue;
20}
21
[email protected]26b5e322011-12-23 01:36:4722namespace content {
23class WebContents;
24}
25
[email protected]ac84431b2011-09-27 17:26:1126// Provides various utility functions that help manipulate tabs.
27class ExtensionTabUtil {
28 public:
29 static int GetWindowId(const Browser* browser);
[email protected]8c3495c2011-09-28 03:32:3030 static int GetWindowIdOfTabStripModel(const TabStripModel* tab_strip_model);
[email protected]26b5e322011-12-23 01:36:4731 static int GetTabId(const content::WebContents* web_contents);
[email protected]ac84431b2011-09-27 17:26:1132 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]ea049a02011-12-25 21:37:0936 static int GetWindowIdOfTab(const content::WebContents* web_contents);
[email protected]8c3495c2011-09-28 03:32:3037 static std::string GetWindowTypeText(const Browser* browser);
[email protected]541e3ee2011-11-22 01:31:1038 static std::string GetWindowShowStateText(const Browser* browser);
[email protected]ac84431b2011-09-27 17:26:1139 static base::ListValue* CreateTabList(const Browser* browser);
40 static base::DictionaryValue* CreateTabValue(
[email protected]ea049a02011-12-25 21:37:0941 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]ac84431b2011-09-27 17:26:1146 // Create a tab value, overriding its kSelectedKey to the provided boolean.
47 static base::DictionaryValue* CreateTabValueActive(
[email protected]ea049a02011-12-25 21:37:0948 const content::WebContents* web_contents,
[email protected]ac84431b2011-09-27 17:26:1149 bool active);
50 static base::DictionaryValue* CreateWindowValue(const Browser* browser,
51 bool populate_tabs);
[email protected]ea049a02011-12-25 21:37:0952 // Gets the |tab_strip_model| and |tab_index| for the given |web_contents|.
53 static bool GetTabStripModel(const content::WebContents* web_contents,
[email protected]ac84431b2011-09-27 17:26:1154 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__