| 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "chrome/common/extensions/api/tabs.h" | 12 #include "chrome/common/extensions/api/tabs.h" |
| 13 #include "ui/base/window_open_disposition.h" | 13 #include "ui/base/window_open_disposition.h" |
| 14 | 14 |
| 15 class Browser; | 15 class Browser; |
| 16 class ChromeExtensionFunctionDetails; | 16 class ChromeExtensionFunctionDetails; |
| 17 class ChromeUIThreadExtensionFunction; | 17 class ChromeUIThreadExtensionFunction; |
| 18 class ExtensionFunction; | 18 class ExtensionFunction; |
| 19 class GURL; | 19 class GURL; |
| 20 class Profile; | 20 class Profile; |
| 21 class TabStripModel; | 21 class TabStripModel; |
| 22 class UIThreadExtensionFunction; |
| 22 | 23 |
| 23 namespace base { | 24 namespace base { |
| 24 class DictionaryValue; | 25 class DictionaryValue; |
| 25 class ListValue; | 26 class ListValue; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace content { | 29 namespace content { |
| 29 class BrowserContext; | 30 class BrowserContext; |
| 30 class WebContents; | 31 class WebContents; |
| 31 } | 32 } |
| 32 | 33 |
| 33 namespace gfx { | 34 namespace gfx { |
| 34 class Rect; | 35 class Rect; |
| 35 } | 36 } |
| 36 | 37 |
| 37 namespace extensions { | 38 namespace extensions { |
| 38 | |
| 39 class Extension; | 39 class Extension; |
| 40 class WindowController; | 40 class WindowController; |
| 41 | 41 |
| 42 // Provides various utility functions that help manipulate tabs. | 42 // Provides various utility functions that help manipulate tabs. |
| 43 class ExtensionTabUtil { | 43 class ExtensionTabUtil { |
| 44 public: | 44 public: |
| 45 struct OpenTabParams { | 45 struct OpenTabParams { |
| 46 OpenTabParams(); | 46 OpenTabParams(); |
| 47 ~OpenTabParams(); | 47 ~OpenTabParams(); |
| 48 | 48 |
| 49 bool create_browser_if_needed; | 49 bool create_browser_if_needed; |
| 50 std::unique_ptr<int> window_id; | 50 std::unique_ptr<int> window_id; |
| 51 std::unique_ptr<int> opener_tab_id; | 51 std::unique_ptr<int> opener_tab_id; |
| 52 std::unique_ptr<std::string> url; | 52 std::unique_ptr<std::string> url; |
| 53 std::unique_ptr<bool> active; | 53 std::unique_ptr<bool> active; |
| 54 std::unique_ptr<bool> pinned; | 54 std::unique_ptr<bool> pinned; |
| 55 std::unique_ptr<int> index; | 55 std::unique_ptr<int> index; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 // Opens a new tab given an extension function |function| and creation | 58 // Opens a new tab given an extension function |function| and creation |
| 59 // parameters |params|. Returns a Tab object if successful, or NULL and | 59 // parameters |params|. Returns a Tab object if successful, or NULL and |
| 60 // optionally sets |error| if an error occurs. | 60 // optionally sets |error| if an error occurs. |
| 61 static base::DictionaryValue* OpenTab( | 61 static base::DictionaryValue* OpenTab(UIThreadExtensionFunction* function, |
| 62 ChromeUIThreadExtensionFunction* function, | 62 const OpenTabParams& params, |
| 63 const OpenTabParams& params, | 63 std::string* error); |
| 64 std::string* error); | |
| 65 | 64 |
| 66 static int GetWindowId(const Browser* browser); | 65 static int GetWindowId(const Browser* browser); |
| 67 static int GetWindowIdOfTabStripModel(const TabStripModel* tab_strip_model); | 66 static int GetWindowIdOfTabStripModel(const TabStripModel* tab_strip_model); |
| 68 static int GetTabId(const content::WebContents* web_contents); | 67 static int GetTabId(const content::WebContents* web_contents); |
| 69 static std::string GetTabStatusText(bool is_loading); | 68 static std::string GetTabStatusText(bool is_loading); |
| 70 static int GetWindowIdOfTab(const content::WebContents* web_contents); | 69 static int GetWindowIdOfTab(const content::WebContents* web_contents); |
| 71 static std::unique_ptr<base::ListValue> CreateTabList( | 70 static std::unique_ptr<base::ListValue> CreateTabList( |
| 72 const Browser* browser, | 71 const Browser* browser, |
| 73 const Extension* extension); | 72 const Extension* extension); |
| 74 | 73 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 static bool OpenOptionsPage(const Extension* extension, Browser* browser); | 175 static bool OpenOptionsPage(const Extension* extension, Browser* browser); |
| 177 | 176 |
| 178 // Returns true if the given Browser can report tabs to extensions. | 177 // Returns true if the given Browser can report tabs to extensions. |
| 179 // Example of Browsers which don't support tabs include apps and devtools. | 178 // Example of Browsers which don't support tabs include apps and devtools. |
| 180 static bool BrowserSupportsTabs(Browser* browser); | 179 static bool BrowserSupportsTabs(Browser* browser); |
| 181 }; | 180 }; |
| 182 | 181 |
| 183 } // namespace extensions | 182 } // namespace extensions |
| 184 | 183 |
| 185 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_ | 184 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_ |
| OLD | NEW |