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

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 comment + git cl format 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
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..ea24e1f74d91ba87af2731589bc707ed8917f3ad 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() &&
- !base::MatchPattern(web_contents->GetTitle(),
- base::UTF8ToUTF16(title)))
- continue;
+ 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(
Devlin 2016/01/20 18:15:40 nitty nit: I find this slightly more readable as:
lazyboy 2016/01/20 19:12:29 Done.
+ ExtensionTabUtil::GetTabId(web_contents),
+ APIPermission::kTab) ||
+ extension_->permissions_data()->HasHostPermission(
+ web_contents->GetURL())) {
+ if (!title.empty() &&
+ !base::MatchPattern(web_contents->GetTitle(),
+ base::UTF8ToUTF16(title))) {
+ continue;
+ }
- if (!url_patterns.is_empty() &&
- !url_patterns.MatchesURL(web_contents->GetURL()))
+ if (!url_patterns.is_empty() &&
+ !url_patterns.MatchesURL(web_contents->GetURL())) {
+ continue;
+ }
+ } else {
continue;
+ }
}
if (loading_status_set && loading != web_contents->IsLoading())

Powered by Google App Engine
This is Rietveld 408576698