OLD | NEW |
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 #include "extensions/browser/warning_set.h" | 5 #include "extensions/browser/warning_set.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 188 |
189 std::string Warning::GetLocalizedMessage(const ExtensionSet* extensions) const { | 189 std::string Warning::GetLocalizedMessage(const ExtensionSet* extensions) const { |
190 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 190 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
191 | 191 |
192 // These parameters may be unsafe (URLs and Extension names) and need | 192 // These parameters may be unsafe (URLs and Extension names) and need |
193 // to be HTML-escaped before being embedded in the UI. Also extension IDs | 193 // to be HTML-escaped before being embedded in the UI. Also extension IDs |
194 // are translated to full extension names. | 194 // are translated to full extension names. |
195 std::vector<base::string16> final_parameters; | 195 std::vector<base::string16> final_parameters; |
196 for (size_t i = 0; i < message_parameters_.size(); ++i) { | 196 for (size_t i = 0; i < message_parameters_.size(); ++i) { |
197 std::string message = message_parameters_[i]; | 197 std::string message = message_parameters_[i]; |
198 if (StartsWithASCII(message, kTranslate, true)) { | 198 if (base::StartsWithASCII(message, kTranslate, true)) { |
199 std::string extension_id = message.substr(sizeof(kTranslate) - 1); | 199 std::string extension_id = message.substr(sizeof(kTranslate) - 1); |
200 const extensions::Extension* extension = | 200 const extensions::Extension* extension = |
201 extensions->GetByID(extension_id); | 201 extensions->GetByID(extension_id); |
202 message = extension ? extension->name() : extension_id; | 202 message = extension ? extension->name() : extension_id; |
203 } | 203 } |
204 final_parameters.push_back(base::UTF8ToUTF16(net::EscapeForHTML(message))); | 204 final_parameters.push_back(base::UTF8ToUTF16(net::EscapeForHTML(message))); |
205 } | 205 } |
206 | 206 |
207 static_assert(kMaxNumberOfParameters == 4u, | 207 static_assert(kMaxNumberOfParameters == 4u, |
208 "You Need To Add More Case Statements"); | 208 "You Need To Add More Case Statements"); |
(...skipping 17 matching lines...) Expand all Loading... |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 bool operator<(const Warning& a, const Warning& b) { | 229 bool operator<(const Warning& a, const Warning& b) { |
230 if (a.extension_id() != b.extension_id()) | 230 if (a.extension_id() != b.extension_id()) |
231 return a.extension_id() < b.extension_id(); | 231 return a.extension_id() < b.extension_id(); |
232 return a.warning_type() < b.warning_type(); | 232 return a.warning_type() < b.warning_type(); |
233 } | 233 } |
234 | 234 |
235 } // namespace extensions | 235 } // namespace extensions |
OLD | NEW |