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

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

Issue 2575173002: [Extensions Bindings] Add a bridge to use current custom bindings (Closed)
Patch Set: . 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
« no previous file with comments | « extensions/renderer/api_binding_bridge.cc ('k') | extensions/renderer/api_binding_hooks.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 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_HOOKS_H_ 5 #ifndef EXTENSIONS_RENDERER_API_BINDING_HOOKS_H_
6 #define EXTENSIONS_RENDERER_API_BINDING_HOOKS_H_ 6 #define EXTENSIONS_RENDERER_API_BINDING_HOOKS_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 const std::string& api_name); 56 const std::string& api_name);
57 57
58 // Looks for a custom hook to handle the given request and, if one exists, 58 // Looks for a custom hook to handle the given request and, if one exists,
59 // runs it. Returns true if a hook was found and run. 59 // runs it. Returns true if a hook was found and run.
60 bool HandleRequest(const std::string& api_name, 60 bool HandleRequest(const std::string& api_name,
61 const std::string& method_name, 61 const std::string& method_name,
62 v8::Local<v8::Context> context, 62 v8::Local<v8::Context> context,
63 const APISignature* signature, 63 const APISignature* signature,
64 gin::Arguments* arguments); 64 gin::Arguments* arguments);
65 65
66 // Returns a JS interface that can be used to register hooks.
67 v8::Local<v8::Object> GetJSHookInterface(const std::string& api_name,
68 v8::Local<v8::Context> context);
69
66 private: 70 private:
67 // Whether we've tried to use any hooks associated with this object. 71 // Whether we've tried to use any hooks associated with this object.
68 bool hooks_used_ = false; 72 bool hooks_used_ = false;
69 73
70 // All registered request handlers. 74 // All registered request handlers.
71 std::map<std::string, HandleRequestHook> request_hooks_; 75 std::map<std::string, HandleRequestHook> request_hooks_;
72 76
73 // The script to run to initialize JS hooks, if any. 77 // The script to run to initialize JS hooks, if any.
74 v8::Global<v8::String> js_hooks_source_; 78 v8::Global<v8::String> js_hooks_source_;
75 79
76 // The name of the JS resource for the hooks. Used to create a ScriptOrigin 80 // The name of the JS resource for the hooks. Used to create a ScriptOrigin
77 // to make exception stack traces more readable. 81 // to make exception stack traces more readable.
78 v8::Global<v8::String> js_resource_name_; 82 v8::Global<v8::String> js_resource_name_;
79 83
80 binding::RunJSFunction run_js_; 84 binding::RunJSFunction run_js_;
81 85
82 DISALLOW_COPY_AND_ASSIGN(APIBindingHooks); 86 DISALLOW_COPY_AND_ASSIGN(APIBindingHooks);
83 }; 87 };
84 88
85 } // namespace extensions 89 } // namespace extensions
86 90
87 #endif // EXTENSIONS_RENDERER_API_BINDING_HOOKS_H_ 91 #endif // EXTENSIONS_RENDERER_API_BINDING_HOOKS_H_
OLDNEW
« no previous file with comments | « extensions/renderer/api_binding_bridge.cc ('k') | extensions/renderer/api_binding_hooks.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698