#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "ui/base/template_expressions.h"
#include <stddef.h>
#include <optional>
#include <ostream>
#include <string_view>
#include "base/check_op.h"
#include "base/no_destructor.h"
#include "base/strings/escape.h"
#include "base/values.h"
#include "build/chromeos_buildflags.h"
#if DCHECK_IS_ON()
#include "third_party/re2/src/re2/re2.h"
#endif
namespace {
const char kLeader[] = …;
const size_t kLeaderSize = …;
const char kKeyOpen = …;
const char kKeyClose = …;
const char kHtmlTemplateEnd[] = …;
const char kHtmlTemplateStart[] = …;
const size_t kHtmlTemplateStartSize = …;
enum HtmlTemplateType { … };
struct HtmlTemplate { … };
HtmlTemplate FindHtmlTemplate(std::string_view source) { … }
std::string PolymerParameterEscape(const std::string& in_string,
bool is_javascript) { … }
bool EscapeForJS(const std::string& in_string,
std::optional<char> in_previous,
std::string* out_string) { … }
#if DCHECK_IS_ON()
bool HasUnexpectedPlaceholder(const std::string& key,
const std::string& replacement) { … }
#endif
bool ReplaceTemplateExpressionsInternal(
std::string_view source,
const ui::TemplateReplacements& replacements,
bool is_javascript,
std::string* formatted,
bool skip_unexpected_placeholder_check = false) { … }
}
namespace ui {
void TemplateReplacementsFromDictionaryValue(
const base::Value::Dict& dictionary,
TemplateReplacements* replacements) { … }
bool ReplaceTemplateExpressionsInJS(std::string_view source,
const TemplateReplacements& replacements,
std::string* formatted) { … }
std::string ReplaceTemplateExpressions(std::string_view source,
const TemplateReplacements& replacements,
bool skip_unexpected_placeholder_check) { … }
}