OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/autofill/core/common/save_password_progress_logger.h" | 5 #include "components/autofill/core/common/save_password_progress_logger.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 181 } |
182 | 182 |
183 // Replaces all characters satisfying IsUnwantedInElementID by a ' ', and turns | 183 // Replaces all characters satisfying IsUnwantedInElementID by a ' ', and turns |
184 // all characters to lowercase. This damages some valid HTML element IDs or | 184 // all characters to lowercase. This damages some valid HTML element IDs or |
185 // names, but it is likely that it will be still possible to match the scrubbed | 185 // names, but it is likely that it will be still possible to match the scrubbed |
186 // string to the original ID or name in the HTML doc. That's good enough for the | 186 // string to the original ID or name in the HTML doc. That's good enough for the |
187 // logging purposes, and provides some security benefits. | 187 // logging purposes, and provides some security benefits. |
188 std::string ScrubElementID(std::string element_id) { | 188 std::string ScrubElementID(std::string element_id) { |
189 std::replace_if( | 189 std::replace_if( |
190 element_id.begin(), element_id.end(), IsUnwantedInElementID, ' '); | 190 element_id.begin(), element_id.end(), IsUnwantedInElementID, ' '); |
191 return StringToLowerASCII(element_id); | 191 return base::StringToLowerASCII(element_id); |
192 } | 192 } |
193 | 193 |
194 std::string ScrubElementID(const base::string16& element_id) { | 194 std::string ScrubElementID(const base::string16& element_id) { |
195 return ScrubElementID(base::UTF16ToUTF8(element_id)); | 195 return ScrubElementID(base::UTF16ToUTF8(element_id)); |
196 } | 196 } |
197 | 197 |
198 std::string FormSchemeToString(PasswordForm::Scheme scheme) { | 198 std::string FormSchemeToString(PasswordForm::Scheme scheme) { |
199 SavePasswordProgressLogger::StringID result_id = | 199 SavePasswordProgressLogger::StringID result_id = |
200 SavePasswordProgressLogger::STRING_INVALID; | 200 SavePasswordProgressLogger::STRING_INVALID; |
201 switch (scheme) { | 201 switch (scheme) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 | 297 |
298 void SavePasswordProgressLogger::LogValue(StringID label, const Value& log) { | 298 void SavePasswordProgressLogger::LogValue(StringID label, const Value& log) { |
299 std::string log_string; | 299 std::string log_string; |
300 bool conversion_to_string_successful = base::JSONWriter::WriteWithOptions( | 300 bool conversion_to_string_successful = base::JSONWriter::WriteWithOptions( |
301 &log, base::JSONWriter::OPTIONS_PRETTY_PRINT, &log_string); | 301 &log, base::JSONWriter::OPTIONS_PRETTY_PRINT, &log_string); |
302 DCHECK(conversion_to_string_successful); | 302 DCHECK(conversion_to_string_successful); |
303 SendLog(GetStringFromID(label) + ": " + log_string); | 303 SendLog(GetStringFromID(label) + ": " + log_string); |
304 } | 304 } |
305 | 305 |
306 } // namespace autofill | 306 } // namespace autofill |
OLD | NEW |