Commit 39d39b0b authored by Michael Ershov's avatar Michael Ershov Committed by Commit Bot

Rename PlatformKeysService into ExtensionPlatformKeysService

This CL renames the class to allow creating a service with
the name PlatformKeysService from
chrome/browser/chromeos/platform_keys/platform_keys* files.
That will allow to mock functions from there and write unit
tests for a code that depends on them.

Bug: 1045895
Change-Id: I179c75aa1efc19acf5d6f10a06cf6ea62a11bf30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2064211
Commit-Queue: Michael Ershov <miersh@google.com>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742650}
parent 9af1bc63
...@@ -1693,6 +1693,10 @@ source_set("chromeos") { ...@@ -1693,6 +1693,10 @@ source_set("chromeos") {
"ownership/owner_settings_service_chromeos.h", "ownership/owner_settings_service_chromeos.h",
"ownership/owner_settings_service_chromeos_factory.cc", "ownership/owner_settings_service_chromeos_factory.cc",
"ownership/owner_settings_service_chromeos_factory.h", "ownership/owner_settings_service_chromeos_factory.h",
"platform_keys/extension_platform_keys_service.cc",
"platform_keys/extension_platform_keys_service.h",
"platform_keys/extension_platform_keys_service_factory.cc",
"platform_keys/extension_platform_keys_service_factory.h",
"platform_keys/key_permissions.cc", "platform_keys/key_permissions.cc",
"platform_keys/key_permissions.h", "platform_keys/key_permissions.h",
"platform_keys/key_permissions_policy_handler.cc", "platform_keys/key_permissions_policy_handler.cc",
...@@ -1700,10 +1704,6 @@ source_set("chromeos") { ...@@ -1700,10 +1704,6 @@ source_set("chromeos") {
"platform_keys/platform_keys.cc", "platform_keys/platform_keys.cc",
"platform_keys/platform_keys.h", "platform_keys/platform_keys.h",
"platform_keys/platform_keys_nss.cc", "platform_keys/platform_keys_nss.cc",
"platform_keys/platform_keys_service.cc",
"platform_keys/platform_keys_service.h",
"platform_keys/platform_keys_service_factory.cc",
"platform_keys/platform_keys_service_factory.h",
"plugin_vm/plugin_vm_drive_image_download_service.cc", "plugin_vm/plugin_vm_drive_image_download_service.cc",
"plugin_vm/plugin_vm_drive_image_download_service.h", "plugin_vm/plugin_vm_drive_image_download_service.h",
"plugin_vm/plugin_vm_engagement_metrics_service.cc", "plugin_vm/plugin_vm_engagement_metrics_service.cc",
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/chromeos/platform_keys/platform_keys_service.h" #include "chrome/browser/chromeos/platform_keys/extension_platform_keys_service.h"
#include <stddef.h> #include <stddef.h>
...@@ -50,7 +50,7 @@ std::vector<KeyPermissions::KeyLocation> TokenIdsToKeyLocations( ...@@ -50,7 +50,7 @@ std::vector<KeyPermissions::KeyLocation> TokenIdsToKeyLocations(
} // namespace } // namespace
class PlatformKeysService::Task { class ExtensionPlatformKeysService::Task {
public: public:
Task() {} Task() {}
virtual ~Task() {} virtual ~Task() {}
...@@ -61,7 +61,7 @@ class PlatformKeysService::Task { ...@@ -61,7 +61,7 @@ class PlatformKeysService::Task {
DISALLOW_ASSIGN(Task); DISALLOW_ASSIGN(Task);
}; };
class PlatformKeysService::GenerateRSAKeyTask : public Task { class ExtensionPlatformKeysService::GenerateRSAKeyTask : public Task {
public: public:
enum class Step { enum class Step {
GENERATE_KEY, GENERATE_KEY,
...@@ -78,7 +78,7 @@ class PlatformKeysService::GenerateRSAKeyTask : public Task { ...@@ -78,7 +78,7 @@ class PlatformKeysService::GenerateRSAKeyTask : public Task {
const std::string& extension_id, const std::string& extension_id,
const GenerateKeyCallback& callback, const GenerateKeyCallback& callback,
KeyPermissions* key_permissions, KeyPermissions* key_permissions,
PlatformKeysService* service, ExtensionPlatformKeysService* service,
content::BrowserContext* browser_context) content::BrowserContext* browser_context)
: token_id_(token_id), : token_id_(token_id),
modulus_length_(modulus_length), modulus_length_(modulus_length),
...@@ -175,14 +175,14 @@ class PlatformKeysService::GenerateRSAKeyTask : public Task { ...@@ -175,14 +175,14 @@ class PlatformKeysService::GenerateRSAKeyTask : public Task {
std::unique_ptr<KeyPermissions::PermissionsForExtension> std::unique_ptr<KeyPermissions::PermissionsForExtension>
extension_permissions_; extension_permissions_;
KeyPermissions* const key_permissions_; KeyPermissions* const key_permissions_;
PlatformKeysService* const service_; ExtensionPlatformKeysService* const service_;
content::BrowserContext* const browser_context_; content::BrowserContext* const browser_context_;
base::WeakPtrFactory<GenerateRSAKeyTask> weak_factory_{this}; base::WeakPtrFactory<GenerateRSAKeyTask> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(GenerateRSAKeyTask); DISALLOW_COPY_AND_ASSIGN(GenerateRSAKeyTask);
}; };
class PlatformKeysService::SignTask : public Task { class ExtensionPlatformKeysService::SignTask : public Task {
public: public:
enum class Step { enum class Step {
GET_EXTENSION_PERMISSIONS, GET_EXTENSION_PERMISSIONS,
...@@ -206,7 +206,7 @@ class PlatformKeysService::SignTask : public Task { ...@@ -206,7 +206,7 @@ class PlatformKeysService::SignTask : public Task {
const std::string& extension_id, const std::string& extension_id,
const SignCallback& callback, const SignCallback& callback,
KeyPermissions* key_permissions, KeyPermissions* key_permissions,
PlatformKeysService* service) ExtensionPlatformKeysService* service)
: token_id_(token_id), : token_id_(token_id),
data_(data), data_(data),
public_key_spki_der_(public_key_spki_der), public_key_spki_der_(public_key_spki_der),
...@@ -331,13 +331,13 @@ class PlatformKeysService::SignTask : public Task { ...@@ -331,13 +331,13 @@ class PlatformKeysService::SignTask : public Task {
extension_permissions_; extension_permissions_;
KeyPermissions* const key_permissions_; KeyPermissions* const key_permissions_;
std::vector<KeyPermissions::KeyLocation> key_locations_; std::vector<KeyPermissions::KeyLocation> key_locations_;
PlatformKeysService* const service_; ExtensionPlatformKeysService* const service_;
base::WeakPtrFactory<SignTask> weak_factory_{this}; base::WeakPtrFactory<SignTask> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(SignTask); DISALLOW_COPY_AND_ASSIGN(SignTask);
}; };
class PlatformKeysService::SelectTask : public Task { class ExtensionPlatformKeysService::SelectTask : public Task {
public: public:
enum class Step { enum class Step {
GET_EXTENSION_PERMISSIONS, GET_EXTENSION_PERMISSIONS,
...@@ -364,7 +364,7 @@ class PlatformKeysService::SelectTask : public Task { ...@@ -364,7 +364,7 @@ class PlatformKeysService::SelectTask : public Task {
const SelectCertificatesCallback& callback, const SelectCertificatesCallback& callback,
content::WebContents* web_contents, content::WebContents* web_contents,
KeyPermissions* key_permissions, KeyPermissions* key_permissions,
PlatformKeysService* service) ExtensionPlatformKeysService* service)
: request_(request), : request_(request),
input_client_certificates_(std::move(input_client_certificates)), input_client_certificates_(std::move(input_client_certificates)),
interactive_(interactive), interactive_(interactive),
...@@ -651,19 +651,17 @@ class PlatformKeysService::SelectTask : public Task { ...@@ -651,19 +651,17 @@ class PlatformKeysService::SelectTask : public Task {
std::unique_ptr<KeyPermissions::PermissionsForExtension> std::unique_ptr<KeyPermissions::PermissionsForExtension>
extension_permissions_; extension_permissions_;
KeyPermissions* const key_permissions_; KeyPermissions* const key_permissions_;
PlatformKeysService* const service_; ExtensionPlatformKeysService* const service_;
base::WeakPtrFactory<SelectTask> weak_factory_{this}; base::WeakPtrFactory<SelectTask> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(SelectTask); DISALLOW_COPY_AND_ASSIGN(SelectTask);
}; };
PlatformKeysService::SelectDelegate::SelectDelegate() { ExtensionPlatformKeysService::SelectDelegate::SelectDelegate() {}
}
PlatformKeysService::SelectDelegate::~SelectDelegate() { ExtensionPlatformKeysService::SelectDelegate::~SelectDelegate() {}
}
PlatformKeysService::PlatformKeysService( ExtensionPlatformKeysService::ExtensionPlatformKeysService(
bool profile_is_managed, bool profile_is_managed,
PrefService* profile_prefs, PrefService* profile_prefs,
policy::PolicyService* profile_policies, policy::PolicyService* profile_policies,
...@@ -678,25 +676,25 @@ PlatformKeysService::PlatformKeysService( ...@@ -678,25 +676,25 @@ PlatformKeysService::PlatformKeysService(
DCHECK(state_store); DCHECK(state_store);
} }
PlatformKeysService::~PlatformKeysService() { ExtensionPlatformKeysService::~ExtensionPlatformKeysService() {}
}
void PlatformKeysService::SetSelectDelegate( void ExtensionPlatformKeysService::SetSelectDelegate(
std::unique_ptr<SelectDelegate> delegate) { std::unique_ptr<SelectDelegate> delegate) {
select_delegate_ = std::move(delegate); select_delegate_ = std::move(delegate);
} }
void PlatformKeysService::GenerateRSAKey(const std::string& token_id, void ExtensionPlatformKeysService::GenerateRSAKey(
unsigned int modulus_length, const std::string& token_id,
const std::string& extension_id, unsigned int modulus_length,
const GenerateKeyCallback& callback) { const std::string& extension_id,
const GenerateKeyCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
StartOrQueueTask(std::make_unique<GenerateRSAKeyTask>( StartOrQueueTask(std::make_unique<GenerateRSAKeyTask>(
token_id, modulus_length, extension_id, callback, &key_permissions_, this, token_id, modulus_length, extension_id, callback, &key_permissions_, this,
browser_context_)); browser_context_));
} }
void PlatformKeysService::SignRSAPKCS1Digest( void ExtensionPlatformKeysService::SignRSAPKCS1Digest(
const std::string& token_id, const std::string& token_id,
const std::string& data, const std::string& data,
const std::string& public_key_spki_der, const std::string& public_key_spki_der,
...@@ -709,7 +707,7 @@ void PlatformKeysService::SignRSAPKCS1Digest( ...@@ -709,7 +707,7 @@ void PlatformKeysService::SignRSAPKCS1Digest(
hash_algorithm, extension_id, callback, &key_permissions_, this))); hash_algorithm, extension_id, callback, &key_permissions_, this)));
} }
void PlatformKeysService::SignRSAPKCS1Raw( void ExtensionPlatformKeysService::SignRSAPKCS1Raw(
const std::string& token_id, const std::string& token_id,
const std::string& data, const std::string& data,
const std::string& public_key_spki_der, const std::string& public_key_spki_der,
...@@ -723,7 +721,7 @@ void PlatformKeysService::SignRSAPKCS1Raw( ...@@ -723,7 +721,7 @@ void PlatformKeysService::SignRSAPKCS1Raw(
&key_permissions_, this))); &key_permissions_, this)));
} }
void PlatformKeysService::SelectClientCertificates( void ExtensionPlatformKeysService::SelectClientCertificates(
const platform_keys::ClientCertificateRequest& request, const platform_keys::ClientCertificateRequest& request,
std::unique_ptr<net::CertificateList> client_certificates, std::unique_ptr<net::CertificateList> client_certificates,
bool interactive, bool interactive,
...@@ -736,13 +734,14 @@ void PlatformKeysService::SelectClientCertificates( ...@@ -736,13 +734,14 @@ void PlatformKeysService::SelectClientCertificates(
callback, web_contents, &key_permissions_, this)); callback, web_contents, &key_permissions_, this));
} }
void PlatformKeysService::StartOrQueueTask(std::unique_ptr<Task> task) { void ExtensionPlatformKeysService::StartOrQueueTask(
std::unique_ptr<Task> task) {
tasks_.push(std::move(task)); tasks_.push(std::move(task));
if (tasks_.size() == 1) if (tasks_.size() == 1)
tasks_.front()->Start(); tasks_.front()->Start();
} }
void PlatformKeysService::TaskFinished(Task* task) { void ExtensionPlatformKeysService::TaskFinished(Task* task) {
DCHECK(!tasks_.empty()); DCHECK(!tasks_.empty());
DCHECK(task == tasks_.front().get()); DCHECK(task == tasks_.front().get());
// Remove all finished tasks from the queue (should be at most one). // Remove all finished tasks from the queue (should be at most one).
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_ #ifndef CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_EXTENSION_PLATFORM_KEYS_SERVICE_H_
#define CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_ #define CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_EXTENSION_PLATFORM_KEYS_SERVICE_H_
#include <memory> #include <memory>
#include <string> #include <string>
...@@ -22,7 +22,7 @@ class PrefService; ...@@ -22,7 +22,7 @@ class PrefService;
namespace content { namespace content {
class BrowserContext; class BrowserContext;
class WebContents; class WebContents;
} } // namespace content
namespace extensions { namespace extensions {
class StateStore; class StateStore;
...@@ -31,7 +31,7 @@ class StateStore; ...@@ -31,7 +31,7 @@ class StateStore;
namespace net { namespace net {
class X509Certificate; class X509Certificate;
typedef std::vector<scoped_refptr<X509Certificate>> CertificateList; typedef std::vector<scoped_refptr<X509Certificate>> CertificateList;
} } // namespace net
namespace policy { namespace policy {
class PolicyService; class PolicyService;
...@@ -39,7 +39,7 @@ class PolicyService; ...@@ -39,7 +39,7 @@ class PolicyService;
namespace chromeos { namespace chromeos {
class PlatformKeysService : public KeyedService { class ExtensionPlatformKeysService : public KeyedService {
public: public:
// The SelectDelegate is used to select a single certificate from all // The SelectDelegate is used to select a single certificate from all
// certificates matching a request (see SelectClientCertificates). E.g. this // certificates matching a request (see SelectClientCertificates). E.g. this
...@@ -76,13 +76,14 @@ class PlatformKeysService : public KeyedService { ...@@ -76,13 +76,14 @@ class PlatformKeysService : public KeyedService {
// |KeyPermissions| for details. // |KeyPermissions| for details.
// |browser_context| and |state_store| must not be null and outlive this // |browser_context| and |state_store| must not be null and outlive this
// object. // object.
explicit PlatformKeysService(bool profile_is_managed, explicit ExtensionPlatformKeysService(
PrefService* profile_prefs, bool profile_is_managed,
policy::PolicyService* profile_policies, PrefService* profile_prefs,
content::BrowserContext* browser_context, policy::PolicyService* profile_policies,
extensions::StateStore* state_store); content::BrowserContext* browser_context,
extensions::StateStore* state_store);
~PlatformKeysService() override; ~ExtensionPlatformKeysService() override;
// Sets the delegate which will be used for interactive // Sets the delegate which will be used for interactive
// SelectClientCertificates calls. // SelectClientCertificates calls.
...@@ -205,11 +206,11 @@ class PlatformKeysService : public KeyedService { ...@@ -205,11 +206,11 @@ class PlatformKeysService : public KeyedService {
KeyPermissions key_permissions_; KeyPermissions key_permissions_;
std::unique_ptr<SelectDelegate> select_delegate_; std::unique_ptr<SelectDelegate> select_delegate_;
base::queue<std::unique_ptr<Task>> tasks_; base::queue<std::unique_ptr<Task>> tasks_;
base::WeakPtrFactory<PlatformKeysService> weak_factory_{this}; base::WeakPtrFactory<ExtensionPlatformKeysService> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(PlatformKeysService); DISALLOW_COPY_AND_ASSIGN(ExtensionPlatformKeysService);
}; };
} // namespace chromeos } // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_ #endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_EXTENSION_PLATFORM_KEYS_SERVICE_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/chromeos/platform_keys/platform_keys_service_factory.h" #include "chrome/browser/chromeos/platform_keys/extension_platform_keys_service_factory.h"
#include <memory> #include <memory>
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/platform_keys/platform_keys_service.h" #include "chrome/browser/chromeos/platform_keys/extension_platform_keys_service.h"
#include "chrome/browser/extensions/extension_system_factory.h" #include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/policy/profile_policy_connector.h" #include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/profiles/incognito_helpers.h" #include "chrome/browser/profiles/incognito_helpers.h"
...@@ -30,7 +30,7 @@ namespace { ...@@ -30,7 +30,7 @@ namespace {
// This delegate selects a certificate by showing the certificate selection // This delegate selects a certificate by showing the certificate selection
// dialog to the user. // dialog to the user.
class DefaultSelectDelegate class DefaultSelectDelegate
: public chromeos::PlatformKeysService::SelectDelegate { : public chromeos::ExtensionPlatformKeysService::SelectDelegate {
public: public:
DefaultSelectDelegate() {} DefaultSelectDelegate() {}
~DefaultSelectDelegate() override {} ~DefaultSelectDelegate() override {}
...@@ -71,33 +71,35 @@ class DefaultSelectDelegate ...@@ -71,33 +71,35 @@ class DefaultSelectDelegate
} // namespace } // namespace
// static // static
PlatformKeysService* PlatformKeysServiceFactory::GetForBrowserContext( ExtensionPlatformKeysService*
ExtensionPlatformKeysServiceFactory::GetForBrowserContext(
content::BrowserContext* context) { content::BrowserContext* context) {
return static_cast<PlatformKeysService*>( return static_cast<ExtensionPlatformKeysService*>(
GetInstance()->GetServiceForBrowserContext(context, true)); GetInstance()->GetServiceForBrowserContext(context, true));
} }
// static // static
PlatformKeysServiceFactory* PlatformKeysServiceFactory::GetInstance() { ExtensionPlatformKeysServiceFactory*
return base::Singleton<PlatformKeysServiceFactory>::get(); ExtensionPlatformKeysServiceFactory::GetInstance() {
return base::Singleton<ExtensionPlatformKeysServiceFactory>::get();
} }
PlatformKeysServiceFactory::PlatformKeysServiceFactory() ExtensionPlatformKeysServiceFactory::ExtensionPlatformKeysServiceFactory()
: BrowserContextKeyedServiceFactory( : BrowserContextKeyedServiceFactory(
"PlatformKeysService", "ExtensionPlatformKeysService",
BrowserContextDependencyManager::GetInstance()) { BrowserContextDependencyManager::GetInstance()) {
DependsOn(extensions::ExtensionSystemFactory::GetInstance()); DependsOn(extensions::ExtensionSystemFactory::GetInstance());
} }
PlatformKeysServiceFactory::~PlatformKeysServiceFactory() { ExtensionPlatformKeysServiceFactory::~ExtensionPlatformKeysServiceFactory() {}
}
content::BrowserContext* PlatformKeysServiceFactory::GetBrowserContextToUse( content::BrowserContext*
ExtensionPlatformKeysServiceFactory::GetBrowserContextToUse(
content::BrowserContext* context) const { content::BrowserContext* context) const {
return chrome::GetBrowserContextRedirectedInIncognito(context); return chrome::GetBrowserContextRedirectedInIncognito(context);
} }
KeyedService* PlatformKeysServiceFactory::BuildServiceInstanceFor( KeyedService* ExtensionPlatformKeysServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const { content::BrowserContext* context) const {
extensions::StateStore* const store = extensions::StateStore* const store =
extensions::ExtensionSystem::Get(context)->state_store(); extensions::ExtensionSystem::Get(context)->state_store();
...@@ -107,9 +109,10 @@ KeyedService* PlatformKeysServiceFactory::BuildServiceInstanceFor( ...@@ -107,9 +109,10 @@ KeyedService* PlatformKeysServiceFactory::BuildServiceInstanceFor(
Profile* const profile = Profile::FromBrowserContext(context); Profile* const profile = Profile::FromBrowserContext(context);
PlatformKeysService* const service = new PlatformKeysService( ExtensionPlatformKeysService* const service =
policy_connector->IsManaged(), profile->GetPrefs(), new ExtensionPlatformKeysService(
policy_connector->policy_service(), context, store); policy_connector->IsManaged(), profile->GetPrefs(),
policy_connector->policy_service(), context, store);
service->SetSelectDelegate(std::make_unique<DefaultSelectDelegate>()); service->SetSelectDelegate(std::make_unique<DefaultSelectDelegate>());
return service; return service;
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_FACTORY_H_ #ifndef CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_EXTENSION_PLATFORM_KEYS_SERVICE_FACTORY_H_
#define CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_FACTORY_H_ #define CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_EXTENSION_PLATFORM_KEYS_SERVICE_FACTORY_H_
#include "base/macros.h" #include "base/macros.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h" #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
...@@ -15,21 +15,23 @@ struct DefaultSingletonTraits; ...@@ -15,21 +15,23 @@ struct DefaultSingletonTraits;
namespace chromeos { namespace chromeos {
class PlatformKeysService; class ExtensionPlatformKeysService;
// Factory to create PlatformKeysService. // Factory to create ExtensionPlatformKeysService.
class PlatformKeysServiceFactory : public BrowserContextKeyedServiceFactory { class ExtensionPlatformKeysServiceFactory
: public BrowserContextKeyedServiceFactory {
public: public:
static PlatformKeysService* GetForBrowserContext( static ExtensionPlatformKeysService* GetForBrowserContext(
content::BrowserContext* context); content::BrowserContext* context);
static PlatformKeysServiceFactory* GetInstance(); static ExtensionPlatformKeysServiceFactory* GetInstance();
private: private:
friend struct base::DefaultSingletonTraits<PlatformKeysServiceFactory>; friend struct base::DefaultSingletonTraits<
ExtensionPlatformKeysServiceFactory>;
PlatformKeysServiceFactory(); ExtensionPlatformKeysServiceFactory();
~PlatformKeysServiceFactory() override; ~ExtensionPlatformKeysServiceFactory() override;
// BrowserContextKeyedServiceFactory: // BrowserContextKeyedServiceFactory:
content::BrowserContext* GetBrowserContextToUse( content::BrowserContext* GetBrowserContextToUse(
...@@ -37,9 +39,9 @@ class PlatformKeysServiceFactory : public BrowserContextKeyedServiceFactory { ...@@ -37,9 +39,9 @@ class PlatformKeysServiceFactory : public BrowserContextKeyedServiceFactory {
KeyedService* BuildServiceInstanceFor( KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override; content::BrowserContext* context) const override;
DISALLOW_COPY_AND_ASSIGN(PlatformKeysServiceFactory); DISALLOW_COPY_AND_ASSIGN(ExtensionPlatformKeysServiceFactory);
}; };
} // namespace chromeos } // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_FACTORY_H_ #endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_EXTENSION_PLATFORM_KEYS_SERVICE_FACTORY_H_
...@@ -58,8 +58,8 @@ struct ClientCertificateRequest { ...@@ -58,8 +58,8 @@ struct ClientCertificateRequest {
namespace subtle { namespace subtle {
// Functions of this namespace shouldn't be called directly from the context of // Functions of this namespace shouldn't be called directly from the context of
// an extension. Instead use PlatformKeysService which enforces restrictions // an extension. Instead use ExtensionPlatformKeysService which enforces
// upon extensions. // restrictions upon extensions.
typedef base::Callback<void(const std::string& public_key_spki_der, typedef base::Callback<void(const std::string& public_key_spki_der,
const std::string& error_message)> const std::string& error_message)>
......
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/chromeos/platform_keys/extension_platform_keys_service.h"
#include "chrome/browser/chromeos/platform_keys/extension_platform_keys_service_factory.h"
#include "chrome/browser/chromeos/platform_keys/platform_keys.h" #include "chrome/browser/chromeos/platform_keys/platform_keys.h"
#include "chrome/browser/chromeos/platform_keys/platform_keys_service.h"
#include "chrome/browser/chromeos/platform_keys/platform_keys_service_factory.h"
#include "chrome/browser/extensions/api/platform_keys/platform_keys_api.h" #include "chrome/browser/extensions/api/platform_keys/platform_keys_api.h"
#include "chrome/common/extensions/api/enterprise_platform_keys.h" #include "chrome/common/extensions/api/enterprise_platform_keys.h"
#include "chrome/common/extensions/api/enterprise_platform_keys_internal.h" #include "chrome/common/extensions/api/enterprise_platform_keys_internal.h"
...@@ -57,8 +57,8 @@ EnterprisePlatformKeysInternalGenerateKeyFunction::Run() { ...@@ -57,8 +57,8 @@ EnterprisePlatformKeysInternalGenerateKeyFunction::Run() {
if (!platform_keys::ValidateToken(params->token_id, &platform_keys_token_id)) if (!platform_keys::ValidateToken(params->token_id, &platform_keys_token_id))
return RespondNow(Error(platform_keys::kErrorInvalidToken)); return RespondNow(Error(platform_keys::kErrorInvalidToken));
chromeos::PlatformKeysService* service = chromeos::ExtensionPlatformKeysService* service =
chromeos::PlatformKeysServiceFactory::GetForBrowserContext( chromeos::ExtensionPlatformKeysServiceFactory::GetForBrowserContext(
browser_context()); browser_context());
DCHECK(service); DCHECK(service);
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/chromeos/platform_keys/extension_platform_keys_service.h"
#include "chrome/browser/chromeos/platform_keys/extension_platform_keys_service_factory.h"
#include "chrome/browser/chromeos/platform_keys/platform_keys.h" #include "chrome/browser/chromeos/platform_keys/platform_keys.h"
#include "chrome/browser/chromeos/platform_keys/platform_keys_service.h"
#include "chrome/browser/chromeos/platform_keys/platform_keys_service_factory.h"
#include "chrome/browser/extensions/api/platform_keys/verify_trust_api.h" #include "chrome/browser/extensions/api/platform_keys/verify_trust_api.h"
#include "chrome/common/extensions/api/platform_keys_internal.h" #include "chrome/common/extensions/api/platform_keys_internal.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h" #include "components/web_modal/web_contents_modal_dialog_manager.h"
...@@ -75,9 +75,7 @@ const struct NameValuePair { ...@@ -75,9 +75,7 @@ const struct NameValuePair {
const char* const name; const char* const name;
const int value; const int value;
} kCertStatusErrors[] = { } kCertStatusErrors[] = {
#define CERT_STATUS_FLAG(name, value) \ #define CERT_STATUS_FLAG(name, value) {#name, value},
{ #name, value } \
,
#include "net/cert/cert_status_flags_list.h" #include "net/cert/cert_status_flags_list.h"
#undef CERT_STATUS_FLAG #undef CERT_STATUS_FLAG
}; };
...@@ -120,8 +118,7 @@ std::string PlatformKeysTokenIdToApiId( ...@@ -120,8 +118,7 @@ std::string PlatformKeysTokenIdToApiId(
} // namespace platform_keys } // namespace platform_keys
PlatformKeysInternalGetPublicKeyFunction:: PlatformKeysInternalGetPublicKeyFunction::
~PlatformKeysInternalGetPublicKeyFunction() { ~PlatformKeysInternalGetPublicKeyFunction() {}
}
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
PlatformKeysInternalGetPublicKeyFunction::Run() { PlatformKeysInternalGetPublicKeyFunction::Run() {
...@@ -170,8 +167,7 @@ PlatformKeysInternalGetPublicKeyFunction::Run() { ...@@ -170,8 +167,7 @@ PlatformKeysInternalGetPublicKeyFunction::Run() {
} }
PlatformKeysInternalSelectClientCertificatesFunction:: PlatformKeysInternalSelectClientCertificatesFunction::
~PlatformKeysInternalSelectClientCertificatesFunction() { ~PlatformKeysInternalSelectClientCertificatesFunction() {}
}
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
PlatformKeysInternalSelectClientCertificatesFunction::Run() { PlatformKeysInternalSelectClientCertificatesFunction::Run() {
...@@ -179,8 +175,8 @@ PlatformKeysInternalSelectClientCertificatesFunction::Run() { ...@@ -179,8 +175,8 @@ PlatformKeysInternalSelectClientCertificatesFunction::Run() {
api_pki::SelectClientCertificates::Params::Create(*args_)); api_pki::SelectClientCertificates::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params); EXTENSION_FUNCTION_VALIDATE(params);
chromeos::PlatformKeysService* service = chromeos::ExtensionPlatformKeysService* service =
chromeos::PlatformKeysServiceFactory::GetForBrowserContext( chromeos::ExtensionPlatformKeysServiceFactory::GetForBrowserContext(
browser_context()); browser_context());
DCHECK(service); DCHECK(service);
...@@ -289,8 +285,7 @@ void PlatformKeysInternalSelectClientCertificatesFunction:: ...@@ -289,8 +285,7 @@ void PlatformKeysInternalSelectClientCertificatesFunction::
api_pki::SelectClientCertificates::Results::Create(result_matches))); api_pki::SelectClientCertificates::Results::Create(result_matches)));
} }
PlatformKeysInternalSignFunction::~PlatformKeysInternalSignFunction() { PlatformKeysInternalSignFunction::~PlatformKeysInternalSignFunction() {}
}
ExtensionFunction::ResponseAction PlatformKeysInternalSignFunction::Run() { ExtensionFunction::ResponseAction PlatformKeysInternalSignFunction::Run() {
std::unique_ptr<api_pki::Sign::Params> params( std::unique_ptr<api_pki::Sign::Params> params(
...@@ -303,8 +298,8 @@ ExtensionFunction::ResponseAction PlatformKeysInternalSignFunction::Run() { ...@@ -303,8 +298,8 @@ ExtensionFunction::ResponseAction PlatformKeysInternalSignFunction::Run() {
return RespondNow(Error(platform_keys::kErrorInvalidToken)); return RespondNow(Error(platform_keys::kErrorInvalidToken));
} }
chromeos::PlatformKeysService* service = chromeos::ExtensionPlatformKeysService* service =
chromeos::PlatformKeysServiceFactory::GetForBrowserContext( chromeos::ExtensionPlatformKeysServiceFactory::GetForBrowserContext(
browser_context()); browser_context());
DCHECK(service); DCHECK(service);
...@@ -352,8 +347,7 @@ void PlatformKeysInternalSignFunction::OnSigned( ...@@ -352,8 +347,7 @@ void PlatformKeysInternalSignFunction::OnSigned(
} }
PlatformKeysVerifyTLSServerCertificateFunction:: PlatformKeysVerifyTLSServerCertificateFunction::
~PlatformKeysVerifyTLSServerCertificateFunction() { ~PlatformKeysVerifyTLSServerCertificateFunction() {}
}
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
PlatformKeysVerifyTLSServerCertificateFunction::Run() { PlatformKeysVerifyTLSServerCertificateFunction::Run() {
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "chrome/browser/chromeos/platform_keys/platform_keys_service.h" #include "chrome/browser/chromeos/platform_keys/extension_platform_keys_service.h"
#include "chrome/browser/chromeos/platform_keys/platform_keys_service_factory.h" #include "chrome/browser/chromeos/platform_keys/extension_platform_keys_service_factory.h"
#include "chrome/browser/extensions/api/platform_keys/platform_keys_test_base.h" #include "chrome/browser/extensions/api/platform_keys/platform_keys_test_base.h"
#include "chrome/browser/net/nss_context.h" #include "chrome/browser/net/nss_context.h"
#include "chrome/browser/policy/profile_policy_connector.h" #include "chrome/browser/policy/profile_policy_connector.h"
...@@ -105,8 +105,8 @@ class PlatformKeysTest : public PlatformKeysTestBase { ...@@ -105,8 +105,8 @@ class PlatformKeysTest : public PlatformKeysTestBase {
mock_policy_provider()->UpdateChromePolicy(policy); mock_policy_provider()->UpdateChromePolicy(policy);
} }
chromeos::PlatformKeysService* GetPlatformKeysService() { chromeos::ExtensionPlatformKeysService* GetExtensionPlatformKeysService() {
return chromeos::PlatformKeysServiceFactory::GetForBrowserContext( return chromeos::ExtensionPlatformKeysServiceFactory::GetForBrowserContext(
profile()); profile());
} }
...@@ -223,7 +223,7 @@ class PlatformKeysTest : public PlatformKeysTestBase { ...@@ -223,7 +223,7 @@ class PlatformKeysTest : public PlatformKeysTestBase {
}; };
class TestSelectDelegate class TestSelectDelegate
: public chromeos::PlatformKeysService::SelectDelegate { : public chromeos::ExtensionPlatformKeysService::SelectDelegate {
public: public:
// On each Select call, selects the next entry in |certs_to_select| from back // On each Select call, selects the next entry in |certs_to_select| from back
// to front. Once the first entry is reached, that one will be selected // to front. Once the first entry is reached, that one will be selected
...@@ -332,7 +332,7 @@ IN_PROC_BROWSER_TEST_P(UnmanagedPlatformKeysTest, Basic) { ...@@ -332,7 +332,7 @@ IN_PROC_BROWSER_TEST_P(UnmanagedPlatformKeysTest, Basic) {
certs.push_back(client_cert2_); certs.push_back(client_cert2_);
certs.push_back(client_cert1_); certs.push_back(client_cert1_);
GetPlatformKeysService()->SetSelectDelegate( GetExtensionPlatformKeysService()->SetSelectDelegate(
std::make_unique<TestSelectDelegate>(certs)); std::make_unique<TestSelectDelegate>(certs));
ASSERT_TRUE(RunExtensionTest("basicTests")) << message_; ASSERT_TRUE(RunExtensionTest("basicTests")) << message_;
...@@ -348,7 +348,7 @@ IN_PROC_BROWSER_TEST_P(UnmanagedPlatformKeysTest, Permissions) { ...@@ -348,7 +348,7 @@ IN_PROC_BROWSER_TEST_P(UnmanagedPlatformKeysTest, Permissions) {
net::CertificateList certs; net::CertificateList certs;
certs.push_back(client_cert1_); certs.push_back(client_cert1_);
GetPlatformKeysService()->SetSelectDelegate( GetExtensionPlatformKeysService()->SetSelectDelegate(
std::make_unique<TestSelectDelegate>(certs)); std::make_unique<TestSelectDelegate>(certs));
ASSERT_TRUE(RunExtensionTest("permissionTests")) << message_; ASSERT_TRUE(RunExtensionTest("permissionTests")) << message_;
...@@ -379,7 +379,7 @@ IN_PROC_BROWSER_TEST_P(ManagedWithoutPermissionPlatformKeysTest, ...@@ -379,7 +379,7 @@ IN_PROC_BROWSER_TEST_P(ManagedWithoutPermissionPlatformKeysTest,
UserPermissionsBlocked) { UserPermissionsBlocked) {
// To verify that the user is not prompted for any certificate selection, // To verify that the user is not prompted for any certificate selection,
// set up a delegate that fails on any invocation. // set up a delegate that fails on any invocation.
GetPlatformKeysService()->SetSelectDelegate( GetExtensionPlatformKeysService()->SetSelectDelegate(
std::make_unique<TestSelectDelegate>(net::CertificateList())); std::make_unique<TestSelectDelegate>(net::CertificateList()));
ASSERT_TRUE(RunExtensionTest("managedProfile")) << message_; ASSERT_TRUE(RunExtensionTest("managedProfile")) << message_;
...@@ -397,7 +397,7 @@ IN_PROC_BROWSER_TEST_P(ManagedWithoutPermissionPlatformKeysTest, ...@@ -397,7 +397,7 @@ IN_PROC_BROWSER_TEST_P(ManagedWithoutPermissionPlatformKeysTest,
// To verify that the user is not prompted for any certificate selection, // To verify that the user is not prompted for any certificate selection,
// set up a delegate that fails on any invocation. // set up a delegate that fails on any invocation.
GetPlatformKeysService()->SetSelectDelegate( GetExtensionPlatformKeysService()->SetSelectDelegate(
std::make_unique<TestSelectDelegate>(net::CertificateList())); std::make_unique<TestSelectDelegate>(net::CertificateList()));
ASSERT_TRUE(RunExtensionTest("corporateKeyWithoutPermissionTests")) ASSERT_TRUE(RunExtensionTest("corporateKeyWithoutPermissionTests"))
...@@ -432,7 +432,7 @@ IN_PROC_BROWSER_TEST_P(ManagedWithPermissionPlatformKeysTest, ...@@ -432,7 +432,7 @@ IN_PROC_BROWSER_TEST_P(ManagedWithPermissionPlatformKeysTest,
net::CertificateList certs; net::CertificateList certs;
certs.push_back(client_cert1_); certs.push_back(client_cert1_);
GetPlatformKeysService()->SetSelectDelegate( GetExtensionPlatformKeysService()->SetSelectDelegate(
std::make_unique<TestSelectDelegate>(certs)); std::make_unique<TestSelectDelegate>(certs));
ASSERT_TRUE(RunExtensionTest("corporateKeyWithPermissionTests")) << message_; ASSERT_TRUE(RunExtensionTest("corporateKeyWithPermissionTests")) << message_;
...@@ -456,7 +456,7 @@ IN_PROC_BROWSER_TEST_P(ManagedWithPermissionPlatformKeysTest, ...@@ -456,7 +456,7 @@ IN_PROC_BROWSER_TEST_P(ManagedWithPermissionPlatformKeysTest,
if (user_status() == UserStatus::MANAGED_AFFILIATED_DOMAIN) if (user_status() == UserStatus::MANAGED_AFFILIATED_DOMAIN)
certs.push_back(nullptr); certs.push_back(nullptr);
GetPlatformKeysService()->SetSelectDelegate( GetExtensionPlatformKeysService()->SetSelectDelegate(
std::make_unique<TestSelectDelegate>(certs)); std::make_unique<TestSelectDelegate>(certs));
ASSERT_TRUE(RunExtensionTest("policyDoesGrantAccessToNonCorporateKey")) ASSERT_TRUE(RunExtensionTest("policyDoesGrantAccessToNonCorporateKey"))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment