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 "net/proxy/dhcp_proxy_script_fetcher_factory.h" | 5 #include "net/proxy/dhcp_proxy_script_fetcher_factory.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 #include "net/proxy/dhcp_proxy_script_fetcher.h" | 9 #include "net/proxy/dhcp_proxy_script_fetcher.h" |
10 | 10 |
11 #if defined(OS_WIN) | 11 #if defined(OS_WIN) |
12 #include "net/proxy/dhcp_proxy_script_fetcher_win.h" | 12 #include "net/proxy/dhcp_proxy_script_fetcher_win.h" |
13 #endif | 13 #endif |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
17 DhcpProxyScriptFetcherFactory::DhcpProxyScriptFetcherFactory() | 17 DhcpProxyScriptFetcherFactory::DhcpProxyScriptFetcherFactory() {} |
18 : feature_enabled_(false) { | 18 |
19 set_enabled(true); | 19 DhcpProxyScriptFetcherFactory::~DhcpProxyScriptFetcherFactory() {} |
20 } | |
21 | 20 |
22 std::unique_ptr<DhcpProxyScriptFetcher> DhcpProxyScriptFetcherFactory::Create( | 21 std::unique_ptr<DhcpProxyScriptFetcher> DhcpProxyScriptFetcherFactory::Create( |
23 URLRequestContext* context) { | 22 URLRequestContext* context) { |
24 if (!feature_enabled_) { | |
25 return base::MakeUnique<DoNothingDhcpProxyScriptFetcher>(); | |
26 } else { | |
27 DCHECK(IsSupported()); | |
28 std::unique_ptr<DhcpProxyScriptFetcher> ret; | |
29 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
30 ret.reset(new DhcpProxyScriptFetcherWin(context)); | 24 return base::MakeUnique<DhcpProxyScriptFetcherWin>(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() { | |
Randy Smith (Not in Mondays)
2017/06/15 19:13:30
I won't say "Never has so many characters been exp
mmenke
2017/06/15 19:33:24
Acknowledged.
| |
49 #if defined(OS_WIN) | |
50 return true; | |
51 #else | 25 #else |
52 return false; | 26 return base::MakeUnique<DoNothingDhcpProxyScriptFetcher>(); |
53 #endif | 27 #endif |
54 } | 28 } |
55 | 29 |
56 } // namespace net | 30 } // namespace net |
OLD | NEW |