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

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

Issue 10909256: Always send the full tab object in ExtensionAction click event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: kalments Created 8 years, 3 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 09d20e039b190178684f99b321227c103094fcc3..416a07b04671d19e2d7b72ff0ea12e18a8b51986 100644
--- a/chrome/browser/extensions/extension_tab_util.cc
+++ b/chrome/browser/extensions/extension_tab_util.cc
@@ -62,19 +62,17 @@ int ExtensionTabUtil::GetWindowIdOfTab(const WebContents* web_contents) {
DictionaryValue* ExtensionTabUtil::CreateTabValue(
const WebContents* contents,
+ TabStripModel* tab_strip,
+ int tab_index,
const Extension* extension) {
- // Find the tab strip and index of this guy.
- TabStripModel* tab_strip = NULL;
- int tab_index;
- if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) {
- return ExtensionTabUtil::CreateTabValue(contents,
- tab_strip,
- tab_index,
- extension);
- }
+ // Only add privacy-sensitive data if the requesting extension has the tabs
+ // permission.
+ bool has_permission = extension && extension->HasAPIPermissionForTab(
+ GetTabId(contents), APIPermission::kTab);
- // Couldn't find it. This can happen if the tab is being dragged.
- return ExtensionTabUtil::CreateTabValue(contents, NULL, -1, extension);
+ return CreateTabValue(contents, tab_strip, tab_index,
+ has_permission ? INCLUDE_PRIVACY_SENSITIVE_FIELDS :
+ OMIT_PRIVACY_SENSITIVE_FIELDS);
}
ListValue* ExtensionTabUtil::CreateTabList(
@@ -97,7 +95,10 @@ DictionaryValue* ExtensionTabUtil::CreateTabValue(
const WebContents* contents,
TabStripModel* tab_strip,
int tab_index,
- const Extension* extension) {
+ IncludePrivacySensitiveFields include_privacy_sensitive_fields) {
+ if (!tab_strip)
+ ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index);
+
DictionaryValue* result = new DictionaryValue();
bool is_loading = contents->IsLoading();
result->SetInteger(keys::kIdKey, GetTabId(contents));
@@ -115,24 +116,7 @@ DictionaryValue* ExtensionTabUtil::CreateTabValue(
result->SetBoolean(keys::kIncognitoKey,
contents->GetBrowserContext()->IsOffTheRecord());
- // Only add privacy-sensitive data if the requesting extension has the tabs
- // permission.
- bool has_permission = false;
- if (extension) {
- if (tab_index >= 0) {
- has_permission =
- extension->HasAPIPermissionForTab(
- tab_index, APIPermission::kTab) ||
- extension->HasAPIPermissionForTab(
- tab_index, APIPermission::kWebNavigation);
- } else {
- has_permission =
- extension->HasAPIPermission(APIPermission::kTab) ||
- extension->HasAPIPermission(APIPermission::kWebNavigation);
- }
- }
-
- if (has_permission) {
+ 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) {
@@ -154,15 +138,6 @@ DictionaryValue* ExtensionTabUtil::CreateTabValue(
return result;
}
-DictionaryValue* ExtensionTabUtil::CreateTabValueActive(
- const WebContents* contents,
- bool active,
- const extensions::Extension* extension) {
- DictionaryValue* result = CreateTabValue(contents, extension);
- result->SetBoolean(keys::kSelectedKey, active);
- return result;
-}
-
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