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

Side by Side Diff: ui/base/template_expressions.h

Issue 2607843002: [MD settings] i18n template replacements in shared HTML resources (Closed)
Patch Set: nits Created 3 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
« no previous file with comments | « content/browser/webui/web_ui_data_source_impl.cc ('k') | ui/base/template_expressions.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 file defines utility functions for replacing template expressions. 5 // This file defines utility functions for replacing template expressions.
6 // For example "Hello ${name}" could have ${name} replaced by the user's name. 6 // For example "Hello ${name}" could have ${name} replaced by the user's name.
7 7
8 #ifndef UI_BASE_TEMPLATE_EXPRESSIONS_H_ 8 #ifndef UI_BASE_TEMPLATE_EXPRESSIONS_H_
9 #define UI_BASE_TEMPLATE_EXPRESSIONS_H_ 9 #define UI_BASE_TEMPLATE_EXPRESSIONS_H_
10 10
11 #include <map> 11 #include <map>
12 #include <string> 12 #include <string>
13 13
14 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
15 #include "ui/base/ui_base_export.h" 15 #include "ui/base/ui_base_export.h"
16 16
17 namespace base {
18 class DictionaryValue;
19 }
20
17 namespace ui { 21 namespace ui {
18 22
19 // Map of strings for template replacement in |ReplaceTemplateExpressions|. 23 // Map of strings for template replacement in |ReplaceTemplateExpressions|.
20 typedef std::map<const std::string, std::string> TemplateReplacements; 24 typedef std::map<const std::string, std::string> TemplateReplacements;
21 25
26 // Convert a dictionary to a replacement map. This helper function is to assist
27 // migration to using TemplateReplacements directly (which is preferred).
28 // TODO(dschuyler): remove this function by using TemplateReplacements directly.
29 UI_BASE_EXPORT void TemplateReplacementsFromDictionaryValue(
30 const base::DictionaryValue& dictionary,
31 TemplateReplacements* replacements);
32
22 // Replace $i18n*{foo} in the format string with the value for the foo key in 33 // Replace $i18n*{foo} in the format string with the value for the foo key in
23 // |subst|. If the key is not found in the |substitutions| that item will 34 // |subst|. If the key is not found in the |substitutions| that item will
24 // be unaltered. 35 // be unaltered.
25 UI_BASE_EXPORT std::string ReplaceTemplateExpressions( 36 UI_BASE_EXPORT std::string ReplaceTemplateExpressions(
26 base::StringPiece source, 37 base::StringPiece source,
27 const TemplateReplacements& replacements); 38 const TemplateReplacements& replacements);
28 39
29 } // namespace ui 40 } // namespace ui
30 41
31 #endif // UI_BASE_TEMPLATE_EXPRESSIONS_H_ 42 #endif // UI_BASE_TEMPLATE_EXPRESSIONS_H_
OLDNEW
« no previous file with comments | « content/browser/webui/web_ui_data_source_impl.cc ('k') | ui/base/template_expressions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698