OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/eula_screen.h" | 5 #include "chrome/browser/chromeos/login/eula_screen.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/chromeos/cros/cros_library.h" | 8 #include "chrome/browser/chromeos/cros/cros_library.h" |
9 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 9 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
10 #include "chrome/browser/chromeos/customization_document.h" | 10 #include "chrome/browser/chromeos/customization_document.h" |
11 #include "chrome/browser/chromeos/login/screen_observer.h" | 11 #include "chrome/browser/chromeos/login/screen_observer.h" |
12 #include "chrome/browser/chromeos/login/wizard_controller.h" | 12 #include "chrome/browser/chromeos/login/wizard_controller.h" |
13 | 13 |
14 namespace chromeos { | 14 namespace chromeos { |
15 | 15 |
16 EulaScreen::EulaScreen(ScreenObserver* observer, EulaScreenActor* actor) | 16 EulaScreen::EulaScreen(ScreenObserver* observer, EulaScreenActor* actor) |
17 : WizardScreen(observer), actor_(actor), password_fetcher_(this) { | 17 : WizardScreen(observer), actor_(actor), password_fetcher_(this) { |
18 actor_->SetDelegate(this); | 18 DCHECK(actor_); |
| 19 if (actor_) |
| 20 actor_->SetDelegate(this); |
19 } | 21 } |
20 | 22 |
21 EulaScreen::~EulaScreen() { | 23 EulaScreen::~EulaScreen() { |
22 if (actor_) | 24 if (actor_) |
23 actor_->SetDelegate(NULL); | 25 actor_->SetDelegate(NULL); |
24 } | 26 } |
25 | 27 |
26 void EulaScreen::PrepareToShow() { | 28 void EulaScreen::PrepareToShow() { |
27 actor_->PrepareToShow(); | 29 if (actor_) |
| 30 actor_->PrepareToShow(); |
28 } | 31 } |
29 | 32 |
30 void EulaScreen::Show() { | 33 void EulaScreen::Show() { |
31 // Command to own the TPM. | 34 // Command to own the TPM. |
32 chromeos::CrosLibrary::Get()-> | 35 chromeos::CrosLibrary::Get()-> |
33 GetCryptohomeLibrary()->TpmCanAttemptOwnership(); | 36 GetCryptohomeLibrary()->TpmCanAttemptOwnership(); |
34 actor_->Show(); | 37 if (actor_) |
| 38 actor_->Show(); |
35 } | 39 } |
36 | 40 |
37 void EulaScreen::Hide() { | 41 void EulaScreen::Hide() { |
38 actor_->Hide(); | 42 if (actor_) |
| 43 actor_->Hide(); |
39 } | 44 } |
40 | 45 |
41 std::string EulaScreen::GetName() const { | 46 std::string EulaScreen::GetName() const { |
42 return WizardController::kEulaScreenName; | 47 return WizardController::kEulaScreenName; |
43 } | 48 } |
44 | 49 |
45 bool EulaScreen::IsTpmEnabled() const { | 50 bool EulaScreen::IsTpmEnabled() const { |
46 return chromeos::CrosLibrary::Get()->GetCryptohomeLibrary()->TpmIsEnabled(); | 51 return chromeos::CrosLibrary::Get()->GetCryptohomeLibrary()->TpmIsEnabled(); |
47 } | 52 } |
48 | 53 |
(...skipping 17 matching lines...) Expand all Loading... |
66 get_screen_observer()->SetUsageStatisticsReporting(is_usage_stats_checked); | 71 get_screen_observer()->SetUsageStatisticsReporting(is_usage_stats_checked); |
67 get_screen_observer()->OnExit(accepted | 72 get_screen_observer()->OnExit(accepted |
68 ? ScreenObserver::EULA_ACCEPTED | 73 ? ScreenObserver::EULA_ACCEPTED |
69 : ScreenObserver::EULA_BACK); | 74 : ScreenObserver::EULA_BACK); |
70 } | 75 } |
71 | 76 |
72 void EulaScreen::InitiatePasswordFetch() { | 77 void EulaScreen::InitiatePasswordFetch() { |
73 if (tpm_password_.empty()) { | 78 if (tpm_password_.empty()) { |
74 password_fetcher_.Fetch(); | 79 password_fetcher_.Fetch(); |
75 // Will call actor after password has been fetched. | 80 // Will call actor after password has been fetched. |
76 } else { | 81 } else if (actor_) { |
77 actor_->OnPasswordFetched(tpm_password_); | 82 actor_->OnPasswordFetched(tpm_password_); |
78 } | 83 } |
79 } | 84 } |
80 | 85 |
81 void EulaScreen::OnPasswordFetched(const std::string& tpm_password) { | 86 void EulaScreen::OnPasswordFetched(const std::string& tpm_password) { |
82 tpm_password_ = tpm_password; | 87 tpm_password_ = tpm_password; |
83 if (actor_) | 88 if (actor_) |
84 actor_->OnPasswordFetched(tpm_password_); | 89 actor_->OnPasswordFetched(tpm_password_); |
85 } | 90 } |
86 | 91 |
87 bool EulaScreen::IsUsageStatsEnabled() const { | 92 bool EulaScreen::IsUsageStatsEnabled() const { |
88 return get_screen_observer()->GetUsageStatisticsReporting(); | 93 return get_screen_observer()->GetUsageStatisticsReporting(); |
89 } | 94 } |
90 | 95 |
91 void EulaScreen::OnActorDestroyed(EulaScreenActor* actor) { | 96 void EulaScreen::OnActorDestroyed(EulaScreenActor* actor) { |
92 if (actor_ == actor) | 97 if (actor_ == actor) |
93 actor_ = NULL; | 98 actor_ = NULL; |
94 } | 99 } |
95 | 100 |
96 } // namespace chromeos | 101 } // namespace chromeos |
OLD | NEW |