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

Side by Side Diff: chrome/browser/chromeos/arc/arc_session_manager.cc

Issue 2844383006: Turn ArcSupportHost from Observer model to Delegate (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/arc/arc_session_manager.h" 5 #include "chrome/browser/chromeos/arc/arc_session_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 // TODO(hidehiko): Revisit to think about lazy initialization. 419 // TODO(hidehiko): Revisit to think about lazy initialization.
420 // 420 //
421 // Don't show UI for ARC Kiosk because the only one UI in kiosk mode must 421 // Don't show UI for ARC Kiosk because the only one UI in kiosk mode must
422 // be the kiosk app. In case of error the UI will be useless as well, because 422 // be the kiosk app. In case of error the UI will be useless as well, because
423 // in typical use case there will be no one nearby the kiosk device, who can 423 // in typical use case there will be no one nearby the kiosk device, who can
424 // do some action to solve the problem be means of UI. 424 // do some action to solve the problem be means of UI.
425 if (!g_disable_ui_for_testing && !IsArcOptInVerificationDisabled() && 425 if (!g_disable_ui_for_testing && !IsArcOptInVerificationDisabled() &&
426 !IsArcKioskMode()) { 426 !IsArcKioskMode()) {
427 DCHECK(!support_host_); 427 DCHECK(!support_host_);
428 support_host_ = base::MakeUnique<ArcSupportHost>(profile_); 428 support_host_ = base::MakeUnique<ArcSupportHost>(profile_);
429 support_host_->AddObserver(this); 429 support_host_->SetErrorHandler(this);
430 } 430 }
431 431
432 DCHECK_EQ(State::NOT_INITIALIZED, state_); 432 DCHECK_EQ(State::NOT_INITIALIZED, state_);
433 SetState(State::STOPPED); 433 SetState(State::STOPPED);
434 434
435 context_ = base::MakeUnique<ArcAuthContext>(profile_); 435 context_ = base::MakeUnique<ArcAuthContext>(profile_);
436 436
437 if (!g_disable_ui_for_testing || 437 if (!g_disable_ui_for_testing ||
438 g_enable_check_android_management_for_testing) { 438 g_enable_check_android_management_for_testing) {
439 ArcAndroidManagementChecker::StartClient(); 439 ArcAndroidManagementChecker::StartClient();
440 } 440 }
441 441
442 // Chrome may be shut down before completing ARC data removal. 442 // Chrome may be shut down before completing ARC data removal.
443 // For such a case, start removing the data now, if necessary. 443 // For such a case, start removing the data now, if necessary.
444 MaybeStartArcDataRemoval(); 444 MaybeStartArcDataRemoval();
445 } 445 }
446 446
447 void ArcSessionManager::Shutdown() { 447 void ArcSessionManager::Shutdown() {
448 enable_requested_ = false; 448 enable_requested_ = false;
449 ShutdownSession(); 449 ShutdownSession();
450 if (support_host_) { 450 if (support_host_) {
451 support_host_->Close(); 451 support_host_->Close();
452 support_host_->RemoveObserver(this);
453 support_host_.reset(); 452 support_host_.reset();
454 } 453 }
455 context_.reset(); 454 context_.reset();
456 profile_ = nullptr; 455 profile_ = nullptr;
457 SetState(State::NOT_INITIALIZED); 456 SetState(State::NOT_INITIALIZED);
458 if (scoped_opt_in_tracker_) { 457 if (scoped_opt_in_tracker_) {
459 scoped_opt_in_tracker_->TrackShutdown(); 458 scoped_opt_in_tracker_->TrackShutdown();
460 scoped_opt_in_tracker_.reset(); 459 scoped_opt_in_tracker_.reset();
461 } 460 }
462 } 461 }
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 } 946 }
948 947
949 // Restart ARC anyway. Let the enterprise reporting instance decide whether 948 // Restart ARC anyway. Let the enterprise reporting instance decide whether
950 // the ARC user data wipe is still required or not. 949 // the ARC user data wipe is still required or not.
951 reenable_arc_ = false; 950 reenable_arc_ = false;
952 VLOG(1) << "Reenable ARC"; 951 VLOG(1) << "Reenable ARC";
953 RequestEnableImpl(); 952 RequestEnableImpl();
954 } 953 }
955 954
956 void ArcSessionManager::OnWindowClosed() { 955 void ArcSessionManager::OnWindowClosed() {
957 DCHECK(support_host_);
958 if (terms_of_service_negotiator_) {
959 // In this case, ArcTermsOfServiceNegotiator should handle the case.
960 // Do nothing.
961 return;
962 }
963 CancelAuthCode(); 956 CancelAuthCode();
964 } 957 }
965 958
966 void ArcSessionManager::OnTermsAgreed(bool is_metrics_enabled,
967 bool is_backup_and_restore_enabled,
968 bool is_location_service_enabled) {
969 DCHECK(support_host_);
970 DCHECK(terms_of_service_negotiator_);
971 // This should be handled in ArcTermsOfServiceNegotiator. Do nothing here.
972 }
973
974 void ArcSessionManager::OnRetryClicked() { 959 void ArcSessionManager::OnRetryClicked() {
975 DCHECK(support_host_); 960 DCHECK(support_host_);
976 961
977 UpdateOptInActionUMA(OptInActionType::RETRY); 962 UpdateOptInActionUMA(OptInActionType::RETRY);
978 963
979 // TODO(hidehiko): Simplify the retry logic. 964 // TODO(hidehiko): Simplify the retry logic.
980 if (terms_of_service_negotiator_) { 965 if (!profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) {
981 // Currently Terms of service is shown. ArcTermsOfServiceNegotiator should
982 // handle this.
983 } else if (!profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) {
984 MaybeStartTermsOfServiceNegotiation(); 966 MaybeStartTermsOfServiceNegotiation();
985 } else if (support_host_->ui_page() == ArcSupportHost::UIPage::ERROR && 967 } else if (support_host_->ui_page() == ArcSupportHost::UIPage::ERROR &&
986 !arc_session_runner_->IsStopped()) { 968 !arc_session_runner_->IsStopped()) {
987 // ERROR_WITH_FEEDBACK is set in OnSignInFailed(). In the case, stopping 969 // ERROR_WITH_FEEDBACK is set in OnSignInFailed(). In the case, stopping
988 // ARC was postponed to contain its internal state into the report. 970 // ARC was postponed to contain its internal state into the report.
989 // Here, on retry, stop it, then restart. 971 // Here, on retry, stop it, then restart.
990 DCHECK_EQ(State::ACTIVE, state_); 972 DCHECK_EQ(State::ACTIVE, state_);
991 support_host_->ShowArcLoading(); 973 support_host_->ShowArcLoading();
992 ShutdownSession(); 974 ShutdownSession();
993 reenable_arc_ = true; 975 reenable_arc_ = true;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 1031
1050 #undef MAP_STATE 1032 #undef MAP_STATE
1051 1033
1052 // Some compilers report an error even if all values of an enum-class are 1034 // Some compilers report an error even if all values of an enum-class are
1053 // covered exhaustively in a switch statement. 1035 // covered exhaustively in a switch statement.
1054 NOTREACHED() << "Invalid value " << static_cast<int>(state); 1036 NOTREACHED() << "Invalid value " << static_cast<int>(state);
1055 return os; 1037 return os;
1056 } 1038 }
1057 1039
1058 } // namespace arc 1040 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698