Fix crash on app list start page contents not existing.
[chromium-blink-merge.git] / extensions / common / permissions / socket_permission.h
blobc2c11564f1f8797bb0ccfcd3d5f3091a68b9076e
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_SOCKET_PERMISSION_H_
6 #define EXTENSIONS_COMMON_PERMISSIONS_SOCKET_PERMISSION_H_
8 #include <string>
10 #include "extensions/common/permissions/api_permission.h"
11 #include "extensions/common/permissions/set_disjunction_permission.h"
12 #include "extensions/common/permissions/socket_permission_data.h"
14 namespace extensions {
16 class SocketPermission
17 : public SetDisjunctionPermission<SocketPermissionData, SocketPermission> {
18 public:
19 struct CheckParam : APIPermission::CheckParam {
20 CheckParam(content::SocketPermissionRequest::OperationType type,
21 const std::string& host,
22 uint16 port)
23 : request(type, host, port) {}
24 content::SocketPermissionRequest request;
27 explicit SocketPermission(const APIPermissionInfo* info);
29 ~SocketPermission() override;
31 PermissionIDSet GetPermissions() const override;
32 // Returns the localized permission messages of this permission.
33 PermissionMessages GetMessages() const override;
35 private:
36 // Add all host messages for this manifest permission into the given lists.
37 // TODO(sashab): Remove the |messages| argument from these methods, and remove
38 // the AddAllHostMessages() function (move all the logic into GetPermissions()
39 // above).
40 void AddAllHostMessages(PermissionMessages& messages,
41 PermissionIDSet& ids) const;
43 bool AddAnyHostMessage(PermissionMessages& messages,
44 PermissionIDSet& ids) const;
45 void AddSubdomainHostMessage(PermissionMessages& messages,
46 PermissionIDSet& ids) const;
47 void AddSpecificHostMessage(PermissionMessages& messages,
48 PermissionIDSet& ids) const;
49 void AddNetworkListMessage(PermissionMessages& messages,
50 PermissionIDSet& ids) const;
53 } // namespace extensions
55 #endif // EXTENSIONS_COMMON_PERMISSIONS_SOCKET_PERMISSION_H_