| 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 <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "components/arc/arc_service.h" | 13 #include "components/arc/arc_service.h" |
| 14 #include "components/arc/common/auth.mojom.h" | 14 #include "components/arc/common/auth.mojom.h" |
| 15 #include "components/arc/instance_holder.h" | 15 #include "components/arc/instance_holder.h" |
| 16 #include "mojo/public/cpp/bindings/binding.h" | 16 #include "mojo/public/cpp/bindings/binding.h" |
| 17 | 17 |
| 18 namespace arc { | 18 namespace arc { |
| 19 | 19 |
| 20 class ArcAuthInfoFetcher; | 20 class ArcAuthInfoFetcher; |
| 21 enum class ArcAuthInfoFetchStatus; |
| 21 | 22 |
| 22 // Implementation of ARC authorization. | 23 // Implementation of ARC authorization. |
| 23 // TODO(hidehiko): Move to c/b/c/arc/auth with adding tests. | 24 // TODO(hidehiko): Move to c/b/c/arc/auth with adding tests. |
| 24 class ArcAuthService : public ArcService, | 25 class ArcAuthService : public ArcService, |
| 25 public mojom::AuthHost, | 26 public mojom::AuthHost, |
| 26 public InstanceHolder<mojom::AuthInstance>::Observer { | 27 public InstanceHolder<mojom::AuthInstance>::Observer { |
| 27 public: | 28 public: |
| 28 explicit ArcAuthService(ArcBridgeService* bridge_service); | 29 explicit ArcAuthService(ArcBridgeService* bridge_service); |
| 29 ~ArcAuthService() override; | 30 ~ArcAuthService() override; |
| 30 | 31 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 55 | 56 |
| 56 private: | 57 private: |
| 57 using AccountInfoCallback = base::Callback<void(mojom::AccountInfoPtr)>; | 58 using AccountInfoCallback = base::Callback<void(mojom::AccountInfoPtr)>; |
| 58 class AccountInfoNotifier; | 59 class AccountInfoNotifier; |
| 59 | 60 |
| 60 // Starts to request account info. | 61 // Starts to request account info. |
| 61 void RequestAccountInfoInternal( | 62 void RequestAccountInfoInternal( |
| 62 std::unique_ptr<AccountInfoNotifier> account_info_notifier); | 63 std::unique_ptr<AccountInfoNotifier> account_info_notifier); |
| 63 | 64 |
| 64 // Callbacks when auth info is fetched. | 65 // Callbacks when auth info is fetched. |
| 65 void OnEnrollmentTokenFetched(const std::string& enrollment_token); | 66 void OnEnrollmentTokenFetched(ArcAuthInfoFetchStatus status, |
| 66 void OnAuthCodeFetched(const std::string& auth_code); | 67 const std::string& enrollment_token); |
| 68 void OnAuthCodeFetched(ArcAuthInfoFetchStatus status, |
| 69 const std::string& auth_code); |
| 67 | 70 |
| 68 // Called to let ARC container know the account info. | 71 // Called to let ARC container know the account info. |
| 69 void OnAccountInfoReady(mojom::AccountInfoPtr account_info); | 72 void OnAccountInfoReady(mojom::AccountInfoPtr account_info); |
| 70 | 73 |
| 71 mojo::Binding<mojom::AuthHost> binding_; | 74 mojo::Binding<mojom::AuthHost> binding_; |
| 72 | 75 |
| 73 std::unique_ptr<AccountInfoNotifier> notifier_; | 76 std::unique_ptr<AccountInfoNotifier> notifier_; |
| 74 std::unique_ptr<ArcAuthInfoFetcher> fetcher_; | 77 std::unique_ptr<ArcAuthInfoFetcher> fetcher_; |
| 75 | 78 |
| 76 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_; | 79 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_; |
| 77 | 80 |
| 78 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); | 81 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); |
| 79 }; | 82 }; |
| 80 | 83 |
| 81 } // namespace arc | 84 } // namespace arc |
| 82 | 85 |
| 83 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ | 86 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ |
| OLD | NEW |