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

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

Issue 2953453002: [Extensions Bindings] Add access checks in custom types (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
« no previous file with comments | « extensions/renderer/chrome_setting.cc ('k') | extensions/renderer/content_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_CONTENT_SETTING_H_ 5 #ifndef EXTENSIONS_RENDERER_CONTENT_SETTING_H_
6 #define EXTENSIONS_RENDERER_CONTENT_SETTING_H_ 6 #define EXTENSIONS_RENDERER_CONTENT_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/api_binding_types.h" 11 #include "extensions/renderer/api_binding_types.h"
12 #include "extensions/renderer/argument_spec.h" 12 #include "extensions/renderer/argument_spec.h"
13 #include "gin/wrappable.h" 13 #include "gin/wrappable.h"
14 #include "v8/include/v8.h" 14 #include "v8/include/v8.h"
15 15
16 namespace base { 16 namespace base {
17 class DictionaryValue; 17 class DictionaryValue;
18 class ListValue; 18 class ListValue;
19 } 19 }
20 20
21 namespace gin { 21 namespace gin {
22 class Arguments; 22 class Arguments;
23 } 23 }
24 24
25 namespace extensions { 25 namespace extensions {
26 class APIEventHandler; 26 class APIEventHandler;
27 class APIRequestHandler; 27 class APIRequestHandler;
28 class BindingAccessChecker;
28 29
29 // The custom implementation of the contentSettings.ContentSetting type exposed 30 // The custom implementation of the contentSettings.ContentSetting type exposed
30 // to APIs. 31 // to APIs.
31 class ContentSetting final : public gin::Wrappable<ContentSetting> { 32 class ContentSetting final : public gin::Wrappable<ContentSetting> {
32 public: 33 public:
33 ~ContentSetting() override; 34 ~ContentSetting() override;
34 35
35 // Creates a ContentSetting object for the given property. 36 // Creates a ContentSetting object for the given property.
36 static v8::Local<v8::Object> Create(const binding::RunJSFunction& run_js, 37 static v8::Local<v8::Object> Create(
37 v8::Isolate* isolate, 38 const binding::RunJSFunction& run_js,
38 const std::string& property_name, 39 v8::Isolate* isolate,
39 const base::ListValue* property_values, 40 const std::string& property_name,
40 APIRequestHandler* request_handler, 41 const base::ListValue* property_values,
41 APIEventHandler* event_handler, 42 APIRequestHandler* request_handler,
42 APITypeReferenceMap* type_refs); 43 APIEventHandler* event_handler,
44 APITypeReferenceMap* type_refs,
45 const BindingAccessChecker* access_checker);
43 46
44 static gin::WrapperInfo kWrapperInfo; 47 static gin::WrapperInfo kWrapperInfo;
45 48
46 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( 49 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
47 v8::Isolate* isolate) override; 50 v8::Isolate* isolate) override;
48 51
49 private: 52 private:
50 ContentSetting(const binding::RunJSFunction& run_js, 53 ContentSetting(const binding::RunJSFunction& run_js,
51 APIRequestHandler* request_handler, 54 APIRequestHandler* request_handler,
52 const APITypeReferenceMap* type_refs, 55 const APITypeReferenceMap* type_refs,
56 const BindingAccessChecker* access_checker,
53 const std::string& pref_name, 57 const std::string& pref_name,
54 const base::DictionaryValue& argument_spec); 58 const base::DictionaryValue& argument_spec);
55 59
56 // JS function handlers: 60 // JS function handlers:
57 void Get(gin::Arguments* arguments); 61 void Get(gin::Arguments* arguments);
58 void Set(gin::Arguments* arguments); 62 void Set(gin::Arguments* arguments);
59 void Clear(gin::Arguments* arguments); 63 void Clear(gin::Arguments* arguments);
60 void GetResourceIdentifiers(gin::Arguments* arguments); 64 void GetResourceIdentifiers(gin::Arguments* arguments);
61 65
62 // Common function handling endpoint. 66 // Common function handling endpoint.
63 void HandleFunction(const std::string& function_name, 67 void HandleFunction(const std::string& function_name,
64 gin::Arguments* arguments); 68 gin::Arguments* arguments);
65 69
66 binding::RunJSFunction run_js_; 70 binding::RunJSFunction run_js_;
67 71
68 APIRequestHandler* request_handler_; 72 APIRequestHandler* request_handler_;
69 73
70 const APITypeReferenceMap* type_refs_; 74 const APITypeReferenceMap* type_refs_;
71 75
76 const BindingAccessChecker* const access_checker_;
77
72 // The name of the preference this ContentSetting is managing. 78 // The name of the preference this ContentSetting is managing.
73 std::string pref_name_; 79 std::string pref_name_;
74 80
75 // The type of argument that calling set() on the ContentSetting expects 81 // The type of argument that calling set() on the ContentSetting expects
76 // (since different settings can take a different type of argument depending 82 // (since different settings can take a different type of argument depending
77 // on the preference it manages). 83 // on the preference it manages).
78 ArgumentSpec argument_spec_; 84 ArgumentSpec argument_spec_;
79 85
80 DISALLOW_COPY_AND_ASSIGN(ContentSetting); 86 DISALLOW_COPY_AND_ASSIGN(ContentSetting);
81 }; 87 };
82 88
83 } // namespace extensions 89 } // namespace extensions
84 90
85 #endif // EXTENSIONS_RENDERER_CONTENT_SETTING_H_ 91 #endif // EXTENSIONS_RENDERER_CONTENT_SETTING_H_
OLDNEW
« no previous file with comments | « extensions/renderer/chrome_setting.cc ('k') | extensions/renderer/content_setting.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698