| 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" |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 } | 471 } |
| 472 | 472 |
| 473 if (!parts_.is_port_wildcard && | 473 if (!parts_.is_port_wildcard && |
| 474 parts_.port != port ) { | 474 parts_.port != port ) { |
| 475 return false; | 475 return false; |
| 476 } | 476 } |
| 477 | 477 |
| 478 return true; | 478 return true; |
| 479 } | 479 } |
| 480 | 480 |
| 481 bool ContentSettingsPattern::MatchesAllHosts() const { |
| 482 return parts_.has_domain_wildcard && parts_.host.empty(); |
| 483 } |
| 484 |
| 481 const std::string ContentSettingsPattern::ToString() const { | 485 const std::string ContentSettingsPattern::ToString() const { |
| 482 if (IsValid()) | 486 if (IsValid()) |
| 483 return content_settings::PatternParser::ToString(parts_); | 487 return content_settings::PatternParser::ToString(parts_); |
| 484 else | 488 else |
| 485 return ""; | 489 return ""; |
| 486 } | 490 } |
| 487 | 491 |
| 488 ContentSettingsPattern::Relation ContentSettingsPattern::Compare( | 492 ContentSettingsPattern::Relation ContentSettingsPattern::Compare( |
| 489 const ContentSettingsPattern& other) const { | 493 const ContentSettingsPattern& other) const { |
| 490 // Two invalid patterns are identical in the way they behave. They don't match | 494 // Two invalid patterns are identical in the way they behave. They don't match |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 if (!parts.is_port_wildcard && other_parts.is_port_wildcard) | 659 if (!parts.is_port_wildcard && other_parts.is_port_wildcard) |
| 656 return ContentSettingsPattern::PREDECESSOR; | 660 return ContentSettingsPattern::PREDECESSOR; |
| 657 | 661 |
| 658 int result = parts.port.compare(other_parts.port); | 662 int result = parts.port.compare(other_parts.port); |
| 659 if (result == 0) | 663 if (result == 0) |
| 660 return ContentSettingsPattern::IDENTITY; | 664 return ContentSettingsPattern::IDENTITY; |
| 661 if (result > 0) | 665 if (result > 0) |
| 662 return ContentSettingsPattern::DISJOINT_ORDER_PRE; | 666 return ContentSettingsPattern::DISJOINT_ORDER_PRE; |
| 663 return ContentSettingsPattern::DISJOINT_ORDER_POST; | 667 return ContentSettingsPattern::DISJOINT_ORDER_POST; |
| 664 } | 668 } |
| OLD | NEW |