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[] = |
| 24 "Proxy authentication required"; |
| 25 const char kCaptivePortalStatusUnrecognized[] = "Unrecognized"; |
| 26 |
19 NetworkPortalDetector* g_network_portal_detector = NULL; | 27 NetworkPortalDetector* g_network_portal_detector = NULL; |
20 bool g_network_portal_detector_set_for_testing = false; | 28 bool g_network_portal_detector_set_for_testing = false; |
21 | 29 |
22 bool IsTestMode() { | 30 bool IsTestMode() { |
23 return CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestType); | 31 return CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestType); |
24 } | 32 } |
25 | 33 |
26 // Stub implementation of NetworkPortalDetector. | 34 // Stub implementation of NetworkPortalDetector. |
27 class NetworkPortalDetectorStubImpl : public NetworkPortalDetector { | 35 class NetworkPortalDetectorStubImpl : public NetworkPortalDetector { |
28 protected: | 36 protected: |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 91 } |
84 } | 92 } |
85 | 93 |
86 // static | 94 // static |
87 NetworkPortalDetector* NetworkPortalDetector::Get() { | 95 NetworkPortalDetector* NetworkPortalDetector::Get() { |
88 CHECK(g_network_portal_detector) | 96 CHECK(g_network_portal_detector) |
89 << "NetworkPortalDetector::Get() called before Initialize()"; | 97 << "NetworkPortalDetector::Get() called before Initialize()"; |
90 return g_network_portal_detector; | 98 return g_network_portal_detector; |
91 } | 99 } |
92 | 100 |
| 101 // 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 |
93 } // namespace chromeos | 121 } // namespace chromeos |
OLD | NEW |