Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "ui/base/template_expressions.h" | 5 #include "ui/base/template_expressions.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "net/base/escape.h" | 10 #include "net/base/escape.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 current_pos = context_end + sizeof(kKeyOpen); | 47 current_pos = context_end + sizeof(kKeyOpen); |
| 48 | 48 |
| 49 size_t key_end = source.find(kKeyClose, current_pos); | 49 size_t key_end = source.find(kKeyClose, current_pos); |
| 50 CHECK_NE(key_end, std::string::npos); | 50 CHECK_NE(key_end, std::string::npos); |
| 51 | 51 |
| 52 std::string key = | 52 std::string key = |
| 53 source.substr(current_pos, key_end - current_pos).as_string(); | 53 source.substr(current_pos, key_end - current_pos).as_string(); |
| 54 CHECK(!key.empty()); | 54 CHECK(!key.empty()); |
| 55 | 55 |
| 56 TemplateReplacements::const_iterator value = replacements.find(key); | 56 TemplateReplacements::const_iterator value = replacements.find(key); |
| 57 CHECK(value != replacements.end()) << "$i18n replacement key \"" << key | 57 CHECK(value != replacements.end()); |
|
Alexander Alekseev
2016/12/09 06:14:02
I just came across this CHECK and it turned out th
dcheng
2016/12/09 06:17:24
LOG(FATAL) isn't equivalent: CHECK attempts (but f
Alexander Alekseev
2016/12/09 07:14:50
This means that that most people used CHECK() with
dcheng
2016/12/09 07:29:36
1. We shouldn't unconditionally emit the string: w
Alexander Alekseev
2016/12/09 07:41:23
1) Do you mean that a single explanation message b
dcheng
2016/12/09 07:56:11
Not necessarily, but there's a binary size tradeof
| |
| 58 << "\" not found"; | |
| 59 | 58 |
| 60 std::string replacement = value->second; | 59 std::string replacement = value->second; |
| 61 if (context.empty()) { | 60 if (context.empty()) { |
| 62 // Make the replacement HTML safe. | 61 // Make the replacement HTML safe. |
| 63 replacement = net::EscapeForHTML(replacement); | 62 replacement = net::EscapeForHTML(replacement); |
| 64 } else if (context == "Raw") { | 63 } else if (context == "Raw") { |
| 65 // Pass the replacement through unchanged. | 64 // Pass the replacement through unchanged. |
| 66 } else { | 65 } else { |
| 67 CHECK(false) << "Unknown context " << context; | 66 // Unknown context |context| |
| 67 CHECK(false); | |
| 68 } | 68 } |
| 69 | 69 |
| 70 formatted.append(replacement); | 70 formatted.append(replacement); |
| 71 | 71 |
| 72 current_pos = key_end + sizeof(kKeyClose); | 72 current_pos = key_end + sizeof(kKeyClose); |
| 73 } | 73 } |
| 74 return formatted; | 74 return formatted; |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace ui | 77 } // namespace ui |
| OLD | NEW |