blob: 37ada1407b8598d0b669739a5a4c50350a4ba3ff [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
22// Provides various utility functions that help manipulate tabs.
23class ExtensionTabUtil {
24 public:
25 static int GetWindowId(const Browser* browser);
[email protected]8c3495c2011-09-28 03:32:3026 static int GetWindowIdOfTabStripModel(const TabStripModel* tab_strip_model);
[email protected]ac84431b2011-09-27 17:26:1127 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]8c3495c2011-09-28 03:32:3033 static std::string GetWindowTypeText(const Browser* browser);
[email protected]ac84431b2011-09-27 17:26:1134 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__