Commit 3b7173a8 authored by tengs's avatar tengs Committed by Commit bot

Ensure EasyUnlockPrivateAPI factory is initialized on start up.

BUG=487486

Review URL: https://codereview.chromium.org/1135183002

Cr-Commit-Position: refs/heads/master@{#329974}
parent 1b64b5ed
......@@ -43,7 +43,8 @@
using proximity_auth::ScreenlockState;
namespace extensions {
namespace api {
namespace easy_unlock_private = api::easy_unlock_private;
namespace {
......@@ -54,7 +55,7 @@ static base::LazyInstance<BrowserContextKeyedAPIFactory<EasyUnlockPrivateAPI> >
EasyUnlockPrivateCryptoDelegate* GetCryptoDelegate(
content::BrowserContext* context) {
return BrowserContextKeyedAPIFactory<EasyUnlockPrivateAPI>::Get(context)
->crypto_delegate();
->GetCryptoDelegate();
}
ScreenlockState ToScreenlockState(easy_unlock_private::State state) {
......@@ -94,12 +95,17 @@ BrowserContextKeyedAPIFactory<EasyUnlockPrivateAPI>*
return g_factory.Pointer();
}
EasyUnlockPrivateAPI::EasyUnlockPrivateAPI(content::BrowserContext* context)
: crypto_delegate_(EasyUnlockPrivateCryptoDelegate::Create()) {
EasyUnlockPrivateAPI::EasyUnlockPrivateAPI(content::BrowserContext* context) {
}
EasyUnlockPrivateAPI::~EasyUnlockPrivateAPI() {}
EasyUnlockPrivateCryptoDelegate* EasyUnlockPrivateAPI::GetCryptoDelegate() {
if (!crypto_delegate_)
crypto_delegate_ = EasyUnlockPrivateCryptoDelegate::Create();
return crypto_delegate_.get();
}
EasyUnlockPrivateGetStringsFunction::EasyUnlockPrivateGetStringsFunction() {
}
EasyUnlockPrivateGetStringsFunction::~EasyUnlockPrivateGetStringsFunction() {
......@@ -836,5 +842,4 @@ bool EasyUnlockPrivateSetAutoPairingResultFunction::RunSync() {
return true;
}
} // namespace api
} // namespace extensions
......@@ -22,11 +22,6 @@ class BrowserContext;
}
namespace extensions {
namespace api {
namespace easy_unlock {
struct SeekDeviceResult;
} // easy_unlock
class EasyUnlockPrivateCryptoDelegate;
......@@ -40,9 +35,7 @@ class EasyUnlockPrivateAPI : public BrowserContextKeyedAPI {
explicit EasyUnlockPrivateAPI(content::BrowserContext* context);
~EasyUnlockPrivateAPI() override;
EasyUnlockPrivateCryptoDelegate* crypto_delegate() {
return crypto_delegate_.get();
}
EasyUnlockPrivateCryptoDelegate* GetCryptoDelegate();
private:
friend class BrowserContextKeyedAPIFactory<EasyUnlockPrivateAPI>;
......@@ -399,7 +392,6 @@ class EasyUnlockPrivateSetAutoPairingResultFunction
DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivateSetAutoPairingResultFunction);
};
} // namespace api
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE_API_H_
......@@ -29,11 +29,11 @@ namespace {
namespace api = extensions::api::easy_unlock_private;
using extensions::api::EasyUnlockPrivateGenerateEcP256KeyPairFunction;
using extensions::api::EasyUnlockPrivatePerformECDHKeyAgreementFunction;
using extensions::api::EasyUnlockPrivateCreateSecureMessageFunction;
using extensions::api::EasyUnlockPrivateUnwrapSecureMessageFunction;
using extensions::api::EasyUnlockPrivateSetAutoPairingResultFunction;
using extensions::EasyUnlockPrivateGenerateEcP256KeyPairFunction;
using extensions::EasyUnlockPrivatePerformECDHKeyAgreementFunction;
using extensions::EasyUnlockPrivateCreateSecureMessageFunction;
using extensions::EasyUnlockPrivateUnwrapSecureMessageFunction;
using extensions::EasyUnlockPrivateSetAutoPairingResultFunction;
// Converts a string to a base::BinaryValue value whose buffer contains the
// string data without the trailing '\0'.
......
......@@ -12,7 +12,6 @@
#include "chrome/common/extensions/api/easy_unlock_private.h"
namespace extensions {
namespace api {
// Wrapper around EasyUnlock dbus client on Chrome OS. The methods read
// extension function pearameters and invoke the associated EasyUnlock dbus
......@@ -34,17 +33,16 @@ class EasyUnlockPrivateCryptoDelegate {
// See chromeos/dbus/easy_unlock_client.h for info on these methods.
virtual void GenerateEcP256KeyPair(const KeyPairCallback& callback) = 0;
virtual void PerformECDHKeyAgreement(
const easy_unlock_private::PerformECDHKeyAgreement::Params& params,
const api::easy_unlock_private::PerformECDHKeyAgreement::Params& params,
const DataCallback& callback) = 0;
virtual void CreateSecureMessage(
const easy_unlock_private::CreateSecureMessage::Params& params,
const api::easy_unlock_private::CreateSecureMessage::Params& params,
const DataCallback& callback) = 0;
virtual void UnwrapSecureMessage(
const easy_unlock_private::UnwrapSecureMessage::Params& params,
const api::easy_unlock_private::UnwrapSecureMessage::Params& params,
const DataCallback& callback) = 0;
};
} // namespace api
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE_CRYPTO_DELEGATE_H_
......@@ -9,7 +9,8 @@
#include "third_party/cros_system_api/dbus/service_constants.h"
namespace extensions {
namespace api {
namespace easy_unlock_private = api::easy_unlock_private;
namespace {
......@@ -39,7 +40,7 @@ std::string SignatureTypeToString(easy_unlock_private::SignatureType type) {
// ChromeOS specific EasyUnlockPrivateCryptoDelegate implementation.
class EasyUnlockPrivateCryptoDelegateChromeOS
: public extensions::api::EasyUnlockPrivateCryptoDelegate {
: public extensions::EasyUnlockPrivateCryptoDelegate {
public:
EasyUnlockPrivateCryptoDelegateChromeOS()
: dbus_client_(
......@@ -128,5 +129,4 @@ scoped_ptr<EasyUnlockPrivateCryptoDelegate>
new EasyUnlockPrivateCryptoDelegateChromeOS());
}
} // namespace api
} // namespace extensions
......@@ -5,13 +5,14 @@
#include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_crypto_delegate.h"
namespace extensions {
namespace api {
namespace easy_unlock_private = api::easy_unlock_private;
namespace {
// Stub EasyUnlockPrivateCryptoDelegate implementation.
class EasyUnlockPrivateCryptoDelegateStub
: public extensions::api::EasyUnlockPrivateCryptoDelegate {
: public extensions::EasyUnlockPrivateCryptoDelegate {
public:
EasyUnlockPrivateCryptoDelegateStub() {}
......@@ -52,5 +53,4 @@ scoped_ptr<EasyUnlockPrivateCryptoDelegate>
new EasyUnlockPrivateCryptoDelegateStub());
}
} // namespace api
} // namespace extensions
......@@ -15,6 +15,7 @@
#include "chrome/browser/extensions/api/cookies/cookies_api.h"
#include "chrome/browser/extensions/api/developer_private/developer_private_api.h"
#include "chrome/browser/extensions/api/dial/dial_api_factory.h"
#include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.h"
#include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
#include "chrome/browser/extensions/api/feedback_private/feedback_private_api.h"
#include "chrome/browser/extensions/api/font_settings/font_settings_api.h"
......@@ -94,6 +95,7 @@ void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
extensions::CookiesAPI::GetFactoryInstance();
extensions::DeveloperPrivateAPI::GetFactoryInstance();
extensions::DialAPIFactory::GetInstance();
extensions::EasyUnlockPrivateAPI::GetFactoryInstance();
extensions::ExtensionActionAPI::GetFactoryInstance();
extensions::ExtensionGarbageCollectorFactory::GetInstance();
extensions::ExtensionStorageMonitorFactory::GetInstance();
......
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