blob: 5dfb36f97d280909a67d607eac5a0287f3f781e5 [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);
26 static int GetTabId(const TabContents* tab_contents);
27 static bool GetTabIdFromArgument(const base::ListValue &args,
28 int argument_index,
29 int *tab_id, std::string* error_message);
30 static std::string GetTabStatusText(bool is_loading);
31 static int GetWindowIdOfTab(const TabContents* tab_contents);
32 static base::ListValue* CreateTabList(const Browser* browser);
33 static base::DictionaryValue* CreateTabValue(
34 const TabContents* tab_contents);
35 static base::DictionaryValue* CreateTabValue(const TabContents* tab_contents,
36 TabStripModel* tab_strip,
37 int tab_index);
38 // Create a tab value, overriding its kSelectedKey to the provided boolean.
39 static base::DictionaryValue* CreateTabValueActive(
40 const TabContents* tab_contents,
41 bool active);
42 static base::DictionaryValue* CreateWindowValue(const Browser* browser,
43 bool populate_tabs);
44 // Gets the |tab_strip_model| and |tab_index| for the given |tab_contents|.
45 static bool GetTabStripModel(const TabContents* tab_contents,
46 TabStripModel** tab_strip_model,
47 int* tab_index);
48 static bool GetDefaultTab(Browser* browser,
49 TabContentsWrapper** contents,
50 int* tab_id);
51 // Any out parameter (|browser|, |tab_strip|, |contents|, & |tab_index|) may
52 // be NULL and will not be set within the function.
53 static bool GetTabById(int tab_id, Profile* profile, bool incognito_enabled,
54 Browser** browser,
55 TabStripModel** tab_strip,
56 TabContentsWrapper** contents,
57 int* tab_index);
58};
59
60#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H__