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

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

Issue 1600553006: chrome.tabs.query: Allow extensions with host permission to see tabs of that host. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix mistake while addressing comments Created 4 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/tabs/tabs_api_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/tabs/tabs_api.cc
diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc
index a1176106d3158048a3183e4271ae5551fbd71235..96158152da3da72f1a87aec88a1463bd103fa49e 100644
--- a/chrome/browser/extensions/api/tabs/tabs_api.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_api.cc
@@ -988,19 +988,29 @@ bool TabsQueryFunction::RunSync() {
continue;
}
- // "title" and "url" properties are considered privileged data and can
- // only be checked if the extension has the "tabs" permission. Otherwise,
- // these properties are ignored.
- if (extension_->permissions_data()->HasAPIPermissionForTab(
- ExtensionTabUtil::GetTabId(web_contents), APIPermission::kTab)) {
+ if (!title.empty() || !url_patterns.is_empty()) {
+ // "title" and "url" properties are considered privileged data and can
+ // only be checked if the extension has the "tabs" permission or it has
+ // access to the WebContents's origin. Otherwise, this tab is considered
+ // not matched.
+ if (!extension_->permissions_data()->HasAPIPermissionForTab(
+ ExtensionTabUtil::GetTabId(web_contents),
+ APIPermission::kTab) &&
+ !extension_->permissions_data()->HasHostPermission(
+ web_contents->GetURL())) {
+ continue;
+ }
+
if (!title.empty() &&
!base::MatchPattern(web_contents->GetTitle(),
- base::UTF8ToUTF16(title)))
+ base::UTF8ToUTF16(title))) {
continue;
+ }
if (!url_patterns.is_empty() &&
- !url_patterns.MatchesURL(web_contents->GetURL()))
+ !url_patterns.MatchesURL(web_contents->GetURL())) {
continue;
+ }
}
if (loading_status_set && loading != web_contents->IsLoading())
« no previous file with comments | « no previous file | chrome/browser/extensions/api/tabs/tabs_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698