| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/login/screens/arc_terms_of_service_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/arc_terms_of_service_screen.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/login/screens/arc_terms_of_service_screen_acto
r.h" |
| 7 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h" | 8 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h" |
| 8 #include "chrome/browser/chromeos/login/wizard_controller.h" | 9 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 9 #include "chrome/browser/metrics/metrics_reporting_state.h" | 10 #include "chrome/browser/metrics/metrics_reporting_state.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
| 12 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 13 #include "components/prefs/pref_service.h" | 14 #include "components/prefs/pref_service.h" |
| 14 | 15 |
| 15 namespace chromeos { | 16 namespace chromeos { |
| 16 | 17 |
| 17 ArcTermsOfServiceScreen::ArcTermsOfServiceScreen( | 18 ArcTermsOfServiceScreen::ArcTermsOfServiceScreen( |
| 18 BaseScreenDelegate* base_screen_delegate, | 19 BaseScreenDelegate* base_screen_delegate, |
| 19 ArcTermsOfServiceScreenActor* actor) | 20 ArcTermsOfServiceScreenActor* actor) |
| 20 : BaseScreen(base_screen_delegate), actor_(actor) { | 21 : BaseScreen(base_screen_delegate), actor_(actor) { |
| 21 DCHECK(actor_); | 22 DCHECK(actor_); |
| 22 if (actor_) | 23 if (actor_) |
| 23 actor_->SetDelegate(this); | 24 actor_->AddObserver(this); |
| 24 } | 25 } |
| 25 | 26 |
| 26 ArcTermsOfServiceScreen::~ArcTermsOfServiceScreen() { | 27 ArcTermsOfServiceScreen::~ArcTermsOfServiceScreen() { |
| 27 if (actor_) | 28 if (actor_) |
| 28 actor_->SetDelegate(nullptr); | 29 actor_->RemoveObserver(this); |
| 29 } | 30 } |
| 30 | 31 |
| 31 void ArcTermsOfServiceScreen::Show() { | 32 void ArcTermsOfServiceScreen::Show() { |
| 32 if (!actor_) | 33 if (!actor_) |
| 33 return; | 34 return; |
| 34 | 35 |
| 35 // Show the screen. | 36 // Show the screen. |
| 36 actor_->Show(); | 37 actor_->Show(); |
| 37 } | 38 } |
| 38 | 39 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 49 ApplyTerms(false); | 50 ApplyTerms(false); |
| 50 } | 51 } |
| 51 | 52 |
| 52 void ArcTermsOfServiceScreen::OnAccept() { | 53 void ArcTermsOfServiceScreen::OnAccept() { |
| 53 ApplyTerms(true); | 54 ApplyTerms(true); |
| 54 } | 55 } |
| 55 | 56 |
| 56 void ArcTermsOfServiceScreen::ApplyTerms(bool accepted) { | 57 void ArcTermsOfServiceScreen::ApplyTerms(bool accepted) { |
| 57 Profile* profile = ProfileManager::GetActiveUserProfile(); | 58 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 58 profile->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, accepted); | 59 profile->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, accepted); |
| 59 profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, accepted); | 60 if (!profile->GetPrefs()->IsManagedPreference(prefs::kArcEnabled)) |
| 61 profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, accepted); |
| 60 | 62 |
| 61 Finish(BaseScreenDelegate::ARC_TERMS_OF_SERVICE_FINISHED); | 63 Finish(BaseScreenDelegate::ARC_TERMS_OF_SERVICE_FINISHED); |
| 62 } | 64 } |
| 63 | 65 |
| 64 void ArcTermsOfServiceScreen::OnActorDestroyed( | 66 void ArcTermsOfServiceScreen::OnActorDestroyed( |
| 65 ArcTermsOfServiceScreenActor* actor) { | 67 ArcTermsOfServiceScreenActor* actor) { |
| 66 DCHECK_EQ(actor, actor_); | 68 DCHECK_EQ(actor, actor_); |
| 67 actor_ = nullptr; | 69 actor_ = nullptr; |
| 68 } | 70 } |
| 69 | 71 |
| 70 } // namespace chromeos | 72 } // namespace chromeos |
| OLD | NEW |