diff options
author | cmasone@google.com <cmasone@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-10 18:29:09 +0000 |
---|---|---|
committer | cmasone@google.com <cmasone@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-10 18:29:09 +0000 |
commit | dc1a80d7c830a09c8f5281af69fc746a86f558b7 (patch) | |
tree | 5470d73e1de9c69d3b008666176200d0f5249183 | |
parent | 4c9e6cbf9921ba74c6de3f863947ec51c4837316 (diff) | |
download | chromium_src-dc1a80d7c830a09c8f5281af69fc746a86f558b7.zip chromium_src-dc1a80d7c830a09c8f5281af69fc746a86f558b7.tar.gz chromium_src-dc1a80d7c830a09c8f5281af69fc746a86f558b7.tar.bz2 |
[Chrome OS] expose async crypto API via CryptohomeLibrary
Also, get ride of the template on LoginLibrary::Delegate. Most of the files are here due to that.
BUG=chromium-os:4929
TEST=None
Review URL: http://codereview.chromium.org/3319018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59120 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/cros/cryptohome_library.cc | 126 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/cryptohome_library.h | 57 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/login_library.cc | 32 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/login_library.h | 11 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/mock_cryptohome_library.h | 19 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/mock_login_library.h | 13 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/mock_owner_key_utils.h | 10 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/owner_key_utils.cc | 7 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/owner_key_utils.h | 2 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/owner_manager.cc | 2 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/owner_manager.h | 4 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/signed_settings.cc | 20 |
12 files changed, 232 insertions, 71 deletions
diff --git a/chrome/browser/chromeos/cros/cryptohome_library.cc b/chrome/browser/chromeos/cros/cryptohome_library.cc index dcdf456..e0b74c7 100644 --- a/chrome/browser/chromeos/cros/cryptohome_library.cc +++ b/chrome/browser/chromeos/cros/cryptohome_library.cc @@ -4,26 +4,53 @@ #include "chrome/browser/chromeos/cros/cryptohome_library.h" +#include "base/hash_tables.h" #include "base/message_loop.h" #include "chrome/browser/chrome_thread.h" +#include "chrome/browser/chromeos/cros/cros_library.h" namespace chromeos { // This class handles the interaction with the ChromeOS cryptohome library APIs. -class CryptohomeLibraryImpl: public CryptohomeLibrary { +class CryptohomeLibraryImpl : public CryptohomeLibrary { public: - CryptohomeLibraryImpl() {} + CryptohomeLibraryImpl() { + if (CrosLibrary::Get()->EnsureLoaded()) + Init(); + } virtual ~CryptohomeLibraryImpl() {} bool CheckKey(const std::string& user_email, const std::string& passhash) { return chromeos::CryptohomeCheckKey(user_email.c_str(), passhash.c_str()); } + bool AsyncCheckKey(const std::string& user_email, + const std::string& passhash, + Delegate* d) { + return CacheCallback( + chromeos::CryptohomeAsyncCheckKey(user_email.c_str(), passhash.c_str()), + d, + "Couldn't initiate async check of user's key."); + } + bool MigrateKey(const std::string& user_email, const std::string& old_hash, const std::string& new_hash) { - return chromeos::CryptohomeMigrateKey(user_email.c_str(), old_hash.c_str(), - new_hash.c_str()); + return chromeos::CryptohomeMigrateKey(user_email.c_str(), + old_hash.c_str(), + new_hash.c_str()); + } + + bool AsyncMigrateKey(const std::string& user_email, + const std::string& old_hash, + const std::string& new_hash, + Delegate* d) { + return CacheCallback( + chromeos::CryptohomeAsyncMigrateKey(user_email.c_str(), + old_hash.c_str(), + new_hash.c_str()), + d, + "Couldn't initiate aync migration of user's key"); } bool Remove(const std::string& user_email) { @@ -34,13 +61,29 @@ class CryptohomeLibraryImpl: public CryptohomeLibrary { const std::string& passhash, int* error_code) { return chromeos::CryptohomeMountAllowFail(user_email.c_str(), - passhash.c_str(), error_code); + passhash.c_str(), + error_code); + } + + bool AsyncMount(const std::string& user_email, + const std::string& passhash, + Delegate* d) { + return CacheCallback( + chromeos::CryptohomeAsyncMount(user_email.c_str(), passhash.c_str()), + d, + "Couldn't initiate async mount of cryptohome."); } bool MountForBwsi(int* error_code) { return chromeos::CryptohomeMountGuest(error_code); } + bool AsyncMountForBwsi(Delegate* d) { + return CacheCallback(chromeos::CryptohomeAsyncMountGuest(), + d, + "Couldn't initiate async mount of cryptohome."); + } + bool IsMounted() { return chromeos::CryptohomeIsMounted(); } @@ -50,10 +93,43 @@ class CryptohomeLibraryImpl: public CryptohomeLibrary { } private: + static void Handler(const chromeos::CryptohomeAsyncCallStatus& event, + void* cryptohome_library) { + CryptohomeLibraryImpl* library = + reinterpret_cast<CryptohomeLibraryImpl*>(cryptohome_library); + library->Dispatch(event); + } + + void Init() { + cryptohome_connection_ = chromeos::CryptohomeMonitorSession(&Handler, this); + } + + void Dispatch(const chromeos::CryptohomeAsyncCallStatus& event) { + callback_map_[event.async_id]->OnComplete(event.return_status, + event.return_code); + callback_map_[event.async_id] = NULL; + } + + bool CacheCallback(int async_id, + Delegate* d, + const char* error) { + if (async_id == 0) { + LOG(ERROR) << error; + return false; + } + callback_map_[async_id] = d; + return true; + } + + typedef base::hash_map<int, Delegate*> CallbackMap; + mutable CallbackMap callback_map_; + + void* cryptohome_connection_; + DISALLOW_COPY_AND_ASSIGN(CryptohomeLibraryImpl); }; -class CryptohomeLibraryStubImpl: public CryptohomeLibrary { +class CryptohomeLibraryStubImpl : public CryptohomeLibrary { public: CryptohomeLibraryStubImpl() {} virtual ~CryptohomeLibraryStubImpl() {} @@ -62,12 +138,31 @@ class CryptohomeLibraryStubImpl: public CryptohomeLibrary { return true; } + bool AsyncCheckKey(const std::string& user_email, + const std::string& passhash, + Delegate* callback) { + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + NewRunnableFunction(&DoStubCallback, callback)); + return true; + } + bool MigrateKey(const std::string& user_email, const std::string& old_hash, const std::string& new_hash) { return true; } + bool AsyncMigrateKey(const std::string& user_email, + const std::string& old_hash, + const std::string& new_hash, + Delegate* callback) { + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + NewRunnableFunction(&DoStubCallback, callback)); + return true; + } + bool Remove(const std::string& user_email) { return true; } @@ -78,10 +173,26 @@ class CryptohomeLibraryStubImpl: public CryptohomeLibrary { return true; } + bool AsyncMount(const std::string& user_email, + const std::string& passhash, + Delegate* callback) { + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + NewRunnableFunction(&DoStubCallback, callback)); + return true; + } + bool MountForBwsi(int* error_code) { return true; } + bool AsyncMountForBwsi(Delegate* callback) { + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + NewRunnableFunction(&DoStubCallback, callback)); + return true; + } + bool IsMounted() { return true; } @@ -94,6 +205,9 @@ class CryptohomeLibraryStubImpl: public CryptohomeLibrary { } private: + static void DoStubCallback(Delegate* callback) { + callback->OnComplete(true, kCryptohomeMountErrorNone); + } DISALLOW_COPY_AND_ASSIGN(CryptohomeLibraryStubImpl); }; diff --git a/chrome/browser/chromeos/cros/cryptohome_library.h b/chrome/browser/chromeos/cros/cryptohome_library.h index 248c0b0..6b01d65 100644 --- a/chrome/browser/chromeos/cros/cryptohome_library.h +++ b/chrome/browser/chromeos/cros/cryptohome_library.h @@ -9,6 +9,7 @@ #include <string> #include "base/singleton.h" +#include "chrome/browser/chromeos/cros/cros_library.h" #include "cros/chromeos_cryptohome.h" namespace chromeos { @@ -17,28 +18,66 @@ namespace chromeos { // APIs. class CryptohomeLibrary { public: - virtual ~CryptohomeLibrary() {} - - // Asks cryptohomed to try to find the cryptohome for |user_email| and then - // mount it using |passhash| to unlock the key. - virtual bool Mount(const std::string& user_email, - const std::string& passhash, - int* error_code) = 0; + class Delegate { + public: + // This will be called back on the UI thread. Consult |return_code| for + // further information beyond mere success or failure. + virtual void OnComplete(bool success, int return_code) = 0; + }; - // Asks cryptohomed to mount a tmpfs for BWSI mode. - virtual bool MountForBwsi(int* error_code) = 0; + virtual ~CryptohomeLibrary() {} // Asks cryptohomed to try to find the cryptohome for |user_email| and then // use |passhash| to unlock the key. virtual bool CheckKey(const std::string& user_email, const std::string& passhash) = 0; + // Asks cryptohomed to asynchronously try to find the cryptohome for + // |user_email| and then use |passhash| to unlock the key. + // Returns true if the attempt is successfully initiated. + // d->OnComplete() will be called with status info on completion. + virtual bool AsyncCheckKey(const std::string& user_email, + const std::string& passhash, + Delegate* callback) = 0; + // Asks cryptohomed to try to find the cryptohome for |user_email| and then // change from using |old_hash| to lock the key to using |new_hash|. virtual bool MigrateKey(const std::string& user_email, const std::string& old_hash, const std::string& new_hash) = 0; + // Asks cryptohomed to asynchronously try to find the cryptohome for + // |user_email| and then change from using |old_hash| to lock the + // key to using |new_hash|. + // Returns true if the attempt is successfully initiated. + // d->OnComplete() will be called with status info on completion. + virtual bool AsyncMigrateKey(const std::string& user_email, + const std::string& old_hash, + const std::string& new_hash, + Delegate* callback) = 0; + + // Asks cryptohomed to try to find the cryptohome for |user_email| and then + // mount it using |passhash| to unlock the key. + virtual bool Mount(const std::string& user_email, + const std::string& passhash, + int* error_code) = 0; + + // Asks cryptohomed to asynchronously try to find the cryptohome for + // |user_email| and then mount it using |passhash| to unlock the key. + // Returns true if the attempt is successfully initiated. + // d->OnComplete() will be called with status info on completion. + virtual bool AsyncMount(const std::string& user_email, + const std::string& passhash, + Delegate* callback) = 0; + + // Asks cryptohomed to mount a tmpfs for BWSI mode. + virtual bool MountForBwsi(int* error_code) = 0; + + // Asks cryptohomed to asynchronously to mount a tmpfs for BWSI mode. + // Returns true if the attempt is successfully initiated. + // d->OnComplete() will be called with status info on completion. + virtual bool AsyncMountForBwsi(Delegate* callback) = 0; + // Asks cryptohomed to try to find the cryptohome for |user_email| and then // nuke it. virtual bool Remove(const std::string& user_email) = 0; diff --git a/chrome/browser/chromeos/cros/login_library.cc b/chrome/browser/chromeos/cros/login_library.cc index 49410da..4b57d44 100644 --- a/chrome/browser/chromeos/cros/login_library.cc +++ b/chrome/browser/chromeos/cros/login_library.cc @@ -41,7 +41,7 @@ class LoginLibraryImpl : public LoginLibrary { } bool SetOwnerKeyAsync(const std::vector<uint8>& public_key_der, - Delegate<bool>* callback) { + Delegate* callback) { DCHECK(callback) << "must provide a callback to SetOwnerKeyAsync()"; if (set_owner_key_callback_) return false; @@ -52,7 +52,7 @@ class LoginLibraryImpl : public LoginLibrary { bool StorePropertyAsync(const std::string& name, const std::string& value, const std::vector<uint8>& signature, - Delegate<bool>* callback) { + Delegate* callback) { DCHECK(callback) << "must provide a callback to StorePropertyAsync()"; if (property_op_callback_) return false; @@ -62,7 +62,7 @@ class LoginLibraryImpl : public LoginLibrary { bool UnwhitelistAsync(const std::string& email, const std::vector<uint8>& signature, - Delegate<bool>* callback) { + Delegate* callback) { DCHECK(callback) << "must provide a callback to UnwhitelistAsync()"; if (whitelist_op_callback_) return false; @@ -72,7 +72,7 @@ class LoginLibraryImpl : public LoginLibrary { bool WhitelistAsync(const std::string& email, const std::vector<uint8>& signature, - Delegate<bool>* callback) { + Delegate* callback) { DCHECK(callback) << "must provide a callback to WhitelistAsync()"; if (whitelist_op_callback_) return false; @@ -134,27 +134,27 @@ class LoginLibraryImpl : public LoginLibrary { void CompleteSetOwnerKey(bool result) { CHECK(set_owner_key_callback_) << "CompleteSetOwnerKey() called without " "a registered callback!"; - set_owner_key_callback_->Run(result); + set_owner_key_callback_->OnComplete(result); set_owner_key_callback_ = NULL; } void CompleteWhitelistOp(bool result) { CHECK(whitelist_op_callback_); - whitelist_op_callback_->Run(result); + whitelist_op_callback_->OnComplete(result); whitelist_op_callback_ = NULL; } void CompletePropertyOp(bool result) { CHECK(property_op_callback_); - property_op_callback_->Run(result); + property_op_callback_->OnComplete(result); property_op_callback_ = NULL; } chromeos::SessionConnection session_connection_; - Delegate<bool>* set_owner_key_callback_; - Delegate<bool>* whitelist_op_callback_; - Delegate<bool>* property_op_callback_; + Delegate* set_owner_key_callback_; + Delegate* whitelist_op_callback_; + Delegate* property_op_callback_; DISALLOW_COPY_AND_ASSIGN(LoginLibraryImpl); }; @@ -178,7 +178,7 @@ class LoginLibraryStubImpl : public LoginLibrary { return true; } bool SetOwnerKeyAsync(const std::vector<uint8>& public_key_der, - Delegate<bool>* callback) { + Delegate* callback) { ChromeThread::PostTask( ChromeThread::UI, FROM_HERE, NewRunnableFunction(&DoStubCallback, callback)); @@ -187,7 +187,7 @@ class LoginLibraryStubImpl : public LoginLibrary { bool StorePropertyAsync(const std::string& name, const std::string& value, const std::vector<uint8>& signature, - Delegate<bool>* callback) { + Delegate* callback) { ChromeThread::PostTask( ChromeThread::UI, FROM_HERE, NewRunnableFunction(&DoStubCallback, callback)); @@ -195,7 +195,7 @@ class LoginLibraryStubImpl : public LoginLibrary { } bool UnwhitelistAsync(const std::string& email, const std::vector<uint8>& signature, - Delegate<bool>* callback) { + Delegate* callback) { ChromeThread::PostTask( ChromeThread::UI, FROM_HERE, NewRunnableFunction(&DoStubCallback, callback)); @@ -203,7 +203,7 @@ class LoginLibraryStubImpl : public LoginLibrary { } bool WhitelistAsync(const std::string& email, const std::vector<uint8>& signature, - Delegate<bool>* callback) { + Delegate* callback) { ChromeThread::PostTask( ChromeThread::UI, FROM_HERE, NewRunnableFunction(&DoStubCallback, callback)); @@ -218,8 +218,8 @@ class LoginLibraryStubImpl : public LoginLibrary { bool RestartJob(int pid, const std::string& command_line) { return true; } private: - static void DoStubCallback(Delegate<bool>* callback) { - callback->Run(true); + static void DoStubCallback(Delegate* callback) { + callback->OnComplete(true); } DISALLOW_COPY_AND_ASSIGN(LoginLibraryStubImpl); diff --git a/chrome/browser/chromeos/cros/login_library.h b/chrome/browser/chromeos/cros/login_library.h index 4905f9e..fc9b11a 100644 --- a/chrome/browser/chromeos/cros/login_library.h +++ b/chrome/browser/chromeos/cros/login_library.h @@ -16,10 +16,9 @@ namespace chromeos { // This interface defines the interaction with the ChromeOS login library APIs. class LoginLibrary { public: - template <class T> class Delegate { public: - virtual void Run(T value) = 0; + virtual void OnComplete(bool value) = 0; }; virtual ~LoginLibrary() {} @@ -47,7 +46,7 @@ class LoginLibrary { // Returns true if the attempt was successfully started. // callback->Run() will be called when the operation is complete. virtual bool SetOwnerKeyAsync(const std::vector<uint8>& public_key_der, - Delegate<bool>* callback) = 0; + Delegate* callback) = 0; // Attempts to issue a signed async request to store |name|=|value|. // |signature| must by a SHA1 with RSA encryption signature over the string @@ -57,7 +56,7 @@ class LoginLibrary { virtual bool StorePropertyAsync(const std::string& name, const std::string& value, const std::vector<uint8>& signature, - Delegate<bool>* callback) = 0; + Delegate* callback) = 0; // Attempts to issue a signed async request to whitelist |email|. // |signature| must by a SHA1 with RSA encryption signature over |email| @@ -66,7 +65,7 @@ class LoginLibrary { // callback->Run() will be called when the operation is complete. virtual bool WhitelistAsync(const std::string& email, const std::vector<uint8>& signature, - Delegate<bool>* callback) = 0; + Delegate* callback) = 0; // Attempts to issue a signed async request to remove |email| from the // whitelist of users allowed to log in to this machine. @@ -76,7 +75,7 @@ class LoginLibrary { // callback->Run() will be called when the operation is complete. virtual bool UnwhitelistAsync(const std::string& email, const std::vector<uint8>& signature, - Delegate<bool>* callback) = 0; + Delegate* callback) = 0; // Retrieves the user white list. Note the call is for display purpose only. // To determine if an email is white listed, you MUST use CheckWhitelist. diff --git a/chrome/browser/chromeos/cros/mock_cryptohome_library.h b/chrome/browser/chromeos/cros/mock_cryptohome_library.h index afdb037..cf41288 100644 --- a/chrome/browser/chromeos/cros/mock_cryptohome_library.h +++ b/chrome/browser/chromeos/cros/mock_cryptohome_library.h @@ -17,15 +17,26 @@ class MockCryptohomeLibrary : public CryptohomeLibrary { public: MockCryptohomeLibrary() {} virtual ~MockCryptohomeLibrary() {} - MOCK_METHOD3(Mount, bool(const std::string& user_email, - const std::string& passhash, - int* error_code)); - MOCK_METHOD1(MountForBwsi, bool(int*)); MOCK_METHOD2(CheckKey, bool(const std::string& user_email, const std::string& passhash)); + MOCK_METHOD3(AsyncCheckKey, bool(const std::string& user_email, + const std::string& passhash, + Delegate* callback)); MOCK_METHOD3(MigrateKey, bool(const std::string& user_email, const std::string& old_hash, const std::string& new_hash)); + MOCK_METHOD4(AsyncMigrateKey, bool(const std::string& user_email, + const std::string& old_hash, + const std::string& new_hash, + Delegate* callback)); + MOCK_METHOD3(Mount, bool(const std::string& user_email, + const std::string& passhash, + int* error_code)); + MOCK_METHOD3(AsyncMount, bool(const std::string& user_email, + const std::string& passhash, + Delegate* callback)); + MOCK_METHOD1(MountForBwsi, bool(int*)); + MOCK_METHOD1(AsyncMountForBwsi, bool(Delegate* callback)); MOCK_METHOD1(Remove, bool(const std::string& user_email)); MOCK_METHOD0(IsMounted, bool(void)); MOCK_METHOD0(GetSystemSalt, CryptohomeBlob(void)); diff --git a/chrome/browser/chromeos/cros/mock_login_library.h b/chrome/browser/chromeos/cros/mock_login_library.h index b935a11..43a77b4 100644 --- a/chrome/browser/chromeos/cros/mock_login_library.h +++ b/chrome/browser/chromeos/cros/mock_login_library.h @@ -17,24 +17,23 @@ class MockLoginLibrary : public LoginLibrary { public: MockLoginLibrary() {} virtual ~MockLoginLibrary() {} - MOCK_METHOD0(EmitLoginPromptReady, bool(void)); MOCK_METHOD2(CheckWhitelist, bool(const std::string&, std::vector<uint8>*)); + MOCK_METHOD0(EmitLoginPromptReady, bool(void)); + MOCK_METHOD1(EnumerateWhitelisted, bool(std::vector<std::string>*)); MOCK_METHOD3(RetrieveProperty, bool(const std::string&, std::string*, std::vector<uint8>*)); - MOCK_METHOD2(SetOwnerKeyAsync, bool(const std::vector<uint8>&, - Delegate<bool>*)); + MOCK_METHOD2(SetOwnerKeyAsync, bool(const std::vector<uint8>&, Delegate*)); MOCK_METHOD4(StorePropertyAsync, bool(const std::string&, const std::string&, const std::vector<uint8>&, - Delegate<bool>*)); + Delegate*)); MOCK_METHOD3(UnwhitelistAsync, bool(const std::string&, const std::vector<uint8>&, - Delegate<bool>*)); + Delegate*)); MOCK_METHOD3(WhitelistAsync, bool(const std::string&, const std::vector<uint8>&, - Delegate<bool>*)); - MOCK_METHOD1(EnumerateWhitelisted, bool(std::vector<std::string>*)); + Delegate*)); MOCK_METHOD2(StartSession, bool(const std::string&, const std::string&)); MOCK_METHOD1(StopSession, bool(const std::string&)); MOCK_METHOD2(RestartJob, bool(int, const std::string&)); diff --git a/chrome/browser/chromeos/login/mock_owner_key_utils.h b/chrome/browser/chromeos/login/mock_owner_key_utils.h index 71580c6..8e5f9aa6 100644 --- a/chrome/browser/chromeos/login/mock_owner_key_utils.h +++ b/chrome/browser/chromeos/login/mock_owner_key_utils.h @@ -26,7 +26,7 @@ class MockKeyUtils : public OwnerKeyUtils { MockKeyUtils() {} MOCK_METHOD0(GenerateKeyPair, RSAPrivateKey*()); MOCK_METHOD2(ExportPublicKeyViaDbus, bool(RSAPrivateKey* pair, - LoginLibrary::Delegate<bool>*)); + LoginLibrary::Delegate*)); MOCK_METHOD2(ExportPublicKeyToFile, bool(RSAPrivateKey* pair, const FilePath& key_file)); MOCK_METHOD2(ImportPublicKey, bool(const FilePath& key_file, @@ -41,13 +41,13 @@ class MockKeyUtils : public OwnerKeyUtils { MOCK_METHOD0(GetOwnerKeyFilePath, FilePath()); // To simulate doing a LoginLibrary::SetOwnerKey call - static void SetOwnerKeyCallback(LoginLibrary::Delegate<bool>* callback, + static void SetOwnerKeyCallback(LoginLibrary::Delegate* callback, bool value) { - callback->Run(value); + callback->OnComplete(value); } static bool ExportPublicKeyViaDbusWin(RSAPrivateKey* key, - LoginLibrary::Delegate<bool>* d) { + LoginLibrary::Delegate* d) { ChromeThread::PostTask( ChromeThread::UI, FROM_HERE, NewRunnableFunction(&SetOwnerKeyCallback, d, true)); @@ -55,7 +55,7 @@ class MockKeyUtils : public OwnerKeyUtils { } static bool ExportPublicKeyViaDbusFail(RSAPrivateKey* key, - LoginLibrary::Delegate<bool>* d) { + LoginLibrary::Delegate* d) { ChromeThread::PostTask( ChromeThread::UI, FROM_HERE, NewRunnableFunction(&SetOwnerKeyCallback, d, false)); diff --git a/chrome/browser/chromeos/login/owner_key_utils.cc b/chrome/browser/chromeos/login/owner_key_utils.cc index 157b863..f9eb1fe 100644 --- a/chrome/browser/chromeos/login/owner_key_utils.cc +++ b/chrome/browser/chromeos/login/owner_key_utils.cc @@ -51,7 +51,7 @@ class OwnerKeyUtilsImpl : public OwnerKeyUtils { RSAPrivateKey* GenerateKeyPair(); bool ExportPublicKeyViaDbus(RSAPrivateKey* pair, - LoginLibrary::Delegate<bool>* d); + LoginLibrary::Delegate* d); bool ExportPublicKeyToFile(RSAPrivateKey* pair, const FilePath& key_file); @@ -110,9 +110,8 @@ RSAPrivateKey* OwnerKeyUtilsImpl::GenerateKeyPair() { return RSAPrivateKey::CreateSensitive(kKeySizeInBits); } -bool OwnerKeyUtilsImpl::ExportPublicKeyViaDbus( - RSAPrivateKey* pair, - LoginLibrary::Delegate<bool>* d) { +bool OwnerKeyUtilsImpl::ExportPublicKeyViaDbus(RSAPrivateKey* pair, + LoginLibrary::Delegate* d) { DCHECK(pair); bool ok = false; diff --git a/chrome/browser/chromeos/login/owner_key_utils.h b/chrome/browser/chromeos/login/owner_key_utils.h index d1dd1a5..4921745 100644 --- a/chrome/browser/chromeos/login/owner_key_utils.h +++ b/chrome/browser/chromeos/login/owner_key_utils.h @@ -54,7 +54,7 @@ class OwnerKeyUtils : public base::RefCounted<OwnerKeyUtils> { // d->Run() will be called with a boolean indicating success or failure when // the attempt is complete. virtual bool ExportPublicKeyViaDbus(base::RSAPrivateKey* pair, - LoginLibrary::Delegate<bool>* d) = 0; + LoginLibrary::Delegate* d) = 0; // DER encodes public half of |pair| and writes it out to |key_file|. // The blob on disk is a DER-encoded X509 SubjectPublicKeyInfo object. diff --git a/chrome/browser/chromeos/login/owner_manager.cc b/chrome/browser/chromeos/login/owner_manager.cc index 91545b6..cf21dc8 100644 --- a/chrome/browser/chromeos/login/owner_manager.cc +++ b/chrome/browser/chromeos/login/owner_manager.cc @@ -81,7 +81,7 @@ void OwnerManager::ExportKey() { } } -void OwnerManager::Run(bool value) { +void OwnerManager::OnComplete(bool value) { LOG(INFO) << "Export public key attempt: " << (value ? "success" : "fail"); NotificationType result = NotificationType::OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED; if (!value) diff --git a/chrome/browser/chromeos/login/owner_manager.h b/chrome/browser/chromeos/login/owner_manager.h index 07145b8..b4526b4 100644 --- a/chrome/browser/chromeos/login/owner_manager.h +++ b/chrome/browser/chromeos/login/owner_manager.h @@ -25,7 +25,7 @@ namespace chromeos { // It handles generating the appropriate keys and storing them in the // appropriate locations. class OwnerManager : public base::RefCountedThreadSafe<OwnerManager>, - public LoginLibrary::Delegate<bool> { + public LoginLibrary::Delegate { public: // Return codes for public/private key operations. enum KeyOpCode { @@ -65,7 +65,7 @@ class OwnerManager : public base::RefCountedThreadSafe<OwnerManager>, void ExportKey(); // Overridden from LoginLibrary::Delegate - void Run(bool value); + void OnComplete(bool value); bool EnsurePublicKey(); bool EnsurePrivateKey(); diff --git a/chrome/browser/chromeos/login/signed_settings.cc b/chrome/browser/chromeos/login/signed_settings.cc index 03961c3..0798fe5 100644 --- a/chrome/browser/chromeos/login/signed_settings.cc +++ b/chrome/browser/chromeos/login/signed_settings.cc @@ -38,7 +38,7 @@ class CheckWhitelistOp : public SignedSettings { }; class WhitelistOp : public SignedSettings, - public LoginLibrary::Delegate<bool> { + public LoginLibrary::Delegate { public: WhitelistOp(const std::string& email, bool add_to_whitelist, @@ -48,8 +48,8 @@ class WhitelistOp : public SignedSettings, // Implementation of OwnerManager::Delegate::OnKeyOpComplete() void OnKeyOpComplete(const OwnerManager::KeyOpCode return_code, const std::vector<uint8>& payload); - // Implementation of LoginLibrary::Delegate::Run() - void Run(bool value); + // Implementation of LoginLibrary::Delegate::OnComplete() + void OnComplete(bool value); private: bool InitiateWhitelistOp(const std::vector<uint8>& signature); @@ -60,7 +60,7 @@ class WhitelistOp : public SignedSettings, }; class StorePropertyOp : public SignedSettings, - public LoginLibrary::Delegate<bool> { + public LoginLibrary::Delegate { public: StorePropertyOp(const std::string& name, const std::string& value, @@ -70,8 +70,8 @@ class StorePropertyOp : public SignedSettings, // Implementation of OwnerManager::Delegate::OnKeyOpComplete() void OnKeyOpComplete(const OwnerManager::KeyOpCode return_code, const std::vector<uint8>& payload); - // Implementation of LoginLibrary::Delegate::Run() - void Run(bool value); + // Implementation of LoginLibrary::Delegate::OnComplete() + void OnComplete(bool value); private: std::string name_; @@ -192,14 +192,14 @@ void WhitelistOp::OnKeyOpComplete(const OwnerManager::KeyOpCode return_code, // Now, sure we're on the UI thread. bool success = false; if (return_code == OwnerManager::SUCCESS) { - // Run() will be called when this is done. + // OnComplete() will be called when this is done. success = InitiateWhitelistOp(payload); } if (!success) d_->OnSettingsOpFailed(); } -void WhitelistOp::Run(bool value) { +void WhitelistOp::OnComplete(bool value) { if (value) d_->OnSettingsOpSucceeded(value); else @@ -246,7 +246,7 @@ void StorePropertyOp::OnKeyOpComplete(const OwnerManager::KeyOpCode return_code, // Now, sure we're on the UI thread. bool success = false; if (return_code == OwnerManager::SUCCESS) { - // Run() will be called when this is done. + // OnComplete() will be called when this is done. success = CrosLibrary::Get()->GetLoginLibrary()->StorePropertyAsync(name_, value_, payload, @@ -256,7 +256,7 @@ void StorePropertyOp::OnKeyOpComplete(const OwnerManager::KeyOpCode return_code, d_->OnSettingsOpFailed(); } -void StorePropertyOp::Run(bool value) { +void StorePropertyOp::OnComplete(bool value) { if (value) d_->OnSettingsOpSucceeded(value); else |