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/proxy/proxy_script_decider.h" | 5 #include "net/proxy/proxy_script_decider.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 bool LooksLikePacScript(const base::string16& script) { | 26 bool LooksLikePacScript(const base::string16& script) { |
27 // Note: this is only an approximation! It may not always work correctly, | 27 // Note: this is only an approximation! It may not always work correctly, |
28 // however it is very likely that legitimate scripts have this exact string, | 28 // however it is very likely that legitimate scripts have this exact string, |
29 // since they must minimally define a function of this name. Conversely, a | 29 // since they must minimally define a function of this name. Conversely, a |
30 // file not containing the string is not likely to be a PAC script. | 30 // file not containing the string is not likely to be a PAC script. |
31 // | 31 // |
32 // An exact test would have to load the script in a javascript evaluator. | 32 // An exact test would have to load the script in a javascript evaluator. |
33 return script.find(ASCIIToUTF16("FindProxyForURL")) != base::string16::npos; | 33 return script.find(base::ASCIIToUTF16("FindProxyForURL")) != |
| 34 base::string16::npos; |
34 } | 35 } |
35 | 36 |
36 } | 37 } |
37 | 38 |
38 // This is the hard-coded location used by the DNS portion of web proxy | 39 // This is the hard-coded location used by the DNS portion of web proxy |
39 // auto-discovery. | 40 // auto-discovery. |
40 // | 41 // |
41 // Note that we not use DNS devolution to find the WPAD host, since that could | 42 // Note that we not use DNS devolution to find the WPAD host, since that could |
42 // be dangerous should our top level domain registry become out of date. | 43 // be dangerous should our top level domain registry become out of date. |
43 // | 44 // |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 } | 473 } |
473 | 474 |
474 // This is safe to call in any state. | 475 // This is safe to call in any state. |
475 if (dhcp_proxy_script_fetcher_) | 476 if (dhcp_proxy_script_fetcher_) |
476 dhcp_proxy_script_fetcher_->Cancel(); | 477 dhcp_proxy_script_fetcher_->Cancel(); |
477 | 478 |
478 DidComplete(); | 479 DidComplete(); |
479 } | 480 } |
480 | 481 |
481 } // namespace net | 482 } // namespace net |
OLD | NEW |