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 // A helper function for using JsTemplate. See jstemplate_builder.h for more | 5 // A helper function for using JsTemplate. See jstemplate_builder.h for more |
6 // info. | 6 // info. |
7 | 7 |
8 #include "chrome/common/jstemplate_builder.h" | 8 #include "chrome/common/jstemplate_builder.h" |
9 | 9 |
10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 output->append(template_id.data(), template_id.size()); | 110 output->append(template_id.data(), template_id.size()); |
111 output->append("');"); | 111 output->append("');"); |
112 output->append("jstProcess(new JsEvalContext(templateData), tp);"); | 112 output->append("jstProcess(new JsEvalContext(templateData), tp);"); |
113 output->append("</script>"); | 113 output->append("</script>"); |
114 } | 114 } |
115 | 115 |
116 void AppendI18nTemplateSourceHtml(std::string* output) { | 116 void AppendI18nTemplateSourceHtml(std::string* output) { |
117 // fetch and cache the pointer of the jstemplate resource source text. | 117 // fetch and cache the pointer of the jstemplate resource source text. |
118 static const base::StringPiece i18n_template_src( | 118 static const base::StringPiece i18n_template_src( |
119 ResourceBundle::GetSharedInstance().GetRawDataResource( | 119 ResourceBundle::GetSharedInstance().GetRawDataResource( |
120 g_version2 ? IDR_I18N_TEMPLATE2_JS : IDR_I18N_TEMPLATE_JS)); | 120 IDR_I18N_TEMPLATE_JS)); |
| 121 static const base::StringPiece i18n_template2_src( |
| 122 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 123 IDR_I18N_TEMPLATE2_JS)); |
| 124 const base::StringPiece* template_src = g_version2 ? |
| 125 &i18n_template2_src : &i18n_template_src; |
121 | 126 |
122 if (i18n_template_src.empty()) { | 127 if (template_src->empty()) { |
123 NOTREACHED() << "Unable to get i18n template src"; | 128 NOTREACHED() << "Unable to get i18n template src"; |
124 return; | 129 return; |
125 } | 130 } |
126 | 131 |
127 output->append("<script>"); | 132 output->append("<script>"); |
128 output->append(i18n_template_src.data(), i18n_template_src.size()); | 133 output->append(template_src->data(), template_src->size()); |
129 output->append("</script>"); | 134 output->append("</script>"); |
130 } | 135 } |
131 | 136 |
132 void AppendI18nTemplateProcessHtml(std::string* output) { | 137 void AppendI18nTemplateProcessHtml(std::string* output) { |
133 if (g_version2) | 138 if (g_version2) |
134 return; | 139 return; |
135 | 140 |
136 static const base::StringPiece i18n_process_src( | 141 static const base::StringPiece i18n_process_src( |
137 ResourceBundle::GetSharedInstance().GetRawDataResource( | 142 ResourceBundle::GetSharedInstance().GetRawDataResource( |
138 IDR_I18N_PROCESS_JS)); | 143 IDR_I18N_PROCESS_JS)); |
139 | 144 |
140 if (i18n_process_src.empty()) { | 145 if (i18n_process_src.empty()) { |
141 NOTREACHED() << "Unable to get i18n process src"; | 146 NOTREACHED() << "Unable to get i18n process src"; |
142 return; | 147 return; |
143 } | 148 } |
144 | 149 |
145 output->append("<script>"); | 150 output->append("<script>"); |
146 output->append(i18n_process_src.data(), i18n_process_src.size()); | 151 output->append(i18n_process_src.data(), i18n_process_src.size()); |
147 output->append("</script>"); | 152 output->append("</script>"); |
148 } | 153 } |
149 | 154 |
150 } // namespace jstemplate_builder | 155 } // namespace jstemplate_builder |
OLD | NEW |