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 "net/base/net_util.h" | 5 #include "net/base/net_util.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1024 if (*host.rbegin() == '.') | 1024 if (*host.rbegin() == '.') |
1025 --host_len; | 1025 --host_len; |
1026 if (host_len < kLocalhostTLDLength) | 1026 if (host_len < kLocalhostTLDLength) |
1027 return false; | 1027 return false; |
1028 | 1028 |
1029 const char* host_suffix = host.data() + host_len - kLocalhostTLDLength; | 1029 const char* host_suffix = host.data() + host_len - kLocalhostTLDLength; |
1030 return base::strncasecmp(host_suffix, kLocalhostTLD, kLocalhostTLDLength) == | 1030 return base::strncasecmp(host_suffix, kLocalhostTLD, kLocalhostTLDLength) == |
1031 0; | 1031 0; |
1032 } | 1032 } |
1033 | 1033 |
1034 bool HasGoogleHost(const GURL& url) { | |
1035 static const char* kSuffixesToGoogleHosts[] = { | |
Ryan Hamilton
2015/04/28 04:25:18
nit: kGoogleHostSuffixes ?
ramant (doing other things)
2015/04/28 17:19:16
Done.
| |
1036 ".google.com", | |
1037 ".youtube.com", | |
1038 ".gmail.com", | |
1039 ".doubleclick.net", | |
1040 ".gstatic.com", | |
1041 ".googlevideo.com", | |
1042 ".googleusercontent.com", | |
1043 ".googlesyndication.com", | |
1044 ".google-analytics.com", | |
1045 ".googleadservices.com", | |
1046 ".googleapis.com", | |
1047 ".ytimg.com", | |
1048 }; | |
1049 const std::string& host = url.host(); | |
1050 for (size_t i = 0; i < arraysize(kSuffixesToGoogleHosts); ++i) { | |
Ryan Hamilton
2015/04/28 04:25:18
nit: I think you can do something like:
for (con
ramant (doing other things)
2015/04/28 17:19:16
Done.
| |
1051 if (EndsWith(host, kSuffixesToGoogleHosts[i], false)) | |
1052 return true; | |
1053 } | |
1054 return false; | |
1055 } | |
1056 | |
1034 NetworkInterface::NetworkInterface() | 1057 NetworkInterface::NetworkInterface() |
1035 : type(NetworkChangeNotifier::CONNECTION_UNKNOWN), prefix_length(0) { | 1058 : type(NetworkChangeNotifier::CONNECTION_UNKNOWN), prefix_length(0) { |
1036 } | 1059 } |
1037 | 1060 |
1038 NetworkInterface::NetworkInterface(const std::string& name, | 1061 NetworkInterface::NetworkInterface(const std::string& name, |
1039 const std::string& friendly_name, | 1062 const std::string& friendly_name, |
1040 uint32 interface_index, | 1063 uint32 interface_index, |
1041 NetworkChangeNotifier::ConnectionType type, | 1064 NetworkChangeNotifier::ConnectionType type, |
1042 const IPAddressNumber& address, | 1065 const IPAddressNumber& address, |
1043 uint32 prefix_length, | 1066 uint32 prefix_length, |
(...skipping 29 matching lines...) Expand all Loading... | |
1073 | 1096 |
1074 unsigned MaskPrefixLength(const IPAddressNumber& mask) { | 1097 unsigned MaskPrefixLength(const IPAddressNumber& mask) { |
1075 IPAddressNumber all_ones(mask.size(), 0xFF); | 1098 IPAddressNumber all_ones(mask.size(), 0xFF); |
1076 return CommonPrefixLength(mask, all_ones); | 1099 return CommonPrefixLength(mask, all_ones); |
1077 } | 1100 } |
1078 | 1101 |
1079 ScopedWifiOptions::~ScopedWifiOptions() { | 1102 ScopedWifiOptions::~ScopedWifiOptions() { |
1080 } | 1103 } |
1081 | 1104 |
1082 } // namespace net | 1105 } // namespace net |
OLD | NEW |