OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/common/permissions/permission_message_util.h" | 5 #include "extensions/common/permissions/permission_message_util.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "content/public/common/url_constants.h" | 9 #include "content/public/common/url_constants.h" |
10 #include "extensions/common/permissions/permission_message.h" | 10 #include "extensions/common/permissions/permission_message.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 bool include_rcd, | 95 bool include_rcd, |
96 bool exclude_file_scheme) { | 96 bool exclude_file_scheme) { |
97 // Use a vector to preserve order (also faster than a map on small sets). | 97 // Use a vector to preserve order (also faster than a map on small sets). |
98 // Each item is a host split into two parts: host without RCDs and | 98 // Each item is a host split into two parts: host without RCDs and |
99 // current best RCD. | 99 // current best RCD. |
100 typedef std::vector<std::pair<std::string, std::string> > HostVector; | 100 typedef std::vector<std::pair<std::string, std::string> > HostVector; |
101 HostVector hosts_best_rcd; | 101 HostVector hosts_best_rcd; |
102 for (URLPatternSet::const_iterator i = host_patterns.begin(); | 102 for (URLPatternSet::const_iterator i = host_patterns.begin(); |
103 i != host_patterns.end(); | 103 i != host_patterns.end(); |
104 ++i) { | 104 ++i) { |
105 if (exclude_file_scheme && i->scheme() == content::kFileScheme) | 105 if (exclude_file_scheme && i->scheme() == url::kFileScheme) |
106 continue; | 106 continue; |
107 | 107 |
108 std::string host = i->host(); | 108 std::string host = i->host(); |
109 | 109 |
110 // Add the subdomain wildcard back to the host, if necessary. | 110 // Add the subdomain wildcard back to the host, if necessary. |
111 if (i->match_subdomains()) | 111 if (i->match_subdomains()) |
112 host = "*." + host; | 112 host = "*." + host; |
113 | 113 |
114 // If the host has an RCD, split it off so we can detect duplicates. | 114 // If the host has an RCD, split it off so we can detect duplicates. |
115 std::string rcd; | 115 std::string rcd; |
(...skipping 25 matching lines...) Expand all Loading... |
141 // Build up the final vector by concatenating hosts and RCDs. | 141 // Build up the final vector by concatenating hosts and RCDs. |
142 std::set<std::string> distinct_hosts; | 142 std::set<std::string> distinct_hosts; |
143 for (HostVector::iterator it = hosts_best_rcd.begin(); | 143 for (HostVector::iterator it = hosts_best_rcd.begin(); |
144 it != hosts_best_rcd.end(); | 144 it != hosts_best_rcd.end(); |
145 ++it) | 145 ++it) |
146 distinct_hosts.insert(it->first + it->second); | 146 distinct_hosts.insert(it->first + it->second); |
147 return distinct_hosts; | 147 return distinct_hosts; |
148 } | 148 } |
149 | 149 |
150 } // namespace permission_message_util | 150 } // namespace permission_message_util |
OLD | NEW |