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

Unified Diff: chrome/browser/ui/views/certificate_selector.h

Issue 932553002: Refactor SSLClientCertificateSelector for reuse with platformKeys API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cert_perms
Patch Set: Addressed Mike's comment. Created 5 years, 10 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/certificate_selector.h
diff --git a/chrome/browser/ui/views/ssl_client_certificate_selector.h b/chrome/browser/ui/views/certificate_selector.h
similarity index 37%
copy from chrome/browser/ui/views/ssl_client_certificate_selector.h
copy to chrome/browser/ui/views/certificate_selector.h
index de4fbed4bffbf4aa25163267776bff05652bbe0c..4c8a19a4c2d43e34d07829732ed64ec6815bad33 100644
--- a/chrome/browser/ui/views/ssl_client_certificate_selector.h
+++ b/chrome/browser/ui/views/certificate_selector.h
@@ -1,63 +1,60 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_UI_VIEWS_SSL_CLIENT_CERTIFICATE_SELECTOR_H_
-#define CHROME_BROWSER_UI_VIEWS_SSL_CLIENT_CERTIFICATE_SELECTOR_H_
+#ifndef CHROME_BROWSER_UI_VIEWS_CERTIFICATE_SELECTOR_H_
+#define CHROME_BROWSER_UI_VIEWS_CERTIFICATE_SELECTOR_H_
-#include <string>
#include <vector>
-#include "base/basictypes.h"
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
-#include "chrome/browser/ssl/ssl_client_auth_observer.h"
-#include "chrome/browser/ssl/ssl_client_certificate_selector.h"
+#include "net/cert/x509_certificate.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/table/table_view_observer.h"
#include "ui/views/window/dialog_delegate.h"
-// This header file exists only for testing. Chrome should access the
-// certificate selector only through the cross-platform interface
-// chrome/browser/ssl_client_certificate_selector.h.
-
-namespace net {
-class SSLCertRequestInfo;
-class X509Certificate;
+namespace content {
+class WebContents;
}
namespace views {
class LabelButton;
class TableView;
-class Widget;
}
-class CertificateSelectorTableModel;
+namespace chrome {
-class SSLClientCertificateSelector : public SSLClientAuthObserver,
- public views::DialogDelegateView,
- public views::ButtonListener,
- public views::TableViewObserver {
+// A dialog that shows a given list of certificates to the user. The user can
+// select a single certificate and look at details of each certificate.
+// The currently selected certificate can be obtained using |GetSelectedCert()|.
+// The explanatory text shown to the user must be provided to |Init()|.
+class CertificateSelector : public views::DialogDelegateView,
+ public views::ButtonListener,
+ public views::TableViewObserver {
public:
- SSLClientCertificateSelector(
- content::WebContents* web_contents,
- const scoped_refptr<net::SSLCertRequestInfo>& cert_request_info,
- const chrome::SelectCertificateCallback& callback);
- ~SSLClientCertificateSelector() override;
+ class CertificateTableModel;
- void Init();
+ // |web_contents| must not be null.
+ CertificateSelector(const net::CertificateList& certificates,
+ content::WebContents* web_contents);
+ ~CertificateSelector() override;
- net::X509Certificate* GetSelectedCert() const;
+ // Initializes the dialog and shows it as a constrained web modal dialog.
+ // |text| is shown above the list of certificates and is supposed to explain
+ // to the user what the implication of the certificate selection is.
+ void Init(const base::string16& text);
- // SSLClientAuthObserver implementation:
- void OnCertSelectedByNotification() override;
+ // Returns the currently selected certificate or null if none is selected.
+ // Must be called after Init().
+ net::X509Certificate* GetSelectedCert() const;
// DialogDelegateView:
bool CanResize() const override;
base::string16 GetWindowTitle() const override;
- void DeleteDelegate() override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override;
- bool Cancel() override;
- bool Accept() override;
views::View* GetInitiallyFocusedView() override;
views::View* CreateExtraView() override;
ui::ModalType GetModalType() const override;
@@ -70,19 +67,17 @@ class SSLClientCertificateSelector : public SSLClientAuthObserver,
void OnDoubleClick() override;
private:
- void CreateCertTable();
+ const net::CertificateList certificates_;
+ scoped_ptr<CertificateTableModel> model_;
- // Callback after unlocking certificate slot.
- void Unlocked(net::X509Certificate* cert);
-
- scoped_ptr<CertificateSelectorTableModel> model_;
-
- content::WebContents* web_contents_;
+ content::WebContents* const web_contents_;
views::TableView* table_;
views::LabelButton* view_cert_button_;
- DISALLOW_COPY_AND_ASSIGN(SSLClientCertificateSelector);
+ DISALLOW_COPY_AND_ASSIGN(CertificateSelector);
};
-#endif // CHROME_BROWSER_UI_VIEWS_SSL_CLIENT_CERTIFICATE_SELECTOR_H_
+} // namespace chrome
+
+#endif // CHROME_BROWSER_UI_VIEWS_CERTIFICATE_SELECTOR_H_

Powered by Google App Engine
This is Rietveld 408576698