| 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..96b3bdba02d2999d56ff5fe64c7d6cc253c1152d
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/arc/optin/arc_terms_of_service_oobe_negotiator.cc
|
| @@ -0,0 +1,61 @@
|
| +// 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(
|
| + PrefService* pref_service)
|
| + : pref_service_(pref_service) {}
|
| +
|
| +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()) {
|
| + 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);
|
| + if (accepted)
|
| + pref_service_->SetBoolean(prefs::kArcEnabled, true);
|
| + ReportResult(accepted);
|
| +}
|
| +
|
| +void ArcTermsOfServiceOOBENegotiator::OnSkip() {
|
| + HandleTermsAccepted(false);
|
| +}
|
| +
|
| +void ArcTermsOfServiceOOBENegotiator::OnAccept() {
|
| + HandleTermsAccepted(true);
|
| +}
|
| +
|
| +void ArcTermsOfServiceOOBENegotiator::OnActorDestroyed(
|
| + chromeos::ArcTermsOfServiceScreenActor* actor) {
|
| + HandleTermsAccepted(false);
|
| +}
|
| +
|
| +} // namespace arc
|
|
|