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