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 "components/content_settings/core/common/content_settings_pattern.h" | 5 #include "components/content_settings/core/common/content_settings_pattern.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 if (parts_.is_scheme_wildcard) | 607 if (parts_.is_scheme_wildcard) |
608 return SCHEME_WILDCARD; | 608 return SCHEME_WILDCARD; |
609 | 609 |
610 for (size_t i = 2; i < arraysize(kSchemeNames); ++i) { | 610 for (size_t i = 2; i < arraysize(kSchemeNames); ++i) { |
611 if (parts_.scheme == kSchemeNames[i]) | 611 if (parts_.scheme == kSchemeNames[i]) |
612 return static_cast<SchemeType>(i); | 612 return static_cast<SchemeType>(i); |
613 } | 613 } |
614 return SCHEME_OTHER; | 614 return SCHEME_OTHER; |
615 } | 615 } |
616 | 616 |
| 617 bool ContentSettingsPattern::HasPath() const { |
| 618 DCHECK_EQ(GetScheme(), SCHEME_FILE); |
| 619 return !parts_.is_path_wildcard && !parts_.path.empty(); |
| 620 } |
| 621 |
617 ContentSettingsPattern::Relation ContentSettingsPattern::Compare( | 622 ContentSettingsPattern::Relation ContentSettingsPattern::Compare( |
618 const ContentSettingsPattern& other) const { | 623 const ContentSettingsPattern& other) const { |
619 // Two invalid patterns are identical in the way they behave. They don't match | 624 // Two invalid patterns are identical in the way they behave. They don't match |
620 // anything and are represented as an empty string. So it's fair to treat them | 625 // anything and are represented as an empty string. So it's fair to treat them |
621 // as identical. | 626 // as identical. |
622 if ((this == &other) || | 627 if ((this == &other) || |
623 (!is_valid_ && !other.is_valid_)) | 628 (!is_valid_ && !other.is_valid_)) |
624 return IDENTITY; | 629 return IDENTITY; |
625 | 630 |
626 if (!is_valid_ && other.is_valid_) | 631 if (!is_valid_ && other.is_valid_) |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 if (!parts.is_path_wildcard && other_parts.is_path_wildcard) | 820 if (!parts.is_path_wildcard && other_parts.is_path_wildcard) |
816 return ContentSettingsPattern::PREDECESSOR; | 821 return ContentSettingsPattern::PREDECESSOR; |
817 | 822 |
818 int result = parts.path.compare(other_parts.path); | 823 int result = parts.path.compare(other_parts.path); |
819 if (result == 0) | 824 if (result == 0) |
820 return ContentSettingsPattern::IDENTITY; | 825 return ContentSettingsPattern::IDENTITY; |
821 if (result > 0) | 826 if (result > 0) |
822 return ContentSettingsPattern::DISJOINT_ORDER_PRE; | 827 return ContentSettingsPattern::DISJOINT_ORDER_PRE; |
823 return ContentSettingsPattern::DISJOINT_ORDER_POST; | 828 return ContentSettingsPattern::DISJOINT_ORDER_POST; |
824 } | 829 } |
OLD | NEW |