[go: nahoru, domu]

blob: eb72c00eef94f7fd508721629e507b19803f59a5 [file] [log] [blame]
// Copyright 2013 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.
#ifndef EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_H_
#define EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_H_
#include <string>
#include <vector>
#include "extensions/common/permissions/api_permission_set.h"
namespace extensions {
// The new kind of Chrome app/extension permission messages.
//
// A PermissionMessage is an immutable object that represents a single bullet
// in the list of an app or extension's permissions. It contains the localized
// permission message to display, as well as the set of permissions that
// contributed to that message (and should be revoked if this permission is
// revoked). It can also optionally contain a list of sub-messages which should
// appear as nested bullet points below the main one.
//
// |permissions| contains the permissions that are 'represented' by this
// message and should be revoked if this permission message is revoked. Note
// that other permissions could have contributed to the message, but these are
// the ones 'contained' in this message - if this set is taken for all
// PermissionMessages, each permission will only be in at most one
// PermissionMessage.
//
// Some permissions may contain nested messages, stored in |submessages|. These
// are appropriate to show as nested bullet points below the permission,
// collapsed if needed. For example, host permission messages may list all the
// sites the app has access to in |submessages|, with a summary message in
// |message|.
//
// TODO(sashab): Add a custom revoke action for each permission and nested
// permission message, registerable as a callback.
class PermissionMessage {
public:
PermissionMessage(const std::u16string& message,
const PermissionIDSet& permissions);
PermissionMessage(const std::u16string& message,
const PermissionIDSet& permissions,
const std::vector<std::u16string>& submessages);
PermissionMessage(const PermissionMessage& other);
virtual ~PermissionMessage();
const std::u16string& message() const { return message_; }
const PermissionIDSet& permissions() const { return permissions_; }
const std::vector<std::u16string>& submessages() const {
return submessages_;
}
private:
const std::u16string message_;
const PermissionIDSet permissions_;
const std::vector<std::u16string> submessages_;
};
using PermissionMessages = std::vector<PermissionMessage>;
} // namespace extensions
#endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_H_