| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <ostream> | 9 #include <ostream> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
| 16 #include "chrome/browser/chromeos/arc/arc_android_management_checker_delegate.h" | |
| 17 #include "chrome/browser/chromeos/arc/arc_auth_code_fetcher_delegate.h" | 16 #include "chrome/browser/chromeos/arc/arc_auth_code_fetcher_delegate.h" |
| 18 #include "chrome/browser/chromeos/arc/arc_auth_context_delegate.h" | 17 #include "chrome/browser/chromeos/arc/arc_auth_context_delegate.h" |
| 18 #include "chrome/browser/chromeos/policy/android_management_client.h" |
| 19 #include "components/arc/arc_bridge_service.h" | 19 #include "components/arc/arc_bridge_service.h" |
| 20 #include "components/arc/arc_service.h" | 20 #include "components/arc/arc_service.h" |
| 21 #include "components/arc/common/auth.mojom.h" | 21 #include "components/arc/common/auth.mojom.h" |
| 22 #include "components/arc/instance_holder.h" | 22 #include "components/arc/instance_holder.h" |
| 23 #include "components/prefs/pref_change_registrar.h" | 23 #include "components/prefs/pref_change_registrar.h" |
| 24 #include "components/syncable_prefs/pref_service_syncable_observer.h" | 24 #include "components/syncable_prefs/pref_service_syncable_observer.h" |
| 25 #include "components/syncable_prefs/synced_pref_observer.h" | 25 #include "components/syncable_prefs/synced_pref_observer.h" |
| 26 #include "mojo/public/cpp/bindings/binding.h" | 26 #include "mojo/public/cpp/bindings/binding.h" |
| 27 | 27 |
| 28 class ArcAppLauncher; | 28 class ArcAppLauncher; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 42 class ArcAuthCodeFetcher; | 42 class ArcAuthCodeFetcher; |
| 43 class ArcAuthContext; | 43 class ArcAuthContext; |
| 44 enum class ProvisioningResult : int; | 44 enum class ProvisioningResult : int; |
| 45 | 45 |
| 46 // This class proxies the request from the client to fetch an auth code from | 46 // This class proxies the request from the client to fetch an auth code from |
| 47 // LSO. It lives on the UI thread. | 47 // LSO. It lives on the UI thread. |
| 48 class ArcAuthService : public ArcService, | 48 class ArcAuthService : public ArcService, |
| 49 public mojom::AuthHost, | 49 public mojom::AuthHost, |
| 50 public ArcBridgeService::Observer, | 50 public ArcBridgeService::Observer, |
| 51 public InstanceHolder<mojom::AuthInstance>::Observer, | 51 public InstanceHolder<mojom::AuthInstance>::Observer, |
| 52 public ArcAndroidManagementCheckerDelegate, | |
| 53 public ArcAuthContextDelegate, | 52 public ArcAuthContextDelegate, |
| 54 public ArcAuthCodeFetcherDelegate, | 53 public ArcAuthCodeFetcherDelegate, |
| 55 public syncable_prefs::PrefServiceSyncableObserver, | 54 public syncable_prefs::PrefServiceSyncableObserver, |
| 56 public syncable_prefs::SyncedPrefObserver { | 55 public syncable_prefs::SyncedPrefObserver { |
| 57 public: | 56 public: |
| 58 enum class State { | 57 enum class State { |
| 59 NOT_INITIALIZED, // Service is not initialized. | 58 NOT_INITIALIZED, // Service is not initialized. |
| 60 STOPPED, // ARC is not running. | 59 STOPPED, // ARC is not running. |
| 61 FETCHING_CODE, // ARC may be running or not. Auth code is fetching. | 60 FETCHING_CODE, // ARC may be running or not. Auth code is fetching. |
| 62 ACTIVE, // ARC is running. | 61 ACTIVE, // ARC is running. |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 void OnSyncedPrefChanged(const std::string& path, bool from_sync) override; | 177 void OnSyncedPrefChanged(const std::string& path, bool from_sync) override; |
| 179 | 178 |
| 180 // ArcAuthContextDelegate: | 179 // ArcAuthContextDelegate: |
| 181 void OnContextReady() override; | 180 void OnContextReady() override; |
| 182 void OnPrepareContextFailed() override; | 181 void OnPrepareContextFailed() override; |
| 183 | 182 |
| 184 // ArcAuthCodeFetcherDelegate: | 183 // ArcAuthCodeFetcherDelegate: |
| 185 void OnAuthCodeSuccess(const std::string& auth_code) override; | 184 void OnAuthCodeSuccess(const std::string& auth_code) override; |
| 186 void OnAuthCodeFailed() override; | 185 void OnAuthCodeFailed() override; |
| 187 | 186 |
| 188 // ArcAndroidManagementCheckerDelegate: | |
| 189 void OnAndroidManagementChecked( | |
| 190 policy::AndroidManagementClient::Result result) override; | |
| 191 | |
| 192 // Stops ARC without changing ArcEnabled preference. | 187 // Stops ARC without changing ArcEnabled preference. |
| 193 void StopArc(); | 188 void StopArc(); |
| 194 | 189 |
| 195 // StopArc(), then EnableArc(). Between them data clear may happens. | 190 // StopArc(), then EnableArc(). Between them data clear may happens. |
| 196 // This is a special method to support enterprise device lost case. | 191 // This is a special method to support enterprise device lost case. |
| 197 // This can be called only when ARC is running. | 192 // This can be called only when ARC is running. |
| 198 void StopAndEnableArc(); | 193 void StopAndEnableArc(); |
| 199 | 194 |
| 200 // Removes the data if ARC is stopped. Otherwise, queue to remove the data | 195 // Removes the data if ARC is stopped. Otherwise, queue to remove the data |
| 201 // on ARC is stopped. | 196 // on ARC is stopped. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 212 void ShowUI(UIPage page, const base::string16& status); | 207 void ShowUI(UIPage page, const base::string16& status); |
| 213 void CloseUI(); | 208 void CloseUI(); |
| 214 void SetUIPage(UIPage page, const base::string16& status); | 209 void SetUIPage(UIPage page, const base::string16& status); |
| 215 void SetState(State state); | 210 void SetState(State state); |
| 216 void ShutdownBridge(); | 211 void ShutdownBridge(); |
| 217 void ShutdownBridgeAndCloseUI(); | 212 void ShutdownBridgeAndCloseUI(); |
| 218 void ShutdownBridgeAndShowUI(UIPage page, const base::string16& status); | 213 void ShutdownBridgeAndShowUI(UIPage page, const base::string16& status); |
| 219 void OnOptInPreferenceChanged(); | 214 void OnOptInPreferenceChanged(); |
| 220 void StartUI(); | 215 void StartUI(); |
| 221 void StartAndroidManagementClient(); | 216 void StartAndroidManagementClient(); |
| 222 void CheckAndroidManagement(bool background_mode); | |
| 223 void OnAndroidManagementPassed(); | 217 void OnAndroidManagementPassed(); |
| 224 void OnArcDataRemoved(bool success); | 218 void OnArcDataRemoved(bool success); |
| 225 void OnArcSignInTimeout(); | 219 void OnArcSignInTimeout(); |
| 226 bool IsAuthCodeRequest() const; | 220 bool IsAuthCodeRequest() const; |
| 227 void FetchAuthCode(); | 221 void FetchAuthCode(); |
| 228 void PrepareContextForAuthCodeRequest(); | 222 void PrepareContextForAuthCodeRequest(); |
| 229 | 223 |
| 224 // Called when the Android management check is done in opt-in flow or |
| 225 // re-auth flow. |
| 226 void OnAndroidManagementChecked( |
| 227 policy::AndroidManagementClient::Result result); |
| 228 |
| 229 // Called when the background Android management check is done. It is |
| 230 // triggered when the second or later ARC boot timing. |
| 231 void OnBackgroundAndroidManagementChecked( |
| 232 policy::AndroidManagementClient::Result result); |
| 233 |
| 230 // Unowned pointer. Keeps current profile. | 234 // Unowned pointer. Keeps current profile. |
| 231 Profile* profile_ = nullptr; | 235 Profile* profile_ = nullptr; |
| 232 | 236 |
| 233 // Registrar used to monitor ARC enabled state. | 237 // Registrar used to monitor ARC enabled state. |
| 234 PrefChangeRegistrar pref_change_registrar_; | 238 PrefChangeRegistrar pref_change_registrar_; |
| 235 | 239 |
| 236 mojo::Binding<AuthHost> binding_; | 240 mojo::Binding<AuthHost> binding_; |
| 237 State state_ = State::NOT_INITIALIZED; | 241 State state_ = State::NOT_INITIALIZED; |
| 238 base::ObserverList<Observer> observer_list_; | 242 base::ObserverList<Observer> observer_list_; |
| 239 std::unique_ptr<ArcAppLauncher> playstore_launcher_; | 243 std::unique_ptr<ArcAppLauncher> playstore_launcher_; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 257 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_; | 261 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_; |
| 258 | 262 |
| 259 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); | 263 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); |
| 260 }; | 264 }; |
| 261 | 265 |
| 262 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); | 266 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); |
| 263 | 267 |
| 264 } // namespace arc | 268 } // namespace arc |
| 265 | 269 |
| 266 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ | 270 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ |
| OLD | NEW |