OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chromeos/net/network_portal_detector.h" | 5 #include "chrome/browser/chromeos/net/network_portal_detector.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/chromeos/net/network_portal_detector_impl.h" | 10 #include "chrome/browser/chromeos/net/network_portal_detector_impl.h" |
11 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" | 11 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chromeos/chromeos_switches.h" | 13 #include "chromeos/chromeos_switches.h" |
14 | 14 |
15 namespace chromeos { | 15 namespace chromeos { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 const char kCaptivePortalStatusUnknown[] = "Unknown"; | |
20 const char kCaptivePortalStatusOffline[] = "Offline"; | |
21 const char kCaptivePortalStatusOnline[] = "Online"; | |
22 const char kCaptivePortalStatusPortal[] = "Portal"; | |
23 const char kCaptivePortalStatusProxyAuthRequired[] = "ProxyAuthRequired"; | |
24 const char kCaptivePortalStatusUnrecognized[] = "Unrecognized"; | |
25 | |
26 NetworkPortalDetector* g_network_portal_detector = NULL; | 19 NetworkPortalDetector* g_network_portal_detector = NULL; |
27 bool g_network_portal_detector_set_for_testing = false; | 20 bool g_network_portal_detector_set_for_testing = false; |
28 | 21 |
29 bool IsTestMode() { | 22 bool IsTestMode() { |
30 return CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestType); | 23 return CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestType); |
31 } | 24 } |
32 | 25 |
33 // Stub implementation of NetworkPortalDetector. | 26 // Stub implementation of NetworkPortalDetector. |
34 class NetworkPortalDetectorStubImpl : public NetworkPortalDetector { | 27 class NetworkPortalDetectorStubImpl : public NetworkPortalDetector { |
35 protected: | 28 protected: |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 85 } |
93 | 86 |
94 // static | 87 // static |
95 NetworkPortalDetector* NetworkPortalDetector::Get() { | 88 NetworkPortalDetector* NetworkPortalDetector::Get() { |
96 CHECK(g_network_portal_detector) | 89 CHECK(g_network_portal_detector) |
97 << "NetworkPortalDetector::Get() called before Initialize()"; | 90 << "NetworkPortalDetector::Get() called before Initialize()"; |
98 return g_network_portal_detector; | 91 return g_network_portal_detector; |
99 } | 92 } |
100 | 93 |
101 // static | 94 // static |
102 std::string NetworkPortalDetector::CaptivePortalStatusString( | |
103 CaptivePortalStatus status) { | |
104 switch (status) { | |
105 case NetworkPortalDetectorImpl::CAPTIVE_PORTAL_STATUS_UNKNOWN: | |
106 return kCaptivePortalStatusUnknown; | |
107 case NetworkPortalDetectorImpl::CAPTIVE_PORTAL_STATUS_OFFLINE: | |
108 return kCaptivePortalStatusOffline; | |
109 case NetworkPortalDetectorImpl::CAPTIVE_PORTAL_STATUS_ONLINE: | |
110 return kCaptivePortalStatusOnline; | |
111 case NetworkPortalDetectorImpl::CAPTIVE_PORTAL_STATUS_PORTAL: | |
112 return kCaptivePortalStatusPortal; | |
113 case NetworkPortalDetectorImpl::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: | |
114 return kCaptivePortalStatusProxyAuthRequired; | |
115 case NetworkPortalDetectorImpl::CAPTIVE_PORTAL_STATUS_COUNT: | |
116 NOTREACHED(); | |
117 } | |
118 return kCaptivePortalStatusUnrecognized; | |
119 } | |
120 | |
121 // static | |
122 bool NetworkPortalDetector::IsInitialized() { | 95 bool NetworkPortalDetector::IsInitialized() { |
123 return g_network_portal_detector; | 96 return g_network_portal_detector; |
124 } | 97 } |
125 | 98 |
126 } // namespace chromeos | 99 } // namespace chromeos |
OLD | NEW |