OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/proxy/dhcp_proxy_script_fetcher_factory.h" |
| 6 |
| 7 #include "net/base/net_errors.h" |
| 8 #include "net/proxy/dhcp_proxy_script_fetcher.h" |
| 9 |
| 10 #if defined(OS_WIN) |
| 11 #include "net/proxy/dhcp_proxy_script_fetcher_win.h" |
| 12 #endif |
| 13 |
| 14 namespace net { |
| 15 |
| 16 DhcpProxyScriptFetcherFactory::DhcpProxyScriptFetcherFactory() { |
| 17 // TODO(joi): Change this default, and the comment on |set_enabled()|, |
| 18 // when the time is right. |
| 19 set_enabled(false); |
| 20 } |
| 21 |
| 22 DhcpProxyScriptFetcher* DhcpProxyScriptFetcherFactory::Create( |
| 23 URLRequestContext* context) { |
| 24 if (!feature_enabled_) { |
| 25 return new DoNothingDhcpProxyScriptFetcher(); |
| 26 } else { |
| 27 DCHECK(IsSupported()); |
| 28 DhcpProxyScriptFetcher* ret = NULL; |
| 29 #if defined(OS_WIN) |
| 30 ret = new WindowsDhcpProxyScriptFetcher(context); |
| 31 #endif |
| 32 DCHECK(ret); |
| 33 return ret; |
| 34 } |
| 35 } |
| 36 |
| 37 void DhcpProxyScriptFetcherFactory::set_enabled(bool enabled) { |
| 38 if (IsSupported()) { |
| 39 feature_enabled_ = enabled; |
| 40 } |
| 41 } |
| 42 |
| 43 bool DhcpProxyScriptFetcherFactory::enabled() const { |
| 44 return feature_enabled_; |
| 45 } |
| 46 |
| 47 // static |
| 48 bool DhcpProxyScriptFetcherFactory::IsSupported() { |
| 49 #if defined(OS_WIN) |
| 50 return true; |
| 51 #else |
| 52 return false; |
| 53 #endif |
| 54 } |
| 55 |
| 56 } // namespace net |
OLD | NEW |