| 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 #ifndef CHROME_RENDERER_EXTENSIONS_BINDINGS_UTILS_H_ | 5 #ifndef CHROME_RENDERER_EXTENSIONS_BINDINGS_UTILS_H_ |
| 6 #define CHROME_RENDERER_EXTENSIONS_BINDINGS_UTILS_H_ | 6 #define CHROME_RENDERER_EXTENSIONS_BINDINGS_UTILS_H_ |
| 7 | 7 |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/linked_ptr.h" | 9 #include "base/linked_ptr.h" |
| 10 #include "base/singleton.h" | 10 #include "base/singleton.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // This is a base class for chrome extension bindings. Common features that | 21 // This is a base class for chrome extension bindings. Common features that |
| 22 // are shared by different modules go here. | 22 // are shared by different modules go here. |
| 23 class ExtensionBase : public v8::Extension { | 23 class ExtensionBase : public v8::Extension { |
| 24 public: | 24 public: |
| 25 ExtensionBase(const char* name, | 25 ExtensionBase(const char* name, |
| 26 const char* source, | 26 const char* source, |
| 27 int dep_count, | 27 int dep_count, |
| 28 const char** deps) | 28 const char** deps) |
| 29 : v8::Extension(name, source, dep_count, deps) {} | 29 : v8::Extension(name, source, dep_count, deps) {} |
| 30 | 30 |
| 31 // Note: do not call this function before or during the chromeHidden.onLoad |
| 32 // event dispatch. The URL might not have been committed yet and might not |
| 33 // be an extension URL. |
| 34 static std::string ExtensionIdForCurrentContext(); |
| 35 |
| 31 // Derived classes should call this at the end of their implementation in | 36 // Derived classes should call this at the end of their implementation in |
| 32 // order to expose common native functions, like GetChromeHidden, to the | 37 // order to expose common native functions, like GetChromeHidden, to the |
| 33 // v8 extension. | 38 // v8 extension. |
| 34 virtual v8::Handle<v8::FunctionTemplate> | 39 virtual v8::Handle<v8::FunctionTemplate> |
| 35 GetNativeFunction(v8::Handle<v8::String> name); | 40 GetNativeFunction(v8::Handle<v8::String> name); |
| 36 | 41 |
| 37 protected: | 42 protected: |
| 38 // Returns a hidden variable for use by the bindings that is unreachable | 43 // Returns a hidden variable for use by the bindings that is unreachable |
| 39 // by the page. | 44 // by the page. |
| 40 static v8::Handle<v8::Value> GetChromeHidden(const v8::Arguments& args); | 45 static v8::Handle<v8::Value> GetChromeHidden(const v8::Arguments& args); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // be a sub-property like "Port.dispatchOnMessage". Returns the result of | 122 // be a sub-property like "Port.dispatchOnMessage". Returns the result of |
| 118 // the function call. If an exception is thrown an empty Handle will be | 123 // the function call. If an exception is thrown an empty Handle will be |
| 119 // returned. | 124 // returned. |
| 120 v8::Handle<v8::Value> CallFunctionInContext(v8::Handle<v8::Context> context, | 125 v8::Handle<v8::Value> CallFunctionInContext(v8::Handle<v8::Context> context, |
| 121 const std::string& function_name, int argc, | 126 const std::string& function_name, int argc, |
| 122 v8::Handle<v8::Value>* argv); | 127 v8::Handle<v8::Value>* argv); |
| 123 | 128 |
| 124 } // namespace bindings_utils | 129 } // namespace bindings_utils |
| 125 | 130 |
| 126 #endif // CHROME_RENDERER_EXTENSIONS_BINDINGS_UTILS_H_ | 131 #endif // CHROME_RENDERER_EXTENSIONS_BINDINGS_UTILS_H_ |
| OLD | NEW |