OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/i18n_custom_bindings.h" | 5 #include "chrome/renderer/extensions/i18n_custom_bindings.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/common/extensions/extension_messages.h" | 8 #include "chrome/common/extensions/extension_messages.h" |
9 #include "chrome/common/extensions/message_bundle.h" | 9 #include "chrome/common/extensions/message_bundle.h" |
10 #include "content/public/renderer/render_view.h" | 10 #include "content/public/renderer/render_view.h" |
11 #include "grit/renderer_resources.h" | 11 #include "grit/renderer_resources.h" |
12 #include "v8/include/v8.h" | 12 #include "v8/include/v8.h" |
13 | 13 |
14 namespace extensions { | 14 namespace extensions { |
15 | 15 |
16 I18NCustomBindings::I18NCustomBindings(Dispatcher* dispatcher, | 16 I18NCustomBindings::I18NCustomBindings(Dispatcher* dispatcher, |
17 v8::Handle<v8::Context> context) | 17 ChromeV8Context* context) |
18 : ChromeV8Extension(dispatcher, context) { | 18 : ChromeV8Extension(dispatcher, context) { |
19 RouteFunction("GetL10nMessage", | 19 RouteFunction("GetL10nMessage", |
20 base::Bind(&I18NCustomBindings::GetL10nMessage, base::Unretained(this))); | 20 base::Bind(&I18NCustomBindings::GetL10nMessage, base::Unretained(this))); |
21 } | 21 } |
22 | 22 |
23 v8::Handle<v8::Value> I18NCustomBindings::GetL10nMessage( | 23 v8::Handle<v8::Value> I18NCustomBindings::GetL10nMessage( |
24 const v8::Arguments& args) { | 24 const v8::Arguments& args) { |
25 if (args.Length() != 3 || !args[0]->IsString()) { | 25 if (args.Length() != 3 || !args[0]->IsString()) { |
26 NOTREACHED() << "Bad arguments"; | 26 NOTREACHED() << "Bad arguments"; |
27 return v8::Undefined(); | 27 return v8::Undefined(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 } else if (args[1]->IsString()) { | 76 } else if (args[1]->IsString()) { |
77 // chrome.i18n.getMessage("message_name", "one param"); | 77 // chrome.i18n.getMessage("message_name", "one param"); |
78 substitutions.push_back(*v8::String::Utf8Value(args[1]->ToString())); | 78 substitutions.push_back(*v8::String::Utf8Value(args[1]->ToString())); |
79 } | 79 } |
80 | 80 |
81 return v8::String::New(ReplaceStringPlaceholders( | 81 return v8::String::New(ReplaceStringPlaceholders( |
82 message, substitutions, NULL).c_str()); | 82 message, substitutions, NULL).c_str()); |
83 } | 83 } |
84 | 84 |
85 } // namespace extension | 85 } // namespace extension |
OLD | NEW |