Fix crash on app list start page contents not existing.
[chromium-blink-merge.git] / extensions / common / permissions / coalesced_permission_message.h
blobc1d3caf7ea550835a6b0ee7bf10df1bf6d6998c5
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_COALESCED_PERMISSION_MESSAGE_H_
6 #define EXTENSIONS_COMMON_PERMISSIONS_COALESCED_PERMISSION_MESSAGE_H_
8 #include <list>
9 #include <string>
11 #include "extensions/common/permissions/api_permission_set.h"
13 namespace extensions {
15 // The new kind of Chrome app/extension permission messages.
17 // A CoalescedPermissionMessage is an immutable object that represents a single
18 // bullet in the list of an app or extension's permissions. It contains the
19 // localized permission message to display, as well as the set of permissions
20 // that contributed to that message (and should be revoked if this permission is
21 // revoked). It can also optionally contain a list of sub-messages which should
22 // appear as nested bullet points below the main one.
24 // |permissions| contains the permissions that are 'represented' by this
25 // message and should be revoked if this permission message is revoked. Note
26 // that other permissions could have contributed to the message, but these are
27 // the ones 'contained' in this message - if this set is taken for all
28 // CoalescedPermissionMessages, each permission will only be in at most one
29 // CoalescedPermissionMessage.
31 // Some permissions may contain nested messages, stored in |submessages|. These
32 // are appropriate to show as nested bullet points below the permission,
33 // collapsed if needed. For example, host permission messages may list all the
34 // sites the app has access to in |submessages|, with a summary message in
35 // |message|.
37 // TODO(sashab): Add a custom revoke action for each permission and nested
38 // permission message, registerable as a callback.
39 // TODO(sashab): Once the existing PermissionMessage is no longer used, rename
40 // this to PermissionMessage.
41 class CoalescedPermissionMessage {
42 public:
43 CoalescedPermissionMessage(const base::string16& message,
44 const PermissionIDSet& permissions);
45 CoalescedPermissionMessage(const base::string16& message,
46 const PermissionIDSet& permissions,
47 const std::vector<base::string16>& submessages);
48 virtual ~CoalescedPermissionMessage();
50 const base::string16& message() const { return message_; }
51 const PermissionIDSet& permissions() const { return permissions_; }
52 const std::vector<base::string16>& submessages() const {
53 return submessages_;
56 private:
57 const base::string16 message_;
58 const PermissionIDSet permissions_;
59 const std::vector<base::string16> submessages_;
62 // Use a linked list to store our list of messages, since we will commonly be
63 // iterating/removing elements but should never be accessing by index.
64 typedef std::list<CoalescedPermissionMessage> CoalescedPermissionMessages;
66 } // namespace extensions
68 #endif // EXTENSIONS_COMMON_PERMISSIONS_COALESCED_PERMISSION_MESSAGE_H_