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

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

Issue 1945433002: [Extensions] Update more bindings and allow for multiple feature access (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Antony's Created 4 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_OBJECT_BACKED_NATIVE_HANDLER_H_ 5 #ifndef EXTENSIONS_RENDERER_OBJECT_BACKED_NATIVE_HANDLER_H_
6 #define EXTENSIONS_RENDERER_OBJECT_BACKED_NATIVE_HANDLER_H_ 6 #define EXTENSIONS_RENDERER_OBJECT_BACKED_NATIVE_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 14 matching lines...) Expand all
25 public: 25 public:
26 explicit ObjectBackedNativeHandler(ScriptContext* context); 26 explicit ObjectBackedNativeHandler(ScriptContext* context);
27 ~ObjectBackedNativeHandler() override; 27 ~ObjectBackedNativeHandler() override;
28 28
29 // Create an object with bindings to the native functions defined through 29 // Create an object with bindings to the native functions defined through
30 // RouteFunction(). 30 // RouteFunction().
31 v8::Local<v8::Object> NewInstance() override; 31 v8::Local<v8::Object> NewInstance() override;
32 32
33 v8::Isolate* GetIsolate() const; 33 v8::Isolate* GetIsolate() const;
34 34
35 protected:
36 typedef base::Callback<void(const v8::FunctionCallbackInfo<v8::Value>&)> 35 typedef base::Callback<void(const v8::FunctionCallbackInfo<v8::Value>&)>
37 HandlerFunction; 36 HandlerFunction;
38 37
38 protected:
39 // Installs a new 'route' from |name| to |handler_function|. This means that 39 // Installs a new 'route' from |name| to |handler_function|. This means that
40 // NewInstance()s of this ObjectBackedNativeHandler will have a property 40 // NewInstance()s of this ObjectBackedNativeHandler will have a property
41 // |name| which will be handled by |handler_function|. 41 // |name| which will be handled by |handler_function|.
42 // 42 //
43 // Routed functions are destroyed along with the destruction of this class, 43 // Routed functions are destroyed along with the destruction of this class,
44 // and are never called back into, therefore it's safe for |handler_function| 44 // and are never called back into, therefore it's safe for |handler_function|
45 // to bind to base::Unretained. 45 // to bind to base::Unretained.
46 // 46 //
47 // |feature_name| corresponds to the api feature the native handler is used 47 // |feature_name[s]| corresponds to the api feature the native handler is used
48 // for. If the associated ScriptContext does not have access to that feature, 48 // for. If the associated ScriptContext does not have access to that feature,
49 // the |handler_function| is not invoked. 49 // the |handler_function| is not invoked.
50 // TODO(devlin): Deprecate the version that doesn't take a |feature_name|. 50 // TODO(devlin): Deprecate the version that doesn't take a |feature_name|.
51 void RouteFunction(const std::string& name, 51 void RouteFunction(const std::string& name,
52 const HandlerFunction& handler_function); 52 const HandlerFunction& handler_function);
53 void RouteFunction(const std::string& name, 53 void RouteFunction(const std::string& name,
54 const std::string& feature_name, 54 const std::string& feature_name,
55 const HandlerFunction& handler_function); 55 const HandlerFunction& handler_function);
56 void RouteFunction(const std::string& name,
57 const std::vector<std::string>& feature_names,
58 const HandlerFunction& handler_function);
56 59
57 ScriptContext* context() const { return context_; } 60 ScriptContext* context() const { return context_; }
58 61
59 void Invalidate() override; 62 void Invalidate() override;
60 63
61 // Returns true if the given |context| is allowed to access the given 64 // Returns true if the given |context| is allowed to access the given
62 // |object|. This should be checked before returning any objects from another 65 // |object|. This should be checked before returning any objects from another
63 // context. 66 // context.
64 // |allow_null_context| indicates that if there is no ScriptContext associated 67 // |allow_null_context| indicates that if there is no ScriptContext associated
65 // with the |object|, it should be allowed. 68 // with the |object|, it should be allowed.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 ScriptContext* context_; 117 ScriptContext* context_;
115 118
116 v8::Global<v8::ObjectTemplate> object_template_; 119 v8::Global<v8::ObjectTemplate> object_template_;
117 120
118 DISALLOW_COPY_AND_ASSIGN(ObjectBackedNativeHandler); 121 DISALLOW_COPY_AND_ASSIGN(ObjectBackedNativeHandler);
119 }; 122 };
120 123
121 } // namespace extensions 124 } // namespace extensions
122 125
123 #endif // EXTENSIONS_RENDERER_OBJECT_BACKED_NATIVE_HANDLER_H_ 126 #endif // EXTENSIONS_RENDERER_OBJECT_BACKED_NATIVE_HANDLER_H_
OLDNEW
« no previous file with comments | « extensions/renderer/file_system_natives.cc ('k') | extensions/renderer/object_backed_native_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698