| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // permitted either the flag is enabled or its field trial is enabled. | 87 // permitted either the flag is enabled or its field trial is enabled. |
| 88 bool IsAllowed(); | 88 bool IsAllowed(); |
| 89 | 89 |
| 90 void AddObserver(EasyUnlockServiceObserver* observer); | 90 void AddObserver(EasyUnlockServiceObserver* observer); |
| 91 void RemoveObserver(EasyUnlockServiceObserver* observer); | 91 void RemoveObserver(EasyUnlockServiceObserver* observer); |
| 92 | 92 |
| 93 protected: | 93 protected: |
| 94 explicit EasyUnlockService(Profile* profile); | 94 explicit EasyUnlockService(Profile* profile); |
| 95 virtual ~EasyUnlockService(); | 95 virtual ~EasyUnlockService(); |
| 96 | 96 |
| 97 // Does service type specific initialization. | 97 // Does a service type specific initialization. |
| 98 virtual void InitializeInternal() = 0; | 98 virtual void InitializeInternal() = 0; |
| 99 | 99 |
| 100 // Does a service type specific shutdown. Called from |Shutdown|. |
| 101 virtual void ShutdownInternal() = 0; |
| 102 |
| 100 // Service type specific tests for whether the service is allowed. Returns | 103 // Service type specific tests for whether the service is allowed. Returns |
| 101 // false if service is not allowed. If true is returned, the service may still | 104 // false if service is not allowed. If true is returned, the service may still |
| 102 // not be allowed if common tests fail (e.g. if Bluetooth is not available). | 105 // not be allowed if common tests fail (e.g. if Bluetooth is not available). |
| 103 virtual bool IsAllowedInternal() = 0; | 106 virtual bool IsAllowedInternal() = 0; |
| 104 | 107 |
| 108 // KeyedService override: |
| 109 virtual void Shutdown() OVERRIDE; |
| 110 |
| 105 // Exposes the profile to which the service is attached to subclasses. | 111 // Exposes the profile to which the service is attached to subclasses. |
| 106 Profile* profile() const { return profile_; } | 112 Profile* profile() const { return profile_; } |
| 107 | 113 |
| 108 // Installs the Easy unlock component app if it isn't installed or enables | 114 // Installs the Easy unlock component app if it isn't installed and enables |
| 109 // the app if it is installed but disabled. | 115 // the app if it is disabled. |
| 110 void LoadApp(); | 116 void LoadApp(); |
| 111 | 117 |
| 112 // Disables the Easy unlock component app if it's loaded. | 118 // Disables the Easy unlock component app if it's loaded. |
| 113 void DisableAppIfLoaded(); | 119 void DisableAppIfLoaded(); |
| 114 | 120 |
| 121 // Unloads the Easy unlock component app if it's loaded. |
| 122 void UnloadApp(); |
| 123 |
| 115 // Reloads the Easy unlock component app if it's loaded. | 124 // Reloads the Easy unlock component app if it's loaded. |
| 116 void ReloadApp(); | 125 void ReloadApp(); |
| 117 | 126 |
| 118 // Checks whether Easy unlock should be running and updates app state. | 127 // Checks whether Easy unlock should be running and updates app state. |
| 119 void UpdateAppState(); | 128 void UpdateAppState(); |
| 120 | 129 |
| 130 // Notifies the easy unlock app that the user state has been updated. |
| 131 void NotifyUserUpdated(); |
| 132 |
| 121 // Notifies observers that the turn off flow status changed. | 133 // Notifies observers that the turn off flow status changed. |
| 122 void NotifyTurnOffOperationStatusChanged(); | 134 void NotifyTurnOffOperationStatusChanged(); |
| 123 | 135 |
| 136 // Resets |screenlock_state_handler_|. |
| 137 void ResetScreenlockStateHandler(); |
| 138 |
| 124 private: | 139 private: |
| 125 // A class to detect whether a bluetooth adapter is present. | 140 // A class to detect whether a bluetooth adapter is present. |
| 126 class BluetoothDetector; | 141 class BluetoothDetector; |
| 127 | 142 |
| 128 // Initializes the service after ExtensionService is ready. | 143 // Initializes the service after ExtensionService is ready. |
| 129 void Initialize(); | 144 void Initialize(); |
| 130 | 145 |
| 131 // Callback when Bluetooth adapter present state changes. | 146 // Callback when Bluetooth adapter present state changes. |
| 132 void OnBluetoothAdapterPresentChanged(); | 147 void OnBluetoothAdapterPresentChanged(); |
| 133 | 148 |
| 134 Profile* profile_; | 149 Profile* profile_; |
| 135 | 150 |
| 136 // Created lazily in |GetScreenlockStateHandler|. | 151 // Created lazily in |GetScreenlockStateHandler|. |
| 137 scoped_ptr<EasyUnlockScreenlockStateHandler> screenlock_state_handler_; | 152 scoped_ptr<EasyUnlockScreenlockStateHandler> screenlock_state_handler_; |
| 138 | 153 |
| 139 scoped_ptr<BluetoothDetector> bluetooth_detector_; | 154 scoped_ptr<BluetoothDetector> bluetooth_detector_; |
| 140 | 155 |
| 141 #if defined(OS_CHROMEOS) | 156 #if defined(OS_CHROMEOS) |
| 142 // Monitors suspend and wake state of ChromeOS. | 157 // Monitors suspend and wake state of ChromeOS. |
| 143 class PowerMonitor; | 158 class PowerMonitor; |
| 144 scoped_ptr<PowerMonitor> power_monitor_; | 159 scoped_ptr<PowerMonitor> power_monitor_; |
| 145 #endif | 160 #endif |
| 146 | 161 |
| 162 // Whether the service has been shut down. |
| 163 bool shut_down_; |
| 164 |
| 147 ObserverList<EasyUnlockServiceObserver> observers_; | 165 ObserverList<EasyUnlockServiceObserver> observers_; |
| 148 | 166 |
| 149 base::WeakPtrFactory<EasyUnlockService> weak_ptr_factory_; | 167 base::WeakPtrFactory<EasyUnlockService> weak_ptr_factory_; |
| 150 | 168 |
| 151 DISALLOW_COPY_AND_ASSIGN(EasyUnlockService); | 169 DISALLOW_COPY_AND_ASSIGN(EasyUnlockService); |
| 152 }; | 170 }; |
| 153 | 171 |
| 154 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_H_ | 172 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_H_ |
| OLD | NEW |