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

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: update test 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_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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 const std::string& api_name); 55 const std::string& api_name);
56 56
57 // Looks for a custom hook to handle the given request and, if one exists, 57 // Looks for a custom hook to handle the given request and, if one exists,
58 // runs it. Returns true if a hook was found and run. 58 // runs it. Returns true if a hook was found and run.
59 bool HandleRequest(const std::string& api_name, 59 bool HandleRequest(const std::string& api_name,
60 const std::string& method_name, 60 const std::string& method_name,
61 v8::Local<v8::Context> context, 61 v8::Local<v8::Context> context,
62 const binding::APISignature* signature, 62 const binding::APISignature* signature,
63 gin::Arguments* arguments); 63 gin::Arguments* arguments);
64 64
65 // Returns a JS interface that can be used to register hooks.
66 v8::Local<v8::Object> GetJSHookInterface(const std::string& api_name,
67 v8::Local<v8::Context> context);
68
65 private: 69 private:
66 // Whether we've tried to use any hooks associated with this object. 70 // Whether we've tried to use any hooks associated with this object.
67 bool hooks_used_ = false; 71 bool hooks_used_ = false;
68 72
69 // All registered request handlers. 73 // All registered request handlers.
70 std::map<std::string, HandleRequestHook> request_hooks_; 74 std::map<std::string, HandleRequestHook> request_hooks_;
71 75
72 // The script to run to initialize JS hooks, if any. 76 // The script to run to initialize JS hooks, if any.
73 v8::Global<v8::String> js_hooks_source_; 77 v8::Global<v8::String> js_hooks_source_;
74 78
75 // The name of the JS resource for the hooks. Used to create a ScriptOrigin 79 // The name of the JS resource for the hooks. Used to create a ScriptOrigin
76 // to make exception stack traces more readable. 80 // to make exception stack traces more readable.
77 v8::Global<v8::String> js_resource_name_; 81 v8::Global<v8::String> js_resource_name_;
78 82
79 binding::RunJSFunction run_js_; 83 binding::RunJSFunction run_js_;
80 84
81 DISALLOW_COPY_AND_ASSIGN(APIBindingHooks); 85 DISALLOW_COPY_AND_ASSIGN(APIBindingHooks);
82 }; 86 };
83 87
84 } // namespace extensions 88 } // namespace extensions
85 89
86 #endif // EXTENSIONS_RENDERER_API_BINDING_HOOKS_H_ 90 #endif // EXTENSIONS_RENDERER_API_BINDING_HOOKS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698