Home | History | Annotate | Download | only in storage
      1 // Copyright 2014 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 "extensions/browser/api/storage/settings_namespace.h"
      6 
      7 #include "base/logging.h"
      8 
      9 namespace extensions {
     10 
     11 namespace settings_namespace {
     12 
     13 namespace {
     14 const char kLocalNamespace[] = "local";
     15 const char kSyncNamespace[] = "sync";
     16 const char kManagedNamespace[] = "managed";
     17 }  // namespace
     18 
     19 std::string ToString(Namespace settings_namespace) {
     20   switch (settings_namespace) {
     21     case LOCAL:
     22       return kLocalNamespace;
     23     case SYNC:
     24       return kSyncNamespace;
     25     case MANAGED:
     26       return kManagedNamespace;
     27     case INVALID:
     28       break;
     29   }
     30   NOTREACHED();
     31   return std::string();
     32 }
     33 
     34 Namespace FromString(const std::string& namespace_string) {
     35   if (namespace_string == kLocalNamespace)
     36     return LOCAL;
     37   if (namespace_string == kSyncNamespace)
     38     return SYNC;
     39   if (namespace_string == kManagedNamespace)
     40     return MANAGED;
     41   return INVALID;
     42 }
     43 
     44 }  // namespace settings_namespace
     45 
     46 }  // namespace extensions
     47