Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(560)

Side by Side Diff: chrome/browser/chromeos/login/screens/eula_screen.cc

Issue 763563002: Implemented event-dispatching for button clicks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 {
21
22 const char kContextKeyUsageStatsEnabled[] = "usageStatsEnabled";
23
24 } // namespace
25
26 EulaScreen::EulaScreen(BaseScreenDelegate* base_screen_delegate, 20 EulaScreen::EulaScreen(BaseScreenDelegate* base_screen_delegate,
27 Delegate* delegate, 21 Delegate* delegate,
28 EulaView* view) 22 EulaView* view)
29 : EulaModel(base_screen_delegate), 23 : EulaModel(base_screen_delegate),
30 delegate_(delegate), 24 delegate_(delegate),
31 view_(view), 25 view_(view),
32 password_fetcher_(this) { 26 password_fetcher_(this) {
33 DCHECK(view_); 27 DCHECK(view_);
34 DCHECK(delegate_); 28 DCHECK(delegate_);
35 if (view_) 29 if (view_)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 if (!eula_page.empty()) 64 if (!eula_page.empty())
71 return GURL(eula_page); 65 return GURL(eula_page);
72 66
73 VLOG(1) << "No eula found for locale: " << locale; 67 VLOG(1) << "No eula found for locale: " << locale;
74 } else { 68 } else {
75 LOG(ERROR) << "No manifest found."; 69 LOG(ERROR) << "No manifest found.";
76 } 70 }
77 return GURL(); 71 return GURL();
78 } 72 }
79 73
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() { 74 void EulaScreen::InitiatePasswordFetch() {
89 if (tpm_password_.empty()) { 75 if (tpm_password_.empty()) {
90 password_fetcher_.Fetch(); 76 password_fetcher_.Fetch();
91 // Will call view after password has been fetched. 77 // Will call view after password has been fetched.
92 } else if (view_) { 78 } else if (view_) {
93 view_->OnPasswordFetched(tpm_password_); 79 view_->OnPasswordFetched(tpm_password_);
94 } 80 }
95 } 81 }
96 82
97 void EulaScreen::OnPasswordFetched(const std::string& tpm_password) { 83 void EulaScreen::OnPasswordFetched(const std::string& tpm_password) {
98 tpm_password_ = tpm_password; 84 tpm_password_ = tpm_password;
99 if (view_) 85 if (view_)
100 view_->OnPasswordFetched(tpm_password_); 86 view_->OnPasswordFetched(tpm_password_);
101 } 87 }
102 88
103 bool EulaScreen::IsUsageStatsEnabled() const { 89 bool EulaScreen::IsUsageStatsEnabled() const {
104 return delegate_ && delegate_->GetUsageStatisticsReporting(); 90 return delegate_ && delegate_->GetUsageStatisticsReporting();
105 } 91 }
106 92
107 void EulaScreen::OnViewDestroyed(EulaView* view) { 93 void EulaScreen::OnViewDestroyed(EulaView* view) {
108 if (view_ == view) 94 if (view_ == view)
109 view_ = NULL; 95 view_ = NULL;
110 } 96 }
111 97
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);
105 }
106
112 void EulaScreen::OnContextKeyUpdated( 107 void EulaScreen::OnContextKeyUpdated(
113 const ::login::ScreenContext::KeyType& key) { 108 const ::login::ScreenContext::KeyType& key) {
114 if (key == kContextKeyUsageStatsEnabled && delegate_) { 109 if (key == kContextKeyUsageStatsEnabled && delegate_) {
115 delegate_->SetUsageStatisticsReporting( 110 delegate_->SetUsageStatisticsReporting(
116 context_.GetBoolean(kContextKeyUsageStatsEnabled)); 111 context_.GetBoolean(kContextKeyUsageStatsEnabled));
117 } 112 }
118 } 113 }
119 114
120 } // namespace chromeos 115 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/screens/eula_screen.h ('k') | chrome/browser/chromeos/login/ui/oobe_display.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698