| 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 EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_UTIL_H_ | 5 #ifndef EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_UTIL_H_ |
| 6 #define EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_UTIL_H_ | 6 #define EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_UTIL_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 | 13 |
| 14 namespace extensions { | 14 namespace extensions { |
| 15 class PermissionIDSet; | 15 class PermissionIDSet; |
| 16 class PermissionMessage; | |
| 17 class URLPatternSet; | 16 class URLPatternSet; |
| 18 } | 17 } |
| 19 | 18 |
| 20 namespace permission_message_util { | 19 namespace permission_message_util { |
| 21 | 20 |
| 22 enum PermissionMessageProperties { kReadOnly, kReadWrite }; | 21 enum PermissionMessageProperties { kReadOnly, kReadWrite }; |
| 23 | 22 |
| 24 // Get a list of hosts to display in a permission message from the given list of | 23 // Get a list of hosts to display in a permission message from the given list of |
| 25 // hosts from the manifest. | 24 // hosts from the manifest. |
| 26 // TODO(sashab): Merge this into AddHostPermissions() once CreateFromHostList() | 25 // TODO(sashab): Merge this into AddHostPermissions(). |
| 27 // is deprecated. | |
| 28 std::vector<base::string16> GetHostListFromHosts( | 26 std::vector<base::string16> GetHostListFromHosts( |
| 29 const std::set<std::string>& hosts, | 27 const std::set<std::string>& hosts, |
| 30 PermissionMessageProperties properties); | 28 PermissionMessageProperties properties); |
| 31 | 29 |
| 32 // Creates the corresponding permission message for a list of hosts. | |
| 33 // The messages change depending on how many hosts are present, and whether | |
| 34 // |read_only| is true. | |
| 35 // TODO(sashab): Deprecate this, prefer AddHostPermissions() instead. | |
| 36 extensions::PermissionMessage CreateFromHostList( | |
| 37 const std::set<std::string>& hosts, | |
| 38 PermissionMessageProperties); | |
| 39 | |
| 40 // Adds the appropriate permissions from given hosts to |permissions|. | 30 // Adds the appropriate permissions from given hosts to |permissions|. |
| 41 void AddHostPermissions(extensions::PermissionIDSet* permissions, | 31 void AddHostPermissions(extensions::PermissionIDSet* permissions, |
| 42 const std::set<std::string>& hosts, | 32 const std::set<std::string>& hosts, |
| 43 PermissionMessageProperties properties); | 33 PermissionMessageProperties properties); |
| 44 | 34 |
| 45 std::set<std::string> GetDistinctHosts( | 35 std::set<std::string> GetDistinctHosts( |
| 46 const extensions::URLPatternSet& host_patterns, | 36 const extensions::URLPatternSet& host_patterns, |
| 47 bool include_rcd, | 37 bool include_rcd, |
| 48 bool exclude_file_scheme); | 38 bool exclude_file_scheme); |
| 49 | 39 |
| 50 } // namespace permission_message_util | 40 } // namespace permission_message_util |
| 51 | 41 |
| 52 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_UTIL_H_ | 42 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_UTIL_H_ |
| OLD | NEW |