Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: chrome/browser/chromeos/arc/arc_auth_context.cc

Issue 2864433003: [ARC] Add browser test of ArcAuthService (Closed)
Patch Set: Rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chromeos/arc/arc_support_host.h" 10 #include "chrome/browser/chromeos/arc/arc_support_host.h"
(...skipping 11 matching lines...) Expand all
22 22
23 namespace arc { 23 namespace arc {
24 24
25 namespace { 25 namespace {
26 26
27 constexpr base::TimeDelta kRefreshTokenTimeout = 27 constexpr base::TimeDelta kRefreshTokenTimeout =
28 base::TimeDelta::FromSeconds(10); 28 base::TimeDelta::FromSeconds(10);
29 29
30 } // namespace 30 } // namespace
31 31
32 ArcAuthContext::ArcAuthContext(Profile* profile) { 32 ArcAuthContext::ArcAuthContext(Profile* profile)
33 : skip_merge_session_for_testing_(false) {
33 // Reuse storage used in ARC OptIn platform app. 34 // Reuse storage used in ARC OptIn platform app.
34 const std::string site_url = base::StringPrintf( 35 const std::string site_url = base::StringPrintf(
35 "%s://%s/persist?%s", content::kGuestScheme, ArcSupportHost::kHostAppId, 36 "%s://%s/persist?%s", content::kGuestScheme, ArcSupportHost::kHostAppId,
36 ArcSupportHost::kStorageId); 37 ArcSupportHost::kStorageId);
37 storage_partition_ = content::BrowserContext::GetStoragePartitionForSite( 38 storage_partition_ = content::BrowserContext::GetStoragePartitionForSite(
38 profile, GURL(site_url)); 39 profile, GURL(site_url));
39 CHECK(storage_partition_); 40 CHECK(storage_partition_);
40 41
41 // Get token service and account ID to fetch auth tokens. 42 // Get token service and account ID to fetch auth tokens.
42 token_service_ = ProfileOAuth2TokenServiceFactory::GetForProfile(profile); 43 token_service_ = ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 88
88 void ArcAuthContext::OnRefreshTokenTimeout() { 89 void ArcAuthContext::OnRefreshTokenTimeout() {
89 LOG(WARNING) << "Failed to wait for refresh token."; 90 LOG(WARNING) << "Failed to wait for refresh token.";
90 token_service_->RemoveObserver(this); 91 token_service_->RemoveObserver(this);
91 base::ResetAndReturn(&callback_).Run(nullptr); 92 base::ResetAndReturn(&callback_).Run(nullptr);
92 } 93 }
93 94
94 void ArcAuthContext::StartFetchers() { 95 void ArcAuthContext::StartFetchers() {
95 DCHECK(!refresh_token_timeout_.IsRunning()); 96 DCHECK(!refresh_token_timeout_.IsRunning());
96 ResetFetchers(); 97 ResetFetchers();
98
99 if (skip_merge_session_for_testing_) {
100 OnMergeSessionSuccess("");
101 return;
102 }
103
97 ubertoken_fetcher_.reset( 104 ubertoken_fetcher_.reset(
98 new UbertokenFetcher(token_service_, this, GaiaConstants::kChromeOSSource, 105 new UbertokenFetcher(token_service_, this, GaiaConstants::kChromeOSSource,
99 storage_partition_->GetURLRequestContext())); 106 storage_partition_->GetURLRequestContext()));
100 ubertoken_fetcher_->StartFetchingToken(account_id_); 107 ubertoken_fetcher_->StartFetchingToken(account_id_);
101 } 108 }
102 109
103 void ArcAuthContext::OnUbertokenSuccess(const std::string& token) { 110 void ArcAuthContext::OnUbertokenSuccess(const std::string& token) {
104 ResetFetchers(); 111 ResetFetchers();
105 merger_fetcher_.reset( 112 merger_fetcher_.reset(
106 new GaiaAuthFetcher(this, GaiaConstants::kChromeOSSource, 113 new GaiaAuthFetcher(this, GaiaConstants::kChromeOSSource,
(...skipping 20 matching lines...) Expand all
127 ResetFetchers(); 134 ResetFetchers();
128 base::ResetAndReturn(&callback_).Run(nullptr); 135 base::ResetAndReturn(&callback_).Run(nullptr);
129 } 136 }
130 137
131 void ArcAuthContext::ResetFetchers() { 138 void ArcAuthContext::ResetFetchers() {
132 merger_fetcher_.reset(); 139 merger_fetcher_.reset();
133 ubertoken_fetcher_.reset(); 140 ubertoken_fetcher_.reset();
134 } 141 }
135 142
136 } // namespace arc 143 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698