NaCl docs: add sanitizers to GSoC ideas
[chromium-blink-merge.git] / chrome / browser / ui / views / platform_keys_certificate_selector_chromeos.cc
blobb5203cad879eb628e5162ff3b4ad09f2ab892d7b
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"
13 namespace chromeos {
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),
22 callback_(callback) {
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);
37 return true;
40 bool PlatformKeysCertificateSelector::Accept() {
41 scoped_refptr<net::X509Certificate> cert = GetSelectedCert();
42 if (!cert)
43 return false;
44 callback_.Run(cert);
45 return true;
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>&)>&
53 callback) {
54 PlatformKeysCertificateSelector* selector =
55 new PlatformKeysCertificateSelector(certificates, extension_name,
56 callback, web_contents);
57 selector->Init();
58 selector->Show();
61 } // namespace chromeos