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

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

Issue 2953453002: [Extensions Bindings] Add access checks in custom types (Closed)
Patch Set: . 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
« no previous file with comments | « extensions/renderer/api_bindings_system.cc ('k') | extensions/renderer/chrome_setting.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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_RENDERER_CHROME_SETTING_H_ 5 #ifndef EXTENSIONS_RENDERER_CHROME_SETTING_H_
6 #define EXTENSIONS_RENDERER_CHROME_SETTING_H_ 6 #define EXTENSIONS_RENDERER_CHROME_SETTING_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "extensions/renderer/argument_spec.h" 11 #include "extensions/renderer/argument_spec.h"
12 #include "gin/wrappable.h" 12 #include "gin/wrappable.h"
13 #include "v8/include/v8.h" 13 #include "v8/include/v8.h"
14 14
15 namespace base { 15 namespace base {
16 class DictionaryValue; 16 class DictionaryValue;
17 class ListValue; 17 class ListValue;
18 } 18 }
19 19
20 namespace gin { 20 namespace gin {
21 class Arguments; 21 class Arguments;
22 } 22 }
23 23
24 namespace extensions { 24 namespace extensions {
25 class APIEventHandler; 25 class APIEventHandler;
26 class APIRequestHandler; 26 class APIRequestHandler;
27 class BindingAccessChecker;
27 28
28 // The custom implementation of the ChromeSetting type exposed to APIs. 29 // The custom implementation of the ChromeSetting type exposed to APIs.
29 class ChromeSetting final : public gin::Wrappable<ChromeSetting> { 30 class ChromeSetting final : public gin::Wrappable<ChromeSetting> {
30 public: 31 public:
31 ~ChromeSetting() override; 32 ~ChromeSetting() override;
32 33
33 // Creates a ChromeSetting object for the given property. 34 // Creates a ChromeSetting object for the given property.
34 static v8::Local<v8::Object> Create(v8::Isolate* isolate, 35 static v8::Local<v8::Object> Create(
35 const std::string& property_name, 36 v8::Isolate* isolate,
36 const base::ListValue* property_values, 37 const std::string& property_name,
37 APIRequestHandler* request_handler, 38 const base::ListValue* property_values,
38 APIEventHandler* event_handler, 39 APIRequestHandler* request_handler,
39 APITypeReferenceMap* type_refs); 40 APIEventHandler* event_handler,
41 APITypeReferenceMap* type_refs,
42 const BindingAccessChecker* access_checker);
40 43
41 static gin::WrapperInfo kWrapperInfo; 44 static gin::WrapperInfo kWrapperInfo;
42 45
43 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( 46 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
44 v8::Isolate* isolate) override; 47 v8::Isolate* isolate) override;
45 48
46 private: 49 private:
47 ChromeSetting(APIRequestHandler* request_handler, 50 ChromeSetting(APIRequestHandler* request_handler,
48 APIEventHandler* event_handler, 51 APIEventHandler* event_handler,
49 const APITypeReferenceMap* type_refs, 52 const APITypeReferenceMap* type_refs,
53 const BindingAccessChecker* access_checker,
50 const std::string& pref_name, 54 const std::string& pref_name,
51 const base::DictionaryValue& argument_spec); 55 const base::DictionaryValue& argument_spec);
52 56
53 // JS function handlers: 57 // JS function handlers:
54 void Get(gin::Arguments* arguments); 58 void Get(gin::Arguments* arguments);
55 void Set(gin::Arguments* arguments); 59 void Set(gin::Arguments* arguments);
56 void Clear(gin::Arguments* arguments); 60 void Clear(gin::Arguments* arguments);
57 61
58 // Returns the onChange event associated with the ChromeSetting. 62 // Returns the onChange event associated with the ChromeSetting.
59 v8::Local<v8::Value> GetOnChangeEvent(gin::Arguments* arguments); 63 v8::Local<v8::Value> GetOnChangeEvent(gin::Arguments* arguments);
60 64
61 // Common function handling endpoint. 65 // Common function handling endpoint.
62 void HandleFunction(const std::string& function_name, 66 void HandleFunction(const std::string& function_name,
63 gin::Arguments* arguments); 67 gin::Arguments* arguments);
64 68
65 APIRequestHandler* request_handler_; 69 APIRequestHandler* request_handler_;
66 70
67 APIEventHandler* event_handler_; 71 APIEventHandler* event_handler_;
68 72
69 const APITypeReferenceMap* type_refs_; 73 const APITypeReferenceMap* type_refs_;
70 74
75 const BindingAccessChecker* access_checker_;
lazyboy 2017/06/22 00:10:25 nit: const BindingAccessChecker* 'const' access_ch
Devlin 2017/06/22 15:49:55 Done (also for storage_area and content_setting)
76
71 // The name of the preference this ChromeSetting is managing. 77 // The name of the preference this ChromeSetting is managing.
72 std::string pref_name_; 78 std::string pref_name_;
73 79
74 // The type of argument that calling set() on the ChromeSetting expects (since 80 // The type of argument that calling set() on the ChromeSetting expects (since
75 // different settings can take a different type of argument depending on the 81 // different settings can take a different type of argument depending on the
76 // preference it manages). 82 // preference it manages).
77 ArgumentSpec argument_spec_; 83 ArgumentSpec argument_spec_;
78 84
79 DISALLOW_COPY_AND_ASSIGN(ChromeSetting); 85 DISALLOW_COPY_AND_ASSIGN(ChromeSetting);
80 }; 86 };
81 87
82 } // namespace extensions 88 } // namespace extensions
83 89
84 #endif // EXTENSIONS_RENDERER_CHROME_SETTING_H_ 90 #endif // EXTENSIONS_RENDERER_CHROME_SETTING_H_
OLDNEW
« no previous file with comments | « extensions/renderer/api_bindings_system.cc ('k') | extensions/renderer/chrome_setting.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698