| 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 #include "chrome/browser/chromeos/arc/arc_auth_context.h" | 5 #include "chrome/browser/chromeos/arc/arc_auth_context.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/chromeos/arc/arc_support_host.h" | 10 #include "chrome/browser/chromeos/arc/arc_support_host.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 12 #include "chrome/browser/signin/signin_manager_factory.h" | 13 #include "chrome/browser/signin/signin_manager_factory.h" |
| 14 #include "chrome/browser/signin/signin_ui_util.h" |
| 13 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 15 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 14 #include "components/signin/core/browser/signin_manager_base.h" | 16 #include "components/signin/core/browser/signin_manager_base.h" |
| 15 #include "content/public/browser/browser_context.h" | 17 #include "content/public/browser/browser_context.h" |
| 16 #include "content/public/browser/storage_partition.h" | 18 #include "content/public/browser/storage_partition.h" |
| 17 #include "content/public/common/url_constants.h" | 19 #include "content/public/common/url_constants.h" |
| 18 #include "google_apis/gaia/gaia_auth_fetcher.h" | 20 #include "google_apis/gaia/gaia_auth_fetcher.h" |
| 19 #include "google_apis/gaia/gaia_constants.h" | 21 #include "google_apis/gaia/gaia_constants.h" |
| 20 | 22 |
| 21 namespace arc { | 23 namespace arc { |
| 22 | 24 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 35 storage_partition_ = content::BrowserContext::GetStoragePartitionForSite( | 37 storage_partition_ = content::BrowserContext::GetStoragePartitionForSite( |
| 36 profile, GURL(site_url)); | 38 profile, GURL(site_url)); |
| 37 CHECK(storage_partition_); | 39 CHECK(storage_partition_); |
| 38 | 40 |
| 39 // Get token service and account ID to fetch auth tokens. | 41 // Get token service and account ID to fetch auth tokens. |
| 40 token_service_ = ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 42 token_service_ = ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 41 const SigninManagerBase* const signin_manager = | 43 const SigninManagerBase* const signin_manager = |
| 42 SigninManagerFactory::GetForProfile(profile); | 44 SigninManagerFactory::GetForProfile(profile); |
| 43 CHECK(token_service_ && signin_manager); | 45 CHECK(token_service_ && signin_manager); |
| 44 account_id_ = signin_manager->GetAuthenticatedAccountId(); | 46 account_id_ = signin_manager->GetAuthenticatedAccountId(); |
| 47 |
| 48 full_account_id_ = base::UTF16ToUTF8( |
| 49 signin_ui_util::GetAuthenticatedUsername(signin_manager)); |
| 45 } | 50 } |
| 46 | 51 |
| 47 ArcAuthContext::~ArcAuthContext() { | 52 ArcAuthContext::~ArcAuthContext() { |
| 48 token_service_->RemoveObserver(this); | 53 token_service_->RemoveObserver(this); |
| 49 } | 54 } |
| 50 | 55 |
| 51 void ArcAuthContext::Prepare(const PrepareCallback& callback) { | 56 void ArcAuthContext::Prepare(const PrepareCallback& callback) { |
| 52 if (context_prepared_) { | 57 if (context_prepared_) { |
| 53 callback.Run(storage_partition_->GetURLRequestContext()); | 58 callback.Run(storage_partition_->GetURLRequestContext()); |
| 54 return; | 59 return; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 ResetFetchers(); | 127 ResetFetchers(); |
| 123 base::ResetAndReturn(&callback_).Run(nullptr); | 128 base::ResetAndReturn(&callback_).Run(nullptr); |
| 124 } | 129 } |
| 125 | 130 |
| 126 void ArcAuthContext::ResetFetchers() { | 131 void ArcAuthContext::ResetFetchers() { |
| 127 merger_fetcher_.reset(); | 132 merger_fetcher_.reset(); |
| 128 ubertoken_fetcher_.reset(); | 133 ubertoken_fetcher_.reset(); |
| 129 } | 134 } |
| 130 | 135 |
| 131 } // namespace arc | 136 } // namespace arc |
| OLD | NEW |