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

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

Issue 1898113002: No SelectFilePolicy for password import and export UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@341477_about_flags
Patch Set: Remove leak suppresion 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 | tools/valgrind/memcheck/suppressions.txt » ('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" 9 #include "base/debug/leak_annotations.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/metrics/field_trial.h" 13 #include "base/metrics/field_trial.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/string_split.h" 16 #include "base/strings/string_split.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #include "chrome/browser/chrome_notification_types.h" 20 #include "chrome/browser/chrome_notification_types.h"
21 #include "chrome/browser/password_manager/password_store_factory.h" 21 #include "chrome/browser/password_manager/password_store_factory.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/sync/profile_sync_service_factory.h" 23 #include "chrome/browser/sync/profile_sync_service_factory.h"
24 #include "chrome/browser/ui/chrome_select_file_policy.h"
25 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
26 #include "chrome/common/url_constants.h" 25 #include "chrome/common/url_constants.h"
27 #include "chrome/grit/generated_resources.h" 26 #include "chrome/grit/generated_resources.h"
28 #include "components/autofill/core/common/password_form.h" 27 #include "components/autofill/core/common/password_form.h"
29 #include "components/browser_sync/browser/profile_sync_service.h" 28 #include "components/browser_sync/browser/profile_sync_service.h"
30 #include "components/password_manager/core/browser/export/password_exporter.h" 29 #include "components/password_manager/core/browser/export/password_exporter.h"
31 #include "components/password_manager/core/browser/password_bubble_experiment.h" 30 #include "components/password_manager/core/browser/password_bubble_experiment.h"
32 #include "components/password_manager/core/browser/password_manager_constants.h" 31 #include "components/password_manager/core/browser/password_manager_constants.h"
33 #include "components/password_manager/core/browser/password_store.h" 32 #include "components/password_manager/core/browser/password_store.h"
34 #include "components/password_manager/core/browser/password_ui_utils.h" 33 #include "components/password_manager/core/browser/password_ui_utils.h"
(...skipping 284 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(this, nullptr);
330 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( 329 select_file_dialog_->SelectFile(
334 ui::SelectFileDialog::SELECT_OPEN_FILE, 330 ui::SelectFileDialog::SELECT_OPEN_FILE,
335 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_IMPORT_DIALOG_TITLE), 331 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_IMPORT_DIALOG_TITLE),
336 base::FilePath(), &file_type_info, 1, file_type_info.extensions[0][0], 332 base::FilePath(), &file_type_info, 1, file_type_info.extensions[0][0],
337 web_ui()->GetWebContents()->GetTopLevelNativeWindow(), 333 web_ui()->GetWebContents()->GetTopLevelNativeWindow(),
338 reinterpret_cast<void*>(IMPORT_FILE_SELECTED)); 334 reinterpret_cast<void*>(IMPORT_FILE_SELECTED));
339 #endif 335 #endif
340 } 336 }
341 337
342 void PasswordManagerHandler::ImportPasswordFileSelected( 338 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. 380 #if !defined(OS_ANDROID) // This is never called on Android.
385 if (!password_manager_presenter_->IsUserAuthenticated()) 381 if (!password_manager_presenter_->IsUserAuthenticated())
386 return; 382 return;
387 383
388 ui::SelectFileDialog::FileTypeInfo file_type_info; 384 ui::SelectFileDialog::FileTypeInfo file_type_info;
389 file_type_info.extensions = 385 file_type_info.extensions =
390 password_manager::PasswordExporter::GetSupportedFileExtensions(); 386 password_manager::PasswordExporter::GetSupportedFileExtensions();
391 DCHECK(!file_type_info.extensions.empty() && 387 DCHECK(!file_type_info.extensions.empty() &&
392 !file_type_info.extensions[0].empty()); 388 !file_type_info.extensions[0].empty());
393 file_type_info.include_all_files = true; 389 file_type_info.include_all_files = true;
394 ChromeSelectFilePolicy* select_file_policy = 390 select_file_dialog_ = ui::SelectFileDialog::Create(this, nullptr);
395 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( 391 select_file_dialog_->SelectFile(
399 ui::SelectFileDialog::SELECT_SAVEAS_FILE, 392 ui::SelectFileDialog::SELECT_SAVEAS_FILE,
400 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_EXPORT_DIALOG_TITLE), 393 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_EXPORT_DIALOG_TITLE),
401 base::FilePath(), &file_type_info, 1, file_type_info.extensions[0][0], 394 base::FilePath(), &file_type_info, 1, file_type_info.extensions[0][0],
402 GetNativeWindow(), reinterpret_cast<void*>(EXPORT_FILE_SELECTED)); 395 GetNativeWindow(), reinterpret_cast<void*>(EXPORT_FILE_SELECTED));
403 #endif 396 #endif
404 } 397 }
405 398
406 void PasswordManagerHandler::ExportPasswordFileSelected( 399 void PasswordManagerHandler::ExportPasswordFileSelected(
407 const base::FilePath& path) { 400 const base::FilePath& path) {
408 std::vector<std::unique_ptr<autofill::PasswordForm>> password_list = 401 std::vector<std::unique_ptr<autofill::PasswordForm>> password_list =
409 password_manager_presenter_->GetAllPasswords(); 402 password_manager_presenter_->GetAllPasswords();
410 UMA_HISTOGRAM_COUNTS("PasswordManager.ExportedPasswordsPerUserInCSV", 403 UMA_HISTOGRAM_COUNTS("PasswordManager.ExportedPasswordsPerUserInCSV",
411 password_list.size()); 404 password_list.size());
412 password_manager::PasswordExporter::Export( 405 password_manager::PasswordExporter::Export(
413 path, std::move(password_list), 406 path, std::move(password_list),
414 content::BrowserThread::GetMessageLoopProxyForThread( 407 content::BrowserThread::GetMessageLoopProxyForThread(
415 content::BrowserThread::FILE) 408 content::BrowserThread::FILE)
416 .get()); 409 .get());
417 } 410 }
418 411
419 } // namespace options 412 } // namespace options
OLDNEW
« no previous file with comments | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698