Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/login/screens/eula_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/eula_screen.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/chromeos/customization_document.h" | 11 #include "chrome/browser/chromeos/customization_document.h" |
| 12 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h" | 12 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h" |
| 13 #include "chrome/browser/chromeos/login/screens/eula_view.h" | 13 #include "chrome/browser/chromeos/login/screens/eula_view.h" |
| 14 #include "chromeos/dbus/cryptohome_client.h" | 14 #include "chromeos/dbus/cryptohome_client.h" |
| 15 #include "chromeos/dbus/dbus_method_call_status.h" | 15 #include "chromeos/dbus/dbus_method_call_status.h" |
| 16 #include "chromeos/dbus/dbus_thread_manager.h" | 16 #include "chromeos/dbus/dbus_thread_manager.h" |
| 17 | 17 |
| 18 namespace chromeos { | 18 namespace chromeos { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 const char kButtonIdAccept[] = "accept-button"; | |
|
dzhioev (left Google)
2014/11/27 12:08:51
This constants should be defined in EulaModel, bec
Denis Kuznetsov (DE-MUC)
2014/11/27 13:51:41
Acknowledged.
ygorshenin1
2014/11/27 14:11:13
Done.
| |
| 23 const char kButtonIdBack[] = "back-button"; | |
| 22 const char kContextKeyUsageStatsEnabled[] = "usageStatsEnabled"; | 24 const char kContextKeyUsageStatsEnabled[] = "usageStatsEnabled"; |
| 23 | 25 |
| 24 } // namespace | 26 } // namespace |
| 25 | 27 |
| 26 EulaScreen::EulaScreen(BaseScreenDelegate* base_screen_delegate, | 28 EulaScreen::EulaScreen(BaseScreenDelegate* base_screen_delegate, |
| 27 Delegate* delegate, | 29 Delegate* delegate, |
| 28 EulaView* view) | 30 EulaView* view) |
| 29 : EulaModel(base_screen_delegate), | 31 : EulaModel(base_screen_delegate), |
| 30 delegate_(delegate), | 32 delegate_(delegate), |
| 31 view_(view), | 33 view_(view), |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 if (!eula_page.empty()) | 72 if (!eula_page.empty()) |
| 71 return GURL(eula_page); | 73 return GURL(eula_page); |
| 72 | 74 |
| 73 VLOG(1) << "No eula found for locale: " << locale; | 75 VLOG(1) << "No eula found for locale: " << locale; |
| 74 } else { | 76 } else { |
| 75 LOG(ERROR) << "No manifest found."; | 77 LOG(ERROR) << "No manifest found."; |
| 76 } | 78 } |
| 77 return GURL(); | 79 return GURL(); |
| 78 } | 80 } |
| 79 | 81 |
| 80 void EulaScreen::OnAcceptButtonClicked() { | |
| 81 Finish(BaseScreenDelegate::EULA_ACCEPTED); | |
| 82 } | |
| 83 | |
| 84 void EulaScreen::OnBackButtonClicked() { | |
| 85 Finish(BaseScreenDelegate::EULA_BACK); | |
| 86 } | |
| 87 | |
| 88 void EulaScreen::InitiatePasswordFetch() { | 82 void EulaScreen::InitiatePasswordFetch() { |
| 89 if (tpm_password_.empty()) { | 83 if (tpm_password_.empty()) { |
| 90 password_fetcher_.Fetch(); | 84 password_fetcher_.Fetch(); |
| 91 // Will call view after password has been fetched. | 85 // Will call view after password has been fetched. |
| 92 } else if (view_) { | 86 } else if (view_) { |
| 93 view_->OnPasswordFetched(tpm_password_); | 87 view_->OnPasswordFetched(tpm_password_); |
| 94 } | 88 } |
| 95 } | 89 } |
| 96 | 90 |
| 97 void EulaScreen::OnPasswordFetched(const std::string& tpm_password) { | 91 void EulaScreen::OnPasswordFetched(const std::string& tpm_password) { |
| 98 tpm_password_ = tpm_password; | 92 tpm_password_ = tpm_password; |
| 99 if (view_) | 93 if (view_) |
| 100 view_->OnPasswordFetched(tpm_password_); | 94 view_->OnPasswordFetched(tpm_password_); |
| 101 } | 95 } |
| 102 | 96 |
| 103 bool EulaScreen::IsUsageStatsEnabled() const { | 97 bool EulaScreen::IsUsageStatsEnabled() const { |
| 104 return delegate_ && delegate_->GetUsageStatisticsReporting(); | 98 return delegate_ && delegate_->GetUsageStatisticsReporting(); |
| 105 } | 99 } |
| 106 | 100 |
| 107 void EulaScreen::OnViewDestroyed(EulaView* view) { | 101 void EulaScreen::OnViewDestroyed(EulaView* view) { |
| 108 if (view_ == view) | 102 if (view_ == view) |
| 109 view_ = NULL; | 103 view_ = NULL; |
| 110 } | 104 } |
| 111 | 105 |
| 106 void EulaScreen::OnButtonClicked(const std::string& button_id) { | |
| 107 if (button_id == kButtonIdAccept) | |
| 108 Finish(BaseScreenDelegate::EULA_ACCEPTED); | |
| 109 else if (button_id == kButtonIdBack) | |
| 110 Finish(BaseScreenDelegate::EULA_BACK); | |
| 111 else | |
|
Denis Kuznetsov (DE-MUC)
2014/11/27 13:51:41
I'd prefer to call the parent in the else-case and
ygorshenin1
2014/11/27 14:11:13
Done.
| |
| 112 LOG(ERROR) << "Unknown button: " << button_id; | |
| 113 } | |
| 114 | |
| 112 void EulaScreen::OnContextKeyUpdated( | 115 void EulaScreen::OnContextKeyUpdated( |
| 113 const ::login::ScreenContext::KeyType& key) { | 116 const ::login::ScreenContext::KeyType& key) { |
| 114 if (key == kContextKeyUsageStatsEnabled && delegate_) { | 117 if (key == kContextKeyUsageStatsEnabled && delegate_) { |
| 115 delegate_->SetUsageStatisticsReporting( | 118 delegate_->SetUsageStatisticsReporting( |
| 116 context_.GetBoolean(kContextKeyUsageStatsEnabled)); | 119 context_.GetBoolean(kContextKeyUsageStatsEnabled)); |
| 117 } | 120 } |
| 118 } | 121 } |
| 119 | 122 |
| 120 } // namespace chromeos | 123 } // namespace chromeos |
| OLD | NEW |