| 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 "chrome/browser/chromeos/arc/arc_android_management_checker_delegate.h" | 15 #include "chrome/browser/chromeos/arc/arc_android_management_checker_delegate.h" |
| 16 #include "chrome/browser/chromeos/arc/arc_auth_context_delegate.h" | 16 #include "chrome/browser/chromeos/arc/arc_auth_context_delegate.h" |
| 17 #include "components/arc/arc_bridge_service.h" | 17 #include "components/arc/arc_bridge_service.h" |
| 18 #include "components/arc/arc_service.h" | 18 #include "components/arc/arc_service.h" |
| 19 #include "components/arc/common/auth.mojom.h" | 19 #include "components/arc/common/auth.mojom.h" |
| 20 #include "components/arc/instance_holder.h" |
| 20 #include "components/prefs/pref_change_registrar.h" | 21 #include "components/prefs/pref_change_registrar.h" |
| 21 #include "components/syncable_prefs/pref_service_syncable_observer.h" | 22 #include "components/syncable_prefs/pref_service_syncable_observer.h" |
| 22 #include "components/syncable_prefs/synced_pref_observer.h" | 23 #include "components/syncable_prefs/synced_pref_observer.h" |
| 23 #include "mojo/public/cpp/bindings/binding.h" | 24 #include "mojo/public/cpp/bindings/binding.h" |
| 24 | 25 |
| 25 class ArcAppLauncher; | 26 class ArcAppLauncher; |
| 26 class Profile; | 27 class Profile; |
| 27 | 28 |
| 28 namespace ash { | 29 namespace ash { |
| 29 class ShelfDelegate; | 30 class ShelfDelegate; |
| 30 } | 31 } |
| 31 | 32 |
| 32 namespace user_prefs { | 33 namespace user_prefs { |
| 33 class PrefRegistrySyncable; | 34 class PrefRegistrySyncable; |
| 34 } | 35 } |
| 35 | 36 |
| 36 namespace arc { | 37 namespace arc { |
| 37 | 38 |
| 38 class ArcAndroidManagementChecker; | 39 class ArcAndroidManagementChecker; |
| 39 class ArcAuthContext; | 40 class ArcAuthContext; |
| 40 | 41 |
| 41 // This class proxies the request from the client to fetch an auth code from | 42 // This class proxies the request from the client to fetch an auth code from |
| 42 // LSO. | 43 // LSO. |
| 43 class ArcAuthService : public ArcService, | 44 class ArcAuthService : public ArcService, |
| 44 public mojom::AuthHost, | 45 public mojom::AuthHost, |
| 45 public ArcBridgeService::Observer, | 46 public ArcBridgeService::Observer, |
| 47 public InstanceHolder<mojom::AuthInstance>::Observer, |
| 46 public ArcAndroidManagementCheckerDelegate, | 48 public ArcAndroidManagementCheckerDelegate, |
| 47 public ArcAuthContextDelegate, | 49 public ArcAuthContextDelegate, |
| 48 public syncable_prefs::PrefServiceSyncableObserver, | 50 public syncable_prefs::PrefServiceSyncableObserver, |
| 49 public syncable_prefs::SyncedPrefObserver { | 51 public syncable_prefs::SyncedPrefObserver { |
| 50 public: | 52 public: |
| 51 enum class State { | 53 enum class State { |
| 52 NOT_INITIALIZED, // Service is not initialized. | 54 NOT_INITIALIZED, // Service is not initialized. |
| 53 STOPPED, // ARC is not running. | 55 STOPPED, // ARC is not running. |
| 54 FETCHING_CODE, // ARC may be running or not. Auth code is fetching. | 56 FETCHING_CODE, // ARC may be running or not. Auth code is fetching. |
| 55 ACTIVE, // ARC is running. | 57 ACTIVE, // ARC is running. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 116 |
| 115 State state() const { return state_; } | 117 State state() const { return state_; } |
| 116 | 118 |
| 117 std::string GetAndResetAuthCode(); | 119 std::string GetAndResetAuthCode(); |
| 118 | 120 |
| 119 // Adds or removes observers. | 121 // Adds or removes observers. |
| 120 void AddObserver(Observer* observer); | 122 void AddObserver(Observer* observer); |
| 121 void RemoveObserver(Observer* observer); | 123 void RemoveObserver(Observer* observer); |
| 122 | 124 |
| 123 // ArcBridgeService::Observer: | 125 // ArcBridgeService::Observer: |
| 124 void OnAuthInstanceReady() override; | |
| 125 void OnBridgeStopped(ArcBridgeService::StopReason reason) override; | 126 void OnBridgeStopped(ArcBridgeService::StopReason reason) override; |
| 126 | 127 |
| 128 // InstanceHolder<mojom::AuthInstance>::Observer: |
| 129 void OnInstanceReady() override; |
| 130 |
| 127 // AuthHost: | 131 // AuthHost: |
| 128 // For security reason this code can be used only once and exists for specific | 132 // For security reason this code can be used only once and exists for specific |
| 129 // period of time. | 133 // period of time. |
| 130 void GetAuthCodeDeprecated( | 134 void GetAuthCodeDeprecated( |
| 131 const GetAuthCodeDeprecatedCallback& callback) override; | 135 const GetAuthCodeDeprecatedCallback& callback) override; |
| 132 void GetAuthCode(const GetAuthCodeCallback& callback) override; | 136 void GetAuthCode(const GetAuthCodeCallback& callback) override; |
| 133 void OnSignInComplete() override; | 137 void OnSignInComplete() override; |
| 134 void OnSignInFailed(arc::mojom::ArcSignInFailureReason reason) override; | 138 void OnSignInFailed(arc::mojom::ArcSignInFailureReason reason) override; |
| 135 // Callback is called with a bool that indicates the management status of the | 139 // Callback is called with a bool that indicates the management status of the |
| 136 // user. | 140 // user. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_; | 218 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_; |
| 215 | 219 |
| 216 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); | 220 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); |
| 217 }; | 221 }; |
| 218 | 222 |
| 219 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); | 223 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); |
| 220 | 224 |
| 221 } // namespace arc | 225 } // namespace arc |
| 222 | 226 |
| 223 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ | 227 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ |
| OLD | NEW |