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 27 matching lines...) Expand all Loading... |
38 public: | 38 public: |
39 static int GetWindowId(const Browser* browser); | 39 static int GetWindowId(const Browser* browser); |
40 static int GetWindowIdOfTabStripModel(const TabStripModel* tab_strip_model); | 40 static int GetWindowIdOfTabStripModel(const TabStripModel* tab_strip_model); |
41 static int GetTabId(const content::WebContents* web_contents); | 41 static int GetTabId(const content::WebContents* web_contents); |
42 static std::string GetTabStatusText(bool is_loading); | 42 static std::string GetTabStatusText(bool is_loading); |
43 static int GetWindowIdOfTab(const content::WebContents* web_contents); | 43 static int GetWindowIdOfTab(const content::WebContents* web_contents); |
44 static base::ListValue* CreateTabList( | 44 static base::ListValue* CreateTabList( |
45 const Browser* browser, | 45 const Browser* browser, |
46 const extensions::Extension* extension); | 46 const extensions::Extension* extension); |
47 | 47 |
48 // Creates a Tab object (see chrome/common/extensions/api/tabs.json) with | |
49 // information about the state of a browser tab. Depending on the | |
50 // permissions of the extension, the object may or may not include sensitive | |
51 // data such as the tab's URL. | |
52 static base::DictionaryValue* CreateTabValue( | 48 static base::DictionaryValue* CreateTabValue( |
53 const content::WebContents* web_contents, | 49 const content::WebContents* web_contents, |
54 const extensions::Extension* extension) { | 50 const extensions::Extension* extension) { |
55 return CreateTabValue(web_contents, NULL, -1, extension); | 51 return CreateTabValue(web_contents, NULL, -1, extension); |
56 } | 52 } |
57 static base::DictionaryValue* CreateTabValue( | 53 static base::DictionaryValue* CreateTabValue( |
58 const content::WebContents* web_contents, | 54 const content::WebContents* web_contents, |
59 TabStripModel* tab_strip, | 55 TabStripModel* tab_strip, |
60 int tab_index, | 56 int tab_index, |
61 const extensions::Extension* extension); | 57 const extensions::Extension* extension); |
62 | 58 |
63 // Creates a Tab object but performs no extension permissions checks; the | 59 enum IncludePrivacySensitiveFields { |
64 // returned object will contain privacy-sensitive data. | 60 INCLUDE_PRIVACY_SENSITIVE_FIELDS, |
| 61 OMIT_PRIVACY_SENSITIVE_FIELDS |
| 62 }; |
65 static base::DictionaryValue* CreateTabValue( | 63 static base::DictionaryValue* CreateTabValue( |
66 const content::WebContents* web_contents) { | 64 const content::WebContents* web_contents, |
67 return CreateTabValue(web_contents, NULL, -1); | 65 IncludePrivacySensitiveFields include_privacy_sensitive_fields) { |
| 66 return CreateTabValue(web_contents, NULL, -1, |
| 67 include_privacy_sensitive_fields); |
68 } | 68 } |
69 static base::DictionaryValue* CreateTabValue( | 69 static base::DictionaryValue* CreateTabValue( |
70 const content::WebContents* web_contents, | 70 const content::WebContents* web_contents, |
71 TabStripModel* tab_strip, | 71 TabStripModel* tab_strip, |
72 int tab_index); | 72 int tab_index, |
73 | 73 IncludePrivacySensitiveFields include_privacy_sensitive_fields); |
74 // Removes any privacy-sensitive fields from a Tab object if appropriate, | |
75 // given the permissions of the extension and the tab in question. The | |
76 // tab_info object is modified in place. | |
77 static void ScrubTabValueForExtension(const content::WebContents* contents, | |
78 const extensions::Extension* extension, | |
79 base::DictionaryValue* tab_info); | |
80 | 74 |
81 // Gets the |tab_strip_model| and |tab_index| for the given |web_contents|. | 75 // Gets the |tab_strip_model| and |tab_index| for the given |web_contents|. |
82 static bool GetTabStripModel(const content::WebContents* web_contents, | 76 static bool GetTabStripModel(const content::WebContents* web_contents, |
83 TabStripModel** tab_strip_model, | 77 TabStripModel** tab_strip_model, |
84 int* tab_index); | 78 int* tab_index); |
85 static bool GetDefaultTab(Browser* browser, | 79 static bool GetDefaultTab(Browser* browser, |
86 content::WebContents** contents, | 80 content::WebContents** contents, |
87 int* tab_id); | 81 int* tab_id); |
88 // Any out parameter (|browser|, |tab_strip|, |contents|, & |tab_index|) may | 82 // Any out parameter (|browser|, |tab_strip|, |contents|, & |tab_index|) may |
89 // be NULL and will not be set within the function. | 83 // be NULL and will not be set within the function. |
(...skipping 26 matching lines...) Expand all Loading... |
116 | 110 |
117 // Executes the specified callback for all tabs in all browser windows. | 111 // Executes the specified callback for all tabs in all browser windows. |
118 static void ForEachTab( | 112 static void ForEachTab( |
119 const base::Callback<void(content::WebContents*)>& callback); | 113 const base::Callback<void(content::WebContents*)>& callback); |
120 | 114 |
121 static extensions::WindowController* GetWindowControllerOfTab( | 115 static extensions::WindowController* GetWindowControllerOfTab( |
122 const content::WebContents* web_contents); | 116 const content::WebContents* web_contents); |
123 }; | 117 }; |
124 | 118 |
125 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H__ | 119 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H__ |
OLD | NEW |