Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: components/content_settings/core/common/content_settings_pattern.cc

Issue 518803009: Move content_settings_pattern and content_settings_pattern_parser to the content_settings component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/content_settings/core/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/strings/string_split.h" 10 #include "base/strings/string_split.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "chrome/common/content_settings_pattern_parser.h" 12 #include "components/content_settings/core/common/content_settings_pattern_parse r.h"
13 #include "net/base/dns_util.h" 13 #include "net/base/dns_util.h"
14 #include "net/base/net_util.h" 14 #include "net/base/net_util.h"
15 #include "url/gurl.h" 15 #include "url/gurl.h"
16 16
17 namespace { 17 namespace {
18 18
19 // The component supports only one scheme for simplicity. 19 // The component supports only one scheme for simplicity.
20 const char* non_port_non_domain_wildcard_scheme = NULL; 20 const char* non_port_non_domain_wildcard_scheme = NULL;
21 21
22 std::string GetDefaultPort(const std::string& scheme) { 22 std::string GetDefaultPort(const std::string& scheme) {
(...skipping 23 matching lines...) Expand all
46 } 46 }
47 47
48 // Compares two domain names. 48 // Compares two domain names.
49 int CompareDomainNames(const std::string& str1, const std::string& str2) { 49 int CompareDomainNames(const std::string& str1, const std::string& str2) {
50 std::vector<std::string> domain_name1; 50 std::vector<std::string> domain_name1;
51 std::vector<std::string> domain_name2; 51 std::vector<std::string> domain_name2;
52 52
53 base::SplitString(str1, '.', &domain_name1); 53 base::SplitString(str1, '.', &domain_name1);
54 base::SplitString(str2, '.', &domain_name2); 54 base::SplitString(str2, '.', &domain_name2);
55 55
56 int i1 = domain_name1.size() - 1; 56 int i1 = static_cast<int>(domain_name1.size()) - 1;
57 int i2 = domain_name2.size() - 1; 57 int i2 = static_cast<int>(domain_name2.size()) - 1;
58 int rv; 58 int rv;
59 while (i1 >= 0 && i2 >= 0) { 59 while (i1 >= 0 && i2 >= 0) {
60 // domain names are stored in puny code. So it's fine to use the compare 60 // domain names are stored in puny code. So it's fine to use the compare
61 // method. 61 // method.
62 rv = domain_name1[i1].compare(domain_name2[i2]); 62 rv = domain_name1[i1].compare(domain_name2[i2]);
63 if (rv != 0) 63 if (rv != 0)
64 return rv; 64 return rv;
65 --i1; 65 --i1;
66 --i2; 66 --i2;
67 } 67 }
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 if (!parts.is_port_wildcard && other_parts.is_port_wildcard) 702 if (!parts.is_port_wildcard && other_parts.is_port_wildcard)
703 return ContentSettingsPattern::PREDECESSOR; 703 return ContentSettingsPattern::PREDECESSOR;
704 704
705 int result = parts.port.compare(other_parts.port); 705 int result = parts.port.compare(other_parts.port);
706 if (result == 0) 706 if (result == 0)
707 return ContentSettingsPattern::IDENTITY; 707 return ContentSettingsPattern::IDENTITY;
708 if (result > 0) 708 if (result > 0)
709 return ContentSettingsPattern::DISJOINT_ORDER_PRE; 709 return ContentSettingsPattern::DISJOINT_ORDER_PRE;
710 return ContentSettingsPattern::DISJOINT_ORDER_POST; 710 return ContentSettingsPattern::DISJOINT_ORDER_POST;
711 } 711 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698