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" |
(...skipping 28 matching lines...) Expand all Loading... |
39 class WindowController; | 39 class WindowController; |
40 | 40 |
41 // Provides various utility functions that help manipulate tabs. | 41 // Provides various utility functions that help manipulate tabs. |
42 class ExtensionTabUtil { | 42 class ExtensionTabUtil { |
43 public: | 43 public: |
44 struct OpenTabParams { | 44 struct OpenTabParams { |
45 OpenTabParams(); | 45 OpenTabParams(); |
46 ~OpenTabParams(); | 46 ~OpenTabParams(); |
47 | 47 |
48 bool create_browser_if_needed; | 48 bool create_browser_if_needed; |
49 scoped_ptr<int> window_id; | 49 std::unique_ptr<int> window_id; |
50 scoped_ptr<int> opener_tab_id; | 50 std::unique_ptr<int> opener_tab_id; |
51 scoped_ptr<std::string> url; | 51 std::unique_ptr<std::string> url; |
52 scoped_ptr<bool> active; | 52 std::unique_ptr<bool> active; |
53 scoped_ptr<bool> pinned; | 53 std::unique_ptr<bool> pinned; |
54 scoped_ptr<int> index; | 54 std::unique_ptr<int> index; |
55 }; | 55 }; |
56 | 56 |
57 // Opens a new tab given an extension function |function| and creation | 57 // Opens a new tab given an extension function |function| and creation |
58 // parameters |params|. Returns a Tab object if successful, or NULL and | 58 // parameters |params|. Returns a Tab object if successful, or NULL and |
59 // optionally sets |error| if an error occurs. | 59 // optionally sets |error| if an error occurs. |
60 static base::DictionaryValue* OpenTab( | 60 static base::DictionaryValue* OpenTab( |
61 ChromeUIThreadExtensionFunction* function, | 61 ChromeUIThreadExtensionFunction* function, |
62 const OpenTabParams& params, | 62 const OpenTabParams& params, |
63 std::string* error); | 63 std::string* error); |
64 | 64 |
(...skipping 15 matching lines...) Expand all Loading... |
80 | 80 |
81 static Browser* GetBrowserFromWindowID( | 81 static Browser* GetBrowserFromWindowID( |
82 const ChromeExtensionFunctionDetails& details, | 82 const ChromeExtensionFunctionDetails& details, |
83 int window_id, | 83 int window_id, |
84 std::string* error_message); | 84 std::string* error_message); |
85 | 85 |
86 // Creates a Tab object (see chrome/common/extensions/api/tabs.json) with | 86 // Creates a Tab object (see chrome/common/extensions/api/tabs.json) with |
87 // information about the state of a browser tab. Depending on the | 87 // information about the state of a browser tab. Depending on the |
88 // permissions of the extension, the object may or may not include sensitive | 88 // permissions of the extension, the object may or may not include sensitive |
89 // data such as the tab's URL. | 89 // data such as the tab's URL. |
90 static scoped_ptr<api::tabs::Tab> CreateTabObject( | 90 static std::unique_ptr<api::tabs::Tab> CreateTabObject( |
91 content::WebContents* web_contents, | 91 content::WebContents* web_contents, |
92 const Extension* extension) { | 92 const Extension* extension) { |
93 return CreateTabObject(web_contents, nullptr, -1, extension); | 93 return CreateTabObject(web_contents, nullptr, -1, extension); |
94 } | 94 } |
95 static scoped_ptr<api::tabs::Tab> CreateTabObject( | 95 static std::unique_ptr<api::tabs::Tab> CreateTabObject( |
96 content::WebContents* web_contents, | 96 content::WebContents* web_contents, |
97 TabStripModel* tab_strip, | 97 TabStripModel* tab_strip, |
98 int tab_index, | 98 int tab_index, |
99 const Extension* extension); | 99 const Extension* extension); |
100 | 100 |
101 // Creates a Tab object but performs no extension permissions checks; the | 101 // Creates a Tab object but performs no extension permissions checks; the |
102 // returned object will contain privacy-sensitive data. | 102 // returned object will contain privacy-sensitive data. |
103 static scoped_ptr<api::tabs::Tab> CreateTabObject( | 103 static std::unique_ptr<api::tabs::Tab> CreateTabObject( |
104 content::WebContents* web_contents) { | 104 content::WebContents* web_contents) { |
105 return CreateTabObject(web_contents, nullptr, -1); | 105 return CreateTabObject(web_contents, nullptr, -1); |
106 } | 106 } |
107 static scoped_ptr<api::tabs::Tab> CreateTabObject( | 107 static std::unique_ptr<api::tabs::Tab> CreateTabObject( |
108 content::WebContents* web_contents, | 108 content::WebContents* web_contents, |
109 TabStripModel* tab_strip, | 109 TabStripModel* tab_strip, |
110 int tab_index); | 110 int tab_index); |
111 | 111 |
112 // Creates a tab MutedInfo object (see chrome/common/extensions/api/tabs.json) | 112 // Creates a tab MutedInfo object (see chrome/common/extensions/api/tabs.json) |
113 // with information about the mute state of a browser tab. | 113 // with information about the mute state of a browser tab. |
114 static scoped_ptr<api::tabs::MutedInfo> CreateMutedInfo( | 114 static std::unique_ptr<api::tabs::MutedInfo> CreateMutedInfo( |
115 content::WebContents* contents); | 115 content::WebContents* contents); |
116 | 116 |
117 // Removes any privacy-sensitive fields from a Tab object if appropriate, | 117 // Removes any privacy-sensitive fields from a Tab object if appropriate, |
118 // given the permissions of the extension and the tab in question. The | 118 // given the permissions of the extension and the tab in question. The |
119 // tab object is modified in place. | 119 // tab object is modified in place. |
120 static void ScrubTabForExtension(const Extension* extension, | 120 static void ScrubTabForExtension(const Extension* extension, |
121 content::WebContents* contents, | 121 content::WebContents* contents, |
122 api::tabs::Tab* tab); | 122 api::tabs::Tab* tab); |
123 | 123 |
124 // Gets the |tab_strip_model| and |tab_index| for the given |web_contents|. | 124 // Gets the |tab_strip_model| and |tab_index| for the given |web_contents|. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 static bool OpenOptionsPage(const Extension* extension, Browser* browser); | 174 static bool OpenOptionsPage(const Extension* extension, Browser* browser); |
175 | 175 |
176 // Returns true if the given Browser can report tabs to extensions. | 176 // Returns true if the given Browser can report tabs to extensions. |
177 // Example of Browsers which don't support tabs include apps and devtools. | 177 // Example of Browsers which don't support tabs include apps and devtools. |
178 static bool BrowserSupportsTabs(Browser* browser); | 178 static bool BrowserSupportsTabs(Browser* browser); |
179 }; | 179 }; |
180 | 180 |
181 } // namespace extensions | 181 } // namespace extensions |
182 | 182 |
183 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_ | 183 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_ |
OLD | NEW |