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

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

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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_tab_util.cc
diff --git a/chrome/browser/extensions/extension_tab_util.cc b/chrome/browser/extensions/extension_tab_util.cc
index c654bf16382663a866909c1d5e8d66914b8f32b3..5d475b09801f0bb8fb72271d4f8a4628b59bb4b5 100644
--- a/chrome/browser/extensions/extension_tab_util.cc
+++ b/chrome/browser/extensions/extension_tab_util.cc
@@ -64,14 +64,9 @@ DictionaryValue* ExtensionTabUtil::CreateTabValue(
TabStripModel* tab_strip,
int tab_index,
const Extension* extension) {
- // 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);
+ DictionaryValue *result = CreateTabValue(contents, tab_strip, tab_index);
+ ScrubTabValueForExtension(contents, extension, result);
+ return result;
}
ListValue* ExtensionTabUtil::CreateTabList(
@@ -92,8 +87,7 @@ ListValue* ExtensionTabUtil::CreateTabList(
DictionaryValue* ExtensionTabUtil::CreateTabValue(
const WebContents* contents,
TabStripModel* tab_strip,
- int tab_index,
- IncludePrivacySensitiveFields include_privacy_sensitive_fields) {
+ int tab_index) {
if (!tab_strip)
ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index);
@@ -114,14 +108,14 @@ DictionaryValue* ExtensionTabUtil::CreateTabValue(
result->SetBoolean(keys::kIncognitoKey,
contents->GetBrowserContext()->IsOffTheRecord());
- 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());
- }
+ // 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 (tab_strip) {
@@ -133,6 +127,19 @@ DictionaryValue* ExtensionTabUtil::CreateTabValue(
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