| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/intranet_redirect_detector.h" | 5 #include "chrome/browser/intranet_redirect_detector.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
| 9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // static | 49 // static |
| 50 GURL IntranetRedirectDetector::RedirectOrigin() { | 50 GURL IntranetRedirectDetector::RedirectOrigin() { |
| 51 const IntranetRedirectDetector* const detector = | 51 const IntranetRedirectDetector* const detector = |
| 52 g_browser_process->intranet_redirect_detector(); | 52 g_browser_process->intranet_redirect_detector(); |
| 53 return detector ? detector->redirect_origin_ : GURL(); | 53 return detector ? detector->redirect_origin_ : GURL(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // static | 56 // static |
| 57 void IntranetRedirectDetector::RegisterPrefs(PrefService* prefs) { | 57 void IntranetRedirectDetector::RegisterPrefs(PrefService* prefs) { |
| 58 prefs->RegisterStringPref(prefs::kLastKnownIntranetRedirectOrigin, | 58 prefs->RegisterStringPref(prefs::kLastKnownIntranetRedirectOrigin, |
| 59 std::string()); | 59 std::string(), |
| 60 false /* don't sync pref */); |
| 60 } | 61 } |
| 61 | 62 |
| 62 void IntranetRedirectDetector::FinishSleep() { | 63 void IntranetRedirectDetector::FinishSleep() { |
| 63 in_sleep_ = false; | 64 in_sleep_ = false; |
| 64 | 65 |
| 65 // If another fetch operation is still running, cancel it. | 66 // If another fetch operation is still running, cancel it. |
| 66 STLDeleteElements(&fetchers_); | 67 STLDeleteElements(&fetchers_); |
| 67 resulting_origins_.clear(); | 68 resulting_origins_.clear(); |
| 68 | 69 |
| 69 // The detector is not needed in Chrome Frame since we have no omnibox there. | 70 // The detector is not needed in Chrome Frame since we have no omnibox there. |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // the same thread. So just use the heuristic that any all-lowercase a-z | 175 // the same thread. So just use the heuristic that any all-lowercase a-z |
| 175 // hostname with the right number of characters is likely from the detector | 176 // hostname with the right number of characters is likely from the detector |
| 176 // (and thus should be blocked). | 177 // (and thus should be blocked). |
| 177 return ((host.length() == IntranetRedirectDetector::kNumCharsInHostnames) && | 178 return ((host.length() == IntranetRedirectDetector::kNumCharsInHostnames) && |
| 178 (host.find_first_not_of("abcdefghijklmnopqrstuvwxyz") == | 179 (host.find_first_not_of("abcdefghijklmnopqrstuvwxyz") == |
| 179 std::string::npos)) ? | 180 std::string::npos)) ? |
| 180 net::ERR_NAME_NOT_RESOLVED : | 181 net::ERR_NAME_NOT_RESOLVED : |
| 181 ResolveUsingPrevious(host, address_family, host_resolver_flags, addrlist, | 182 ResolveUsingPrevious(host, address_family, host_resolver_flags, addrlist, |
| 182 os_error); | 183 os_error); |
| 183 } | 184 } |
| OLD | NEW |