| 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 "chrome/common/view_types.h" |
| 14 #include "v8/include/v8.h" | 15 #include "v8/include/v8.h" |
| 15 | 16 |
| 16 class GURL; | 17 class GURL; |
| 17 class URLPattern; | 18 class URLPattern; |
| 19 class WebView; |
| 18 | 20 |
| 19 class ExtensionProcessBindings { | 21 class ExtensionProcessBindings { |
| 20 public: | 22 public: |
| 21 static void SetFunctionNames(const std::vector<std::string>& names); | 23 static void SetFunctionNames(const std::vector<std::string>& names); |
| 22 static v8::Extension* Get(); | 24 static v8::Extension* Get(); |
| 23 | 25 |
| 24 // Handles a response to an API request. | 26 // Handles a response to an API request. |
| 25 static void HandleResponse(int request_id, bool success, | 27 static void HandleResponse(int request_id, bool success, |
| 26 const std::string& response, | 28 const std::string& response, |
| 27 const std::string& error); | 29 const std::string& error); |
| 28 | 30 |
| 29 // Sets the page action ids for a particular extension. | 31 // Sets the page action ids for a particular extension. |
| 30 static void SetPageActions(const std::string& extension_id, | 32 static void SetPageActions(const std::string& extension_id, |
| 31 const std::vector<std::string>& page_actions); | 33 const std::vector<std::string>& page_actions); |
| 32 | 34 |
| 33 // Sets the API permissions for a particular extension. | 35 // Sets the API permissions for a particular extension. |
| 34 static void SetAPIPermissions(const std::string& extension_id, | 36 static void SetAPIPermissions(const std::string& extension_id, |
| 35 const std::vector<std::string>& permissions); | 37 const std::vector<std::string>& permissions); |
| 36 | 38 |
| 37 // Sets the host permissions for a particular extension. | 39 // Sets the host permissions for a particular extension. |
| 38 static void SetHostPermissions(const GURL& extension_url, | 40 static void SetHostPermissions(const GURL& extension_url, |
| 39 const std::vector<URLPattern>& permissions); | 41 const std::vector<URLPattern>& permissions); |
| 40 | 42 |
| 41 // Check if the extension in the currently running context has permission to | 43 // Check if the extension in the currently running context has permission to |
| 42 // access the given extension function. Must be called with a valid V8 | 44 // access the given extension function. Must be called with a valid V8 |
| 43 // context in scope. | 45 // context in scope. |
| 44 static bool CurrentContextHasPermission(const std::string& function_name); | 46 static bool CurrentContextHasPermission(const std::string& function_name); |
| 45 | 47 |
| 46 // Throw a V8 exception indicating that permission to access function_name was | 48 // Throw a V8 exception indicating that permission to access function_name was |
| 47 // denied. Must be called with a valid V8 context in scope. | 49 // denied. Must be called with a valid V8 context in scope. |
| 48 static v8::Handle<v8::Value> ThrowPermissionDeniedException( | 50 static v8::Handle<v8::Value> ThrowPermissionDeniedException( |
| 49 const std::string& function_name); | 51 const std::string& function_name); |
| 52 |
| 53 // For EXTENSION_* |type| values, adds/replaces a special class name on to |
| 54 // the document element (e.g. "extension_toolstrip", "extension_mole") so |
| 55 // that the page can use CSS rules to control its display appropriately. |
| 56 static void SetViewType(WebView* view, ViewType::Type type); |
| 50 }; | 57 }; |
| 51 | 58 |
| 52 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_PROCESS_BINDINGS_H_ | 59 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_PROCESS_BINDINGS_H_ |
| OLD | NEW |