| 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/common/shelf/shelf_delegate.h" | 9 #include "ash/common/shelf/shelf_delegate.h" |
| 10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 // static | 147 // static |
| 148 ArcAuthService* ArcAuthService::Get() { | 148 ArcAuthService* ArcAuthService::Get() { |
| 149 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 149 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 150 return g_arc_auth_service; | 150 return g_arc_auth_service; |
| 151 } | 151 } |
| 152 | 152 |
| 153 // static | 153 // static |
| 154 void ArcAuthService::RegisterProfilePrefs( | 154 void ArcAuthService::RegisterProfilePrefs( |
| 155 user_prefs::PrefRegistrySyncable* registry) { | 155 user_prefs::PrefRegistrySyncable* registry) { |
| 156 registry->RegisterBooleanPref( | 156 // TODO(dspaid): Implement a mechanism to allow this to sync on first boot |
| 157 prefs::kArcEnabled, false, | 157 // only. |
| 158 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 158 registry->RegisterBooleanPref(prefs::kArcEnabled, false); |
| 159 registry->RegisterBooleanPref(prefs::kArcSignedIn, false); | 159 registry->RegisterBooleanPref(prefs::kArcSignedIn, false); |
| 160 registry->RegisterBooleanPref(prefs::kArcBackupRestoreEnabled, true); | 160 registry->RegisterBooleanPref(prefs::kArcBackupRestoreEnabled, true); |
| 161 registry->RegisterBooleanPref(prefs::kArcLocationServiceEnabled, true); | 161 registry->RegisterBooleanPref(prefs::kArcLocationServiceEnabled, true); |
| 162 } | 162 } |
| 163 | 163 |
| 164 // static | 164 // static |
| 165 void ArcAuthService::DisableUIForTesting() { | 165 void ArcAuthService::DisableUIForTesting() { |
| 166 g_disable_ui_for_testing = true; | 166 g_disable_ui_for_testing = true; |
| 167 } | 167 } |
| 168 | 168 |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 UpdateEnabledStateUMA(false); | 512 UpdateEnabledStateUMA(false); |
| 513 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, false); | 513 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, false); |
| 514 } | 514 } |
| 515 ShutdownBridgeAndCloseUI(); | 515 ShutdownBridgeAndCloseUI(); |
| 516 } | 516 } |
| 517 | 517 |
| 518 void ArcAuthService::OnOptInPreferenceChanged() { | 518 void ArcAuthService::OnOptInPreferenceChanged() { |
| 519 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 519 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 520 DCHECK(profile_); | 520 DCHECK(profile_); |
| 521 | 521 |
| 522 // TODO(dspaid): Move code from OnSyncedPrefChanged into this method. |
| 523 OnSyncedPrefChanged(prefs::kArcEnabled, IsArcManaged()); |
| 524 |
| 522 const bool arc_enabled = IsArcEnabled(); | 525 const bool arc_enabled = IsArcEnabled(); |
| 523 FOR_EACH_OBSERVER(Observer, observer_list_, OnOptInEnabled(arc_enabled)); | 526 FOR_EACH_OBSERVER(Observer, observer_list_, OnOptInEnabled(arc_enabled)); |
| 524 | 527 |
| 525 if (!arc_enabled) { | 528 if (!arc_enabled) { |
| 526 StopArc(); | 529 StopArc(); |
| 527 return; | 530 return; |
| 528 } | 531 } |
| 529 | 532 |
| 530 if (state_ == State::ACTIVE) | 533 if (state_ == State::ACTIVE) |
| 531 return; | 534 return; |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 return os << kStateFetchingCode; | 809 return os << kStateFetchingCode; |
| 807 case ArcAuthService::State::ACTIVE: | 810 case ArcAuthService::State::ACTIVE: |
| 808 return os << kStateActive; | 811 return os << kStateActive; |
| 809 default: | 812 default: |
| 810 NOTREACHED(); | 813 NOTREACHED(); |
| 811 return os; | 814 return os; |
| 812 } | 815 } |
| 813 } | 816 } |
| 814 | 817 |
| 815 } // namespace arc | 818 } // namespace arc |
| OLD | NEW |