OLD | NEW |
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 "ash/shelf/shelf_delegate.h" | 9 #include "ash/shelf/shelf_delegate.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 335 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
336 return profile_ != nullptr; | 336 return profile_ != nullptr; |
337 } | 337 } |
338 | 338 |
339 void ArcAuthService::OnPrimaryUserProfilePrepared(Profile* profile) { | 339 void ArcAuthService::OnPrimaryUserProfilePrepared(Profile* profile) { |
340 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 340 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
341 DCHECK(profile && profile != profile_); | 341 DCHECK(profile && profile != profile_); |
342 | 342 |
343 Shutdown(); | 343 Shutdown(); |
344 | 344 |
345 profile_ = profile; | |
346 SetState(State::STOPPED); | |
347 | |
348 if (!IsAllowedForProfile(profile)) | 345 if (!IsAllowedForProfile(profile)) |
349 return; | 346 return; |
350 | 347 |
351 // TODO(khmel): Move this to IsAllowedForProfile. | 348 // TODO(khmel): Move this to IsAllowedForProfile. |
352 if (IsArcDisabledForEnterprise() && IsAccountManaged(profile)) { | 349 if (IsArcDisabledForEnterprise() && IsAccountManaged(profile)) { |
353 VLOG(2) << "Enterprise users are not supported in ARC."; | 350 VLOG(2) << "Enterprise users are not supported in ARC."; |
354 return; | 351 return; |
355 } | 352 } |
356 | 353 |
| 354 profile_ = profile; |
| 355 SetState(State::STOPPED); |
| 356 |
357 PrefServiceSyncableFromProfile(profile_)->AddSyncedPrefObserver( | 357 PrefServiceSyncableFromProfile(profile_)->AddSyncedPrefObserver( |
358 prefs::kArcEnabled, this); | 358 prefs::kArcEnabled, this); |
359 | 359 |
360 context_.reset(new ArcAuthContext(this, profile_)); | 360 context_.reset(new ArcAuthContext(this, profile_)); |
361 | 361 |
362 // In case UI is disabled we assume that ARC is opted-in. | 362 // In case UI is disabled we assume that ARC is opted-in. |
363 if (IsOptInVerificationDisabled()) { | 363 if (IsOptInVerificationDisabled()) { |
364 auth_code_.clear(); | 364 auth_code_.clear(); |
365 StartArc(); | 365 StartArc(); |
366 return; | 366 return; |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 } | 630 } |
631 | 631 |
632 bool ArcAuthService::IsArcManaged() const { | 632 bool ArcAuthService::IsArcManaged() const { |
633 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 633 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
634 DCHECK(profile_); | 634 DCHECK(profile_); |
635 return profile_->GetPrefs()->IsManagedPreference(prefs::kArcEnabled); | 635 return profile_->GetPrefs()->IsManagedPreference(prefs::kArcEnabled); |
636 } | 636 } |
637 | 637 |
638 bool ArcAuthService::IsArcEnabled() const { | 638 bool ArcAuthService::IsArcEnabled() const { |
639 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 639 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 640 if (!IsAllowed()) |
| 641 return false; |
| 642 |
640 DCHECK(profile_); | 643 DCHECK(profile_); |
641 return profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled); | 644 return profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled); |
642 } | 645 } |
643 | 646 |
644 void ArcAuthService::EnableArc() { | 647 void ArcAuthService::EnableArc() { |
645 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 648 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
646 DCHECK(profile_); | 649 DCHECK(profile_); |
647 | 650 |
648 if (IsArcEnabled()) { | 651 if (IsArcEnabled()) { |
649 OnOptInPreferenceChanged(); | 652 OnOptInPreferenceChanged(); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 return os << kStateFetchingCode; | 754 return os << kStateFetchingCode; |
752 case ArcAuthService::State::ACTIVE: | 755 case ArcAuthService::State::ACTIVE: |
753 return os << kStateActive; | 756 return os << kStateActive; |
754 default: | 757 default: |
755 NOTREACHED(); | 758 NOTREACHED(); |
756 return os; | 759 return os; |
757 } | 760 } |
758 } | 761 } |
759 | 762 |
760 } // namespace arc | 763 } // namespace arc |
OLD | NEW |