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

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

Issue 2844383006: Turn ArcSupportHost from Observer model to Delegate (Closed)
Patch Set: addressed comments 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_->SetErrorDelegate(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_->SetErrorDelegate(nullptr);
451 support_host_->Close(); 452 support_host_->Close();
452 support_host_->RemoveObserver(this);
453 support_host_.reset(); 453 support_host_.reset();
454 } 454 }
455 context_.reset(); 455 context_.reset();
456 profile_ = nullptr; 456 profile_ = nullptr;
457 SetState(State::NOT_INITIALIZED); 457 SetState(State::NOT_INITIALIZED);
458 if (scoped_opt_in_tracker_) { 458 if (scoped_opt_in_tracker_) {
459 scoped_opt_in_tracker_->TrackShutdown(); 459 scoped_opt_in_tracker_->TrackShutdown();
460 scoped_opt_in_tracker_.reset(); 460 scoped_opt_in_tracker_.reset();
461 } 461 }
462 } 462 }
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 return; 946 return;
947 } 947 }
948 948
949 // Restart ARC anyway. Let the enterprise reporting instance decide whether 949 // Restart ARC anyway. Let the enterprise reporting instance decide whether
950 // the ARC user data wipe is still required or not. 950 // the ARC user data wipe is still required or not.
951 reenable_arc_ = false; 951 reenable_arc_ = false;
952 VLOG(1) << "Reenable ARC"; 952 VLOG(1) << "Reenable ARC";
953 RequestEnableImpl(); 953 RequestEnableImpl();
954 } 954 }
955 955
956 void ArcSessionManager::OnWindowClosed() { 956 void ArcSessionManager::OnOptInAborted() {
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(); 957 CancelAuthCode();
964 } 958 }
965 959
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() { 960 void ArcSessionManager::OnRetryClicked() {
975 DCHECK(support_host_); 961 DCHECK(support_host_);
962 DCHECK_EQ(support_host_->ui_page(), ArcSupportHost::UIPage::ERROR);
963 DCHECK(!terms_of_service_negotiator_);
hidehiko 2017/05/15 09:05:44 Could you verify that this is not a part of auth f
victorhsieh0 2017/05/15 22:31:53 Any suggestion on how to check this? Auth is most
hidehiko 2017/05/25 12:05:52 Three scenarios, I'm worried about. 1) - Enable AR
victorhsieh0 2017/05/26 19:38:41 Done. It's a bit hacky but please let me know if
hidehiko 2017/05/31 17:17:01 Thank you for manual check. Could you double check
victorhsieh0 2017/05/31 20:49:28 I see the problem now. How would you suggest to f
hidehiko 2017/06/01 16:25:58 I think kArcTermsAccepted sounds safer.
victorhsieh0 2017/06/01 21:27:23 Done. Reverted some changes here. Also added a T
976 964
977 UpdateOptInActionUMA(OptInActionType::RETRY); 965 UpdateOptInActionUMA(OptInActionType::RETRY);
978 966
979 // TODO(hidehiko): Simplify the retry logic. 967 if (arc_session_runner_->IsStopped()) {
hidehiko 2017/05/15 09:05:44 The condition looks negated? Unfortunately, it is
victorhsieh0 2017/05/15 22:31:53 Done.
980 if (terms_of_service_negotiator_) { 968 // ARC may be kept alive for the user to send feedback during some opt-in
981 // Currently Terms of service is shown. ArcTermsOfServiceNegotiator should 969 // failure, in order to include ARC's internal state into the report. Here,
982 // handle this. 970 // on retry, stop it, then restart.
983 } else if (!profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) {
984 MaybeStartTermsOfServiceNegotiation();
985 } else if (support_host_->ui_page() == ArcSupportHost::UIPage::ERROR &&
986 !arc_session_runner_->IsStopped()) {
987 // ERROR_WITH_FEEDBACK is set in OnSignInFailed(). In the case, stopping
988 // ARC was postponed to contain its internal state into the report.
989 // Here, on retry, stop it, then restart.
990 DCHECK_EQ(State::ACTIVE, state_); 971 DCHECK_EQ(State::ACTIVE, state_);
991 support_host_->ShowArcLoading(); 972 support_host_->ShowArcLoading();
992 ShutdownSession(); 973 ShutdownSession();
993 reenable_arc_ = true; 974 reenable_arc_ = true;
994 } else if (state_ == State::ACTIVE) {
995 // This case is handled in ArcAuthService.
996 // Do nothing.
997 } else { 975 } else {
998 // Otherwise, we restart ARC. Note: this is the first boot case. 976 // Otherwise, we simply start ARC again.
999 // For second or later boot, either ERROR_WITH_FEEDBACK case or ACTIVE
1000 // case must hit.
1001 StartAndroidManagementCheck(); 977 StartAndroidManagementCheck();
1002 } 978 }
1003 } 979 }
1004 980
1005 void ArcSessionManager::OnSendFeedbackClicked() { 981 void ArcSessionManager::OnSendFeedbackClicked() {
1006 DCHECK(support_host_); 982 DCHECK(support_host_);
1007 chrome::OpenFeedbackDialog(nullptr, chrome::kFeedbackSourceArcApp); 983 chrome::OpenFeedbackDialog(nullptr, chrome::kFeedbackSourceArcApp);
1008 } 984 }
1009 985
1010 void ArcSessionManager::SetArcSessionRunnerForTesting( 986 void ArcSessionManager::SetArcSessionRunnerForTesting(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 1025
1050 #undef MAP_STATE 1026 #undef MAP_STATE
1051 1027
1052 // Some compilers report an error even if all values of an enum-class are 1028 // Some compilers report an error even if all values of an enum-class are
1053 // covered exhaustively in a switch statement. 1029 // covered exhaustively in a switch statement.
1054 NOTREACHED() << "Invalid value " << static_cast<int>(state); 1030 NOTREACHED() << "Invalid value " << static_cast<int>(state);
1055 return os; 1031 return os;
1056 } 1032 }
1057 1033
1058 } // namespace arc 1034 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698