1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/platform_keys_certificate_selector_chromeos.h"
7 #include "base/memory/ref_counted.h"
8 #include "base/strings/string16.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/grit/generated_resources.h"
11 #include "ui/base/l10n/l10n_util.h"
15 PlatformKeysCertificateSelector::PlatformKeysCertificateSelector(
16 const net::CertificateList
& certificates
,
17 const std::string
& extension_name
,
18 const CertificateSelectedCallback
& callback
,
19 content::WebContents
* web_contents
)
20 : CertificateSelector(certificates
, web_contents
),
21 extension_name_(extension_name
),
25 PlatformKeysCertificateSelector::~PlatformKeysCertificateSelector() {
28 void PlatformKeysCertificateSelector::Init() {
29 const base::string16 text
=
30 l10n_util::GetStringFUTF16(IDS_PLATFORM_KEYS_SELECT_CERT_DIALOG_TEXT
,
31 base::ASCIIToUTF16(extension_name_
));
32 CertificateSelector::InitWithText(text
);
35 bool PlatformKeysCertificateSelector::Cancel() {
36 callback_
.Run(nullptr);
40 bool PlatformKeysCertificateSelector::Accept() {
41 scoped_refptr
<net::X509Certificate
> cert
= GetSelectedCert();
48 void ShowPlatformKeysCertificateSelector(
49 content::WebContents
* web_contents
,
50 const std::string
& extension_name
,
51 const net::CertificateList
& certificates
,
52 const base::Callback
<void(const scoped_refptr
<net::X509Certificate
>&)>&
54 PlatformKeysCertificateSelector
* selector
=
55 new PlatformKeysCertificateSelector(certificates
, extension_name
,
56 callback
, web_contents
);
61 } // namespace chromeos