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

Side by Side Diff: extensions/browser/warning_set.cc

Issue 1242023005: Remove legacy StartsWithASCII function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: y Created 5 years, 5 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
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 #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
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 (base::StartsWithASCII(message, kTranslate, true)) { 198 if (base::StartsWith(message, kTranslate, base::CompareCase::SENSITIVE)) {
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
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
OLDNEW
« no previous file with comments | « extensions/browser/guest_view/web_view/web_view_guest.cc ('k') | extensions/common/csp_validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698