| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_CONTEXT_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_CONTEXT_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "base/timer/timer.h" | |
| 13 #include "google_apis/gaia/ubertoken_fetcher.h" | |
| 14 | |
| 15 class Profile; | |
| 16 class ProfileOAuth2TokenService; | |
| 17 | |
| 18 namespace content { | |
| 19 class StoragePartition; | |
| 20 } | |
| 21 | |
| 22 namespace arc { | |
| 23 | |
| 24 class ArcAuthContextDelegate; | |
| 25 | |
| 26 class ArcAuthContext : public UbertokenConsumer, | |
| 27 public GaiaAuthConsumer, | |
| 28 public OAuth2TokenService::Observer { | |
| 29 public: | |
| 30 ArcAuthContext(ArcAuthContextDelegate* delegate, Profile* profile); | |
| 31 ~ArcAuthContext() override; | |
| 32 | |
| 33 void PrepareContext(); | |
| 34 | |
| 35 // OAuth2TokenService::Observer: | |
| 36 void OnRefreshTokenAvailable(const std::string& account_id) override; | |
| 37 void OnRefreshTokensLoaded() override; | |
| 38 | |
| 39 // UbertokenConsumer: | |
| 40 void OnUbertokenSuccess(const std::string& token) override; | |
| 41 void OnUbertokenFailure(const GoogleServiceAuthError& error) override; | |
| 42 | |
| 43 // GaiaAuthConsumer: | |
| 44 void OnMergeSessionSuccess(const std::string& data) override; | |
| 45 void OnMergeSessionFailure(const GoogleServiceAuthError& error) override; | |
| 46 | |
| 47 const std::string& account_id() const { return account_id_; } | |
| 48 | |
| 49 ProfileOAuth2TokenService* token_service() { return token_service_; } | |
| 50 | |
| 51 private: | |
| 52 void StartFetchers(); | |
| 53 void OnRefreshTokenTimeout(); | |
| 54 | |
| 55 // Unowned pointers. | |
| 56 ArcAuthContextDelegate* const delegate_; | |
| 57 ProfileOAuth2TokenService* token_service_; | |
| 58 | |
| 59 bool context_prepared_ = false; | |
| 60 | |
| 61 // Owned by content::BrowserContent. Used to isolate cookies for auth server | |
| 62 // communication and shared with Arc OptIn UI platform app. | |
| 63 content::StoragePartition* storage_partition_ = nullptr; | |
| 64 | |
| 65 std::string account_id_; | |
| 66 std::unique_ptr<GaiaAuthFetcher> merger_fetcher_; | |
| 67 std::unique_ptr<UbertokenFetcher> ubertoken_fetcher_; | |
| 68 base::OneShotTimer refresh_token_timeout_; | |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(ArcAuthContext); | |
| 71 }; | |
| 72 | |
| 73 } // namespace arc | |
| 74 | |
| 75 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_CONTEXT_H_ | |
| OLD | NEW |