Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / extensions / common / permissions / permission_message.h
blobbdb053a8d82b513e02355a2feaf2fcb5dde12f2c
1 // Copyright 2013 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.
5 #ifndef EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_H_
6 #define EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_H_
8 #include <list>
9 #include <string>
10 #include <vector>
12 #include "extensions/common/permissions/api_permission_set.h"
14 namespace extensions {
16 // The new kind of Chrome app/extension permission messages.
18 // A PermissionMessage is an immutable object that represents a single bullet
19 // in the list of an app or extension's permissions. It contains the localized
20 // permission message to display, as well as the set of permissions that
21 // contributed to that message (and should be revoked if this permission is
22 // revoked). It can also optionally contain a list of sub-messages which should
23 // appear as nested bullet points below the main one.
25 // |permissions| contains the permissions that are 'represented' by this
26 // message and should be revoked if this permission message is revoked. Note
27 // that other permissions could have contributed to the message, but these are
28 // the ones 'contained' in this message - if this set is taken for all
29 // PermissionMessages, each permission will only be in at most one
30 // PermissionMessage.
32 // Some permissions may contain nested messages, stored in |submessages|. These
33 // are appropriate to show as nested bullet points below the permission,
34 // collapsed if needed. For example, host permission messages may list all the
35 // sites the app has access to in |submessages|, with a summary message in
36 // |message|.
38 // TODO(sashab): Add a custom revoke action for each permission and nested
39 // permission message, registerable as a callback.
40 class PermissionMessage {
41 public:
42 PermissionMessage(const base::string16& message,
43 const PermissionIDSet& permissions);
44 PermissionMessage(const base::string16& message,
45 const PermissionIDSet& permissions,
46 const std::vector<base::string16>& submessages);
47 virtual ~PermissionMessage();
49 const base::string16& message() const { return message_; }
50 const PermissionIDSet& permissions() const { return permissions_; }
51 const std::vector<base::string16>& submessages() const {
52 return submessages_;
55 private:
56 const base::string16 message_;
57 const PermissionIDSet permissions_;
58 const std::vector<base::string16> submessages_;
61 // TODO(treib): Make this an std::vector when we have C++11 library support on
62 // all platforms. (In C++03, std::vector's elements must be copy-assignable...)
63 typedef std::list<PermissionMessage> PermissionMessages;
65 } // namespace extensions
67 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_H_