OLD | NEW |
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/common/content_settings_pattern.h" | 5 #include "chrome/common/content_settings_pattern.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "chrome/common/content_settings_pattern_parser.h" | 12 #include "chrome/common/content_settings_pattern_parser.h" |
13 #include "chrome/common/render_messages.h" | 13 #include "chrome/common/render_messages.h" |
14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
15 #include "net/base/dns_util.h" | |
16 #include "net/base/net_util.h" | |
17 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
18 #include "googleurl/src/url_canon.h" | 16 #include "googleurl/src/url_canon.h" |
19 #include "ipc/ipc_message_utils.h" | 17 #include "ipc/ipc_message_utils.h" |
| 18 #include "net/base/dns_util.h" |
| 19 #include "net/base/net_util.h" |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 std::string GetDefaultPort(const std::string& scheme) { | 23 std::string GetDefaultPort(const std::string& scheme) { |
24 if (scheme == chrome::kHttpScheme) | 24 if (scheme == chrome::kHttpScheme) |
25 return "80"; | 25 return "80"; |
26 if (scheme == chrome::kHttpsScheme) | 26 if (scheme == chrome::kHttpsScheme) |
27 return "443"; | 27 return "443"; |
28 return ""; | 28 return ""; |
29 } | 29 } |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 160 |
161 // static | 161 // static |
162 bool ContentSettingsPattern::Builder::Canonicalize(PatternParts* parts) { | 162 bool ContentSettingsPattern::Builder::Canonicalize(PatternParts* parts) { |
163 // Canonicalize the scheme part. | 163 // Canonicalize the scheme part. |
164 const std::string scheme(StringToLowerASCII(parts->scheme)); | 164 const std::string scheme(StringToLowerASCII(parts->scheme)); |
165 parts->scheme = scheme; | 165 parts->scheme = scheme; |
166 | 166 |
167 if (parts->scheme == std::string(chrome::kFileScheme) && | 167 if (parts->scheme == std::string(chrome::kFileScheme) && |
168 !parts->is_path_wildcard) { | 168 !parts->is_path_wildcard) { |
169 GURL url(std::string(chrome::kFileScheme) + | 169 GURL url(std::string(chrome::kFileScheme) + |
170 std::string(chrome::kStandardSchemeSeparator) + parts->path); | 170 std::string(content::kStandardSchemeSeparator) + parts->path); |
171 parts->path = url.path(); | 171 parts->path = url.path(); |
172 } | 172 } |
173 | 173 |
174 // Canonicalize the host part. | 174 // Canonicalize the host part. |
175 const std::string host(parts->host); | 175 const std::string host(parts->host); |
176 url_canon::CanonHostInfo host_info; | 176 url_canon::CanonHostInfo host_info; |
177 std::string canonicalized_host(net::CanonicalizeHost(host, &host_info)); | 177 std::string canonicalized_host(net::CanonicalizeHost(host, &host_info)); |
178 if (host_info.IsIPAddress() && parts->has_domain_wildcard) | 178 if (host_info.IsIPAddress() && parts->has_domain_wildcard) |
179 return false; | 179 return false; |
180 canonicalized_host = net::TrimEndingDot(canonicalized_host); | 180 canonicalized_host = net::TrimEndingDot(canonicalized_host); |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 if (!parts.is_port_wildcard && other_parts.is_port_wildcard) | 655 if (!parts.is_port_wildcard && other_parts.is_port_wildcard) |
656 return ContentSettingsPattern::PREDECESSOR; | 656 return ContentSettingsPattern::PREDECESSOR; |
657 | 657 |
658 int result = parts.port.compare(other_parts.port); | 658 int result = parts.port.compare(other_parts.port); |
659 if (result == 0) | 659 if (result == 0) |
660 return ContentSettingsPattern::IDENTITY; | 660 return ContentSettingsPattern::IDENTITY; |
661 if (result > 0) | 661 if (result > 0) |
662 return ContentSettingsPattern::DISJOINT_ORDER_PRE; | 662 return ContentSettingsPattern::DISJOINT_ORDER_PRE; |
663 return ContentSettingsPattern::DISJOINT_ORDER_POST; | 663 return ContentSettingsPattern::DISJOINT_ORDER_POST; |
664 } | 664 } |
OLD | NEW |