Chromium Code Reviews| 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 |
| 39 void ArcTermsOfServiceScreen::Hide() { | 40 void ArcTermsOfServiceScreen::Hide() { |
| 40 if (actor_) | 41 if (actor_) |
| 41 actor_->Hide(); | 42 actor_->Hide(); |
| 42 } | 43 } |
| 43 | 44 |
| 44 std::string ArcTermsOfServiceScreen::GetName() const { | 45 std::string ArcTermsOfServiceScreen::GetName() const { |
| 45 return WizardController::kArcTermsOfServiceScreenName; | 46 return WizardController::kArcTermsOfServiceScreenName; |
| 46 } | 47 } |
| 47 | 48 |
| 48 void ArcTermsOfServiceScreen::OnSkip() { | 49 void ArcTermsOfServiceScreen::OnSkip() { |
| 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); |
|
hidehiko
2016/12/16 05:31:51
Looks a kind of race.
Because both ArcTermsOfServi
khmel
2016/12/16 18:37:55
There is no race condition here. ArcTermsOfService
hidehiko
2016/12/19 15:49:44
Ah, maybe "race" was not a good word choice. Sorry
khmel
2016/12/19 17:48:10
I don't see any problem in order which are they ca
hidehiko
2016/12/20 15:20:45
I meant a test for this specific implementation. I
khmel
2016/12/20 16:27:57
Unit test that validates using OOBE negotiator alr
| |
| 59 profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, accepted); | 60 if (!profile->GetPrefs()->IsManagedPreference(prefs::kArcEnabled)) |
|
hidehiko
2016/12/16 05:31:51
Is this check really needed?
khmel
2016/12/16 18:37:55
This prevents calling redundant OnOptInProfileChan
hidehiko
2016/12/19 15:49:44
According to the current implementation and commen
khmel
2016/12/19 17:48:10
I have no idea at this moment who calls this metho
hidehiko
2016/12/20 15:20:45
Even if there is similar code, code change for the
khmel
2016/12/20 16:27:57
I think investigation of this conceptual problem i
| |
| 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 |