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

Side by Side Diff: extensions/renderer/binding_access_checker.h

Issue 2947843004: [Extensions Bindings] Introduce BindingAccessChecker (Closed)
Patch Set: lazyboy's Created 3 years, 6 months 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 2017 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 EXTENSIONS_RENDERER_BINDING_ACCESS_CHECKER_H_
6 #define EXTENSIONS_RENDERER_BINDING_ACCESS_CHECKER_H_
7
8 #include <string>
9
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "v8/include/v8.h"
13
14 namespace extensions {
15
16 // A helper class to handle access-checking API features.
17 class BindingAccessChecker {
18 public:
19 // The callback for determining if a given API feature (specified by |name|)
20 // is available in the given context.
21 using AvailabilityCallback =
22 base::Callback<bool(v8::Local<v8::Context>, const std::string& name)>;
23
24 BindingAccessChecker(const AvailabilityCallback& is_available);
25 ~BindingAccessChecker();
26
27 // Returns true if the feature specified by |full_name| is available to the
28 // given |context|.
29 bool HasAccess(v8::Local<v8::Context> context,
30 const std::string& full_name) const;
31
32 // Same as HasAccess(), but throws an exception in the |context| if it doesn't
33 // have access.
34 bool HasAccessOrThrowError(v8::Local<v8::Context> context,
35 const std::string& full_name) const;
36
37 private:
38 AvailabilityCallback is_available_;
39
40 DISALLOW_COPY_AND_ASSIGN(BindingAccessChecker);
41 };
42
43 } // namespace extensions
44
45 #endif // EXTENSIONS_RENDERER_BINDING_ACCESS_CHECKER_H_
OLDNEW
« no previous file with comments | « extensions/renderer/api_bindings_system.cc ('k') | extensions/renderer/binding_access_checker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698