OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_H_ |
6 #define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_H_ | 6 #define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/observer_list.h" |
10 #include "base/prefs/pref_change_registrar.h" | 12 #include "base/prefs/pref_change_registrar.h" |
11 #include "components/keyed_service/core/keyed_service.h" | 13 #include "components/keyed_service/core/keyed_service.h" |
12 | 14 |
| 15 namespace base { |
| 16 class DictionaryValue; |
| 17 class ListValue; |
| 18 } |
| 19 |
13 namespace user_prefs { | 20 namespace user_prefs { |
14 class PrefRegistrySyncable; | 21 class PrefRegistrySyncable; |
15 } | 22 } |
16 | 23 |
| 24 class EasyUnlockServiceObserver; |
| 25 class EasyUnlockToggleFlow; |
17 class Profile; | 26 class Profile; |
18 | 27 |
19 class EasyUnlockService : public KeyedService { | 28 class EasyUnlockService : public KeyedService { |
20 public: | 29 public: |
| 30 enum TurnOffFlowStatus { |
| 31 IDLE, |
| 32 PENDING, |
| 33 FAIL, |
| 34 }; |
| 35 |
21 explicit EasyUnlockService(Profile* profile); | 36 explicit EasyUnlockService(Profile* profile); |
22 virtual ~EasyUnlockService(); | 37 virtual ~EasyUnlockService(); |
23 | 38 |
24 // Gets EasyUnlockService instance. | 39 // Gets EasyUnlockService instance. |
25 static EasyUnlockService* Get(Profile* profile); | 40 static EasyUnlockService* Get(Profile* profile); |
26 | 41 |
27 // Registers Easy Unlock profile preferences. | 42 // Registers Easy Unlock profile preferences. |
28 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 43 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
29 | 44 |
30 // Launches Easy Unlock Setup app. | 45 // Launches Easy Unlock Setup app. |
31 void LaunchSetup(); | 46 void LaunchSetup(); |
32 | 47 |
33 // Whether easy unlock is allowed to be used. If the controlling preference | 48 // Whether easy unlock is allowed to be used. If the controlling preference |
34 // is set (from policy), this returns the preference value. Otherwise, it is | 49 // is set (from policy), this returns the preference value. Otherwise, it is |
35 // permitted either the flag is enabled or its field trial is enabled. | 50 // permitted either the flag is enabled or its field trial is enabled. |
36 bool IsAllowed(); | 51 bool IsAllowed(); |
37 | 52 |
| 53 // Gets/Sets/Clears the permit access for the local device. |
| 54 const base::DictionaryValue* GetPermitAccess() const; |
| 55 void SetPermitAccess(const base::DictionaryValue& permit); |
| 56 void ClearPermitAccess(); |
| 57 |
| 58 // Gets/Sets/Clears the remote devices list. |
| 59 const base::ListValue* GetRemoteDevices() const; |
| 60 void SetRemoteDevices(const base::ListValue& devices); |
| 61 void ClearRemoteDevices(); |
| 62 |
| 63 void RunTurnOffFlow(); |
| 64 void ResetTurnOffFlow(); |
| 65 |
| 66 void AddObserver(EasyUnlockServiceObserver* observer); |
| 67 void RemoveObserver(EasyUnlockServiceObserver* observer); |
| 68 |
| 69 TurnOffFlowStatus turn_off_flow_status() const { |
| 70 return turn_off_flow_status_; |
| 71 } |
| 72 |
38 private: | 73 private: |
39 void Initialize(); | 74 void Initialize(); |
40 void LoadApp(); | 75 void LoadApp(); |
41 void UnloadApp(); | 76 void UnloadApp(); |
42 void OnPrefsChanged(); | 77 void OnPrefsChanged(); |
43 | 78 |
| 79 void SetTurnOffFlowStatus(TurnOffFlowStatus status); |
| 80 void OnTurnOffFlowFinished(bool success); |
| 81 |
44 Profile* profile_; | 82 Profile* profile_; |
45 PrefChangeRegistrar registrar_; | 83 PrefChangeRegistrar registrar_; |
| 84 ObserverList<EasyUnlockServiceObserver> observers_; |
| 85 |
| 86 TurnOffFlowStatus turn_off_flow_status_; |
| 87 scoped_ptr<EasyUnlockToggleFlow> turn_off_flow_; |
| 88 |
46 base::WeakPtrFactory<EasyUnlockService> weak_ptr_factory_; | 89 base::WeakPtrFactory<EasyUnlockService> weak_ptr_factory_; |
47 | 90 |
48 DISALLOW_COPY_AND_ASSIGN(EasyUnlockService); | 91 DISALLOW_COPY_AND_ASSIGN(EasyUnlockService); |
49 }; | 92 }; |
50 | 93 |
51 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_H_ | 94 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_H_ |
OLD | NEW |