Index: components/captive_portal/captive_portal_types.cc |
diff --git a/components/captive_portal/captive_portal_types.cc b/components/captive_portal/captive_portal_types.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b89d4f233fbd8b5adc548ec0ca6efef3f32132a1 |
--- /dev/null |
+++ b/components/captive_portal/captive_portal_types.cc |
@@ -0,0 +1,57 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "components/captive_portal/captive_portal_types.h" |
+ |
+#include "base/logging.h" |
+ |
+namespace captive_portal { |
+ |
+namespace { |
+ |
+const char* const kCaptivePortalResultNames[] = { |
+ "InternetConnected", |
+ "NoResponse", |
+ "BehindCaptivePortal", |
+ "NumCaptivePortalResults", |
+}; |
+COMPILE_ASSERT(arraysize(kCaptivePortalResultNames) == RESULT_COUNT + 1, |
+ captive_portal_result_name_count_mismatch); |
+ |
+const char kCaptivePortalStatusUnknown[] = "Unknown"; |
+const char kCaptivePortalStatusOffline[] = "Offline"; |
+const char kCaptivePortalStatusOnline[] = "Online"; |
+const char kCaptivePortalStatusPortal[] = "Portal"; |
+const char kCaptivePortalStatusProxyAuthRequired[] = "ProxyAuthRequired"; |
+const char kCaptivePortalStatusUnrecognized[] = "Unrecognized"; |
+ |
+} // namespace |
+ |
+ |
+std::string CaptivePortalResultToString(CaptivePortalResult result) { |
+ DCHECK_GE(result, 0); |
+ DCHECK_LT(static_cast<unsigned int>(result), |
+ arraysize(kCaptivePortalResultNames)); |
+ return kCaptivePortalResultNames[result]; |
+} |
+ |
+std::string CaptivePortalStatusString(CaptivePortalStatus status) { |
+ switch (status) { |
+ case CAPTIVE_PORTAL_STATUS_UNKNOWN: |
+ return kCaptivePortalStatusUnknown; |
+ case CAPTIVE_PORTAL_STATUS_OFFLINE: |
+ return kCaptivePortalStatusOffline; |
+ case CAPTIVE_PORTAL_STATUS_ONLINE: |
+ return kCaptivePortalStatusOnline; |
+ case CAPTIVE_PORTAL_STATUS_PORTAL: |
+ return kCaptivePortalStatusPortal; |
+ case CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: |
+ return kCaptivePortalStatusProxyAuthRequired; |
+ case CAPTIVE_PORTAL_STATUS_COUNT: |
+ NOTREACHED(); |
+ } |
+ return kCaptivePortalStatusUnrecognized; |
+} |
+ |
+} // namespace captive_portal |