OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/google/core/browser/google_url_tracker.h" | 5 #include "components/google/core/browser/google_url_tracker.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // Don't update the URL if the request didn't succeed. | 90 // Don't update the URL if the request didn't succeed. |
91 if (!source->GetStatus().is_success() || (source->GetResponseCode() != 200)) { | 91 if (!source->GetStatus().is_success() || (source->GetResponseCode() != 200)) { |
92 already_fetched_ = false; | 92 already_fetched_ = false; |
93 return; | 93 return; |
94 } | 94 } |
95 | 95 |
96 // See if the response data was valid. It should be ".google.<TLD>". | 96 // See if the response data was valid. It should be ".google.<TLD>". |
97 std::string url_str; | 97 std::string url_str; |
98 source->GetResponseAsString(&url_str); | 98 source->GetResponseAsString(&url_str); |
99 base::TrimWhitespace(url_str, base::TRIM_ALL, &url_str); | 99 base::TrimWhitespace(url_str, base::TRIM_ALL, &url_str); |
100 if (!base::StartsWithASCII(url_str, ".google.", false)) | 100 if (!base::StartsWith(url_str, ".google.", |
| 101 base::CompareCase::INSENSITIVE_ASCII)) |
101 return; | 102 return; |
102 GURL url("https://www" + url_str); | 103 GURL url("https://www" + url_str); |
103 if (!url.is_valid() || (url.path().length() > 1) || url.has_query() || | 104 if (!url.is_valid() || (url.path().length() > 1) || url.has_query() || |
104 url.has_ref() || | 105 url.has_ref() || |
105 !google_util::IsGoogleDomainUrl(url, google_util::DISALLOW_SUBDOMAIN, | 106 !google_util::IsGoogleDomainUrl(url, google_util::DISALLOW_SUBDOMAIN, |
106 google_util::DISALLOW_NON_STANDARD_PORTS)) | 107 google_util::DISALLOW_NON_STANDARD_PORTS)) |
107 return; | 108 return; |
108 | 109 |
109 if (url != google_url_) { | 110 if (url != google_url_) { |
110 google_url_ = url; | 111 google_url_ = url; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // Also retry kMaxRetries times on network change errors. A network change can | 177 // Also retry kMaxRetries times on network change errors. A network change can |
177 // propagate through Chrome in various stages, so it's possible for this code | 178 // propagate through Chrome in various stages, so it's possible for this code |
178 // to be reached via OnNetworkChanged(), and then have the fetch we kick off | 179 // to be reached via OnNetworkChanged(), and then have the fetch we kick off |
179 // be canceled due to e.g. the DNS server changing at a later time. In general | 180 // be canceled due to e.g. the DNS server changing at a later time. In general |
180 // it's not possible to ensure that by the time we reach here any requests we | 181 // it's not possible to ensure that by the time we reach here any requests we |
181 // start won't be canceled in this fashion, so retrying is the best we can do. | 182 // start won't be canceled in this fashion, so retrying is the best we can do. |
182 fetcher_->SetAutomaticallyRetryOnNetworkChanges(kMaxRetries); | 183 fetcher_->SetAutomaticallyRetryOnNetworkChanges(kMaxRetries); |
183 | 184 |
184 fetcher_->Start(); | 185 fetcher_->Start(); |
185 } | 186 } |
OLD | NEW |