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