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

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

Issue 9003014: Replace WebUI::tab_contents() with web_contents() and switch all users to use web_contents.h inst... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/crypto_module_password_dialog.h" 17 #include "chrome/browser/ui/crypto_module_password_dialog.h"
18 #include "content/browser/tab_contents/tab_contents.h"
19 #include "content/browser/tab_contents/tab_contents_view.h" 18 #include "content/browser/tab_contents/tab_contents_view.h"
20 #include "content/public/browser/browser_thread.h" // for FileAccessProvider 19 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/web_contents.h"
21 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
22 #include "net/base/crypto_module.h" 22 #include "net/base/crypto_module.h"
23 #include "net/base/x509_certificate.h" 23 #include "net/base/x509_certificate.h"
24 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/base/l10n/l10n_util_collator.h" 25 #include "ui/base/l10n/l10n_util_collator.h"
26 26
27 #if defined(OS_CHROMEOS) 27 #if defined(OS_CHROMEOS)
28 #include "chrome/browser/chromeos/cros/cros_library.h" 28 #include "chrome/browser/chromeos/cros/cros_library.h"
29 #include "chrome/browser/chromeos/cros/cryptohome_library.h" 29 #include "chrome/browser/chromeos/cros/cryptohome_library.h"
30 #endif 30 #endif
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 SelectFileDialog::FileTypeInfo file_type_info; 561 SelectFileDialog::FileTypeInfo file_type_info;
562 file_type_info.extensions.resize(1); 562 file_type_info.extensions.resize(1);
563 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("p12")); 563 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("p12"));
564 file_type_info.extension_description_overrides.push_back( 564 file_type_info.extension_description_overrides.push_back(
565 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_PKCS12_FILES)); 565 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_PKCS12_FILES));
566 file_type_info.include_all_files = true; 566 file_type_info.include_all_files = true;
567 select_file_dialog_ = SelectFileDialog::Create(this); 567 select_file_dialog_ = SelectFileDialog::Create(this);
568 select_file_dialog_->SelectFile( 568 select_file_dialog_->SelectFile(
569 SelectFileDialog::SELECT_SAVEAS_FILE, string16(), 569 SelectFileDialog::SELECT_SAVEAS_FILE, string16(),
570 FilePath(), &file_type_info, 1, FILE_PATH_LITERAL("p12"), 570 FilePath(), &file_type_info, 1, FILE_PATH_LITERAL("p12"),
571 web_ui()->tab_contents(), GetParentWindow(), 571 web_ui()->web_contents(), GetParentWindow(),
572 reinterpret_cast<void*>(EXPORT_PERSONAL_FILE_SELECTED)); 572 reinterpret_cast<void*>(EXPORT_PERSONAL_FILE_SELECTED));
573 } 573 }
574 574
575 void CertificateManagerHandler::ExportAllPersonal(const ListValue* args) { 575 void CertificateManagerHandler::ExportAllPersonal(const ListValue* args) {
576 NOTIMPLEMENTED(); 576 NOTIMPLEMENTED();
577 } 577 }
578 578
579 void CertificateManagerHandler::ExportPersonalFileSelected( 579 void CertificateManagerHandler::ExportPersonalFileSelected(
580 const FilePath& path) { 580 const FilePath& path) {
581 file_path_ = path; 581 file_path_ = path;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 } 650 }
651 file_type_info.extensions.resize(1); 651 file_type_info.extensions.resize(1);
652 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("p12")); 652 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("p12"));
653 file_type_info.extension_description_overrides.push_back( 653 file_type_info.extension_description_overrides.push_back(
654 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_PKCS12_FILES)); 654 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_PKCS12_FILES));
655 file_type_info.include_all_files = true; 655 file_type_info.include_all_files = true;
656 select_file_dialog_ = SelectFileDialog::Create(this); 656 select_file_dialog_ = SelectFileDialog::Create(this);
657 select_file_dialog_->SelectFile( 657 select_file_dialog_->SelectFile(
658 SelectFileDialog::SELECT_OPEN_FILE, string16(), 658 SelectFileDialog::SELECT_OPEN_FILE, string16(),
659 FilePath(), &file_type_info, 1, FILE_PATH_LITERAL("p12"), 659 FilePath(), &file_type_info, 1, FILE_PATH_LITERAL("p12"),
660 web_ui()->tab_contents(), GetParentWindow(), 660 web_ui()->web_contents(), GetParentWindow(),
661 reinterpret_cast<void*>(IMPORT_PERSONAL_FILE_SELECTED)); 661 reinterpret_cast<void*>(IMPORT_PERSONAL_FILE_SELECTED));
662 } 662 }
663 663
664 void CertificateManagerHandler::ImportPersonalFileSelected( 664 void CertificateManagerHandler::ImportPersonalFileSelected(
665 const FilePath& path) { 665 const FilePath& path) {
666 file_path_ = path; 666 file_path_ = path;
667 web_ui()->CallJavascriptFunction( 667 web_ui()->CallJavascriptFunction(
668 "CertificateManager.importPersonalAskPassword"); 668 "CertificateManager.importPersonalAskPassword");
669 } 669 }
670 670
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 select_file_dialog_->ListenerDestroyed(); 768 select_file_dialog_->ListenerDestroyed();
769 select_file_dialog_ = NULL; 769 select_file_dialog_ = NULL;
770 } 770 }
771 771
772 void CertificateManagerHandler::ImportServer(const ListValue* args) { 772 void CertificateManagerHandler::ImportServer(const ListValue* args) {
773 select_file_dialog_ = SelectFileDialog::Create(this); 773 select_file_dialog_ = SelectFileDialog::Create(this);
774 ShowCertSelectFileDialog( 774 ShowCertSelectFileDialog(
775 select_file_dialog_.get(), 775 select_file_dialog_.get(),
776 SelectFileDialog::SELECT_OPEN_FILE, 776 SelectFileDialog::SELECT_OPEN_FILE,
777 FilePath(), 777 FilePath(),
778 web_ui()->tab_contents(), 778 web_ui()->web_contents(),
779 GetParentWindow(), 779 GetParentWindow(),
780 reinterpret_cast<void*>(IMPORT_SERVER_FILE_SELECTED)); 780 reinterpret_cast<void*>(IMPORT_SERVER_FILE_SELECTED));
781 } 781 }
782 782
783 void CertificateManagerHandler::ImportServerFileSelected(const FilePath& path) { 783 void CertificateManagerHandler::ImportServerFileSelected(const FilePath& path) {
784 file_path_ = path; 784 file_path_ = path;
785 file_access_provider_->StartRead( 785 file_access_provider_->StartRead(
786 file_path_, 786 file_path_,
787 &consumer_, 787 &consumer_,
788 base::Bind(&CertificateManagerHandler::ImportServerFileRead, 788 base::Bind(&CertificateManagerHandler::ImportServerFileRead,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 not_imported); 824 not_imported);
825 } 825 }
826 ImportExportCleanup(); 826 ImportExportCleanup();
827 } 827 }
828 828
829 void CertificateManagerHandler::ImportCA(const ListValue* args) { 829 void CertificateManagerHandler::ImportCA(const ListValue* args) {
830 select_file_dialog_ = SelectFileDialog::Create(this); 830 select_file_dialog_ = SelectFileDialog::Create(this);
831 ShowCertSelectFileDialog(select_file_dialog_.get(), 831 ShowCertSelectFileDialog(select_file_dialog_.get(),
832 SelectFileDialog::SELECT_OPEN_FILE, 832 SelectFileDialog::SELECT_OPEN_FILE,
833 FilePath(), 833 FilePath(),
834 web_ui()->tab_contents(), 834 web_ui()->web_contents(),
835 GetParentWindow(), 835 GetParentWindow(),
836 reinterpret_cast<void*>(IMPORT_CA_FILE_SELECTED)); 836 reinterpret_cast<void*>(IMPORT_CA_FILE_SELECTED));
837 } 837 }
838 838
839 void CertificateManagerHandler::ImportCAFileSelected(const FilePath& path) { 839 void CertificateManagerHandler::ImportCAFileSelected(const FilePath& path) {
840 file_path_ = path; 840 file_path_ = path;
841 file_access_provider_->StartRead( 841 file_access_provider_->StartRead(
842 file_path_, 842 file_path_,
843 &consumer_, 843 &consumer_,
844 base::Bind(&CertificateManagerHandler::ImportCAFileRead, 844 base::Bind(&CertificateManagerHandler::ImportCAFileRead,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 l10n_util::GetStringUTF8(IDS_CERT_MANAGER_CA_IMPORT_ERROR_TITLE), 908 l10n_util::GetStringUTF8(IDS_CERT_MANAGER_CA_IMPORT_ERROR_TITLE),
909 not_imported); 909 not_imported);
910 } 910 }
911 ImportExportCleanup(); 911 ImportExportCleanup();
912 } 912 }
913 913
914 void CertificateManagerHandler::Export(const ListValue* args) { 914 void CertificateManagerHandler::Export(const ListValue* args) {
915 net::X509Certificate* cert = CallbackArgsToCert(args); 915 net::X509Certificate* cert = CallbackArgsToCert(args);
916 if (!cert) 916 if (!cert)
917 return; 917 return;
918 ShowCertExportDialog(web_ui()->tab_contents(), GetParentWindow(), 918 ShowCertExportDialog(web_ui()->web_contents(), GetParentWindow(),
919 cert->os_cert_handle()); 919 cert->os_cert_handle());
920 } 920 }
921 921
922 void CertificateManagerHandler::Delete(const ListValue* args) { 922 void CertificateManagerHandler::Delete(const ListValue* args) {
923 net::X509Certificate* cert = CallbackArgsToCert(args); 923 net::X509Certificate* cert = CallbackArgsToCert(args);
924 if (!cert) 924 if (!cert)
925 return; 925 return;
926 bool result = certificate_manager_model_->Delete(cert); 926 bool result = certificate_manager_model_->Delete(cert);
927 if (!result) { 927 if (!result) {
928 // TODO(mattm): better error messages? 928 // TODO(mattm): better error messages?
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary(); 1041 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary();
1042 1042
1043 // TODO(xiyuan): Use async way when underlying supports it. 1043 // TODO(xiyuan): Use async way when underlying supports it.
1044 base::FundamentalValue ready(cryptohome->Pkcs11IsTpmTokenReady()); 1044 base::FundamentalValue ready(cryptohome->Pkcs11IsTpmTokenReady());
1045 web_ui()->CallJavascriptFunction("CertificateManager.onCheckTpmTokenReady", 1045 web_ui()->CallJavascriptFunction("CertificateManager.onCheckTpmTokenReady",
1046 ready); 1046 ready);
1047 } 1047 }
1048 #endif 1048 #endif
1049 1049
1050 gfx::NativeWindow CertificateManagerHandler::GetParentWindow() const { 1050 gfx::NativeWindow CertificateManagerHandler::GetParentWindow() const {
1051 return web_ui()->tab_contents()->GetView()->GetTopLevelNativeWindow(); 1051 return web_ui()->web_contents()->GetView()->GetTopLevelNativeWindow();
1052 } 1052 }
1053 1053
1054 } // namespace options2 1054 } // namespace options2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698