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

Unified Diff: chrome/browser/extensions/extension_tab_util.cc

Issue 11866012: Revert 176406 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_tab_util.cc
===================================================================
--- chrome/browser/extensions/extension_tab_util.cc (revision 176424)
+++ chrome/browser/extensions/extension_tab_util.cc (working copy)
@@ -64,9 +64,14 @@
TabStripModel* tab_strip,
int tab_index,
const Extension* extension) {
- DictionaryValue *result = CreateTabValue(contents, tab_strip, tab_index);
- ScrubTabValueForExtension(contents, extension, result);
- return result;
+ // Only add privacy-sensitive data if the requesting extension has the tabs
+ // permission.
+ bool has_permission = extension && extension->HasAPIPermissionForTab(
+ GetTabId(contents), APIPermission::kTab);
+
+ return CreateTabValue(contents, tab_strip, tab_index,
+ has_permission ? INCLUDE_PRIVACY_SENSITIVE_FIELDS :
+ OMIT_PRIVACY_SENSITIVE_FIELDS);
}
ListValue* ExtensionTabUtil::CreateTabList(
@@ -87,7 +92,8 @@
DictionaryValue* ExtensionTabUtil::CreateTabValue(
const WebContents* contents,
TabStripModel* tab_strip,
- int tab_index) {
+ int tab_index,
+ IncludePrivacySensitiveFields include_privacy_sensitive_fields) {
if (!tab_strip)
ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index);
@@ -108,14 +114,14 @@
result->SetBoolean(keys::kIncognitoKey,
contents->GetBrowserContext()->IsOffTheRecord());
- // Privacy-sensitive fields: these should be stripped off by
- // ScrubTabValueForExtension if the extension should not see them.
- result->SetString(keys::kUrlKey, contents->GetURL().spec());
- result->SetString(keys::kTitleKey, contents->GetTitle());
- if (!is_loading) {
- NavigationEntry* entry = contents->GetController().GetActiveEntry();
- if (entry && entry->GetFavicon().valid)
- result->SetString(keys::kFaviconUrlKey, entry->GetFavicon().url.spec());
+ if (include_privacy_sensitive_fields == INCLUDE_PRIVACY_SENSITIVE_FIELDS) {
+ result->SetString(keys::kUrlKey, contents->GetURL().spec());
+ result->SetString(keys::kTitleKey, contents->GetTitle());
+ if (!is_loading) {
+ NavigationEntry* entry = contents->GetController().GetActiveEntry();
+ if (entry && entry->GetFavicon().valid)
+ result->SetString(keys::kFaviconUrlKey, entry->GetFavicon().url.spec());
+ }
}
if (tab_strip) {
@@ -127,19 +133,6 @@
return result;
}
-void ExtensionTabUtil::ScrubTabValueForExtension(const WebContents* contents,
- const Extension* extension,
- DictionaryValue* tab_info) {
- bool has_permission = extension && extension->HasAPIPermissionForTab(
- GetTabId(contents), APIPermission::kTab);
-
- if (!has_permission) {
- tab_info->Remove(keys::kUrlKey, NULL);
- tab_info->Remove(keys::kTitleKey, NULL);
- tab_info->Remove(keys::kFaviconUrlKey, NULL);
- }
-}
-
bool ExtensionTabUtil::GetTabStripModel(const WebContents* web_contents,
TabStripModel** tab_strip_model,
int* tab_index) {
« no previous file with comments | « chrome/browser/extensions/extension_tab_util.h ('k') | chrome/browser/extensions/extension_tab_util_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698