Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: chrome/browser/extensions/extension_tab_util.h

Issue 11824004: Do not pass URLs in onUpdated events to extensions unless they have the (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Update test Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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.
48 static base::DictionaryValue* CreateTabValue( 52 static base::DictionaryValue* CreateTabValue(
49 const content::WebContents* web_contents, 53 const content::WebContents* web_contents,
50 const extensions::Extension* extension) { 54 const extensions::Extension* extension) {
51 return CreateTabValue(web_contents, NULL, -1, extension); 55 return CreateTabValue(web_contents, NULL, -1, extension);
52 } 56 }
53 static base::DictionaryValue* CreateTabValue( 57 static base::DictionaryValue* CreateTabValue(
54 const content::WebContents* web_contents, 58 const content::WebContents* web_contents,
55 TabStripModel* tab_strip, 59 TabStripModel* tab_strip,
56 int tab_index, 60 int tab_index,
57 const extensions::Extension* extension); 61 const extensions::Extension* extension);
58 62
59 enum IncludePrivacySensitiveFields { 63 // Creates a Tab object but performs no extension permissions checks; the
60 INCLUDE_PRIVACY_SENSITIVE_FIELDS, 64 // returned object will contain privacy-sensitive data.
61 OMIT_PRIVACY_SENSITIVE_FIELDS
62 };
63 static base::DictionaryValue* CreateTabValue( 65 static base::DictionaryValue* CreateTabValue(
64 const content::WebContents* web_contents, 66 const content::WebContents* web_contents) {
65 IncludePrivacySensitiveFields include_privacy_sensitive_fields) { 67 return CreateTabValue(web_contents, NULL, -1);
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 IncludePrivacySensitiveFields include_privacy_sensitive_fields); 73
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);
74 80
75 // Gets the |tab_strip_model| and |tab_index| for the given |web_contents|. 81 // Gets the |tab_strip_model| and |tab_index| for the given |web_contents|.
76 static bool GetTabStripModel(const content::WebContents* web_contents, 82 static bool GetTabStripModel(const content::WebContents* web_contents,
77 TabStripModel** tab_strip_model, 83 TabStripModel** tab_strip_model,
78 int* tab_index); 84 int* tab_index);
79 static bool GetDefaultTab(Browser* browser, 85 static bool GetDefaultTab(Browser* browser,
80 content::WebContents** contents, 86 content::WebContents** contents,
81 int* tab_id); 87 int* tab_id);
82 // Any out parameter (|browser|, |tab_strip|, |contents|, & |tab_index|) may 88 // Any out parameter (|browser|, |tab_strip|, |contents|, & |tab_index|) may
83 // be NULL and will not be set within the function. 89 // be NULL and will not be set within the function.
(...skipping 26 matching lines...) Expand all
110 116
111 // Executes the specified callback for all tabs in all browser windows. 117 // Executes the specified callback for all tabs in all browser windows.
112 static void ForEachTab( 118 static void ForEachTab(
113 const base::Callback<void(content::WebContents*)>& callback); 119 const base::Callback<void(content::WebContents*)>& callback);
114 120
115 static extensions::WindowController* GetWindowControllerOfTab( 121 static extensions::WindowController* GetWindowControllerOfTab(
116 const content::WebContents* web_contents); 122 const content::WebContents* web_contents);
117 }; 123 };
118 124
119 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H__ 125 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H__
OLDNEW
« no previous file with comments | « chrome/browser/extensions/browser_event_router.cc ('k') | chrome/browser/extensions/extension_tab_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698