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

Side by Side Diff: chrome/common/jstemplate_builder.cc

Issue 10269008: fix jstemplate_builder::UseVersion2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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
« no previous file with comments | « chrome/common/jstemplate_builder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // 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"
11 #include "base/json/json_string_value_serializer.h" 11 #include "base/json/json_string_value_serializer.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "grit/common_resources.h" 14 #include "grit/common_resources.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 16
17 namespace { 17 namespace {
18 18
19 // True when building version 2 templates. See UseVersion2 class. 19 // Non-zero when building version 2 templates. See UseVersion2 class.
20 bool g_version2 = false; 20 int g_version2 = 0;
21 21
22 } // namespace 22 } // namespace
23 23
24 namespace jstemplate_builder { 24 namespace jstemplate_builder {
25 25
26 UseVersion2::UseVersion2() : previous_value_(g_version2) { 26 UseVersion2::UseVersion2() {
27 g_version2 = true; 27 g_version2++;
28 } 28 }
29 29
30 UseVersion2::~UseVersion2() { 30 UseVersion2::~UseVersion2() {
31 g_version2 = previous_value_; 31 g_version2--;
32 } 32 }
33 33
34 std::string GetTemplateHtml(const base::StringPiece& html_template, 34 std::string GetTemplateHtml(const base::StringPiece& html_template,
35 const DictionaryValue* json, 35 const DictionaryValue* json,
36 const base::StringPiece& template_id) { 36 const base::StringPiece& template_id) {
37 std::string output(html_template.data(), html_template.size()); 37 std::string output(html_template.data(), html_template.size());
38 AppendJsonHtml(json, &output); 38 AppendJsonHtml(json, &output);
39 AppendJsTemplateSourceHtml(&output); 39 AppendJsTemplateSourceHtml(&output);
40 AppendJsTemplateProcessHtml(template_id, &output); 40 AppendJsTemplateProcessHtml(template_id, &output);
41 return output; 41 return output;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 NOTREACHED() << "Unable to get i18n process src"; 146 NOTREACHED() << "Unable to get i18n process src";
147 return; 147 return;
148 } 148 }
149 149
150 output->append("<script>"); 150 output->append("<script>");
151 output->append(i18n_process_src.data(), i18n_process_src.size()); 151 output->append(i18n_process_src.data(), i18n_process_src.size());
152 output->append("</script>"); 152 output->append("</script>");
153 } 153 }
154 154
155 } // namespace jstemplate_builder 155 } // namespace jstemplate_builder
OLDNEW
« no previous file with comments | « chrome/common/jstemplate_builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698