Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_COMMON_EXTENSIONS_PERMISSIONS_CHROME_PERMISSION_MESSAGE_RULES_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_PERMISSIONS_CHROME_PERMISSION_MESSAGE_RULES_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_PERMISSIONS_CHROME_PERMISSION_MESSAGE_RULES_H_ | 6 #define CHROME_COMMON_EXTENSIONS_PERMISSIONS_CHROME_PERMISSION_MESSAGE_RULES_H_ |
| 7 | 7 |
| 8 #include <initializer_list> | |
| 8 #include <set> | 9 #include <set> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 13 #include "extensions/common/permissions/api_permission.h" | 14 #include "extensions/common/permissions/api_permission.h" |
| 14 #include "extensions/common/permissions/api_permission_set.h" | 15 #include "extensions/common/permissions/api_permission_set.h" |
| 15 #include "extensions/common/permissions/permission_message.h" | 16 #include "extensions/common/permissions/permission_message.h" |
| 16 | 17 |
| 17 namespace extensions { | 18 namespace extensions { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 static std::vector<ChromePermissionMessageRule> GetAllRules(); | 63 static std::vector<ChromePermissionMessageRule> GetAllRules(); |
| 63 | 64 |
| 64 std::set<APIPermission::ID> required_permissions() const; | 65 std::set<APIPermission::ID> required_permissions() const; |
| 65 std::set<APIPermission::ID> optional_permissions() const; | 66 std::set<APIPermission::ID> optional_permissions() const; |
| 66 std::set<APIPermission::ID> all_permissions() const; | 67 std::set<APIPermission::ID> all_permissions() const; |
| 67 | 68 |
| 68 PermissionMessage GetPermissionMessage( | 69 PermissionMessage GetPermissionMessage( |
| 69 const PermissionIDSet& permissions) const; | 70 const PermissionIDSet& permissions) const; |
| 70 | 71 |
| 71 private: | 72 private: |
| 72 class PermissionIDSetInitializer; | |
| 73 | |
| 74 // Create a rule using the default formatter (display the message with ID | 73 // Create a rule using the default formatter (display the message with ID |
| 75 // |message_id|). | 74 // |message_id|). |
| 76 ChromePermissionMessageRule(int message_id, | 75 ChromePermissionMessageRule( |
| 77 const PermissionIDSetInitializer& required, | 76 int message_id, |
| 78 const PermissionIDSetInitializer& optional); | 77 const std::initializer_list<APIPermission::ID>& required, |
| 78 const std::initializer_list<APIPermission::ID>& optional); | |
| 79 // Create a rule with a custom formatter. Takes ownership of |formatter|. | 79 // Create a rule with a custom formatter. Takes ownership of |formatter|. |
| 80 ChromePermissionMessageRule(ChromePermissionMessageFormatter* formatter, | 80 ChromePermissionMessageRule( |
| 81 const PermissionIDSetInitializer& required, | 81 ChromePermissionMessageFormatter* formatter, |
| 82 const PermissionIDSetInitializer& optional); | 82 const std::initializer_list<APIPermission::ID>& required, |
| 83 const std::initializer_list<APIPermission::ID>& optional); | |
|
Marc Treib
2016/11/30 14:42:52
I'm not very familiar with initializer_lists yet -
tbarzic
2016/11/30 18:35:44
I was hoping to use std::set, too, but clang compl
| |
| 83 | 84 |
| 84 std::set<APIPermission::ID> required_permissions_; | 85 std::set<APIPermission::ID> required_permissions_; |
| 85 std::set<APIPermission::ID> optional_permissions_; | 86 std::set<APIPermission::ID> optional_permissions_; |
| 86 | 87 |
| 87 // Owned by this class. linked_ptr is needed because this object is copyable | 88 // Owned by this class. linked_ptr is needed because this object is copyable |
| 88 // and stored in a returned vector. | 89 // and stored in a returned vector. |
| 89 linked_ptr<ChromePermissionMessageFormatter> formatter_; | 90 linked_ptr<ChromePermissionMessageFormatter> formatter_; |
| 90 }; | 91 }; |
| 91 | 92 |
| 92 } // namespace extensions | 93 } // namespace extensions |
| 93 | 94 |
| 94 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_CHROME_PERMISSION_MESSAGE_RULES_ H_ | 95 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_CHROME_PERMISSION_MESSAGE_RULES_ H_ |
| OLD | NEW |