| 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/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/prefs/pref_change_registrar.h" | 10 #include "base/prefs/pref_change_registrar.h" |
| 11 #include "components/keyed_service/core/keyed_service.h" | 11 #include "components/keyed_service/core/keyed_service.h" |
| 12 | 12 |
| 13 namespace user_prefs { | 13 namespace user_prefs { |
| 14 class PrefRegistrySyncable; | 14 class PrefRegistrySyncable; |
| 15 } | 15 } |
| 16 | 16 |
| 17 class EasyUnlockScreenlockStateHandler; |
| 17 class Profile; | 18 class Profile; |
| 18 | 19 |
| 19 class EasyUnlockService : public KeyedService { | 20 class EasyUnlockService : public KeyedService { |
| 20 public: | 21 public: |
| 21 explicit EasyUnlockService(Profile* profile); | 22 explicit EasyUnlockService(Profile* profile); |
| 22 virtual ~EasyUnlockService(); | 23 virtual ~EasyUnlockService(); |
| 23 | 24 |
| 24 // Gets EasyUnlockService instance. | 25 // Gets EasyUnlockService instance. |
| 25 static EasyUnlockService* Get(Profile* profile); | 26 static EasyUnlockService* Get(Profile* profile); |
| 26 | 27 |
| 27 // Registers Easy Unlock profile preferences. | 28 // Registers Easy Unlock profile preferences. |
| 28 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 29 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 29 | 30 |
| 30 // Launches Easy Unlock Setup app. | 31 // Launches Easy Unlock Setup app. |
| 31 void LaunchSetup(); | 32 void LaunchSetup(); |
| 32 | 33 |
| 33 // Whether easy unlock is allowed to be used. If the controlling preference | 34 // 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 | 35 // 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. | 36 // permitted either the flag is enabled or its field trial is enabled. |
| 36 bool IsAllowed(); | 37 bool IsAllowed(); |
| 37 | 38 |
| 39 EasyUnlockScreenlockStateHandler* screenlock_state_handler() const { |
| 40 return screenlock_state_handler_.get(); |
| 41 } |
| 42 |
| 38 private: | 43 private: |
| 39 void Initialize(); | 44 void Initialize(); |
| 40 void LoadApp(); | 45 void LoadApp(); |
| 41 void UnloadApp(); | 46 void UnloadApp(); |
| 42 void OnPrefsChanged(); | 47 void OnPrefsChanged(); |
| 43 | 48 |
| 44 Profile* profile_; | 49 Profile* profile_; |
| 45 PrefChangeRegistrar registrar_; | 50 PrefChangeRegistrar registrar_; |
| 51 scoped_ptr<EasyUnlockScreenlockStateHandler> screenlock_state_handler_; |
| 46 base::WeakPtrFactory<EasyUnlockService> weak_ptr_factory_; | 52 base::WeakPtrFactory<EasyUnlockService> weak_ptr_factory_; |
| 47 | 53 |
| 48 DISALLOW_COPY_AND_ASSIGN(EasyUnlockService); | 54 DISALLOW_COPY_AND_ASSIGN(EasyUnlockService); |
| 49 }; | 55 }; |
| 50 | 56 |
| 51 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_H_ | 57 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_H_ |
| OLD | NEW |