1 // Copyright (c) 2011 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/eula_screen.h"
7 #include "base/logging.h"
8 #include "chrome/browser/chromeos/cros/cros_library.h"
9 #include "chrome/browser/chromeos/cros/cryptohome_library.h"
10 #include "chrome/browser/chromeos/customization_document.h"
11 #include "chrome/browser/chromeos/login/screen_observer.h"
12 #include "chrome/browser/chromeos/login/views_eula_screen_actor.h"
16 const char kGoogleEulaUrl
[] = "about:terms";
22 EulaScreen::EulaScreen(::WizardScreenDelegate
* delegate
)
23 : WizardScreen(delegate
),
24 actor_(new ViewsEulaScreenActor(delegate
)) {
25 actor_
->SetDelegate(this);
28 EulaScreen::~EulaScreen() {
31 void EulaScreen::Show() {
32 // Command to own the TPM.
33 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) {
34 chromeos::CrosLibrary::Get()->
35 GetCryptohomeLibrary()->TpmCanAttemptOwnership();
37 LOG(ERROR
) << "Cros library not loaded. "
38 << "We must have disabled the link that led here.";
43 void EulaScreen::Hide() {
47 gfx::Size
EulaScreen::GetScreenSize() const {
48 return actor_
->GetScreenSize();
51 bool EulaScreen::IsTpmEnabled() const {
52 return chromeos::CrosLibrary::Get()->EnsureLoaded() &&
53 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary()->TpmIsEnabled();
56 GURL
EulaScreen::GetGoogleEulaUrl() const {
57 return GURL(kGoogleEulaUrl
);
60 GURL
EulaScreen::GetOemEulaUrl() const {
61 const StartupCustomizationDocument
* customization
=
62 StartupCustomizationDocument::GetInstance();
63 if (customization
->IsReady()) {
64 std::string locale
= customization
->initial_locale();
65 std::string eula_page
= customization
->GetEULAPage(locale
);
66 if (!eula_page
.empty())
67 return GURL(eula_page
);
69 VLOG(1) << "No eula found for locale: " << locale
;
71 LOG(ERROR
) << "No manifest found.";
76 void EulaScreen::OnExit(bool accepted
) {
77 ScreenObserver
* observer
= delegate()->GetObserver(this);
78 observer
->set_usage_statistics_reporting(actor_
->IsUsageStatsChecked());
79 observer
->OnExit(accepted
80 ? ScreenObserver::EULA_ACCEPTED
81 : ScreenObserver::EULA_BACK
);
84 std::string
* EulaScreen::GetTpmPasswordStorage() {
85 return &tpm_password_
;
88 bool EulaScreen::IsUsageStatsEnabled() const {
89 const ScreenObserver
* observer
= delegate()->GetObserver(this);
90 return observer
->usage_statistics_reporting();
93 } // namespace chromeos