electron/chromium_src/chrome/browser/certificate_manager_model.h
Electron Bot a006cf681b
chore: bump chromium to 91.0.4448.0 (master) (#28009)
* chore: bump chromium in DEPS to 91.0.4435.3

* build: add 'use_rts' definition

Refs: 2694187

* chore: update patches

* chore: media_internal_resources becomes resources

Refs: 2699022

* chore: update patches

* refactor: extensions::ViewType moved to mojom

Refs: 2710351

* chore: might_have_observers has been removed

Refs: 2667839

* refactor: CertVerifier is not in the network namespace anymore

Refs: 2689805

* refactor: ExtensionUserScriptManager is now UserScriptManager

Refs: 2657617

* refactor: content::SiteInstance::GetSiteForURL was removed

Refs: 2680274

* refactor: MenuItemType was moved to mojom

Refs: 2071443

* refactor: extensions::ViewType was moved to mojom

Refs: 2710351

* refacotr: grit::ResourceMap replaced with webui::ResourcePath

Refs: 2685601

* refactor: blink::MenuItem::Type was moved to mojom

Refs: 2071443

* refactor: CreateDataPipe deprecated form was removed

Refs: 2698090

* refactor: DesktopMediaList::Type replaces content::DesktopMediaType_*

Refs: 2700637

* chore: wire up activation_time in OSR

Refs: 2638372

* chore: remove deleted file from chromium_src list

* chore: fix lint

* update patches

* chore: bump chromium in DEPS to 91.0.4438.0

* chore: bump chromium in DEPS to 91.0.4439.0

* chore: bump chromium in DEPS to 91.0.4440.0

* chore: bump chromium in DEPS to 91.0.4441.0

* chore: bump chromium in DEPS to 91.0.4442.0

* chore: bump chromium in DEPS to 91.0.4443.0

* chore: bump chromium in DEPS to 91.0.4445.0

* chore: bump chromium in DEPS to 91.0.4446.0

* chore: update patches

* fixup gn check

* Merge branch 'master' into roller/chromium/master

* update to xcode 12.4.0

Needed because of 8008deb41c

* 2752406: [LSC] Replace base::string16 with std::u16string in //ui

2752406

* 2752406: [LSC] Replace base::string16 with std::u16string in //ui

2752406

* 2752932: Associate each AwProxyingURLLoaderFactory with a frame tree node id.

2752932

* 2651385: Moving Profile::shared_cors_origin_access_list_ into //content layer.

2651385

* 2734095: Introduce StoragePartitionId type to wrap current string representation.

2734095

* chore: bump chromium in DEPS to 91.0.4448.0

* Update patches

* 2743594: Remove WebSize from blink.

2743594

* 2725403: Add URLLoaderClient::OnReceiveEarlyHints()

2725403

* 2651385: Moving Profile::shared_cors_origin_access_list_ into //content layer.

2651385

* 2721718: Move HostID to extensions::mojom::HostID

2721718

* 2733070: Rename observer to URLLoaderNetworkServiceObserver

2733070

* Use nogncheck for content/browser/site_instance_impl.h

This is needed because  //content/browser:browser is not a visible target

* 2648046: Introduce alert notification helper .app

2648046

* 2752406: [LSC] Replace base::string16 with std::u16string in //ui

2752406

* only include mac notifications on mac

* add additional skipping of atk toolchain check

* 2757472: Reland "Reland "[LSC] Remove base::string16 alias""

2757472

* 2757472: Reland "Reland "[LSC] Remove base::string16 alias""

2757472

* 2720306: [api] Remove deprecated [Shared]ArrayBuffer API

2720306

* Fixup 2721718: Move HostID to extensions::mojom::HostID

* fixup 2651385: Moving Profile::shared_cors_origin_access_list_ into //content layer

* Fixup 2752406: [LSC] Replace base::string16 with std::u16string in //ui

* Fixup 2725403: Add URLLoaderClient::OnReceiveEarlyHints()

* update node headers

* chore: bump chromium in DEPS to 91.0.4449.0

* Revert "chore: bump chromium in DEPS to 91.0.4449.0"

This reverts commit bccafa0289.

* 2693008: Fix loading non-system cursors on Windows on browser_tests

2693008

* 2757472: Reland "Reland "[LSC] Remove base::string16 alias""

2757472

* undo changes to WebContentsPreferences::GetPreloadPath to fix mac build

* fix StrCat issue

* incantations for WebContentsPreferences::GetPreloadPath wide strings

* bump nan

* fix GetAsString maybe?

* windows build fixes

* more windows build fix

* SetAppUserModelID -> wstring

* upgrade nan dep in tests

* lint

* wstrings are cross-platform

* linter

* only bind setAppUserModelId on windows

* fix a messed up merge

* well that was an odyssey

* backport fcdf35e from v8 to fix nan crash

* disable typedarrays-test.js

* don't defer in NSWindow creation

2707696

* use PartitionAllocator for ArrayBuffers in the main process

* fix patches

* chore: omit some unnecessary conversions

* refactor: make LoginItemSettings::path a wstring

* refactor: make ShowTaskDialog take a wstr

* Revert "refactor: make LoginItemSettings::path a wstring"

This reverts commit 9127cff58b.

Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
Co-authored-by: Jeremy Rose <jeremya@chromium.org>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-03-30 21:17:09 -05:00

116 lines
4.8 KiB
C++

// Copyright (c) 2012 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_CERTIFICATE_MANAGER_MODEL_H_
#define CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_
#include <map>
#include <memory>
#include <string>
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "net/cert/nss_cert_database.h"
namespace content {
class BrowserContext;
class ResourceContext;
} // namespace content
// CertificateManagerModel provides the data to be displayed in the certificate
// manager dialog, and processes changes from the view.
class CertificateManagerModel {
public:
using CreationCallback =
base::OnceCallback<void(std::unique_ptr<CertificateManagerModel>)>;
// Creates a CertificateManagerModel. The model will be passed to the callback
// when it is ready. The caller must ensure the model does not outlive the
// |browser_context|.
static void Create(content::BrowserContext* browser_context,
CreationCallback callback);
~CertificateManagerModel();
bool is_user_db_available() const { return is_user_db_available_; }
// Accessor for read-only access to the underlying NSSCertDatabase.
const net::NSSCertDatabase* cert_db() const { return cert_db_; }
// Import private keys and certificates from PKCS #12 encoded
// |data|, using the given |password|. If |is_extractable| is false,
// mark the private key as unextractable from the module.
// Returns a net error code on failure.
int ImportFromPKCS12(PK11SlotInfo* slot_info,
const std::string& data,
const std::u16string& password,
bool is_extractable,
net::ScopedCERTCertificateList* imported_certs);
// Import user certificate from DER encoded |data|.
// Returns a net error code on failure.
int ImportUserCert(const std::string& data);
// Import CA certificates.
// Tries to import all the certificates given. The root will be trusted
// according to |trust_bits|. Any certificates that could not be imported
// will be listed in |not_imported|.
// |trust_bits| should be a bit field of TRUST* values from NSSCertDatabase.
// Returns false if there is an internal error, otherwise true is returned and
// |not_imported| should be checked for any certificates that were not
// imported.
bool ImportCACerts(const net::ScopedCERTCertificateList& certificates,
net::NSSCertDatabase::TrustBits trust_bits,
net::NSSCertDatabase::ImportCertFailureList* not_imported);
// Import server certificate. The first cert should be the server cert. Any
// additional certs should be intermediate/CA certs and will be imported but
// not given any trust.
// Any certificates that could not be imported will be listed in
// |not_imported|.
// |trust_bits| can be set to explicitly trust or distrust the certificate, or
// use TRUST_DEFAULT to inherit trust as normal.
// Returns false if there is an internal error, otherwise true is returned and
// |not_imported| should be checked for any certificates that were not
// imported.
bool ImportServerCert(
const net::ScopedCERTCertificateList& certificates,
net::NSSCertDatabase::TrustBits trust_bits,
net::NSSCertDatabase::ImportCertFailureList* not_imported);
// Set trust values for certificate.
// |trust_bits| should be a bit field of TRUST* values from NSSCertDatabase.
// Returns true on success or false on failure.
bool SetCertTrust(CERTCertificate* cert,
net::CertType type,
net::NSSCertDatabase::TrustBits trust_bits);
// Delete the cert. Returns true on success. |cert| is still valid when this
// function returns.
bool Delete(CERTCertificate* cert);
private:
CertificateManagerModel(net::NSSCertDatabase* nss_cert_database,
bool is_user_db_available);
// Methods used during initialization, see the comment at the top of the .cc
// file for details.
static void DidGetCertDBOnUIThread(net::NSSCertDatabase* cert_db,
bool is_user_db_available,
CreationCallback callback);
static void DidGetCertDBOnIOThread(CreationCallback callback,
net::NSSCertDatabase* cert_db);
static void GetCertDBOnIOThread(content::ResourceContext* context,
CreationCallback callback);
net::NSSCertDatabase* cert_db_;
// Whether the certificate database has a public slot associated with the
// profile. If not set, importing certificates is not allowed with this model.
bool is_user_db_available_;
DISALLOW_COPY_AND_ASSIGN(CertificateManagerModel);
};
#endif // CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_