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

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 sample extensions 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 1eedf6e1e117e336dfeefc958d4d1706f3dcf195..b319fa214afa285412b251d2011d6bfc6756635b 100644
--- a/chrome/browser/extensions/api/tabs/tabs.cc
+++ b/chrome/browser/extensions/api/tabs/tabs.cc
@@ -264,7 +264,7 @@ bool GetWindowFunction::RunImpl() {
return false;
if (populate_tabs)
- SetResult(controller->CreateWindowValueWithTabs());
+ SetResult(controller->CreateWindowValueWithTabs(GetExtension()));
else
SetResult(controller->CreateWindowValue());
return true;
@@ -285,7 +285,7 @@ bool GetCurrentWindowFunction::RunImpl() {
return false;
}
if (populate_tabs)
- SetResult(controller->CreateWindowValueWithTabs());
+ SetResult(controller->CreateWindowValueWithTabs(GetExtension()));
else
SetResult(controller->CreateWindowValue());
return true;
@@ -312,7 +312,7 @@ bool GetLastFocusedWindowFunction::RunImpl() {
WindowController* controller =
browser->extension_window_controller();
if (populate_tabs)
- SetResult(controller->CreateWindowValueWithTabs());
+ SetResult(controller->CreateWindowValueWithTabs(GetExtension()));
else
SetResult(controller->CreateWindowValue());
return true;
@@ -335,7 +335,7 @@ bool GetAllWindowsFunction::RunImpl() {
if (!this->CanOperateOnWindow(*iter))
continue;
if (populate_tabs)
- window_list->Append((*iter)->CreateWindowValueWithTabs());
+ window_list->Append((*iter)->CreateWindowValueWithTabs(GetExtension()));
else
window_list->Append((*iter)->CreateWindowValue());
}
@@ -587,7 +587,8 @@ bool CreateWindowFunction::RunImpl() {
panel->Show();
SetResult(
- panel->extension_window_controller()->CreateWindowValueWithTabs());
+ panel->extension_window_controller()->CreateWindowValueWithTabs(
+ GetExtension()));
return true;
}
#endif
@@ -639,7 +640,8 @@ bool CreateWindowFunction::RunImpl() {
SetResult(Value::CreateNullValue());
} else {
SetResult(
- new_window->extension_window_controller()->CreateWindowValueWithTabs());
+ new_window->extension_window_controller()->CreateWindowValueWithTabs(
+ GetExtension()));
}
return true;
@@ -820,7 +822,8 @@ bool GetSelectedTabFunction::RunImpl() {
}
SetResult(ExtensionTabUtil::CreateTabValue(contents->web_contents(),
tab_strip,
- tab_strip->active_index()));
+ tab_strip->active_index(),
+ GetExtension()));
return true;
}
@@ -834,7 +837,7 @@ bool GetAllTabsInWindowFunction::RunImpl() {
if (!GetBrowserFromWindowID(this, window_id, &browser))
return false;
- SetResult(ExtensionTabUtil::CreateTabList(browser));
+ SetResult(ExtensionTabUtil::CreateTabList(browser, GetExtension()));
return true;
}
@@ -945,7 +948,7 @@ bool QueryTabsFunction::RunImpl() {
continue;
result->Append(ExtensionTabUtil::CreateTabValue(
- web_contents, tab_strip, i));
+ web_contents, tab_strip, i, GetExtension()));
}
}
@@ -1082,7 +1085,7 @@ bool CreateTabFunction::RunImpl() {
if (has_callback()) {
SetResult(ExtensionTabUtil::CreateTabValue(
params.target_contents->web_contents(),
- tab_strip, new_index));
+ tab_strip, new_index, GetExtension()));
}
return true;
@@ -1101,7 +1104,8 @@ bool GetTabFunction::RunImpl() {
SetResult(ExtensionTabUtil::CreateTabValue(contents->web_contents(),
tab_strip,
- tab_index));
+ tab_index,
+ GetExtension()));
return true;
}
@@ -1110,7 +1114,7 @@ bool GetCurrentTabFunction::RunImpl() {
WebContents* contents = dispatcher()->delegate()->GetAssociatedWebContents();
if (contents)
- SetResult(ExtensionTabUtil::CreateTabValue(contents));
+ SetResult(ExtensionTabUtil::CreateTabValue(contents, GetExtension()));
return true;
}
@@ -1167,7 +1171,8 @@ bool HighlightTabsFunction::RunImpl() {
selection.set_active(active_index);
browser->tab_strip_model()->SetSelectionFromModel(selection);
SetResult(
- browser->extension_window_controller()->CreateWindowValueWithTabs());
+ browser->extension_window_controller()->CreateWindowValueWithTabs(
+ GetExtension()));
return true;
}
@@ -1343,11 +1348,8 @@ void UpdateTabFunction::PopulateResult() {
if (!has_callback())
return;
- if (GetExtension()->HasAPIPermission(extensions::APIPermission::kTab)) {
- SetResult(ExtensionTabUtil::CreateTabValue(tab_contents_->web_contents()));
- } else {
- SetResult(Value::CreateNullValue());
- }
+ SetResult(ExtensionTabUtil::CreateTabValue(tab_contents_->web_contents(),
+ GetExtension()));
}
void UpdateTabFunction::OnExecuteCodeFinished(const std::string& error,
@@ -1439,9 +1441,13 @@ bool MoveTabsFunction::RunImpl() {
target_tab_strip->InsertTabContentsAt(
new_index, contents, TabStripModel::ADD_NONE);
- if (has_callback())
+ if (has_callback()) {
tab_values.Append(ExtensionTabUtil::CreateTabValue(
- contents->web_contents(), target_tab_strip, new_index));
+ contents->web_contents(),
+ target_tab_strip,
+ new_index,
+ GetExtension()));
+ }
continue;
}
@@ -1457,9 +1463,11 @@ bool MoveTabsFunction::RunImpl() {
if (new_index != tab_index)
source_tab_strip->MoveTabContentsAt(tab_index, new_index, false);
- if (has_callback())
+ if (has_callback()) {
tab_values.Append(ExtensionTabUtil::CreateTabValue(
- contents->web_contents(), source_tab_strip, new_index));
+ contents->web_contents(), source_tab_strip, new_index,
+ GetExtension()));
+ }
}
if (!has_callback())

Powered by Google App Engine
This is Rietveld 408576698