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()) |