Home | History | Annotate | Download | only in signin
      1 // Copyright 2014 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_REGULAR_H_
      6 #define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_REGULAR_H_
      7 
      8 #include <string>
      9 
     10 #include "base/macros.h"
     11 #include "base/memory/scoped_ptr.h"
     12 #include "base/prefs/pref_change_registrar.h"
     13 #include "chrome/browser/signin/easy_unlock_service.h"
     14 
     15 #if defined(OS_CHROMEOS)
     16 #include "chrome/browser/chromeos/login/easy_unlock/short_lived_user_context.h"
     17 #endif
     18 
     19 namespace base {
     20 class DictionaryValue;
     21 class ListValue;
     22 }
     23 
     24 class EasyUnlockToggleFlow;
     25 class Profile;
     26 
     27 // EasyUnlockService instance that should be used for regular, non-signin
     28 // profiles.
     29 class EasyUnlockServiceRegular : public EasyUnlockService {
     30  public:
     31   explicit EasyUnlockServiceRegular(Profile* profile);
     32   virtual ~EasyUnlockServiceRegular();
     33 
     34  private:
     35   // EasyUnlockService implementation.
     36   virtual EasyUnlockService::Type GetType() const OVERRIDE;
     37   virtual std::string GetUserEmail() const OVERRIDE;
     38   virtual void LaunchSetup() OVERRIDE;
     39   virtual const base::DictionaryValue* GetPermitAccess() const OVERRIDE;
     40   virtual void SetPermitAccess(const base::DictionaryValue& permit) OVERRIDE;
     41   virtual void ClearPermitAccess() OVERRIDE;
     42   virtual const base::ListValue* GetRemoteDevices() const OVERRIDE;
     43   virtual void SetRemoteDevices(const base::ListValue& devices) OVERRIDE;
     44   virtual void ClearRemoteDevices() OVERRIDE;
     45   virtual void RunTurnOffFlow() OVERRIDE;
     46   virtual void ResetTurnOffFlow() OVERRIDE;
     47   virtual TurnOffFlowStatus GetTurnOffFlowStatus() const OVERRIDE;
     48   virtual std::string GetChallenge() const OVERRIDE;
     49   virtual std::string GetWrappedSecret() const OVERRIDE;
     50   virtual void RecordEasySignInOutcome(const std::string& user_id,
     51                                        bool success) const OVERRIDE;
     52   virtual void RecordPasswordLoginEvent(
     53       const std::string& user_id) const OVERRIDE;
     54   virtual void InitializeInternal() OVERRIDE;
     55   virtual void ShutdownInternal() OVERRIDE;
     56   virtual bool IsAllowedInternal() OVERRIDE;
     57 
     58   // Opens the component packaged app responsible for setting up Smart Lock.
     59   void OpenSetupApp();
     60 
     61   // Callback when the controlling pref changes.
     62   void OnPrefsChanged();
     63 
     64   // Sets the new turn-off flow status.
     65   void SetTurnOffFlowStatus(TurnOffFlowStatus status);
     66 
     67   // Callback invoked when turn off flow has finished.
     68   void OnTurnOffFlowFinished(bool success);
     69 
     70 #if defined(OS_CHROMEOS)
     71   void OnUserContextFromReauth(const chromeos::UserContext& user_context);
     72   void OnKeysRefreshedForSetDevices(bool success);
     73 
     74   scoped_ptr<chromeos::ShortLivedUserContext> short_lived_user_context_;
     75 #endif
     76 
     77   PrefChangeRegistrar registrar_;
     78 
     79   TurnOffFlowStatus turn_off_flow_status_;
     80   scoped_ptr<EasyUnlockToggleFlow> turn_off_flow_;
     81 
     82   base::WeakPtrFactory<EasyUnlockServiceRegular> weak_ptr_factory_;
     83 
     84   DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceRegular);
     85 };
     86 
     87 #endif  // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_REGULAR_H_
     88