Extensions: Remove the intermediate PermissionMessageStrings interface
[chromium-blink-merge.git] / extensions / common / permissions / coalesced_permission_message.h
blob2848091e36a0e82ec8b0d9ba55d1567a52d06fc0
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>
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 CoalescedPermissionMessage is an immutable object that represents a single
19 // bullet in the list of an app or extension's permissions. It contains the
20 // localized permission message to display, as well as the set of permissions
21 // that 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 // CoalescedPermissionMessages, each permission will only be in at most one
30 // CoalescedPermissionMessage.
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 // TODO(sashab): Once the existing PermissionMessage is no longer used, rename
41 // this to PermissionMessage.
42 class CoalescedPermissionMessage {
43 public:
44 CoalescedPermissionMessage(const base::string16& message,
45 const PermissionIDSet& permissions);
46 CoalescedPermissionMessage(const base::string16& message,
47 const PermissionIDSet& permissions,
48 const std::vector<base::string16>& submessages);
49 virtual ~CoalescedPermissionMessage();
51 const base::string16& message() const { return message_; }
52 const PermissionIDSet& permissions() const { return permissions_; }
53 const std::vector<base::string16>& submessages() const {
54 return submessages_;
57 private:
58 const base::string16 message_;
59 const PermissionIDSet permissions_;
60 const std::vector<base::string16> submessages_;
63 // TODO(treib): Make this an std::vector when we have C++11 library support on
64 // all platforms. (In C++03, std::vector's elements must be copy-assignable...)
65 typedef std::list<CoalescedPermissionMessage> CoalescedPermissionMessages;
67 } // namespace extensions
69 #endif // EXTENSIONS_COMMON_PERMISSIONS_COALESCED_PERMISSION_MESSAGE_H_