| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/renderer/extensions/bindings_utils.h" | 5 #include "chrome/renderer/extensions/bindings_utils.h" |
| 6 | 6 |
| 7 #include "base/string_split.h" | 7 #include "base/string_split.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/renderer/render_view.h" | 9 #include "chrome/renderer/render_view.h" |
| 10 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 10 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
| 11 | 11 |
| 12 using WebKit::WebFrame; | 12 using WebKit::WebFrame; |
| 13 using WebKit::WebView; | 13 using WebKit::WebView; |
| 14 | 14 |
| 15 namespace bindings_utils { | 15 namespace bindings_utils { |
| 16 | 16 |
| 17 const char* kChromeHidden = "chromeHidden"; | 17 const char* kChromeHidden = "chromeHidden"; |
| 18 const char* kValidateCallbacks = "validateCallbacks"; | 18 const char* kValidateCallbacks = "validateCallbacks"; |
| 19 | 19 |
| 20 struct SingletonData { | 20 struct SingletonData { |
| 21 ContextList contexts; | 21 ContextList contexts; |
| 22 PendingRequestMap pending_requests; | 22 PendingRequestMap pending_requests; |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 typedef std::map<int, std::string> StringMap; |
| 26 |
| 27 const char* GetStringResource(int resource_id) { |
| 28 StringMap* strings = Singleton<StringMap>::get(); |
| 29 StringMap::iterator it = strings->find(resource_id); |
| 30 if (it == strings->end()) { |
| 31 it = strings->insert(std::make_pair( |
| 32 resource_id, |
| 33 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 34 resource_id).as_string())).first; |
| 35 } |
| 36 return it->second.c_str(); |
| 37 } |
| 38 |
| 25 // ExtensionBase | 39 // ExtensionBase |
| 26 | 40 |
| 27 v8::Handle<v8::FunctionTemplate> | 41 v8::Handle<v8::FunctionTemplate> |
| 28 ExtensionBase::GetNativeFunction(v8::Handle<v8::String> name) { | 42 ExtensionBase::GetNativeFunction(v8::Handle<v8::String> name) { |
| 29 if (name->Equals(v8::String::New("GetChromeHidden"))) { | 43 if (name->Equals(v8::String::New("GetChromeHidden"))) { |
| 30 return v8::FunctionTemplate::New(GetChromeHidden); | 44 return v8::FunctionTemplate::New(GetChromeHidden); |
| 31 } | 45 } |
| 32 | 46 |
| 33 return v8::Handle<v8::FunctionTemplate>(); | 47 return v8::Handle<v8::FunctionTemplate>(); |
| 34 } | 48 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } | 173 } |
| 160 | 174 |
| 161 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); | 175 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); |
| 162 if (!function.IsEmpty()) | 176 if (!function.IsEmpty()) |
| 163 return function->Call(v8::Object::New(), argc, argv); | 177 return function->Call(v8::Object::New(), argc, argv); |
| 164 | 178 |
| 165 return v8::Undefined(); | 179 return v8::Undefined(); |
| 166 } | 180 } |
| 167 | 181 |
| 168 } // namespace bindings_utils | 182 } // namespace bindings_utils |
| OLD | NEW |