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

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

Issue 1898143002: Properly delete the unused policy in password_manager_handler_unittest.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@341477_about_flags
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options/password_manager_handler_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/leak_annotations.h"
10 #include "base/feature_list.h" 9 #include "base/feature_list.h"
11 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
12 #include "base/macros.h" 11 #include "base/macros.h"
13 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
14 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
15 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
17 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
18 #include "base/values.h" 17 #include "base/values.h"
19 #include "build/build_config.h" 18 #include "build/build_config.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 318
320 void PasswordManagerHandler::HandlePasswordImport(const base::ListValue* args) { 319 void PasswordManagerHandler::HandlePasswordImport(const base::ListValue* args) {
321 #if !defined(OS_ANDROID) // This is never called on Android. 320 #if !defined(OS_ANDROID) // This is never called on Android.
322 ui::SelectFileDialog::FileTypeInfo file_type_info; 321 ui::SelectFileDialog::FileTypeInfo file_type_info;
323 322
324 file_type_info.extensions = 323 file_type_info.extensions =
325 password_manager::PasswordImporter::GetSupportedFileExtensions(); 324 password_manager::PasswordImporter::GetSupportedFileExtensions();
326 DCHECK(!file_type_info.extensions.empty() && 325 DCHECK(!file_type_info.extensions.empty() &&
327 !file_type_info.extensions[0].empty()); 326 !file_type_info.extensions[0].empty());
328 file_type_info.include_all_files = true; 327 file_type_info.include_all_files = true;
329 ChromeSelectFilePolicy* select_file_policy = 328 select_file_dialog_ = ui::SelectFileDialog::Create(
330 new ChromeSelectFilePolicy(web_ui()->GetWebContents()); 329 this, new ChromeSelectFilePolicy(web_ui()->GetWebContents()));
331 ANNOTATE_LEAKING_OBJECT_PTR(select_file_policy);
332 select_file_dialog_ = ui::SelectFileDialog::Create(this, select_file_policy);
333 select_file_dialog_->SelectFile( 330 select_file_dialog_->SelectFile(
334 ui::SelectFileDialog::SELECT_OPEN_FILE, 331 ui::SelectFileDialog::SELECT_OPEN_FILE,
335 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_IMPORT_DIALOG_TITLE), 332 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_IMPORT_DIALOG_TITLE),
336 base::FilePath(), &file_type_info, 1, file_type_info.extensions[0][0], 333 base::FilePath(), &file_type_info, 1, file_type_info.extensions[0][0],
337 web_ui()->GetWebContents()->GetTopLevelNativeWindow(), 334 web_ui()->GetWebContents()->GetTopLevelNativeWindow(),
338 reinterpret_cast<void*>(IMPORT_FILE_SELECTED)); 335 reinterpret_cast<void*>(IMPORT_FILE_SELECTED));
339 #endif 336 #endif
340 } 337 }
341 338
342 void PasswordManagerHandler::ImportPasswordFileSelected( 339 void PasswordManagerHandler::ImportPasswordFileSelected(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 #if !defined(OS_ANDROID) // This is never called on Android. 381 #if !defined(OS_ANDROID) // This is never called on Android.
385 if (!password_manager_presenter_->IsUserAuthenticated()) 382 if (!password_manager_presenter_->IsUserAuthenticated())
386 return; 383 return;
387 384
388 ui::SelectFileDialog::FileTypeInfo file_type_info; 385 ui::SelectFileDialog::FileTypeInfo file_type_info;
389 file_type_info.extensions = 386 file_type_info.extensions =
390 password_manager::PasswordExporter::GetSupportedFileExtensions(); 387 password_manager::PasswordExporter::GetSupportedFileExtensions();
391 DCHECK(!file_type_info.extensions.empty() && 388 DCHECK(!file_type_info.extensions.empty() &&
392 !file_type_info.extensions[0].empty()); 389 !file_type_info.extensions[0].empty());
393 file_type_info.include_all_files = true; 390 file_type_info.include_all_files = true;
394 ChromeSelectFilePolicy* select_file_policy = 391 select_file_dialog_ = ui::SelectFileDialog::Create(
395 new ChromeSelectFilePolicy(web_ui()->GetWebContents()); 392 this, new ChromeSelectFilePolicy(web_ui()->GetWebContents()));
396 ANNOTATE_LEAKING_OBJECT_PTR(select_file_policy);
397 select_file_dialog_ = ui::SelectFileDialog::Create(this, select_file_policy);
398 select_file_dialog_->SelectFile( 393 select_file_dialog_->SelectFile(
399 ui::SelectFileDialog::SELECT_SAVEAS_FILE, 394 ui::SelectFileDialog::SELECT_SAVEAS_FILE,
400 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_EXPORT_DIALOG_TITLE), 395 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_EXPORT_DIALOG_TITLE),
401 base::FilePath(), &file_type_info, 1, file_type_info.extensions[0][0], 396 base::FilePath(), &file_type_info, 1, file_type_info.extensions[0][0],
402 GetNativeWindow(), reinterpret_cast<void*>(EXPORT_FILE_SELECTED)); 397 GetNativeWindow(), reinterpret_cast<void*>(EXPORT_FILE_SELECTED));
403 #endif 398 #endif
404 } 399 }
405 400
406 void PasswordManagerHandler::ExportPasswordFileSelected( 401 void PasswordManagerHandler::ExportPasswordFileSelected(
407 const base::FilePath& path) { 402 const base::FilePath& path) {
408 std::vector<std::unique_ptr<autofill::PasswordForm>> password_list = 403 std::vector<std::unique_ptr<autofill::PasswordForm>> password_list =
409 password_manager_presenter_->GetAllPasswords(); 404 password_manager_presenter_->GetAllPasswords();
410 UMA_HISTOGRAM_COUNTS("PasswordManager.ExportedPasswordsPerUserInCSV", 405 UMA_HISTOGRAM_COUNTS("PasswordManager.ExportedPasswordsPerUserInCSV",
411 password_list.size()); 406 password_list.size());
412 password_manager::PasswordExporter::Export( 407 password_manager::PasswordExporter::Export(
413 path, std::move(password_list), 408 path, std::move(password_list),
414 content::BrowserThread::GetMessageLoopProxyForThread( 409 content::BrowserThread::GetMessageLoopProxyForThread(
415 content::BrowserThread::FILE) 410 content::BrowserThread::FILE)
416 .get()); 411 .get());
417 } 412 }
418 413
419 } // namespace options 414 } // namespace options
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options/password_manager_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698