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

Unified Diff: chrome/browser/chromeos/arc/optin/arc_terms_of_service_oobe_negotiator.cc

Issue 2561023002: arc: ARC loading progress should not be shown when started from OOBE. (Closed)
Patch Set: refactored Created 3 years, 11 months 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 side-by-side diff with in-line comments
Download patch
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..dda1de66297cd7bc0dc5bf88c97295f31de5e78c
--- /dev/null
+++ b/chrome/browser/chromeos/arc/optin/arc_terms_of_service_oobe_negotiator.cc
@@ -0,0 +1,68 @@
+// 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"
+
+namespace arc {
+
+namespace {
+chromeos::ArcTermsOfServiceScreenActor* actor_for_testing = nullptr;
hidehiko 2017/01/30 10:12:36 nit: please insert an empty line above.
khmel 2017/01/31 02:47:09 Done.
+
+chromeos::ArcTermsOfServiceScreenActor* GetScreenActor() {
+ // Inject testing instance.
+ if (actor_for_testing)
+ return actor_for_testing;
+
+ chromeos::LoginDisplayHost* host = chromeos::LoginDisplayHost::default_host();
+ if (!host)
+ return nullptr;
+ DCHECK(host->GetOobeUI());
+ return host->GetOobeUI()->GetArcTermsOfServiceScreenActor();
+}
+
+} // namespace
+
+// static
+void ArcTermsOfServiceOobeNegotiator::SetArcTermsOfServiceScreenActorForTesting(
+ chromeos::ArcTermsOfServiceScreenActor* actor) {
+ actor_for_testing = actor;
+}
+
+ArcTermsOfServiceOobeNegotiator::ArcTermsOfServiceOobeNegotiator() = default;
+
+ArcTermsOfServiceOobeNegotiator::~ArcTermsOfServiceOobeNegotiator() = default;
+
+void ArcTermsOfServiceOobeNegotiator::StartNegotiationImpl() {
+ chromeos::ArcTermsOfServiceScreenActor* screen_actor = GetScreenActor();
+ DCHECK(screen_actor);
+ screen_actor->AddObserver(this);
+}
+
+void ArcTermsOfServiceOobeNegotiator::HandleTermsAccepted(bool accepted) {
+ chromeos::ArcTermsOfServiceScreenActor* screen_actor = GetScreenActor();
+ // In case called from OnActorDestroyed, screen actor is not available.
+ if (screen_actor)
hidehiko 2017/01/30 10:12:36 What situation |screen_actor| gets nullptr? IIUC,
khmel 2017/01/31 02:47:09 Done.
+ screen_actor->RemoveObserver(this);
+ ReportResult(accepted);
+}
+
+void ArcTermsOfServiceOobeNegotiator::OnSkip() {
+ HandleTermsAccepted(false);
+}
+
+void ArcTermsOfServiceOobeNegotiator::OnAccept() {
+ HandleTermsAccepted(true);
+}
+
+void ArcTermsOfServiceOobeNegotiator::OnActorDestroyed(
+ chromeos::ArcTermsOfServiceScreenActor* actor) {
+ HandleTermsAccepted(false);
+}
+
+} // namespace arc

Powered by Google App Engine
This is Rietveld 408576698