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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 DCHECK(thread_checker.Get().CalledOnValidThread()); | 341 DCHECK(thread_checker.Get().CalledOnValidThread()); |
342 return profile_ != nullptr; | 342 return profile_ != nullptr; |
343 } | 343 } |
344 | 344 |
345 void ArcAuthService::OnPrimaryUserProfilePrepared(Profile* profile) { | 345 void ArcAuthService::OnPrimaryUserProfilePrepared(Profile* profile) { |
346 DCHECK(profile && profile != profile_); | 346 DCHECK(profile && profile != profile_); |
347 DCHECK(thread_checker.Get().CalledOnValidThread()); | 347 DCHECK(thread_checker.Get().CalledOnValidThread()); |
348 | 348 |
349 Shutdown(); | 349 Shutdown(); |
350 | 350 |
351 profile_ = profile; | |
352 SetState(State::STOPPED); | |
353 | |
354 if (!IsAllowedForProfile(profile)) | 351 if (!IsAllowedForProfile(profile)) |
355 return; | 352 return; |
356 | 353 |
357 // TODO(khmel): Move this to IsAllowedForProfile. | 354 // TODO(khmel): Move this to IsAllowedForProfile. |
358 if (IsArcDisabledForEnterprise() && IsAccountManaged(profile)) { | 355 if (IsArcDisabledForEnterprise() && IsAccountManaged(profile)) { |
359 VLOG(2) << "Enterprise users are not supported in ARC."; | 356 VLOG(2) << "Enterprise users are not supported in ARC."; |
360 return; | 357 return; |
361 } | 358 } |
362 | 359 |
| 360 profile_ = profile; |
| 361 SetState(State::STOPPED); |
| 362 |
363 PrefServiceSyncableFromProfile(profile_)->AddSyncedPrefObserver( | 363 PrefServiceSyncableFromProfile(profile_)->AddSyncedPrefObserver( |
364 prefs::kArcEnabled, this); | 364 prefs::kArcEnabled, this); |
365 | 365 |
366 context_.reset(new ArcAuthContext(this, profile_)); | 366 context_.reset(new ArcAuthContext(this, profile_)); |
367 | 367 |
368 // In case UI is disabled we assume that ARC is opted-in. | 368 // In case UI is disabled we assume that ARC is opted-in. |
369 if (!IsOptInVerificationDisabled()) { | 369 if (!IsOptInVerificationDisabled()) { |
370 if (!disable_ui_for_testing || enable_check_android_management_for_testing) | 370 if (!disable_ui_for_testing || enable_check_android_management_for_testing) |
371 ArcAndroidManagementChecker::StartClient(); | 371 ArcAndroidManagementChecker::StartClient(); |
372 pref_change_registrar_.Init(profile_->GetPrefs()); | 372 pref_change_registrar_.Init(profile_->GetPrefs()); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 } | 634 } |
635 | 635 |
636 bool ArcAuthService::IsArcManaged() const { | 636 bool ArcAuthService::IsArcManaged() const { |
637 DCHECK(thread_checker.Get().CalledOnValidThread()); | 637 DCHECK(thread_checker.Get().CalledOnValidThread()); |
638 DCHECK(profile_); | 638 DCHECK(profile_); |
639 return profile_->GetPrefs()->IsManagedPreference(prefs::kArcEnabled); | 639 return profile_->GetPrefs()->IsManagedPreference(prefs::kArcEnabled); |
640 } | 640 } |
641 | 641 |
642 bool ArcAuthService::IsArcEnabled() const { | 642 bool ArcAuthService::IsArcEnabled() const { |
643 DCHECK(thread_checker.Get().CalledOnValidThread()); | 643 DCHECK(thread_checker.Get().CalledOnValidThread()); |
| 644 if (!IsAllowed()) |
| 645 return false; |
| 646 |
644 DCHECK(profile_); | 647 DCHECK(profile_); |
645 return profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled); | 648 return profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled); |
646 } | 649 } |
647 | 650 |
648 void ArcAuthService::EnableArc() { | 651 void ArcAuthService::EnableArc() { |
649 DCHECK(thread_checker.Get().CalledOnValidThread()); | 652 DCHECK(thread_checker.Get().CalledOnValidThread()); |
650 DCHECK(profile_); | 653 DCHECK(profile_); |
651 | 654 |
652 if (!IsArcEnabled()) { | 655 if (!IsArcEnabled()) { |
653 if (IsArcManaged()) | 656 if (IsArcManaged()) |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 return os << kStateFetchingCode; | 758 return os << kStateFetchingCode; |
756 case ArcAuthService::State::ACTIVE: | 759 case ArcAuthService::State::ACTIVE: |
757 return os << kStateActive; | 760 return os << kStateActive; |
758 default: | 761 default: |
759 NOTREACHED(); | 762 NOTREACHED(); |
760 return os; | 763 return os; |
761 } | 764 } |
762 } | 765 } |
763 | 766 |
764 } // namespace arc | 767 } // namespace arc |
OLD | NEW |