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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_UTIL_H_
6 #define EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_UTIL_H_
12 #include "base/strings/string16.h"
14 namespace extensions
{
15 class PermissionIDSet
;
16 class PermissionMessage
;
20 namespace permission_message_util
{
22 enum PermissionMessageProperties
{ kReadOnly
, kReadWrite
};
24 // Get a list of hosts to display in a permission message from the given list of
25 // hosts from the manifest.
26 // TODO(sashab): Merge this into AddHostPermissions() once CreateFromHostList()
28 std::vector
<base::string16
> GetHostListFromHosts(
29 const std::set
<std::string
>& hosts
,
30 PermissionMessageProperties properties
);
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
);
40 // Adds the appropriate permissions from given hosts to |permissions|.
41 void AddHostPermissions(extensions::PermissionIDSet
* permissions
,
42 const std::set
<std::string
>& hosts
,
43 PermissionMessageProperties properties
);
45 std::set
<std::string
> GetDistinctHosts(
46 const extensions::URLPatternSet
& host_patterns
,
48 bool exclude_file_scheme
);
50 } // namespace permission_message_util
52 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_UTIL_H_