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

Side by Side Diff: ui/webui/jstemplate_builder.h

Issue 11929016: Move jstemplate_builder.* to ui\webui so it can be reused by webui implementations outside of chrom… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync to 177705 to get yfriendman's fix Created 7 years, 11 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 | « ui/webui/DEPS ('k') | ui/webui/jstemplate_builder.cc » ('j') | 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 // This provides some helper methods for building and rendering an 5 // This provides some helper methods for building and rendering an
6 // internal html page. The flow is as follows: 6 // internal html page. The flow is as follows:
7 // - instantiate a builder given a webframe that we're going to render content 7 // - instantiate a builder given a webframe that we're going to render content
8 // into 8 // into
9 // - load the template html and load the jstemplate javascript into the frame 9 // - load the template html and load the jstemplate javascript into the frame
10 // - given a json data object, run the jstemplate javascript which fills in 10 // - given a json data object, run the jstemplate javascript which fills in
11 // template values 11 // template values
12 12
13 #ifndef CHROME_COMMON_JSTEMPLATE_BUILDER_H_ 13 #ifndef UI_WEBUI_JSTEMPLATE_BUILDER_H_
14 #define CHROME_COMMON_JSTEMPLATE_BUILDER_H_ 14 #define UI_WEBUI_JSTEMPLATE_BUILDER_H_
15 15
16 #include <string> 16 #include <string>
17 17
18 #include "base/string_piece.h" 18 #include "base/string_piece.h"
19 #include "ui/base/ui_export.h"
19 20
20 namespace base { 21 namespace base {
21 class DictionaryValue; 22 class DictionaryValue;
22 } 23 }
23 24
24 namespace jstemplate_builder { 25 namespace jstemplate_builder {
25 26
26 // While an object of this class is in scope, the template builder will output 27 // While an object of this class is in scope, the template builder will output
27 // version 2 html. Version 2 uses load_time_data.js and i18n_template2.js, and 28 // version 2 html. Version 2 uses load_time_data.js and i18n_template2.js, and
28 // should soon become the default. 29 // should soon become the default.
29 class UseVersion2 { 30 class UI_EXPORT UseVersion2 {
30 public: 31 public:
31 UseVersion2(); 32 UseVersion2();
32 ~UseVersion2(); 33 ~UseVersion2();
33 34
34 private: 35 private:
35 DISALLOW_COPY_AND_ASSIGN(UseVersion2); 36 DISALLOW_COPY_AND_ASSIGN(UseVersion2);
36 }; 37 };
37 38
38 // A helper function that generates a string of HTML to be loaded. The 39 // A helper function that generates a string of HTML to be loaded. The
39 // string includes the HTML and the javascript code necessary to generate the 40 // string includes the HTML and the javascript code necessary to generate the
40 // full page with support for JsTemplates. 41 // full page with support for JsTemplates.
41 std::string GetTemplateHtml(const base::StringPiece& html_template, 42 UI_EXPORT std::string GetTemplateHtml(const base::StringPiece& html_template,
42 const base::DictionaryValue* json, 43 const base::DictionaryValue* json,
43 const base::StringPiece& template_id); 44 const base::StringPiece& template_id);
44 45
45 // A helper function that generates a string of HTML to be loaded. The 46 // A helper function that generates a string of HTML to be loaded. The
46 // string includes the HTML and the javascript code necessary to generate the 47 // string includes the HTML and the javascript code necessary to generate the
47 // full page with support for i18n Templates. 48 // full page with support for i18n Templates.
48 std::string GetI18nTemplateHtml(const base::StringPiece& html_template, 49 UI_EXPORT std::string GetI18nTemplateHtml(
49 const base::DictionaryValue* json); 50 const base::StringPiece& html_template,
51 const base::DictionaryValue* json);
50 52
51 // A helper function that generates a string of HTML to be loaded. The 53 // A helper function that generates a string of HTML to be loaded. The
52 // string includes the HTML and the javascript code necessary to generate the 54 // string includes the HTML and the javascript code necessary to generate the
53 // full page with support for both i18n Templates and JsTemplates. 55 // full page with support for both i18n Templates and JsTemplates.
54 std::string GetTemplatesHtml(const base::StringPiece& html_template, 56 UI_EXPORT std::string GetTemplatesHtml(const base::StringPiece& html_template,
55 const base::DictionaryValue* json, 57 const base::DictionaryValue* json,
56 const base::StringPiece& template_id); 58 const base::StringPiece& template_id);
57 59
58 // The following functions build up the different parts that the above 60 // The following functions build up the different parts that the above
59 // templates use. 61 // templates use.
60 62
61 // Appends a script tag with a variable name |templateData| that has the JSON 63 // Appends a script tag with a variable name |templateData| that has the JSON
62 // assigned to it. 64 // assigned to it.
63 void AppendJsonHtml(const base::DictionaryValue* json, std::string* output); 65 UI_EXPORT void AppendJsonHtml(const base::DictionaryValue* json,
66 std::string* output);
64 67
65 // Same as AppendJsonHtml(), except does not include the <script></script> 68 // Same as AppendJsonHtml(), except does not include the <script></script>
66 // tag wrappers. 69 // tag wrappers.
67 void AppendJsonJS(const base::DictionaryValue* json, std::string* output); 70 UI_EXPORT void AppendJsonJS(const base::DictionaryValue* json,
71 std::string* output);
68 72
69 // Appends the source for JsTemplates in a script tag. 73 // Appends the source for JsTemplates in a script tag.
70 void AppendJsTemplateSourceHtml(std::string* output); 74 UI_EXPORT void AppendJsTemplateSourceHtml(std::string* output);
71 75
72 // Appends the code that processes the JsTemplate with the JSON. You should 76 // Appends the code that processes the JsTemplate with the JSON. You should
73 // call AppendJsTemplateSourceHtml and AppendJsonHtml before calling this. 77 // call AppendJsTemplateSourceHtml and AppendJsonHtml before calling this.
74 void AppendJsTemplateProcessHtml(const base::StringPiece& template_id, 78 UI_EXPORT void AppendJsTemplateProcessHtml(const base::StringPiece& template_id,
75 std::string* output); 79 std::string* output);
76 80
77 // Appends the source for i18n Templates in a script tag. 81 // Appends the source for i18n Templates in a script tag.
78 void AppendI18nTemplateSourceHtml(std::string* output); 82 UI_EXPORT void AppendI18nTemplateSourceHtml(std::string* output);
79 83
80 // Appends the code that processes the i18n Template with the JSON. You 84 // Appends the code that processes the i18n Template with the JSON. You
81 // should call AppendJsTemplateSourceHtml and AppendJsonHtml before calling 85 // should call AppendJsTemplateSourceHtml and AppendJsonHtml before calling
82 // this. 86 // this.
83 void AppendI18nTemplateProcessHtml(std::string* output); 87 UI_EXPORT void AppendI18nTemplateProcessHtml(std::string* output);
84 88
85 } // namespace jstemplate_builder 89 } // namespace jstemplate_builder
86 #endif // CHROME_COMMON_JSTEMPLATE_BUILDER_H_ 90 #endif // UI_WEBUI_JSTEMPLATE_BUILDER_H_
OLDNEW
« no previous file with comments | « ui/webui/DEPS ('k') | ui/webui/jstemplate_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698