Chromium Code Reviews| Index: chrome/browser/chromeos/arc/optin/arc_terms_of_service_oobe_negotiator.cc |
| diff --git a/chrome/browser/chromeos/arc/optin/arc_terms_of_service_oobe_negotiator.cc b/chrome/browser/chromeos/arc/optin/arc_terms_of_service_oobe_negotiator.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a153b39f21066a0b92e770ebe57b62f79e731bbe |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/arc/optin/arc_terms_of_service_oobe_negotiator.cc |
| @@ -0,0 +1,57 @@ |
| +// Copyright 2016 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/arc/optin/arc_terms_of_service_oobe_negotiator.h" |
| + |
| +#include "base/bind.h" |
| +#include "chrome/browser/chromeos/login/screens/arc_terms_of_service_screen_actor.h" |
| +#include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| +#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| +#include "chrome/common/pref_names.h" |
| +#include "components/prefs/pref_service.h" |
| + |
| +namespace arc { |
| + |
| +ArcTermsOfServiceOOBENegotiator::ArcTermsOfServiceOOBENegotiator() = default; |
| + |
| +ArcTermsOfServiceOOBENegotiator::~ArcTermsOfServiceOOBENegotiator() { |
| + chromeos::LoginDisplayHost* host = chromeos::LoginDisplayHost::default_host(); |
| + if (host && host->GetOobeUI()) |
| + host->GetOobeUI()->GetArcTermsOfServiceScreenActor()->RemoveObserver(this); |
| +} |
| + |
| +void ArcTermsOfServiceOOBENegotiator::StartNegotiation( |
| + const NegotiationCallback& callback) { |
| + ArcTermsOfServiceNegotiator::StartNegotiation(callback); |
| + |
| + chromeos::LoginDisplayHost* host = chromeos::LoginDisplayHost::default_host(); |
| + if (!host || !host->GetOobeUI()) { |
|
hidehiko
2016/12/16 05:31:51
Could you comment when this happens?
Also, can we
khmel
2016/12/16 18:37:55
Changed to DCHECK
hidehiko
2016/12/19 15:49:44
Comments are still missing. Please find my comment
khmel
2016/12/19 17:48:10
Resolved in .h comments
|
| + ReportResult(false); |
| + return; |
| + } |
| + |
| + host->GetOobeUI()->GetArcTermsOfServiceScreenActor()->AddObserver(this); |
| +} |
| + |
| +void ArcTermsOfServiceOOBENegotiator::HandleTermsAccepted(bool accepted) { |
| + chromeos::LoginDisplayHost* host = chromeos::LoginDisplayHost::default_host(); |
| + DCHECK(host && host->GetOobeUI()); |
| + host->GetOobeUI()->GetArcTermsOfServiceScreenActor()->RemoveObserver(this); |
| + ReportResult(accepted); |
| +} |
| + |
| +void ArcTermsOfServiceOOBENegotiator::OnSkip() { |
| + HandleTermsAccepted(false); |
| +} |
| + |
| +void ArcTermsOfServiceOOBENegotiator::OnAccept() { |
| + HandleTermsAccepted(true); |
| +} |
| + |
| +void ArcTermsOfServiceOOBENegotiator::OnActorDestroyed( |
| + chromeos::ArcTermsOfServiceScreenActor* actor) { |
| + HandleTermsAccepted(false); |
| +} |
| + |
| +} // namespace arc |