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

Side by Side Diff: chrome/browser/ui/webui/options2/certificate_manager_handler2.cc

Issue 10667026: Start consolidating cross-port file selection code into ui/base/dialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos Created 8 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 | Annotate | Revision Log
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 "chrome/browser/ui/webui/options2/certificate_manager_handler2.h" 5 #include "chrome/browser/ui/webui/options2/certificate_manager_handler2.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_util.h" // for FileAccessProvider 9 #include "base/file_util.h" // for FileAccessProvider
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
11 #include "base/safe_strerror_posix.h" 11 #include "base/safe_strerror_posix.h"
12 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/certificate_viewer.h" 15 #include "chrome/browser/certificate_viewer.h"
16 #include "chrome/browser/ui/certificate_dialogs.h" 16 #include "chrome/browser/ui/certificate_dialogs.h"
17 #include "chrome/browser/ui/chrome_select_file_policy.h"
17 #include "chrome/browser/ui/crypto_module_password_dialog.h" 18 #include "chrome/browser/ui/crypto_module_password_dialog.h"
18 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
20 #include "content/public/browser/web_contents_view.h" 21 #include "content/public/browser/web_contents_view.h"
21 #include "grit/generated_resources.h" 22 #include "grit/generated_resources.h"
22 #include "net/base/crypto_module.h" 23 #include "net/base/crypto_module.h"
23 #include "net/base/net_errors.h" 24 #include "net/base/net_errors.h"
24 #include "net/base/x509_certificate.h" 25 #include "net/base/x509_certificate.h"
25 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
26 #include "ui/base/l10n/l10n_util_collator.h" 27 #include "ui/base/l10n/l10n_util_collator.h"
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 return; 557 return;
557 558
558 selected_cert_list_.push_back(cert); 559 selected_cert_list_.push_back(cert);
559 560
560 SelectFileDialog::FileTypeInfo file_type_info; 561 SelectFileDialog::FileTypeInfo file_type_info;
561 file_type_info.extensions.resize(1); 562 file_type_info.extensions.resize(1);
562 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("p12")); 563 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("p12"));
563 file_type_info.extension_description_overrides.push_back( 564 file_type_info.extension_description_overrides.push_back(
564 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_PKCS12_FILES)); 565 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_PKCS12_FILES));
565 file_type_info.include_all_files = true; 566 file_type_info.include_all_files = true;
566 select_file_dialog_ = SelectFileDialog::Create(this); 567 select_file_dialog_ = SelectFileDialog::Create(
568 this, new ChromeSelectFilePolicy(web_ui()->GetWebContents()));
567 select_file_dialog_->SelectFile( 569 select_file_dialog_->SelectFile(
568 SelectFileDialog::SELECT_SAVEAS_FILE, string16(), 570 SelectFileDialog::SELECT_SAVEAS_FILE, string16(),
569 FilePath(), &file_type_info, 1, FILE_PATH_LITERAL("p12"), 571 FilePath(), &file_type_info, 1, FILE_PATH_LITERAL("p12"),
570 web_ui()->GetWebContents(), GetParentWindow(), 572 GetParentWindow(),
571 reinterpret_cast<void*>(EXPORT_PERSONAL_FILE_SELECTED)); 573 reinterpret_cast<void*>(EXPORT_PERSONAL_FILE_SELECTED));
572 } 574 }
573 575
574 void CertificateManagerHandler::ExportAllPersonal(const ListValue* args) { 576 void CertificateManagerHandler::ExportAllPersonal(const ListValue* args) {
575 NOTIMPLEMENTED(); 577 NOTIMPLEMENTED();
576 } 578 }
577 579
578 void CertificateManagerHandler::ExportPersonalFileSelected( 580 void CertificateManagerHandler::ExportPersonalFileSelected(
579 const FilePath& path) { 581 const FilePath& path) {
580 file_path_ = path; 582 file_path_ = path;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 // so bail. 647 // so bail.
646 web_ui()->CallJavascriptFunction("CertificateRestoreOverlay.dismiss"); 648 web_ui()->CallJavascriptFunction("CertificateRestoreOverlay.dismiss");
647 ImportExportCleanup(); 649 ImportExportCleanup();
648 return; 650 return;
649 } 651 }
650 file_type_info.extensions.resize(1); 652 file_type_info.extensions.resize(1);
651 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("p12")); 653 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("p12"));
652 file_type_info.extension_description_overrides.push_back( 654 file_type_info.extension_description_overrides.push_back(
653 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_PKCS12_FILES)); 655 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_PKCS12_FILES));
654 file_type_info.include_all_files = true; 656 file_type_info.include_all_files = true;
655 select_file_dialog_ = SelectFileDialog::Create(this); 657 select_file_dialog_ = SelectFileDialog::Create(
658 this, new ChromeSelectFilePolicy(web_ui()->GetWebContents()));
656 select_file_dialog_->SelectFile( 659 select_file_dialog_->SelectFile(
657 SelectFileDialog::SELECT_OPEN_FILE, string16(), 660 SelectFileDialog::SELECT_OPEN_FILE, string16(),
658 FilePath(), &file_type_info, 1, FILE_PATH_LITERAL("p12"), 661 FilePath(), &file_type_info, 1, FILE_PATH_LITERAL("p12"),
659 web_ui()->GetWebContents(), GetParentWindow(), 662 GetParentWindow(),
660 reinterpret_cast<void*>(IMPORT_PERSONAL_FILE_SELECTED)); 663 reinterpret_cast<void*>(IMPORT_PERSONAL_FILE_SELECTED));
661 } 664 }
662 665
663 void CertificateManagerHandler::ImportPersonalFileSelected( 666 void CertificateManagerHandler::ImportPersonalFileSelected(
664 const FilePath& path) { 667 const FilePath& path) {
665 file_path_ = path; 668 file_path_ = path;
666 web_ui()->CallJavascriptFunction( 669 web_ui()->CallJavascriptFunction(
667 "CertificateManager.importPersonalAskPassword"); 670 "CertificateManager.importPersonalAskPassword");
668 } 671 }
669 672
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 module_ = NULL; 765 module_ = NULL;
763 766
764 // There may be pending file dialogs, we need to tell them that we've gone 767 // There may be pending file dialogs, we need to tell them that we've gone
765 // away so they don't try and call back to us. 768 // away so they don't try and call back to us.
766 if (select_file_dialog_.get()) 769 if (select_file_dialog_.get())
767 select_file_dialog_->ListenerDestroyed(); 770 select_file_dialog_->ListenerDestroyed();
768 select_file_dialog_ = NULL; 771 select_file_dialog_ = NULL;
769 } 772 }
770 773
771 void CertificateManagerHandler::ImportServer(const ListValue* args) { 774 void CertificateManagerHandler::ImportServer(const ListValue* args) {
772 select_file_dialog_ = SelectFileDialog::Create(this); 775 select_file_dialog_ = SelectFileDialog::Create(
776 this, new ChromeSelectFilePolicy(web_ui()->GetWebContents()));
773 ShowCertSelectFileDialog( 777 ShowCertSelectFileDialog(
774 select_file_dialog_.get(), 778 select_file_dialog_.get(),
775 SelectFileDialog::SELECT_OPEN_FILE, 779 SelectFileDialog::SELECT_OPEN_FILE,
776 FilePath(), 780 FilePath(),
777 web_ui()->GetWebContents(),
778 GetParentWindow(), 781 GetParentWindow(),
779 reinterpret_cast<void*>(IMPORT_SERVER_FILE_SELECTED)); 782 reinterpret_cast<void*>(IMPORT_SERVER_FILE_SELECTED));
780 } 783 }
781 784
782 void CertificateManagerHandler::ImportServerFileSelected(const FilePath& path) { 785 void CertificateManagerHandler::ImportServerFileSelected(const FilePath& path) {
783 file_path_ = path; 786 file_path_ = path;
784 file_access_provider_->StartRead( 787 file_access_provider_->StartRead(
785 file_path_, 788 file_path_,
786 &consumer_, 789 &consumer_,
787 base::Bind(&CertificateManagerHandler::ImportServerFileRead, 790 base::Bind(&CertificateManagerHandler::ImportServerFileRead,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 l10n_util::GetStringUTF8(IDS_CERT_MANAGER_UNKNOWN_ERROR)); 824 l10n_util::GetStringUTF8(IDS_CERT_MANAGER_UNKNOWN_ERROR));
822 } else if (!not_imported.empty()) { 825 } else if (!not_imported.empty()) {
823 ShowImportErrors( 826 ShowImportErrors(
824 l10n_util::GetStringUTF8(IDS_CERT_MANAGER_SERVER_IMPORT_ERROR_TITLE), 827 l10n_util::GetStringUTF8(IDS_CERT_MANAGER_SERVER_IMPORT_ERROR_TITLE),
825 not_imported); 828 not_imported);
826 } 829 }
827 ImportExportCleanup(); 830 ImportExportCleanup();
828 } 831 }
829 832
830 void CertificateManagerHandler::ImportCA(const ListValue* args) { 833 void CertificateManagerHandler::ImportCA(const ListValue* args) {
831 select_file_dialog_ = SelectFileDialog::Create(this); 834 select_file_dialog_ = SelectFileDialog::Create(
835 this, new ChromeSelectFilePolicy(web_ui()->GetWebContents()));
832 ShowCertSelectFileDialog(select_file_dialog_.get(), 836 ShowCertSelectFileDialog(select_file_dialog_.get(),
833 SelectFileDialog::SELECT_OPEN_FILE, 837 SelectFileDialog::SELECT_OPEN_FILE,
834 FilePath(), 838 FilePath(),
835 web_ui()->GetWebContents(),
836 GetParentWindow(), 839 GetParentWindow(),
837 reinterpret_cast<void*>(IMPORT_CA_FILE_SELECTED)); 840 reinterpret_cast<void*>(IMPORT_CA_FILE_SELECTED));
838 } 841 }
839 842
840 void CertificateManagerHandler::ImportCAFileSelected(const FilePath& path) { 843 void CertificateManagerHandler::ImportCAFileSelected(const FilePath& path) {
841 file_path_ = path; 844 file_path_ = path;
842 file_access_provider_->StartRead( 845 file_access_provider_->StartRead(
843 file_path_, 846 file_path_,
844 &consumer_, 847 &consumer_,
845 base::Bind(&CertificateManagerHandler::ImportCAFileRead, 848 base::Bind(&CertificateManagerHandler::ImportCAFileRead,
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 web_ui()->CallJavascriptFunction("CertificateManager.onCheckTpmTokenReady", 1064 web_ui()->CallJavascriptFunction("CertificateManager.onCheckTpmTokenReady",
1062 ready); 1065 ready);
1063 } 1066 }
1064 #endif 1067 #endif
1065 1068
1066 gfx::NativeWindow CertificateManagerHandler::GetParentWindow() const { 1069 gfx::NativeWindow CertificateManagerHandler::GetParentWindow() const {
1067 return web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(); 1070 return web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow();
1068 } 1071 }
1069 1072
1070 } // namespace options2 1073 } // namespace options2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698