| 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 const int ContentSettingsPattern::kContentSettingsPatternVersion = 1; | 367 const int ContentSettingsPattern::kContentSettingsPatternVersion = 1; |
| 368 | 368 |
| 369 // static | 369 // static |
| 370 BuilderInterface* ContentSettingsPattern::CreateBuilder( | 370 BuilderInterface* ContentSettingsPattern::CreateBuilder( |
| 371 bool validate) { | 371 bool validate) { |
| 372 return new Builder(validate); | 372 return new Builder(validate); |
| 373 } | 373 } |
| 374 | 374 |
| 375 // static | 375 // static |
| 376 ContentSettingsPattern ContentSettingsPattern::Wildcard() { | 376 ContentSettingsPattern ContentSettingsPattern::Wildcard() { |
| 377 std::unique_ptr<ContentSettingsPattern::BuilderInterface> builder( | 377 PatternParts parts; |
| 378 ContentSettingsPattern::CreateBuilder(true)); | 378 parts.is_scheme_wildcard = true; |
| 379 builder->WithSchemeWildcard()->WithDomainWildcard()->WithPortWildcard()-> | 379 parts.has_domain_wildcard = true; |
| 380 WithPathWildcard(); | 380 parts.is_port_wildcard = true; |
| 381 return builder->Build(); | 381 parts.is_path_wildcard = true; |
| 382 return ContentSettingsPattern(parts, true); |
| 382 } | 383 } |
| 383 | 384 |
| 384 // static | 385 // static |
| 385 ContentSettingsPattern ContentSettingsPattern::FromURL( | 386 ContentSettingsPattern ContentSettingsPattern::FromURL( |
| 386 const GURL& url) { | 387 const GURL& url) { |
| 387 std::unique_ptr<ContentSettingsPattern::BuilderInterface> builder( | 388 std::unique_ptr<ContentSettingsPattern::BuilderInterface> builder( |
| 388 ContentSettingsPattern::CreateBuilder(false)); | 389 ContentSettingsPattern::CreateBuilder(false)); |
| 389 const GURL* local_url = &url; | 390 const GURL* local_url = &url; |
| 390 if (url.SchemeIsFileSystem() && url.inner_url()) { | 391 if (url.SchemeIsFileSystem() && url.inner_url()) { |
| 391 local_url = url.inner_url(); | 392 local_url = url.inner_url(); |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 if (!parts.is_path_wildcard && other_parts.is_path_wildcard) | 821 if (!parts.is_path_wildcard && other_parts.is_path_wildcard) |
| 821 return ContentSettingsPattern::PREDECESSOR; | 822 return ContentSettingsPattern::PREDECESSOR; |
| 822 | 823 |
| 823 int result = parts.path.compare(other_parts.path); | 824 int result = parts.path.compare(other_parts.path); |
| 824 if (result == 0) | 825 if (result == 0) |
| 825 return ContentSettingsPattern::IDENTITY; | 826 return ContentSettingsPattern::IDENTITY; |
| 826 if (result > 0) | 827 if (result > 0) |
| 827 return ContentSettingsPattern::DISJOINT_ORDER_PRE; | 828 return ContentSettingsPattern::DISJOINT_ORDER_PRE; |
| 828 return ContentSettingsPattern::DISJOINT_ORDER_POST; | 829 return ContentSettingsPattern::DISJOINT_ORDER_POST; |
| 829 } | 830 } |
| OLD | NEW |