Chromium Code Reviews| 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()) |