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

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

Issue 2705213002: Show different error message if ARC is disabled. (Closed)
Patch Set: Fix browsertests and add a new test for 904 Arc Disabled Created 3 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_service.h" 5 #include "chrome/browser/chromeos/arc/arc_auth_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // IsArcKioskMode() is true. Both cases are handled above. 260 // IsArcKioskMode() is true. Both cases are handled above.
261 fetcher_ = base::MakeUnique<ArcManualAuthCodeFetcher>( 261 fetcher_ = base::MakeUnique<ArcManualAuthCodeFetcher>(
262 ArcSessionManager::Get()->auth_context(), 262 ArcSessionManager::Get()->auth_context(),
263 ArcSessionManager::Get()->support_host()); 263 ArcSessionManager::Get()->support_host());
264 } 264 }
265 fetcher_->Fetch(base::Bind(&ArcAuthService::OnAuthCodeFetched, 265 fetcher_->Fetch(base::Bind(&ArcAuthService::OnAuthCodeFetched,
266 weak_ptr_factory_.GetWeakPtr())); 266 weak_ptr_factory_.GetWeakPtr()));
267 } 267 }
268 268
269 void ArcAuthService::OnEnrollmentTokenFetched( 269 void ArcAuthService::OnEnrollmentTokenFetched(
270 ArcAuthInfoFetchStatus status,
270 const std::string& enrollment_token) { 271 const std::string& enrollment_token) {
271 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 272 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
272 fetcher_.reset(); 273 fetcher_.reset();
273 274
274 if (enrollment_token.empty()) { 275 switch (status) {
276 case ArcAuthInfoFetchStatus::SUCCESS:
277 notifier_->Notify(true /*is_enforced*/, enrollment_token,
278 mojom::ChromeAccountType::ACTIVE_DIRECTORY_ACCOUNT,
279 true);
280 notifier_.reset();
281 return;
282 case ArcAuthInfoFetchStatus::ARC_DISABLED:
283 ArcSessionManager::Get()->OnProvisioningFinished(
284 ProvisioningResult::ARC_DISABLED);
285 return;
286 default:
287 ArcSessionManager::Get()->OnProvisioningFinished(
288 ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR);
289 return;
290 }
291 }
292
293 void ArcAuthService::OnAuthCodeFetched(ArcAuthInfoFetchStatus status,
294 const std::string& auth_code) {
295 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
296 fetcher_.reset();
297
298 if (status != ArcAuthInfoFetchStatus::SUCCESS) {
275 ArcSessionManager::Get()->OnProvisioningFinished( 299 ArcSessionManager::Get()->OnProvisioningFinished(
276 ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR); 300 ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR);
277 return; 301 return;
278 }
279
280 notifier_->Notify(true /*is_enforced*/, enrollment_token,
281 mojom::ChromeAccountType::ACTIVE_DIRECTORY_ACCOUNT, true);
282 notifier_.reset();
283 }
284
285 void ArcAuthService::OnAuthCodeFetched(const std::string& auth_code) {
286 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
287 fetcher_.reset();
288
289 if (auth_code.empty()) {
290 ArcSessionManager::Get()->OnProvisioningFinished(
291 ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR);
292 return;
293 } 302 }
294 303
295 notifier_->Notify( 304 notifier_->Notify(
296 !IsArcOptInVerificationDisabled(), auth_code, GetAccountType(), 305 !IsArcOptInVerificationDisabled(), auth_code, GetAccountType(),
297 policy_util::IsAccountManaged(ArcSessionManager::Get()->profile())); 306 policy_util::IsAccountManaged(ArcSessionManager::Get()->profile()));
298 notifier_.reset(); 307 notifier_.reset();
299 } 308 }
300 309
301 } // namespace arc 310 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698