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

Unified Diff: chrome/browser/ui/views/ssl_client_certificate_selector.cc

Issue 319013002: Reland Fix Views web-modal dialog widget creation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert MediaGalleriesScanResultDialogViews::AcceptDialogForTesting. Created 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/ssl_client_certificate_selector.cc
diff --git a/chrome/browser/ui/views/ssl_client_certificate_selector.cc b/chrome/browser/ui/views/ssl_client_certificate_selector.cc
index 08eefd9d8750aa273e6490ec0d4c303218cc6cb0..814d8bac03547a6ba859a3ba4323b553452fab03 100644
--- a/chrome/browser/ui/views/ssl_client_certificate_selector.cc
+++ b/chrome/browser/ui/views/ssl_client_certificate_selector.cc
@@ -5,13 +5,10 @@
#include "chrome/browser/ui/views/ssl_client_certificate_selector.h"
#include "base/compiler_specific.h"
-#include "base/i18n/time_formatting.h"
#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/certificate_viewer.h"
-#include "components/web_modal/web_contents_modal_dialog_host.h"
-#include "components/web_modal/web_contents_modal_dialog_manager.h"
-#include "components/web_modal/web_contents_modal_dialog_manager_delegate.h"
+#include "chrome/browser/ui/views/constrained_window_views.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "grit/generated_resources.h"
@@ -20,7 +17,6 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/table_model.h"
#include "ui/base/models/table_model_observer.h"
-#include "ui/gfx/native_widget_types.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/table/table_view.h"
@@ -33,19 +29,6 @@
#include "chrome/browser/ui/crypto_module_password_dialog_nss.h"
#endif
-using content::BrowserThread;
-using content::WebContents;
-using web_modal::WebContentsModalDialogManager;
-using web_modal::WebContentsModalDialogManagerDelegate;
-
-namespace {
-
-// The dimensions of the certificate selector table view, in pixels.
-static const int kTableViewWidth = 400;
-static const int kTableViewHeight = 100;
-
-} // namespace
-
///////////////////////////////////////////////////////////////////////////////
// CertificateSelectorTableModel:
@@ -98,14 +81,13 @@ void CertificateSelectorTableModel::SetObserver(
// SSLClientCertificateSelector:
SSLClientCertificateSelector::SSLClientCertificateSelector(
- WebContents* web_contents,
+ content::WebContents* web_contents,
const net::HttpNetworkSession* network_session,
net::SSLCertRequestInfo* cert_request_info,
const chrome::SelectCertificateCallback& callback)
: SSLClientAuthObserver(network_session, cert_request_info, callback),
model_(new CertificateSelectorTableModel(cert_request_info)),
web_contents_(web_contents),
- window_(NULL),
table_(NULL),
view_cert_button_(NULL) {
DVLOG(1) << __FUNCTION__;
@@ -137,6 +119,10 @@ void SSLClientCertificateSelector::Init() {
layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
+ // The dimensions of the certificate selector table view, in pixels.
+ static const int kTableViewWidth = 400;
+ static const int kTableViewHeight = 100;
+
CreateCertTable();
layout->StartRow(1, column_set_id);
layout->AddView(table_->CreateParentIfNecessary(), 1, 1,
@@ -147,15 +133,7 @@ void SSLClientCertificateSelector::Init() {
StartObserving();
- WebContentsModalDialogManager* web_contents_modal_dialog_manager =
- WebContentsModalDialogManager::FromWebContents(web_contents_);
- WebContentsModalDialogManagerDelegate* modal_delegate =
- web_contents_modal_dialog_manager->delegate();
- DCHECK(modal_delegate);
- window_ = views::Widget::CreateWindowAsFramelessChild(
- this, modal_delegate->GetWebContentsModalDialogHost()->GetHostView());
- web_contents_modal_dialog_manager->ShowModalDialog(
- window_->GetNativeView());
+ ShowWebModalDialogViews(this, web_contents_);
// Select the first row automatically. This must be done after the dialog has
// been created.
@@ -165,8 +143,7 @@ void SSLClientCertificateSelector::Init() {
net::X509Certificate* SSLClientCertificateSelector::GetSelectedCert() const {
int selected = table_->FirstSelectedRow();
if (selected >= 0 &&
- selected < static_cast<int>(
- cert_request_info()->client_certs.size()))
+ selected < static_cast<int>(cert_request_info()->client_certs.size()))
return cert_request_info()->client_certs[selected].get();
return NULL;
}
@@ -176,8 +153,7 @@ net::X509Certificate* SSLClientCertificateSelector::GetSelectedCert() const {
void SSLClientCertificateSelector::OnCertSelectedByNotification() {
DVLOG(1) << __FUNCTION__;
- DCHECK(window_);
- window_->Close();
+ GetWidget()->Close();
}
///////////////////////////////////////////////////////////////////////////////
@@ -207,7 +183,6 @@ bool SSLClientCertificateSelector::Cancel() {
DVLOG(1) << __FUNCTION__;
StopObserving();
CertificateSelected(NULL);
-
return true;
}
@@ -224,7 +199,7 @@ bool SSLClientCertificateSelector::Accept() {
cert,
chrome::kCryptoModulePasswordClientAuth,
cert_request_info()->host_and_port,
- window_->GetNativeView(),
+ GetWidget()->GetNativeView(),
base::Bind(&SSLClientCertificateSelector::Unlocked,
base::Unretained(this),
cert));
@@ -250,11 +225,7 @@ views::View* SSLClientCertificateSelector::CreateExtraView() {
}
ui::ModalType SSLClientCertificateSelector::GetModalType() const {
-#if defined(USE_ASH)
return ui::MODAL_TYPE_CHILD;
-#else
- return views::WidgetDelegate::GetModalType();
-#endif
}
///////////////////////////////////////////////////////////////////////////////
@@ -279,7 +250,7 @@ void SSLClientCertificateSelector::OnSelectionChanged() {
void SSLClientCertificateSelector::OnDoubleClick() {
if (Accept())
- window_->Close();
+ GetWidget()->Close();
}
///////////////////////////////////////////////////////////////////////////////
@@ -288,9 +259,7 @@ void SSLClientCertificateSelector::OnDoubleClick() {
void SSLClientCertificateSelector::CreateCertTable() {
std::vector<ui::TableColumn> columns;
columns.push_back(ui::TableColumn());
- table_ = new views::TableView(model_.get(),
- columns,
- views::TEXT_ONLY,
+ table_ = new views::TableView(model_.get(), columns, views::TEXT_ONLY,
true /* single_selection */);
table_->SetObserver(this);
}
@@ -298,7 +267,7 @@ void SSLClientCertificateSelector::CreateCertTable() {
void SSLClientCertificateSelector::Unlocked(net::X509Certificate* cert) {
DVLOG(1) << __FUNCTION__;
CertificateSelected(cert);
- window_->Close();
+ GetWidget()->Close();
}
namespace chrome {
@@ -309,7 +278,7 @@ void ShowSSLClientCertificateSelector(
net::SSLCertRequestInfo* cert_request_info,
const chrome::SelectCertificateCallback& callback) {
DVLOG(1) << __FUNCTION__ << " " << contents;
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
(new SSLClientCertificateSelector(
contents, network_session, cert_request_info, callback))->Init();
}

Powered by Google App Engine
This is Rietveld 408576698