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

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

Issue 569803004: Allow "url" to be an array of URL patterns (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update tabs.query documentation Created 6 years, 3 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/common/extensions/api/tabs.json » ('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 a39c477073c746c872e2d7a989415912697ad4ed..6fc19f7cdef1e29dfa4ee88576f58e1d2c908750 100644
--- a/chrome/browser/extensions/api/tabs/tabs_api.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_api.cc
@@ -802,12 +802,21 @@ bool TabsQueryFunction::RunSync() {
bool loading = params->query_info.status ==
tabs::Query::Params::QueryInfo::STATUS_LOADING;
- // It is o.k. to use URLPattern::SCHEME_ALL here because this function does
- // not grant access to the content of the tabs, only to seeing their URLs and
- // meta data.
- URLPattern url_pattern(URLPattern::SCHEME_ALL, "<all_urls>");
- if (params->query_info.url.get())
- url_pattern = URLPattern(URLPattern::SCHEME_ALL, *params->query_info.url);
+ URLPatternSet url_patterns;
+ if (params->query_info.url.get()) {
+ std::vector<std::string> url_pattern_strings;
+ if (params->query_info.url->as_string)
+ url_pattern_strings.push_back(*params->query_info.url->as_string);
+ else if (params->query_info.url->as_strings)
+ url_pattern_strings.swap(*params->query_info.url->as_strings);
+ // It is o.k. to use URLPattern::SCHEME_ALL here because this function does
+ // not grant access to the content of the tabs, only to seeing their URLs
+ // and meta data.
+ if (!url_patterns.Populate(url_pattern_strings, URLPattern::SCHEME_ALL,
+ true, &error_)) {
+ return false;
+ }
+ }
std::string title;
if (params->query_info.title.get())
@@ -893,7 +902,8 @@ bool TabsQueryFunction::RunSync() {
base::UTF8ToUTF16(title)))
continue;
- if (!url_pattern.MatchesURL(web_contents->GetURL()))
+ if (!url_patterns.is_empty() &&
+ !url_patterns.MatchesURL(web_contents->GetURL()))
continue;
if (loading_status_set && loading != web_contents->IsLoading())
« no previous file with comments | « no previous file | chrome/common/extensions/api/tabs.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698