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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
10 #include "base/linked_ptr.h" | 10 #include "base/linked_ptr.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // v8 extension. | 43 // v8 extension. |
44 virtual v8::Handle<v8::FunctionTemplate> | 44 virtual v8::Handle<v8::FunctionTemplate> |
45 GetNativeFunction(v8::Handle<v8::String> name); | 45 GetNativeFunction(v8::Handle<v8::String> name); |
46 | 46 |
47 protected: | 47 protected: |
48 // Returns a hidden variable for use by the bindings that is unreachable | 48 // Returns a hidden variable for use by the bindings that is unreachable |
49 // by the page. | 49 // by the page. |
50 static v8::Handle<v8::Value> GetChromeHidden(const v8::Arguments& args); | 50 static v8::Handle<v8::Value> GetChromeHidden(const v8::Arguments& args); |
51 }; | 51 }; |
52 | 52 |
53 template<int kResourceId> | 53 const char* GetStringResource(int resource_id); |
54 struct StringResourceTemplate { | |
55 StringResourceTemplate() | |
56 : resource(ResourceBundle::GetSharedInstance().GetRawDataResource( | |
57 kResourceId).as_string()) { | |
58 } | |
59 std::string resource; | |
60 }; | |
61 | |
62 template<int kResourceId> | |
63 const char* GetStringResource() { | |
64 return | |
65 Singleton< StringResourceTemplate<kResourceId> >::get()->resource.c_str(); | |
66 } | |
67 | 54 |
68 // Contains information about a single javascript context. | 55 // Contains information about a single javascript context. |
69 struct ContextInfo { | 56 struct ContextInfo { |
70 ContextInfo(v8::Persistent<v8::Context> context, | 57 ContextInfo(v8::Persistent<v8::Context> context, |
71 const std::string& extension_id, | 58 const std::string& extension_id, |
72 WebKit::WebFrame* parent_frame, | 59 WebKit::WebFrame* parent_frame, |
73 RenderView* render_view); | 60 RenderView* render_view); |
74 ~ContextInfo(); | 61 ~ContextInfo(); |
75 | 62 |
76 v8::Persistent<v8::Context> context; | 63 v8::Persistent<v8::Context> context; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // be a sub-property like "Port.dispatchOnMessage". Returns the result of | 114 // be a sub-property like "Port.dispatchOnMessage". Returns the result of |
128 // the function call. If an exception is thrown an empty Handle will be | 115 // the function call. If an exception is thrown an empty Handle will be |
129 // returned. | 116 // returned. |
130 v8::Handle<v8::Value> CallFunctionInContext(v8::Handle<v8::Context> context, | 117 v8::Handle<v8::Value> CallFunctionInContext(v8::Handle<v8::Context> context, |
131 const std::string& function_name, int argc, | 118 const std::string& function_name, int argc, |
132 v8::Handle<v8::Value>* argv); | 119 v8::Handle<v8::Value>* argv); |
133 | 120 |
134 } // namespace bindings_utils | 121 } // namespace bindings_utils |
135 | 122 |
136 #endif // CHROME_RENDERER_EXTENSIONS_BINDINGS_UTILS_H_ | 123 #endif // CHROME_RENDERER_EXTENSIONS_BINDINGS_UTILS_H_ |
OLD | NEW |