| Index: chrome/browser/signin/easy_unlock_service_signin_chromeos.h
|
| diff --git a/chrome/browser/signin/easy_unlock_service_signin_chromeos.h b/chrome/browser/signin/easy_unlock_service_signin_chromeos.h
|
| index 980afc5169d422c691d833294b4f0cc0a15f147e..00b950bea2f6ba29b6a12320636a046287b40ae0 100644
|
| --- a/chrome/browser/signin/easy_unlock_service_signin_chromeos.h
|
| +++ b/chrome/browser/signin/easy_unlock_service_signin_chromeos.h
|
| @@ -5,28 +5,52 @@
|
| #ifndef CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_SIGNIN_CHROMEOS_H_
|
| #define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_SIGNIN_CHROMEOS_H_
|
|
|
| +#include <map>
|
| #include <string>
|
|
|
| #include "base/macros.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/memory/weak_ptr.h"
|
| +#include "base/values.h"
|
| #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_types.h"
|
| #include "chrome/browser/signin/easy_unlock_service.h"
|
|
|
| -namespace base {
|
| -class DictionaryValue;
|
| -class ListValue;
|
| -}
|
| -
|
| // EasyUnlockService instance that should be used for signin profile.
|
| class EasyUnlockServiceSignin : public EasyUnlockService {
|
| public:
|
| explicit EasyUnlockServiceSignin(Profile* profile);
|
| virtual ~EasyUnlockServiceSignin();
|
|
|
| - void SetAssociatedUser(const std::string& user_id);
|
| -
|
| private:
|
| + // The load state of a user's cryptohome key data.
|
| + enum UserDataState {
|
| + // Initial state, the key data is empty and not being loaded.
|
| + USER_DATA_STATE_INITIAL,
|
| + // The key data is empty, but being loaded.
|
| + USER_DATA_STATE_LOADING,
|
| + // The key data has been loaded.
|
| + USER_DATA_STATE_LOADED
|
| + };
|
| +
|
| + // Structure containing a user's key data loaded from cryptohome.
|
| + struct UserData {
|
| + UserData();
|
| + ~UserData();
|
| +
|
| + // The loading state of the data.
|
| + UserDataState state;
|
| +
|
| + // The data as returned from cryptohome.
|
| + chromeos::EasyUnlockDeviceKeyDataList devices;
|
| +
|
| + // The list of remote device dictionaries understood by Easy unlock app.
|
| + // This will be returned by |GetRemoteDevices| method.
|
| + base::ListValue remote_devices_value;
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(UserData);
|
| + };
|
| +
|
| // EasyUnlockService implementation:
|
| virtual EasyUnlockService::Type GetType() const OVERRIDE;
|
| virtual std::string GetUserEmail() const OVERRIDE;
|
| @@ -44,20 +68,31 @@ class EasyUnlockServiceSignin : public EasyUnlockService {
|
| virtual bool IsAllowedInternal() OVERRIDE;
|
| virtual void InitializeInternal() OVERRIDE;
|
|
|
| - // Fetches |remote_devices_| info from cryptohome keys.
|
| - void FetchCryptohomeKeys();
|
| + // Loads the device data associated with the user's Easy unlock keys from
|
| + // crypthome.
|
| + void LoadCurrentUserDataIfNeeded();
|
|
|
| - // Callback invoked when the cryptohome keys are fetched.
|
| - void OnCryptohomeKeysFetched(
|
| + // Callback invoked when the user's device data is loaded from cryptohome.
|
| + void OnUserDataLoaded(
|
| + const std::string& user_id,
|
| bool success,
|
| - const chromeos::EasyUnlockDeviceKeyDataList& devices);
|
| + const chromeos::EasyUnlockDeviceKeyDataList& data);
|
|
|
| - // User id of the associated user.
|
| + // If the device data has been loaded for the current user, returns is.
|
| + // Otherwise, returns NULL.
|
| + const UserData* FindLoadedDataForCurrentUser() const;
|
| +
|
| + // User id of the user currently associated with the service.
|
| std::string user_id_;
|
|
|
| - // Remote devices of the associated user.
|
| - chromeos::EasyUnlockDeviceKeyDataList remote_devices_;
|
| - scoped_ptr<base::ListValue> remote_devices_value_;
|
| + // Maps user ids to their fetched cryptohome key data.
|
| + std::map<std::string, UserData*> user_data_;
|
| +
|
| + // Whether failed attempts to load user data should be retried.
|
| + // This is to handle case where cryptohome daemon is not started in time the
|
| + // service attempts to load some data. Retries will be allowed only until the
|
| + // first data load finishes (even if it fails).
|
| + bool allow_cryptohome_backoff_;
|
|
|
| base::WeakPtrFactory<EasyUnlockServiceSignin> weak_ptr_factory_;
|
|
|
|
|