OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // Exposes extension APIs into the extension process. | 5 // Exposes extension APIs into the extension process. |
6 | 6 |
7 #ifndef CHROME_RENDERER_EXTENSIONS_EXTENSION_PROCESS_BINDINGS_H_ | 7 #ifndef CHROME_RENDERER_EXTENSIONS_EXTENSION_PROCESS_BINDINGS_H_ |
8 #define CHROME_RENDERER_EXTENSIONS_EXTENSION_PROCESS_BINDINGS_H_ | 8 #define CHROME_RENDERER_EXTENSIONS_EXTENSION_PROCESS_BINDINGS_H_ |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "v8/include/v8.h" | 14 #include "v8/include/v8.h" |
15 | 15 |
16 class ExtensionProcessBindings { | 16 class ExtensionProcessBindings { |
17 public: | 17 public: |
18 static void SetFunctionNames(const std::vector<std::string>& names); | 18 static void SetFunctionNames(const std::vector<std::string>& names); |
19 static v8::Extension* Get(); | 19 static v8::Extension* Get(); |
20 | 20 |
21 // Handles a response to an API request. | 21 // Handles a response to an API request. |
22 static void HandleResponse(int request_id, bool success, | 22 static void HandleResponse(int request_id, bool success, |
23 const std::string& response, | 23 const std::string& response, |
24 const std::string& error); | 24 const std::string& error); |
25 | 25 |
26 // Sets the page action ids for a particular extension. | 26 // Sets the page action ids for a particular extension. |
27 static void SetPageActions(const std::string& extension_id, | 27 static void SetPageActions(const std::string& extension_id, |
28 const std::vector<std::string>& page_actions); | 28 const std::vector<std::string>& page_actions); |
| 29 |
| 30 // Sets the permissions for a particular extension. |
| 31 static void SetPermissions(const std::string& extension_id, |
| 32 const std::vector<std::string>& permissions); |
| 33 |
| 34 // Check if the extension in the currently running context has permission to |
| 35 // access the given extension function. Must be called with a valid V8 |
| 36 // context in scope. |
| 37 static bool CurrentContextHasPermission(const std::string& function_name); |
| 38 |
| 39 // Throw a V8 exception indicating that permission to access function_name was |
| 40 // denied. Must be called with a valid V8 context in scope. |
| 41 static v8::Handle<v8::Value> ThrowPermissionDeniedException( |
| 42 const std::string& function_name); |
29 }; | 43 }; |
30 | 44 |
31 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_PROCESS_BINDINGS_H_ | 45 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_PROCESS_BINDINGS_H_ |
OLD | NEW |