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

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

Issue 2575173002: [Extensions Bindings] Add a bridge to use current custom bindings (Closed)
Patch Set: jbroman II Created 4 years 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_API_BINDING_H_ 5 #ifndef EXTENSIONS_RENDERER_API_BINDING_H_
6 #define EXTENSIONS_RENDERER_API_BINDING_H_ 6 #define EXTENSIONS_RENDERER_API_BINDING_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 ArgumentSpec::RefMap* type_refs); 68 ArgumentSpec::RefMap* type_refs);
69 ~APIBinding(); 69 ~APIBinding();
70 70
71 // Returns a new v8::Object for the API this APIBinding represents. 71 // Returns a new v8::Object for the API this APIBinding represents.
72 v8::Local<v8::Object> CreateInstance( 72 v8::Local<v8::Object> CreateInstance(
73 v8::Local<v8::Context> context, 73 v8::Local<v8::Context> context,
74 v8::Isolate* isolate, 74 v8::Isolate* isolate,
75 APIEventHandler* event_handler, 75 APIEventHandler* event_handler,
76 const AvailabilityCallback& is_available); 76 const AvailabilityCallback& is_available);
77 77
78 // Returns the JS interface to use when registering hooks with legacy custom
79 // bindings.
80 v8::Local<v8::Object> GetJSHookInterface(v8::Local<v8::Context> context);
81
78 private: 82 private:
79 // Handles a call an API method with the given |name| and matches the 83 // Handles a call an API method with the given |name| and matches the
80 // arguments against |signature|. 84 // arguments against |signature|.
81 void HandleCall(const std::string& name, 85 void HandleCall(const std::string& name,
82 const APISignature* signature, 86 const APISignature* signature,
83 gin::Arguments* args); 87 gin::Arguments* args);
84 88
85 // The root name of the API, e.g. "tabs" for chrome.tabs. 89 // The root name of the API, e.g. "tabs" for chrome.tabs.
86 std::string api_name_; 90 std::string api_name_;
87 91
88 // A map from method name to expected signature. 92 // A map from method name to expected signature.
89 std::map<std::string, std::unique_ptr<APISignature>> signatures_; 93 std::map<std::string, std::unique_ptr<APISignature>> signatures_;
90 94
91 // The names of all events associated with this API. 95 // The names of all events associated with this API.
92 std::vector<std::string> event_names_; 96 std::vector<std::string> event_names_;
93 97
94 // The callback to use when an API is invoked with valid arguments. 98 // The callback to use when an API is invoked with valid arguments.
95 APIMethodCallback method_callback_; 99 APIMethodCallback method_callback_;
96 100
97 // The registered hooks for this API. Null if there are no registered custom 101 // The registered hooks for this API. Null if there are no registered custom
lazyboy 2016/12/21 19:49:58 This can't be null anymore?
Devlin 2016/12/22 01:49:10 Whoops - missed this one. Done.
98 // hooks. 102 // hooks.
99 std::unique_ptr<APIBindingHooks> binding_hooks_; 103 std::unique_ptr<APIBindingHooks> binding_hooks_;
100 104
101 // The reference map for all known types; required to outlive this object. 105 // The reference map for all known types; required to outlive this object.
102 const ArgumentSpec::RefMap* type_refs_; 106 const ArgumentSpec::RefMap* type_refs_;
103 107
104 base::WeakPtrFactory<APIBinding> weak_factory_; 108 base::WeakPtrFactory<APIBinding> weak_factory_;
105 109
106 DISALLOW_COPY_AND_ASSIGN(APIBinding); 110 DISALLOW_COPY_AND_ASSIGN(APIBinding);
107 }; 111 };
108 112
109 } // namespace extensions 113 } // namespace extensions
110 114
111 #endif // EXTENSIONS_RENDERER_API_BINDING_H_ 115 #endif // EXTENSIONS_RENDERER_API_BINDING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698