Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(586)

Side by Side Diff: chrome/common/extensions/api/sockets/sockets_handler.h

Issue 51433002: Enable permission warnings from ManifestHandlers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address code review feedback. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #ifndef CHROME_COMMON_EXTENSIONS_API_SOCKETS_SOCKETS_HANDLER_H_
6 #define CHROME_COMMON_EXTENSIONS_API_SOCKETS_SOCKETS_HANDLER_H_
7
8 #include "base/strings/string16.h"
9 #include "chrome/common/extensions/extension.h"
10 #include "chrome/common/extensions/permissions/socket_permission_data.h"
11 #include "extensions/common/manifest_handler.h"
12
13 namespace extensions {
14
15 // Parses the "sockets" manifest key.
16 class SocketsHandler : public ManifestHandler {
17 public:
18 SocketsHandler();
19 virtual ~SocketsHandler();
20
21 virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
22
23 private:
24 virtual const std::vector<std::string> Keys() const OVERRIDE;
25
26 DISALLOW_COPY_AND_ASSIGN(SocketsHandler);
27 };
28
29 // The parsed form of the "sockets" manifest entry.
30 class SocketsManifestData : public Extension::ManifestData {
31 public:
32 SocketsManifestData();
33 virtual ~SocketsManifestData();
34
35 // Gets the ExternallyConnectableInfo for |extension|, or NULL if none was
36 // specified.
37 static SocketsManifestData* Get(const Extension* extension);
38
39 static bool CheckRequest(const Extension* extension,
40 const content::SocketPermissionRequest& request);
41
42 // Tries to construct the info based on |value|, as it would have appeared in
43 // the manifest. Sets |error| and returns an empty scoped_ptr on failure.
44 static scoped_ptr<SocketsManifestData> FromValue(
45 const base::Value& value,
46 std::vector<InstallWarning>* install_warnings,
47 string16* error);
48
49 private:
50 typedef std::set<SocketPermissionEntry> PermissionSet;
51
52 static bool ParseHostPattern(
53 SocketsManifestData* manifest_data,
54 content::SocketPermissionRequest::OperationType operation_type,
55 const scoped_ptr<std::string>& value,
56 string16* error);
57
58 void AddPermission(const SocketPermissionEntry& entry);
59
60 bool CheckRequestImpl(const Extension* extension,
61 const content::SocketPermissionRequest& request);
62
63 PermissionSet permissions_;
64 };
65
66 } // namespace extensions
67
68 #endif // CHROME_COMMON_EXTENSIONS_API_SOCKETS_SOCKETS_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698