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

Side by Side Diff: chrome/browser/ui/webui/options/password_manager_handler.cc

Issue 2051663003: base::ListValue::Append cleanup: pass unique_ptr instead of the released pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/webui/options/password_manager_handler.h" 5 #include "chrome/browser/ui/webui/options/password_manager_handler.h"
6 6
7 #include <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/command_line.h" 10 #include "base/command_line.h"
9 #include "base/feature_list.h" 11 #include "base/feature_list.h"
10 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
11 #include "base/macros.h" 13 #include "base/macros.h"
12 #include "base/metrics/field_trial.h" 14 #include "base/metrics/field_trial.h"
13 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
14 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
16 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 kPasswordField, 278 kPasswordField,
277 base::string16(saved_password->password_value.length(), ' ')); 279 base::string16(saved_password->password_value.length(), ' '));
278 if (!saved_password->federation_origin.unique()) { 280 if (!saved_password->federation_origin.unique()) {
279 entry->SetString( 281 entry->SetString(
280 kFederationField, 282 kFederationField,
281 l10n_util::GetStringFUTF16( 283 l10n_util::GetStringFUTF16(
282 IDS_PASSWORDS_VIA_FEDERATION, 284 IDS_PASSWORDS_VIA_FEDERATION,
283 base::UTF8ToUTF16(saved_password->federation_origin.host()))); 285 base::UTF8ToUTF16(saved_password->federation_origin.host())));
284 } 286 }
285 287
286 entries.Append(entry.release()); 288 entries.Append(std::move(entry));
287 } 289 }
288 290
289 web_ui()->CallJavascriptFunctionUnsafe( 291 web_ui()->CallJavascriptFunctionUnsafe(
290 "PasswordManager.setSavedPasswordsList", entries); 292 "PasswordManager.setSavedPasswordsList", entries);
291 } 293 }
292 294
293 void PasswordManagerHandler::SetPasswordExceptionList( 295 void PasswordManagerHandler::SetPasswordExceptionList(
294 const std::vector<std::unique_ptr<autofill::PasswordForm>>& 296 const std::vector<std::unique_ptr<autofill::PasswordForm>>&
295 password_exception_list) { 297 password_exception_list) {
296 base::ListValue entries; 298 base::ListValue entries;
297 for (const auto& exception : password_exception_list) { 299 for (const auto& exception : password_exception_list) {
298 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue); 300 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue);
299 CopyOriginInfoOfPasswordForm(*exception, entry.get()); 301 CopyOriginInfoOfPasswordForm(*exception, entry.get());
300 entries.Append(entry.release()); 302 entries.Append(std::move(entry));
301 } 303 }
302 304
303 web_ui()->CallJavascriptFunctionUnsafe( 305 web_ui()->CallJavascriptFunctionUnsafe(
304 "PasswordManager.setPasswordExceptionsList", entries); 306 "PasswordManager.setPasswordExceptionsList", entries);
305 } 307 }
306 308
307 void PasswordManagerHandler::FileSelected(const base::FilePath& path, 309 void PasswordManagerHandler::FileSelected(const base::FilePath& path,
308 int index, 310 int index,
309 void* params) { 311 void* params) {
310 switch (static_cast<FileSelectorCaller>(reinterpret_cast<intptr_t>(params))) { 312 switch (static_cast<FileSelectorCaller>(reinterpret_cast<intptr_t>(params))) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 password_manager_presenter_->GetAllPasswords(); 407 password_manager_presenter_->GetAllPasswords();
406 UMA_HISTOGRAM_COUNTS("PasswordManager.ExportedPasswordsPerUserInCSV", 408 UMA_HISTOGRAM_COUNTS("PasswordManager.ExportedPasswordsPerUserInCSV",
407 password_list.size()); 409 password_list.size());
408 password_manager::PasswordExporter::Export( 410 password_manager::PasswordExporter::Export(
409 path, password_list, content::BrowserThread::GetMessageLoopProxyForThread( 411 path, password_list, content::BrowserThread::GetMessageLoopProxyForThread(
410 content::BrowserThread::FILE) 412 content::BrowserThread::FILE)
411 .get()); 413 .get());
412 } 414 }
413 415
414 } // namespace options 416 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698