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

Side by Side Diff: extensions/renderer/bindings/api_bindings_system.h

Issue 2961103002: [Extensions Bindings] Add an ExceptionHandler class (Closed)
Patch Set: jbroman's Created 3 years, 5 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_BINDINGS_API_BINDINGS_SYSTEM_H_ 5 #ifndef EXTENSIONS_RENDERER_BINDINGS_API_BINDINGS_SYSTEM_H_
6 #define EXTENSIONS_RENDERER_BINDINGS_API_BINDINGS_SYSTEM_H_ 6 #define EXTENSIONS_RENDERER_BINDINGS_API_BINDINGS_SYSTEM_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "extensions/renderer/bindings/api_binding.h" 14 #include "extensions/renderer/bindings/api_binding.h"
15 #include "extensions/renderer/bindings/api_binding_types.h" 15 #include "extensions/renderer/bindings/api_binding_types.h"
16 #include "extensions/renderer/bindings/api_event_handler.h" 16 #include "extensions/renderer/bindings/api_event_handler.h"
17 #include "extensions/renderer/bindings/api_last_error.h" 17 #include "extensions/renderer/bindings/api_last_error.h"
18 #include "extensions/renderer/bindings/api_request_handler.h" 18 #include "extensions/renderer/bindings/api_request_handler.h"
19 #include "extensions/renderer/bindings/api_type_reference_map.h" 19 #include "extensions/renderer/bindings/api_type_reference_map.h"
20 #include "extensions/renderer/bindings/binding_access_checker.h" 20 #include "extensions/renderer/bindings/binding_access_checker.h"
21 #include "extensions/renderer/bindings/exception_handler.h"
21 22
22 namespace base { 23 namespace base {
23 class DictionaryValue; 24 class DictionaryValue;
24 class ListValue; 25 class ListValue;
25 } 26 }
26 27
27 namespace extensions { 28 namespace extensions {
28 class APIBindingHooks; 29 class APIBindingHooks;
29 30
30 // A class encompassing the necessary pieces to construct the JS entry points 31 // A class encompassing the necessary pieces to construct the JS entry points
(...skipping 13 matching lines...) Expand all
44 const BindingAccessChecker* access_checker)>; 45 const BindingAccessChecker* access_checker)>;
45 46
46 APIBindingsSystem( 47 APIBindingsSystem(
47 const binding::RunJSFunction& call_js, 48 const binding::RunJSFunction& call_js,
48 const binding::RunJSFunctionSync& call_js_sync, 49 const binding::RunJSFunctionSync& call_js_sync,
49 const GetAPISchemaMethod& get_api_schema, 50 const GetAPISchemaMethod& get_api_schema,
50 const BindingAccessChecker::AvailabilityCallback& is_available, 51 const BindingAccessChecker::AvailabilityCallback& is_available,
51 const APIRequestHandler::SendRequestMethod& send_request, 52 const APIRequestHandler::SendRequestMethod& send_request,
52 const APIEventHandler::EventListenersChangedMethod& 53 const APIEventHandler::EventListenersChangedMethod&
53 event_listeners_changed, 54 event_listeners_changed,
55 const binding::AddConsoleError& add_console_error,
54 APILastError last_error); 56 APILastError last_error);
55 ~APIBindingsSystem(); 57 ~APIBindingsSystem();
56 58
57 // Returns a new v8::Object representing the api specified by |api_name|. 59 // Returns a new v8::Object representing the api specified by |api_name|.
58 v8::Local<v8::Object> CreateAPIInstance( 60 v8::Local<v8::Object> CreateAPIInstance(
59 const std::string& api_name, 61 const std::string& api_name,
60 v8::Local<v8::Context> context, 62 v8::Local<v8::Context> context,
61 APIBindingHooks** hooks_out); 63 APIBindingHooks** hooks_out);
62 64
63 // Responds to the request with the given |request_id|, calling the callback 65 // Responds to the request with the given |request_id|, calling the callback
(...skipping 23 matching lines...) Expand all
87 // storage.StorageArea). 89 // storage.StorageArea).
88 void RegisterCustomType(const std::string& type_name, 90 void RegisterCustomType(const std::string& type_name,
89 const CustomTypeHandler& function); 91 const CustomTypeHandler& function);
90 92
91 // Handles any cleanup necessary before releasing the given |context|. 93 // Handles any cleanup necessary before releasing the given |context|.
92 void WillReleaseContext(v8::Local<v8::Context> context); 94 void WillReleaseContext(v8::Local<v8::Context> context);
93 95
94 APIRequestHandler* request_handler() { return &request_handler_; } 96 APIRequestHandler* request_handler() { return &request_handler_; }
95 APIEventHandler* event_handler() { return &event_handler_; } 97 APIEventHandler* event_handler() { return &event_handler_; }
96 APITypeReferenceMap* type_reference_map() { return &type_reference_map_; } 98 APITypeReferenceMap* type_reference_map() { return &type_reference_map_; }
99 ExceptionHandler* exception_handler() { return &exception_handler_; }
97 100
98 private: 101 private:
99 // Creates a new APIBinding for the given |api_name|. 102 // Creates a new APIBinding for the given |api_name|.
100 std::unique_ptr<APIBinding> CreateNewAPIBinding(const std::string& api_name); 103 std::unique_ptr<APIBinding> CreateNewAPIBinding(const std::string& api_name);
101 104
102 // Callback for the APITypeReferenceMap in order to initialize an unknown 105 // Callback for the APITypeReferenceMap in order to initialize an unknown
103 // type. 106 // type.
104 void InitializeType(const std::string& name); 107 void InitializeType(const std::string& name);
105 108
106 // Handles creating the type for the specified property. 109 // Handles creating the type for the specified property.
107 v8::Local<v8::Object> CreateCustomType( 110 v8::Local<v8::Object> CreateCustomType(
108 v8::Isolate* isolate, 111 v8::Isolate* isolate,
109 const std::string& type_name, 112 const std::string& type_name,
110 const std::string& property_name, 113 const std::string& property_name,
111 const base::ListValue* property_values); 114 const base::ListValue* property_values);
112 115
113 // The map of cached API reference types. 116 // The map of cached API reference types.
114 APITypeReferenceMap type_reference_map_; 117 APITypeReferenceMap type_reference_map_;
115 118
119 // The exception handler for the system.
120 ExceptionHandler exception_handler_;
121
116 // The request handler associated with the system. 122 // The request handler associated with the system.
117 APIRequestHandler request_handler_; 123 APIRequestHandler request_handler_;
118 124
119 // The event handler associated with the system. 125 // The event handler associated with the system.
120 APIEventHandler event_handler_; 126 APIEventHandler event_handler_;
121 127
122 // The access checker associated with the system. 128 // The access checker associated with the system.
123 BindingAccessChecker access_checker_; 129 BindingAccessChecker access_checker_;
124 130
125 // A map from api_name -> APIBinding for constructed APIs. APIBindings are 131 // A map from api_name -> APIBinding for constructed APIs. APIBindings are
(...skipping 14 matching lines...) Expand all
140 // The method to retrieve the DictionaryValue describing a given extension 146 // The method to retrieve the DictionaryValue describing a given extension
141 // API. Curried in for testing purposes so we can use fake APIs. 147 // API. Curried in for testing purposes so we can use fake APIs.
142 GetAPISchemaMethod get_api_schema_; 148 GetAPISchemaMethod get_api_schema_;
143 149
144 DISALLOW_COPY_AND_ASSIGN(APIBindingsSystem); 150 DISALLOW_COPY_AND_ASSIGN(APIBindingsSystem);
145 }; 151 };
146 152
147 } // namespace 153 } // namespace
148 154
149 #endif // EXTENSIONS_RENDERER_BINDINGS_API_BINDINGS_SYSTEM_H_ 155 #endif // EXTENSIONS_RENDERER_BINDINGS_API_BINDINGS_SYSTEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698