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/screens/eula_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/eula_screen.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/chromeos/customization_document.h" | 9 #include "chrome/browser/chromeos/customization_document.h" |
10 #include "chrome/browser/chromeos/login/screens/screen_observer.h" | 10 #include "chrome/browser/chromeos/login/screens/screen_observer.h" |
11 #include "chrome/browser/chromeos/login/wizard_controller.h" | 11 #include "chrome/browser/chromeos/login/wizard_controller.h" |
12 #include "chromeos/dbus/cryptohome_client.h" | 12 #include "chromeos/dbus/cryptohome_client.h" |
13 #include "chromeos/dbus/dbus_method_call_status.h" | 13 #include "chromeos/dbus/dbus_method_call_status.h" |
14 #include "chromeos/dbus/dbus_thread_manager.h" | 14 #include "chromeos/dbus/dbus_thread_manager.h" |
15 | 15 |
16 namespace chromeos { | 16 namespace chromeos { |
17 | 17 |
18 EulaScreen::EulaScreen(ScreenObserver* observer, EulaScreenActor* actor) | 18 EulaScreen::EulaScreen(ScreenObserver* observer, EulaScreenActor* actor) |
19 : BaseScreen(observer), actor_(actor), password_fetcher_(this) { | 19 : BaseScreen(observer), actor_(actor), password_fetcher_(this) { |
20 DCHECK(actor_); | 20 DCHECK(actor_); |
21 if (actor_) | 21 if (actor_) |
22 actor_->SetDelegate(this); | 22 actor_->SetDelegate(this); |
23 } | 23 } |
24 | 24 |
25 EulaScreen::~EulaScreen() { | 25 EulaScreen::~EulaScreen() { |
26 if (actor_) | 26 if (actor_) |
27 actor_->SetDelegate(NULL); | 27 actor_->SetDelegate(NULL); |
28 } | 28 } |
29 | 29 |
| 30 void EulaScreen::SetDelegate(Delegate* delegate) { |
| 31 DCHECK(delegate); |
| 32 delegate_ = delegate; |
| 33 } |
| 34 |
30 void EulaScreen::PrepareToShow() { | 35 void EulaScreen::PrepareToShow() { |
31 if (actor_) | 36 if (actor_) |
32 actor_->PrepareToShow(); | 37 actor_->PrepareToShow(); |
33 } | 38 } |
34 | 39 |
35 void EulaScreen::Show() { | 40 void EulaScreen::Show() { |
36 // Command to own the TPM. | 41 // Command to own the TPM. |
37 DBusThreadManager::Get()->GetCryptohomeClient()->TpmCanAttemptOwnership( | 42 DBusThreadManager::Get()->GetCryptohomeClient()->TpmCanAttemptOwnership( |
38 EmptyVoidDBusMethodCallback()); | 43 EmptyVoidDBusMethodCallback()); |
39 if (actor_) | 44 if (actor_) |
(...skipping 21 matching lines...) Expand all Loading... |
61 return GURL(eula_page); | 66 return GURL(eula_page); |
62 | 67 |
63 VLOG(1) << "No eula found for locale: " << locale; | 68 VLOG(1) << "No eula found for locale: " << locale; |
64 } else { | 69 } else { |
65 LOG(ERROR) << "No manifest found."; | 70 LOG(ERROR) << "No manifest found."; |
66 } | 71 } |
67 return GURL(); | 72 return GURL(); |
68 } | 73 } |
69 | 74 |
70 void EulaScreen::OnExit(bool accepted, bool usage_stats_enabled) { | 75 void EulaScreen::OnExit(bool accepted, bool usage_stats_enabled) { |
71 get_screen_observer()->SetUsageStatisticsReporting(usage_stats_enabled); | 76 if (delegate_) |
| 77 delegate_->SetUsageStatisticsReporting(usage_stats_enabled); |
72 get_screen_observer()->OnExit(accepted | 78 get_screen_observer()->OnExit(accepted |
73 ? ScreenObserver::EULA_ACCEPTED | 79 ? ScreenObserver::EULA_ACCEPTED |
74 : ScreenObserver::EULA_BACK); | 80 : ScreenObserver::EULA_BACK); |
75 } | 81 } |
76 | 82 |
77 void EulaScreen::InitiatePasswordFetch() { | 83 void EulaScreen::InitiatePasswordFetch() { |
78 if (tpm_password_.empty()) { | 84 if (tpm_password_.empty()) { |
79 password_fetcher_.Fetch(); | 85 password_fetcher_.Fetch(); |
80 // Will call actor after password has been fetched. | 86 // Will call actor after password has been fetched. |
81 } else if (actor_) { | 87 } else if (actor_) { |
82 actor_->OnPasswordFetched(tpm_password_); | 88 actor_->OnPasswordFetched(tpm_password_); |
83 } | 89 } |
84 } | 90 } |
85 | 91 |
86 void EulaScreen::OnPasswordFetched(const std::string& tpm_password) { | 92 void EulaScreen::OnPasswordFetched(const std::string& tpm_password) { |
87 tpm_password_ = tpm_password; | 93 tpm_password_ = tpm_password; |
88 if (actor_) | 94 if (actor_) |
89 actor_->OnPasswordFetched(tpm_password_); | 95 actor_->OnPasswordFetched(tpm_password_); |
90 } | 96 } |
91 | 97 |
92 bool EulaScreen::IsUsageStatsEnabled() const { | 98 bool EulaScreen::IsUsageStatsEnabled() const { |
93 return get_screen_observer()->GetUsageStatisticsReporting(); | 99 return delegate_ && delegate_->GetUsageStatisticsReporting(); |
94 } | 100 } |
95 | 101 |
96 void EulaScreen::OnActorDestroyed(EulaScreenActor* actor) { | 102 void EulaScreen::OnActorDestroyed(EulaScreenActor* actor) { |
97 if (actor_ == actor) | 103 if (actor_ == actor) |
98 actor_ = NULL; | 104 actor_ = NULL; |
99 } | 105 } |
100 | 106 |
101 } // namespace chromeos | 107 } // namespace chromeos |
OLD | NEW |