Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: chrome/renderer/extensions/i18n_custom_bindings.cc

Issue 9386001: Implement a module system for the extension bindings JS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/common/extensions/extension_messages.h" 7 #include "chrome/common/extensions/extension_messages.h"
8 #include "chrome/common/extensions/extension_message_bundle.h" 8 #include "chrome/common/extensions/extension_message_bundle.h"
9 #include "content/public/renderer/render_view.h" 9 #include "content/public/renderer/render_view.h"
10 #include "grit/renderer_resources.h" 10 #include "grit/renderer_resources.h"
11 #include "v8/include/v8.h" 11 #include "v8/include/v8.h"
12 12
13 namespace extensions { 13 namespace extensions {
14 14
15 I18NCustomBindings::I18NCustomBindings( 15 I18NCustomBindings::I18NCustomBindings()
16 int dependency_count, const char** dependencies) 16 : ChromeV8Extension(NULL) {
17 : ChromeV8Extension( 17 RouteStaticFunction("GetL10nMessage", &GetL10nMessage);
18 "extensions/i18n_custom_bindings.js",
19 IDR_I18N_CUSTOM_BINDINGS_JS,
20 dependency_count,
21 dependencies,
22 NULL) {}
23
24 v8::Handle<v8::FunctionTemplate> I18NCustomBindings::GetNativeFunction(
25 v8::Handle<v8::String> name) {
26 if (name->Equals(v8::String::New("GetL10nMessage")))
27 return v8::FunctionTemplate::New(GetL10nMessage);
28
29 return ChromeV8Extension::GetNativeFunction(name);
30 } 18 }
31 19
32 // static 20 // static
33 v8::Handle<v8::Value> I18NCustomBindings::GetL10nMessage( 21 v8::Handle<v8::Value> I18NCustomBindings::GetL10nMessage(
34 const v8::Arguments& args) { 22 const v8::Arguments& args) {
35 if (args.Length() != 3 || !args[0]->IsString()) { 23 if (args.Length() != 3 || !args[0]->IsString()) {
36 NOTREACHED() << "Bad arguments"; 24 NOTREACHED() << "Bad arguments";
37 return v8::Undefined(); 25 return v8::Undefined();
38 } 26 }
39 27
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } else { 83 } else {
96 NOTREACHED() << "Couldn't parse second parameter."; 84 NOTREACHED() << "Couldn't parse second parameter.";
97 return v8::Undefined(); 85 return v8::Undefined();
98 } 86 }
99 87
100 return v8::String::New(ReplaceStringPlaceholders( 88 return v8::String::New(ReplaceStringPlaceholders(
101 message, substitutions, NULL).c_str()); 89 message, substitutions, NULL).c_str());
102 } 90 }
103 91
104 } // namespace extension 92 } // namespace extension
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/i18n_custom_bindings.h ('k') | chrome/renderer/extensions/json_schema_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698