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::GetInstance() { |
| 17 return Singleton<DhcpProxyScriptFetcherFactory>::get(); |
| 18 } |
| 19 |
| 20 DhcpProxyScriptFetcher* DhcpProxyScriptFetcherFactory::Create( |
| 21 URLRequestContext* context) const { |
| 22 if (!feature_enabled_) { |
| 23 return new DoNothingDhcpProxyScriptFetcher(); |
| 24 } else { |
| 25 DCHECK(IsSupported()); |
| 26 DhcpProxyScriptFetcher* ret = NULL; |
| 27 #if defined(OS_WIN) |
| 28 ret = new WindowsDhcpProxyScriptFetcher(context); |
| 29 #endif |
| 30 DCHECK(ret); |
| 31 return ret; |
| 32 } |
| 33 } |
| 34 |
| 35 void DhcpProxyScriptFetcherFactory::SetEnabled(bool enabled) { |
| 36 if (IsSupported()) { |
| 37 feature_enabled_ = enabled; |
| 38 } |
| 39 } |
| 40 |
| 41 bool DhcpProxyScriptFetcherFactory::IsEnabled() const { |
| 42 return feature_enabled_; |
| 43 } |
| 44 |
| 45 bool DhcpProxyScriptFetcherFactory::IsSupported() { |
| 46 #if defined(OS_WIN) |
| 47 return true; |
| 48 #else |
| 49 return false; |
| 50 #endif |
| 51 } |
| 52 |
| 53 DhcpProxyScriptFetcherFactory::DhcpProxyScriptFetcherFactory() |
| 54 : feature_enabled_(false) { |
| 55 } |
| 56 |
| 57 DhcpProxyScriptFetcherFactory::~DhcpProxyScriptFetcherFactory() {} |
| 58 |
| 59 } // namespace net |
OLD | NEW |