Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / chromeos / login / screens / eula_screen.cc
blob42306b123a5bacb1370a3a3cffb8e7ba12c37eea
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/bind.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"
18 namespace chromeos {
20 EulaScreen::EulaScreen(BaseScreenDelegate* base_screen_delegate,
21 Delegate* delegate,
22 EulaView* view)
23 : EulaModel(base_screen_delegate),
24 delegate_(delegate),
25 view_(view),
26 password_fetcher_(this) {
27 DCHECK(view_);
28 DCHECK(delegate_);
29 if (view_)
30 view_->Bind(*this);
33 EulaScreen::~EulaScreen() {
34 if (view_)
35 view_->Unbind();
38 void EulaScreen::PrepareToShow() {
39 if (view_)
40 view_->PrepareToShow();
43 void EulaScreen::Show() {
44 // Command to own the TPM.
45 DBusThreadManager::Get()->GetCryptohomeClient()->TpmCanAttemptOwnership(
46 EmptyVoidDBusMethodCallback());
47 if (view_)
48 view_->Show();
51 void EulaScreen::Hide() {
52 if (view_)
53 view_->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;
68 } else {
69 LOG(ERROR) << "No manifest found.";
71 return GURL();
74 void EulaScreen::InitiatePasswordFetch() {
75 if (tpm_password_.empty()) {
76 password_fetcher_.Fetch();
77 // Will call view after password has been fetched.
78 } else if (view_) {
79 view_->OnPasswordFetched(tpm_password_);
83 void EulaScreen::OnPasswordFetched(const std::string& tpm_password) {
84 tpm_password_ = tpm_password;
85 if (view_)
86 view_->OnPasswordFetched(tpm_password_);
89 bool EulaScreen::IsUsageStatsEnabled() const {
90 return delegate_ && delegate_->GetUsageStatisticsReporting();
93 void EulaScreen::OnViewDestroyed(EulaView* view) {
94 if (view_ == view)
95 view_ = NULL;
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);
103 else
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