| 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 35%
|
| copy from chrome/browser/ui/views/ssl_client_certificate_selector.h
|
| copy to chrome/browser/ui/views/certificate_selector.h
|
| index de4fbed4bffbf4aa25163267776bff05652bbe0c..e4f52cf79149f4559861e8d0a7e53a46eff45419 100644
|
| --- a/chrome/browser/ui/views/ssl_client_certificate_selector.h
|
| +++ b/chrome/browser/ui/views/certificate_selector.h
|
| @@ -1,63 +1,58 @@
|
| -// 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/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 base class for dialogs that show 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 |InitWithText()|.
|
| +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;
|
|
|
| + // Returns the currently selected certificate or null if none is selected.
|
| + // Must be called after |InitWithText()|.
|
| net::X509Certificate* GetSelectedCert() const;
|
|
|
| - // SSLClientAuthObserver implementation:
|
| - void OnCertSelectedByNotification() override;
|
| + // Shows this dialog as a constrained web modal dialog and focuses the first
|
| + // certificate.
|
| + // Must be called after |InitWithText()|.
|
| + void Show();
|
|
|
| // 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;
|
| @@ -69,20 +64,24 @@ class SSLClientCertificateSelector : public SSLClientAuthObserver,
|
| void OnSelectionChanged() override;
|
| void OnDoubleClick() override;
|
|
|
| - private:
|
| - void CreateCertTable();
|
| -
|
| - // Callback after unlocking certificate slot.
|
| - void Unlocked(net::X509Certificate* cert);
|
| + protected:
|
| + // Initializes the 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 InitWithText(const base::string16& text);
|
|
|
| - scoped_ptr<CertificateSelectorTableModel> model_;
|
| + private:
|
| + const net::CertificateList certificates_;
|
| + scoped_ptr<CertificateTableModel> 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_
|
|
|