| 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 ArcAuthCodeFetcher; | 20 class ArcAuthInfoFetcher; |
| 21 | 21 |
| 22 // Implementation of ARC authorization. | 22 // Implementation of ARC authorization. |
| 23 // TODO(hidehiko): Move to c/b/c/arc/auth with adding tests. | 23 // TODO(hidehiko): Move to c/b/c/arc/auth with adding tests. |
| 24 class ArcAuthService : public ArcService, | 24 class ArcAuthService : public ArcService, |
| 25 public mojom::AuthHost, | 25 public mojom::AuthHost, |
| 26 public InstanceHolder<mojom::AuthInstance>::Observer { | 26 public InstanceHolder<mojom::AuthInstance>::Observer { |
| 27 public: | 27 public: |
| 28 explicit ArcAuthService(ArcBridgeService* bridge_service); | 28 explicit ArcAuthService(ArcBridgeService* bridge_service); |
| 29 ~ArcAuthService() override; | 29 ~ArcAuthService() override; |
| 30 | 30 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 54 const GetIsAccountManagedDeprecatedCallback& callback) override; | 54 const GetIsAccountManagedDeprecatedCallback& callback) override; |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 using AccountInfoCallback = base::Callback<void(mojom::AccountInfoPtr)>; | 57 using AccountInfoCallback = base::Callback<void(mojom::AccountInfoPtr)>; |
| 58 class AccountInfoNotifier; | 58 class AccountInfoNotifier; |
| 59 | 59 |
| 60 // Starts to request account info. | 60 // Starts to request account info. |
| 61 void RequestAccountInfoInternal( | 61 void RequestAccountInfoInternal( |
| 62 std::unique_ptr<AccountInfoNotifier> account_info_notifier); | 62 std::unique_ptr<AccountInfoNotifier> account_info_notifier); |
| 63 | 63 |
| 64 // Callback on auth_code fetched. | 64 // Callbacks when auth info is fetched. |
| 65 void OnAuthCodeFetched(const std::string& auth_code); | 65 void OnAuthCodeFetched(const std::string& auth_code); |
| 66 void OnEnrollmentTokenFetched(const std::string& enrollment_token); |
| 66 | 67 |
| 67 // Called to let ARC container know the account info. | 68 // Called to let ARC container know the account info. |
| 68 void OnAccountInfoReady(mojom::AccountInfoPtr account_info); | 69 void OnAccountInfoReady(mojom::AccountInfoPtr account_info); |
| 69 | 70 |
| 70 mojo::Binding<mojom::AuthHost> binding_; | 71 mojo::Binding<mojom::AuthHost> binding_; |
| 71 | 72 |
| 72 std::unique_ptr<AccountInfoNotifier> notifier_; | 73 std::unique_ptr<AccountInfoNotifier> notifier_; |
| 73 std::unique_ptr<ArcAuthCodeFetcher> fetcher_; | 74 std::unique_ptr<ArcAuthInfoFetcher> fetcher_; |
| 74 | 75 |
| 75 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_; | 76 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_; |
| 76 | 77 |
| 77 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); | 78 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); |
| 78 }; | 79 }; |
| 79 | 80 |
| 80 } // namespace arc | 81 } // namespace arc |
| 81 | 82 |
| 82 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ | 83 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ |
| OLD | NEW |