OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_RENDERER_EXTENSIONS_CUSTOM_BINDINGS_UTIL_H_ | 5 #ifndef CHROME_RENDERER_EXTENSIONS_CUSTOM_BINDINGS_UTIL_H_ |
6 #define CHROME_RENDERER_EXTENSIONS_CUSTOM_BINDINGS_UTIL_H_ | 6 #define CHROME_RENDERER_EXTENSIONS_CUSTOM_BINDINGS_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "chrome/renderer/extensions/chrome_v8_context.h" | 12 #include "chrome/renderer/extensions/chrome_v8_context.h" |
13 #include "chrome/renderer/extensions/chrome_v8_extension.h" | 13 #include "chrome/renderer/extensions/chrome_v8_extension.h" |
14 | 14 |
15 class Extension; | 15 class Extension; |
16 class ExtensionDispatcher; | 16 class ExtensionDispatcher; |
17 | 17 |
18 namespace v8 { | 18 namespace v8 { |
19 class Extension; | 19 class Extension; |
20 } | 20 } |
21 | 21 |
22 namespace extensions { | 22 namespace extensions { |
23 | 23 |
24 // Utilities for managing the set of V8 extensions for extension API custom | 24 // Utilities for managing the set of V8 extensions for extension API custom |
25 // bindings. | 25 // bindings. |
26 namespace custom_bindings_util { | 26 namespace custom_bindings_util { |
27 | 27 |
28 // Creates V8 extensions for all custom bindings. | |
29 std::vector<v8::Extension*> GetAll(ExtensionDispatcher* extension_dispatcher); | |
30 | |
31 // Extracts the name of an API from the name of the V8 extension which contains | 28 // Extracts the name of an API from the name of the V8 extension which contains |
32 // custom bindings for it. | 29 // custom bindings for it. |
33 // Returns an empty string if the extension is not for a custom binding. | 30 // Returns an empty string if the extension is not for a custom binding. |
34 std::string GetAPIName(const std::string& v8_extension_name); | 31 std::string GetAPIName(const std::string& v8_extension_name); |
35 | 32 |
36 // Returns whether the custom binding for an API should be allowed to run for | 33 // Returns whether the custom binding for an API should be allowed to run for |
37 // |extension|. This is based on whether the extension has any permission | 34 // |extension|. This is based on whether the extension has any permission |
38 // (required or optional) for that API, and what context the APIs are intended | 35 // (required or optional) for that API, and what context the APIs are intended |
39 // to run in. | 36 // to run in. |
40 bool AllowAPIInjection(const std::string& api_name, | 37 bool AllowAPIInjection(const std::string& api_name, |
41 const Extension& extension, | 38 const Extension& extension, |
42 ChromeV8Context::ContextType context_type); | 39 ChromeV8Context::ContextType context_type); |
43 | 40 |
44 } // namespace custom_bindings_util | 41 } // namespace custom_bindings_util |
45 | 42 |
46 } // namespace extensions | 43 } // namespace extensions |
47 | 44 |
48 #endif // CHROME_RENDERER_EXTENSIONS_CUSTOM_BINDINGS_UTIL_H_ | 45 #endif // CHROME_RENDERER_EXTENSIONS_CUSTOM_BINDINGS_UTIL_H_ |
OLD | NEW |