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

Unified Diff: chrome/browser/extensions/api/tabs/tabs.cc

Issue 10829186: Tabs API is usable without tabs permission. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fixed failing browser/api tests Created 8 years, 4 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/api/tabs/tabs.cc
diff --git a/chrome/browser/extensions/api/tabs/tabs.cc b/chrome/browser/extensions/api/tabs/tabs.cc
index 73749424f4cd4381b1edeec9df148fb692417f45..39183623e73a3fb86b362a09a980fdd04ebd3a77 100644
--- a/chrome/browser/extensions/api/tabs/tabs.cc
+++ b/chrome/browser/extensions/api/tabs/tabs.cc
@@ -819,9 +819,13 @@ bool GetSelectedTabFunction::RunImpl() {
error_ = keys::kNoSelectedTabError;
return false;
}
- SetResult(ExtensionTabUtil::CreateTabValue(contents->web_contents(),
- tab_strip,
- tab_strip->active_index()));
+ DictionaryValue* result = ExtensionTabUtil::CreateTabValue(
Aaron Boodman 2012/08/10 06:44:51 Can we pass Extension* into CreateTabValue and let
chebert 2012/08/13 23:52:17 An overloaded version is called from the MenuManag
+ contents->web_contents(),
+ tab_strip,
+ tab_strip->active_index());
+ if (!GetExtension()->HasAPIPermission(extensions::APIPermission::kTab))
+ ExtensionTabUtil::StripTabOfSensitiveData(result);
+ SetResult(result);
return true;
}
@@ -945,8 +949,11 @@ bool QueryTabsFunction::RunImpl() {
if (!MatchesQueryArg(loading, web_contents->IsLoading()))
continue;
- result->Append(ExtensionTabUtil::CreateTabValue(
- web_contents, tab_strip, i));
+ DictionaryValue* tab = ExtensionTabUtil::CreateTabValue(
+ web_contents, tab_strip, i);
+ if (!GetExtension()->HasAPIPermission(extensions::APIPermission::kTab))
+ ExtensionTabUtil::StripTabOfSensitiveData(tab);
+ result->Append(tab);
}
}
@@ -1081,9 +1088,12 @@ bool CreateTabFunction::RunImpl() {
// Return data about the newly created tab.
if (has_callback()) {
- SetResult(ExtensionTabUtil::CreateTabValue(
+ DictionaryValue* result = ExtensionTabUtil::CreateTabValue(
params.target_contents->web_contents(),
- tab_strip, new_index));
+ tab_strip, new_index);
+ if (!GetExtension()->HasAPIPermission(extensions::APIPermission::kTab))
+ ExtensionTabUtil::StripTabOfSensitiveData(result);
+ SetResult(result);
}
return true;
@@ -1100,9 +1110,13 @@ bool GetTabFunction::RunImpl() {
NULL, &tab_strip, &contents, &tab_index, &error_))
return false;
- SetResult(ExtensionTabUtil::CreateTabValue(contents->web_contents(),
- tab_strip,
- tab_index));
+ DictionaryValue* result = ExtensionTabUtil::CreateTabValue(
+ contents->web_contents(),
+ tab_strip,
+ tab_index);
+ if (!GetExtension()->HasAPIPermission(extensions::APIPermission::kTab))
+ ExtensionTabUtil::StripTabOfSensitiveData(result);
+ SetResult(result);
return true;
}
@@ -1110,8 +1124,12 @@ bool GetCurrentTabFunction::RunImpl() {
DCHECK(dispatcher());
WebContents* contents = dispatcher()->delegate()->GetAssociatedWebContents();
- if (contents)
- SetResult(ExtensionTabUtil::CreateTabValue(contents));
+ if (contents) {
+ DictionaryValue* result = ExtensionTabUtil::CreateTabValue(contents);
+ if (!GetExtension()->HasAPIPermission(extensions::APIPermission::kTab))
+ ExtensionTabUtil::StripTabOfSensitiveData(result);
+ SetResult(result);
+ }
return true;
}
@@ -1340,11 +1358,11 @@ void UpdateTabFunction::PopulateResult() {
if (!has_callback())
return;
- if (GetExtension()->HasAPIPermission(extensions::APIPermission::kTab)) {
- SetResult(ExtensionTabUtil::CreateTabValue(tab_contents_->web_contents()));
- } else {
- SetResult(Value::CreateNullValue());
- }
+ DictionaryValue* result = ExtensionTabUtil::CreateTabValue(
+ tab_contents_->web_contents());
+ if (!GetExtension()->HasAPIPermission(extensions::APIPermission::kTab))
+ ExtensionTabUtil::StripTabOfSensitiveData(result);
+ SetResult(result);
}
void UpdateTabFunction::OnExecuteCodeFinished(bool success,
@@ -1439,9 +1457,15 @@ bool MoveTabsFunction::RunImpl() {
target_tab_strip->InsertTabContentsAt(
new_index, contents, TabStripModel::ADD_NONE);
- if (has_callback())
- tab_values.Append(ExtensionTabUtil::CreateTabValue(
- contents->web_contents(), target_tab_strip, new_index));
+ if (has_callback()) {
+ DictionaryValue* result = ExtensionTabUtil::CreateTabValue(
+ contents->web_contents(), target_tab_strip, new_index);
+ if (!GetExtension()->HasAPIPermission(
+ extensions::APIPermission::kTab)) {
+ ExtensionTabUtil::StripTabOfSensitiveData(result);
+ }
+ tab_values.Append(result);
+ }
continue;
}
@@ -1457,9 +1481,13 @@ bool MoveTabsFunction::RunImpl() {
if (new_index != tab_index)
source_tab_strip->MoveTabContentsAt(tab_index, new_index, false);
- if (has_callback())
- tab_values.Append(ExtensionTabUtil::CreateTabValue(
- contents->web_contents(), source_tab_strip, new_index));
+ if (has_callback()) {
+ DictionaryValue* result = ExtensionTabUtil::CreateTabValue(
+ contents->web_contents(), source_tab_strip, new_index);
+ if (!GetExtension()->HasAPIPermission(extensions::APIPermission::kTab))
+ ExtensionTabUtil::StripTabOfSensitiveData(result);
+ tab_values.Append(result);
+ }
}
if (!has_callback())
« no previous file with comments | « no previous file | chrome/browser/extensions/api/tabs/tabs_test.cc » ('j') | chrome/common/extensions/permissions/permission_set.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698