Home | History | Annotate | Download | only in permissions
      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 #ifndef EXTENSIONS_COMMON_PERMISSIONS_MEDIA_GALLERIES_PERMISSION_DATA_H_
      6 #define EXTENSIONS_COMMON_PERMISSIONS_MEDIA_GALLERIES_PERMISSION_DATA_H_
      7 
      8 #include <string>
      9 
     10 #include "base/basictypes.h"
     11 #include "base/memory/scoped_ptr.h"
     12 #include "extensions/common/permissions/api_permission.h"
     13 
     14 namespace base {
     15 class Value;
     16 }
     17 
     18 namespace extensions {
     19 
     20 // A MediaGalleriesPermissionData instance represents a single part of the
     21 // MediaGalleriesPermission. e.g. "read" or "allAutoDetected".
     22 class MediaGalleriesPermissionData {
     23  public:
     24   MediaGalleriesPermissionData();
     25 
     26   // Check if |param| (which must be a MediaGalleriesPermission::CheckParam)
     27   // matches the encapsulated attribute.
     28   bool Check(const APIPermission::CheckParam* param) const;
     29 
     30   // Convert |this| into a base::Value.
     31   scoped_ptr<base::Value> ToValue() const;
     32 
     33   // Populate |this| from a base::Value.
     34   bool FromValue(const base::Value* value);
     35 
     36   bool operator<(const MediaGalleriesPermissionData& rhs) const;
     37   bool operator==(const MediaGalleriesPermissionData& rhs) const;
     38 
     39   std::string permission() const { return permission_; }
     40 
     41   // This accessor is provided for IPC_STRUCT_TRAITS_MEMBER.  Please think
     42   // twice before using it for anything else.
     43   std::string& permission() { return permission_; }
     44 
     45  private:
     46   std::string permission_;
     47 };
     48 
     49 }  // namespace extensions
     50 
     51 #endif  // EXTENSIONS_COMMON_PERMISSIONS_MEDIA_GALLERIES_PERMISSION_DATA_H_
     52