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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/login/screens/eula_screen.h"
8 #include "base/bind_helpers.h"
9 #include "base/logging.h"
10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/chromeos/customization/customization_document.h"
12 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h"
13 #include "chrome/browser/chromeos/login/screens/eula_view.h"
14 #include "chromeos/dbus/cryptohome_client.h"
15 #include "chromeos/dbus/dbus_method_call_status.h"
16 #include "chromeos/dbus/dbus_thread_manager.h"
20 EulaScreen::EulaScreen(BaseScreenDelegate
* base_screen_delegate
,
23 : EulaModel(base_screen_delegate
),
26 password_fetcher_(this) {
33 EulaScreen::~EulaScreen() {
38 void EulaScreen::PrepareToShow() {
40 view_
->PrepareToShow();
43 void EulaScreen::Show() {
44 // Command to own the TPM.
45 DBusThreadManager::Get()->GetCryptohomeClient()->TpmCanAttemptOwnership(
46 EmptyVoidDBusMethodCallback());
51 void EulaScreen::Hide() {
56 GURL
EulaScreen::GetOemEulaUrl() const {
57 const StartupCustomizationDocument
* customization
=
58 StartupCustomizationDocument::GetInstance();
59 if (customization
->IsReady()) {
60 // Previously we're using "initial locale" that device initially
61 // booted with out-of-box. http://crbug.com/145142
62 std::string locale
= g_browser_process
->GetApplicationLocale();
63 std::string eula_page
= customization
->GetEULAPage(locale
);
64 if (!eula_page
.empty())
65 return GURL(eula_page
);
67 VLOG(1) << "No eula found for locale: " << locale
;
69 LOG(ERROR
) << "No manifest found.";
74 void EulaScreen::InitiatePasswordFetch() {
75 if (tpm_password_
.empty()) {
76 password_fetcher_
.Fetch();
77 // Will call view after password has been fetched.
79 view_
->OnPasswordFetched(tpm_password_
);
83 void EulaScreen::OnPasswordFetched(const std::string
& tpm_password
) {
84 tpm_password_
= tpm_password
;
86 view_
->OnPasswordFetched(tpm_password_
);
89 bool EulaScreen::IsUsageStatsEnabled() const {
90 return delegate_
&& delegate_
->GetUsageStatisticsReporting();
93 void EulaScreen::OnViewDestroyed(EulaView
* view
) {
98 void EulaScreen::OnUserAction(const std::string
& action_id
) {
99 if (action_id
== kUserActionAcceptButtonClicked
)
100 Finish(BaseScreenDelegate::EULA_ACCEPTED
);
101 else if (action_id
== kUserActionBackButtonClicked
)
102 Finish(BaseScreenDelegate::EULA_BACK
);
104 BaseScreen::OnUserAction(action_id
);
107 void EulaScreen::OnContextKeyUpdated(
108 const ::login::ScreenContext::KeyType
& key
) {
109 if (key
== kContextKeyUsageStatsEnabled
&& delegate_
) {
110 delegate_
->SetUsageStatisticsReporting(
111 context_
.GetBoolean(kContextKeyUsageStatsEnabled
));
115 } // namespace chromeos