Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / chromeos / login / screens / eula_screen.cc
blob98f5828873a8d68fdf6d78fa7b55982563241c0e
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"
7 #include "base/logging.h"
8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/chromeos/customization_document.h"
10 #include "chrome/browser/chromeos/login/screens/screen_observer.h"
11 #include "chrome/browser/chromeos/login/wizard_controller.h"
12 #include "chromeos/dbus/cryptohome_client.h"
13 #include "chromeos/dbus/dbus_method_call_status.h"
14 #include "chromeos/dbus/dbus_thread_manager.h"
16 namespace chromeos {
18 EulaScreen::EulaScreen(ScreenObserver* observer, EulaScreenActor* actor)
19 : WizardScreen(observer), actor_(actor), password_fetcher_(this) {
20 DCHECK(actor_);
21 if (actor_)
22 actor_->SetDelegate(this);
25 EulaScreen::~EulaScreen() {
26 if (actor_)
27 actor_->SetDelegate(NULL);
30 void EulaScreen::PrepareToShow() {
31 if (actor_)
32 actor_->PrepareToShow();
35 void EulaScreen::Show() {
36 // Command to own the TPM.
37 DBusThreadManager::Get()->GetCryptohomeClient()->TpmCanAttemptOwnership(
38 EmptyVoidDBusMethodCallback());
39 if (actor_)
40 actor_->Show();
43 void EulaScreen::Hide() {
44 if (actor_)
45 actor_->Hide();
48 std::string EulaScreen::GetName() const {
49 return WizardController::kEulaScreenName;
52 GURL EulaScreen::GetOemEulaUrl() const {
53 const StartupCustomizationDocument* customization =
54 StartupCustomizationDocument::GetInstance();
55 if (customization->IsReady()) {
56 // Previously we're using "initial locale" that device initially
57 // booted with out-of-box. http://crbug.com/145142
58 std::string locale = g_browser_process->GetApplicationLocale();
59 std::string eula_page = customization->GetEULAPage(locale);
60 if (!eula_page.empty())
61 return GURL(eula_page);
63 VLOG(1) << "No eula found for locale: " << locale;
64 } else {
65 LOG(ERROR) << "No manifest found.";
67 return GURL();
70 void EulaScreen::OnExit(bool accepted, bool usage_stats_enabled) {
71 get_screen_observer()->SetUsageStatisticsReporting(usage_stats_enabled);
72 get_screen_observer()->OnExit(accepted
73 ? ScreenObserver::EULA_ACCEPTED
74 : ScreenObserver::EULA_BACK);
77 void EulaScreen::InitiatePasswordFetch() {
78 if (tpm_password_.empty()) {
79 password_fetcher_.Fetch();
80 // Will call actor after password has been fetched.
81 } else if (actor_) {
82 actor_->OnPasswordFetched(tpm_password_);
86 void EulaScreen::OnPasswordFetched(const std::string& tpm_password) {
87 tpm_password_ = tpm_password;
88 if (actor_)
89 actor_->OnPasswordFetched(tpm_password_);
92 bool EulaScreen::IsUsageStatsEnabled() const {
93 return get_screen_observer()->GetUsageStatisticsReporting();
96 void EulaScreen::OnActorDestroyed(EulaScreenActor* actor) {
97 if (actor_ == actor)
98 actor_ = NULL;
101 } // namespace chromeos