OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "chrome/common/extensions/api/tabs.h" | 11 #include "chrome/common/extensions/api/tabs.h" |
12 #include "ui/base/window_open_disposition.h" | 12 #include "ui/base/window_open_disposition.h" |
13 | 13 |
14 class Browser; | 14 class Browser; |
15 class ChromeAsyncExtensionFunction; | 15 class ChromeUIThreadExtensionFunction; |
16 class GURL; | 16 class GURL; |
17 class Profile; | 17 class Profile; |
18 class TabStripModel; | 18 class TabStripModel; |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 class DictionaryValue; | 21 class DictionaryValue; |
22 class ListValue; | 22 class ListValue; |
23 } | 23 } |
24 | 24 |
25 namespace content { | 25 namespace content { |
(...skipping 20 matching lines...) Expand all Loading... |
46 scoped_ptr<int> opener_tab_id; | 46 scoped_ptr<int> opener_tab_id; |
47 scoped_ptr<std::string> url; | 47 scoped_ptr<std::string> url; |
48 scoped_ptr<bool> active; | 48 scoped_ptr<bool> active; |
49 scoped_ptr<bool> pinned; | 49 scoped_ptr<bool> pinned; |
50 scoped_ptr<int> index; | 50 scoped_ptr<int> index; |
51 }; | 51 }; |
52 | 52 |
53 // Opens a new tab given an extension function |function| and creation | 53 // Opens a new tab given an extension function |function| and creation |
54 // parameters |params|. Returns a Tab object if successful, or NULL and | 54 // parameters |params|. Returns a Tab object if successful, or NULL and |
55 // optionally sets |error| if an error occurs. | 55 // optionally sets |error| if an error occurs. |
56 static base::DictionaryValue* OpenTab(ChromeAsyncExtensionFunction* function, | 56 static base::DictionaryValue* OpenTab( |
57 const OpenTabParams& params, | 57 ChromeUIThreadExtensionFunction* function, |
58 std::string* error); | 58 const OpenTabParams& params, |
| 59 std::string* error); |
59 | 60 |
60 static int GetWindowId(const Browser* browser); | 61 static int GetWindowId(const Browser* browser); |
61 static int GetWindowIdOfTabStripModel(const TabStripModel* tab_strip_model); | 62 static int GetWindowIdOfTabStripModel(const TabStripModel* tab_strip_model); |
62 static int GetTabId(const content::WebContents* web_contents); | 63 static int GetTabId(const content::WebContents* web_contents); |
63 static std::string GetTabStatusText(bool is_loading); | 64 static std::string GetTabStatusText(bool is_loading); |
64 static int GetWindowIdOfTab(const content::WebContents* web_contents); | 65 static int GetWindowIdOfTab(const content::WebContents* web_contents); |
65 static base::ListValue* CreateTabList(const Browser* browser, | 66 static base::ListValue* CreateTabList(const Browser* browser, |
66 const Extension* extension); | 67 const Extension* extension); |
67 static Browser* GetBrowserFromWindowID(ChromeAsyncExtensionFunction* function, | 68 static Browser* GetBrowserFromWindowID( |
68 int window_id, | 69 ChromeUIThreadExtensionFunction* function, |
69 std::string* error_message); | 70 int window_id, |
| 71 std::string* error_message); |
70 | 72 |
71 // Creates a Tab object (see chrome/common/extensions/api/tabs.json) with | 73 // Creates a Tab object (see chrome/common/extensions/api/tabs.json) with |
72 // information about the state of a browser tab. Depending on the | 74 // information about the state of a browser tab. Depending on the |
73 // permissions of the extension, the object may or may not include sensitive | 75 // permissions of the extension, the object may or may not include sensitive |
74 // data such as the tab's URL. | 76 // data such as the tab's URL. |
75 static base::DictionaryValue* CreateTabValue( | 77 static base::DictionaryValue* CreateTabValue( |
76 const content::WebContents* web_contents, | 78 const content::WebContents* web_contents, |
77 const Extension* extension) { | 79 const Extension* extension) { |
78 return CreateTabValue(web_contents, NULL, -1, extension); | 80 return CreateTabValue(web_contents, NULL, -1, extension); |
79 } | 81 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 static WindowController* GetWindowControllerOfTab( | 151 static WindowController* GetWindowControllerOfTab( |
150 const content::WebContents* web_contents); | 152 const content::WebContents* web_contents); |
151 | 153 |
152 // Open the extension's options page. | 154 // Open the extension's options page. |
153 static void OpenOptionsPage(const Extension* extension, Browser* browser); | 155 static void OpenOptionsPage(const Extension* extension, Browser* browser); |
154 }; | 156 }; |
155 | 157 |
156 } // namespace extensions | 158 } // namespace extensions |
157 | 159 |
158 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_ | 160 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_ |
OLD | NEW |