diff options
author | Primiano Tucci <primiano@google.com> | 2014-09-30 14:45:55 +0100 |
---|---|---|
committer | Primiano Tucci <primiano@google.com> | 2014-09-30 14:45:55 +0100 |
commit | 1320f92c476a1ad9d19dba2a48c72b75566198e9 (patch) | |
tree | ea7f149ccad687b22c18a72b729646568b2d54fb /chrome/browser/signin/easy_unlock_service_signin_chromeos.h | |
parent | 39b78c562f50ad7d5551ee861121f899239525a2 (diff) | |
download | chromium_org-1320f92c476a1ad9d19dba2a48c72b75566198e9.tar.gz |
Merge from Chromium at DEPS revision 267aeeb8d85c
This commit was generated by merge_to_master.py.
Change-Id: Id3aac9713b301fae64408cdaee0888724eeb7c0e
Diffstat (limited to 'chrome/browser/signin/easy_unlock_service_signin_chromeos.h')
-rw-r--r-- | chrome/browser/signin/easy_unlock_service_signin_chromeos.h | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/chrome/browser/signin/easy_unlock_service_signin_chromeos.h b/chrome/browser/signin/easy_unlock_service_signin_chromeos.h new file mode 100644 index 0000000000..77e662f470 --- /dev/null +++ b/chrome/browser/signin/easy_unlock_service_signin_chromeos.h @@ -0,0 +1,120 @@ +// Copyright 2014 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_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" +#include "chrome/browser/signin/screenlock_bridge.h" +#include "chromeos/login/login_state.h" + +// EasyUnlockService instance that should be used for signin profile. +class EasyUnlockServiceSignin : public EasyUnlockService, + public ScreenlockBridge::Observer, + public chromeos::LoginState::Observer { + public: + explicit EasyUnlockServiceSignin(Profile* profile); + virtual ~EasyUnlockServiceSignin(); + + 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; + virtual void LaunchSetup() OVERRIDE; + virtual const base::DictionaryValue* GetPermitAccess() const OVERRIDE; + virtual void SetPermitAccess(const base::DictionaryValue& permit) OVERRIDE; + virtual void ClearPermitAccess() OVERRIDE; + virtual const base::ListValue* GetRemoteDevices() const OVERRIDE; + virtual void SetRemoteDevices(const base::ListValue& devices) OVERRIDE; + virtual void ClearRemoteDevices() OVERRIDE; + virtual void RunTurnOffFlow() OVERRIDE; + virtual void ResetTurnOffFlow() OVERRIDE; + virtual TurnOffFlowStatus GetTurnOffFlowStatus() const OVERRIDE; + virtual std::string GetChallenge() const OVERRIDE; + virtual std::string GetWrappedSecret() const OVERRIDE; + virtual void InitializeInternal() OVERRIDE; + virtual void ShutdownInternal() OVERRIDE; + virtual bool IsAllowedInternal() OVERRIDE; + + // ScreenlockBridge::Observer implementation: + virtual void OnScreenDidLock() OVERRIDE; + virtual void OnScreenDidUnlock() OVERRIDE; + virtual void OnFocusedUserChanged(const std::string& user_id) OVERRIDE; + + // chromeos::LoginState::Observer implementation: + virtual void LoggedInStateChanged() OVERRIDE; + + // Loads the device data associated with the user's Easy unlock keys from + // crypthome. + void LoadCurrentUserDataIfNeeded(); + + // Callback invoked when the user's device data is loaded from cryptohome. + void OnUserDataLoaded( + const std::string& user_id, + bool success, + const chromeos::EasyUnlockDeviceKeyDataList& data); + + // If the device data has been loaded for the current user, returns it. + // Otherwise, returns NULL. + const UserData* FindLoadedDataForCurrentUser() const; + + // User id of the user currently associated with the service. + std::string user_id_; + + // 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_; + + // Whether the service has been successfully initialized, and has not been + // shut down. + bool service_active_; + + base::WeakPtrFactory<EasyUnlockServiceSignin> weak_ptr_factory_; + + DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceSignin); +}; + +#endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_SIGNIN_CHROMEOS_H_ |