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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/common/extensions/api/tabs.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/tabs/tabs_api.h" 5 #include "chrome/browser/extensions/api/tabs/tabs_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 795
796 bool TabsQueryFunction::RunSync() { 796 bool TabsQueryFunction::RunSync() {
797 scoped_ptr<tabs::Query::Params> params(tabs::Query::Params::Create(*args_)); 797 scoped_ptr<tabs::Query::Params> params(tabs::Query::Params::Create(*args_));
798 EXTENSION_FUNCTION_VALIDATE(params.get()); 798 EXTENSION_FUNCTION_VALIDATE(params.get());
799 799
800 bool loading_status_set = params->query_info.status != 800 bool loading_status_set = params->query_info.status !=
801 tabs::Query::Params::QueryInfo::STATUS_NONE; 801 tabs::Query::Params::QueryInfo::STATUS_NONE;
802 bool loading = params->query_info.status == 802 bool loading = params->query_info.status ==
803 tabs::Query::Params::QueryInfo::STATUS_LOADING; 803 tabs::Query::Params::QueryInfo::STATUS_LOADING;
804 804
805 // It is o.k. to use URLPattern::SCHEME_ALL here because this function does 805 URLPatternSet url_patterns;
806 // not grant access to the content of the tabs, only to seeing their URLs and 806 if (params->query_info.url.get()) {
807 // meta data. 807 std::vector<std::string> url_pattern_strings;
808 URLPattern url_pattern(URLPattern::SCHEME_ALL, "<all_urls>"); 808 if (params->query_info.url->as_string)
809 if (params->query_info.url.get()) 809 url_pattern_strings.push_back(*params->query_info.url->as_string);
810 url_pattern = URLPattern(URLPattern::SCHEME_ALL, *params->query_info.url); 810 else if (params->query_info.url->as_strings)
811 url_pattern_strings.swap(*params->query_info.url->as_strings);
812 // It is o.k. to use URLPattern::SCHEME_ALL here because this function does
813 // not grant access to the content of the tabs, only to seeing their URLs
814 // and meta data.
815 if (!url_patterns.Populate(url_pattern_strings, URLPattern::SCHEME_ALL,
816 true, &error_)) {
817 return false;
818 }
819 }
811 820
812 std::string title; 821 std::string title;
813 if (params->query_info.title.get()) 822 if (params->query_info.title.get())
814 title = *params->query_info.title; 823 title = *params->query_info.title;
815 824
816 int window_id = extension_misc::kUnknownWindowId; 825 int window_id = extension_misc::kUnknownWindowId;
817 if (params->query_info.window_id.get()) 826 if (params->query_info.window_id.get())
818 window_id = *params->query_info.window_id; 827 window_id = *params->query_info.window_id;
819 828
820 int index = -1; 829 int index = -1;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 895
887 if (!MatchesBool(params->query_info.pinned.get(), 896 if (!MatchesBool(params->query_info.pinned.get(),
888 tab_strip->IsTabPinned(i))) { 897 tab_strip->IsTabPinned(i))) {
889 continue; 898 continue;
890 } 899 }
891 900
892 if (!title.empty() && !MatchPattern(web_contents->GetTitle(), 901 if (!title.empty() && !MatchPattern(web_contents->GetTitle(),
893 base::UTF8ToUTF16(title))) 902 base::UTF8ToUTF16(title)))
894 continue; 903 continue;
895 904
896 if (!url_pattern.MatchesURL(web_contents->GetURL())) 905 if (!url_patterns.is_empty() &&
906 !url_patterns.MatchesURL(web_contents->GetURL()))
897 continue; 907 continue;
898 908
899 if (loading_status_set && loading != web_contents->IsLoading()) 909 if (loading_status_set && loading != web_contents->IsLoading())
900 continue; 910 continue;
901 911
902 result->Append(ExtensionTabUtil::CreateTabValue( 912 result->Append(ExtensionTabUtil::CreateTabValue(
903 web_contents, tab_strip, i, extension())); 913 web_contents, tab_strip, i, extension()));
904 } 914 }
905 } 915 }
906 916
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 ZoomController::ZoomMode zoom_mode = zoom_controller->zoom_mode(); 1925 ZoomController::ZoomMode zoom_mode = zoom_controller->zoom_mode();
1916 api::tabs::ZoomSettings zoom_settings; 1926 api::tabs::ZoomSettings zoom_settings;
1917 ZoomModeToZoomSettings(zoom_mode, &zoom_settings); 1927 ZoomModeToZoomSettings(zoom_mode, &zoom_settings);
1918 1928
1919 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); 1929 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings);
1920 SendResponse(true); 1930 SendResponse(true);
1921 return true; 1931 return true;
1922 } 1932 }
1923 1933
1924 } // namespace extensions 1934 } // namespace extensions
OLDNEW
« 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