summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/login/eula_screen.cc
blob: e4b0d52c070a49fc780a53ce09c705214ba532f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/chromeos/login/eula_screen.h"

#include "base/logging.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/cryptohome_library.h"
#include "chrome/browser/chromeos/customization_document.h"
#include "chrome/browser/chromeos/login/screen_observer.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"

namespace chromeos {

EulaScreen::EulaScreen(ScreenObserver* observer, EulaScreenActor* actor)
    : WizardScreen(observer), actor_(actor), password_fetcher_(this) {
  actor_->SetDelegate(this);
}

EulaScreen::~EulaScreen() {
  if (actor_)
    actor_->SetDelegate(NULL);
}

void EulaScreen::PrepareToShow() {
  actor_->PrepareToShow();
}

void EulaScreen::Show() {
  // Command to own the TPM.
  chromeos::CrosLibrary::Get()->
      GetCryptohomeLibrary()->TpmCanAttemptOwnership();
  actor_->Show();
}

void EulaScreen::Hide() {
  actor_->Hide();
}

std::string EulaScreen::GetName() const {
  return WizardController::kEulaScreenName;
}

bool EulaScreen::IsTpmEnabled() const {
  return chromeos::CrosLibrary::Get()->GetCryptohomeLibrary()->TpmIsEnabled();
}

GURL EulaScreen::GetOemEulaUrl() const {
  const StartupCustomizationDocument* customization =
      StartupCustomizationDocument::GetInstance();
  if (customization->IsReady()) {
    std::string locale = customization->initial_locale();
    std::string eula_page = customization->GetEULAPage(locale);
    if (!eula_page.empty())
      return GURL(eula_page);

    VLOG(1) << "No eula found for locale: " << locale;
  } else {
    LOG(ERROR) << "No manifest found.";
  }
  return GURL();
}

void EulaScreen::OnExit(bool accepted, bool is_usage_stats_checked) {
  get_screen_observer()->SetUsageStatisticsReporting(is_usage_stats_checked);
  get_screen_observer()->OnExit(accepted
                   ? ScreenObserver::EULA_ACCEPTED
                   : ScreenObserver::EULA_BACK);
}

void EulaScreen::InitiatePasswordFetch() {
  if (tpm_password_.empty()) {
    password_fetcher_.Fetch();
    // Will call actor after password has been fetched.
  } else {
    actor_->OnPasswordFetched(tpm_password_);
  }
}

void EulaScreen::OnPasswordFetched(const std::string& tpm_password) {
  tpm_password_ = tpm_password;
  if (actor_)
    actor_->OnPasswordFetched(tpm_password_);
}

bool EulaScreen::IsUsageStatsEnabled() const {
  return get_screen_observer()->GetUsageStatisticsReporting();
}

void EulaScreen::OnActorDestroyed(EulaScreenActor* actor) {
  if (actor_ == actor)
    actor_ = NULL;
}

}  // namespace chromeos