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

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

Issue 2476973003: Remove initial_opt_in_ field. (Closed)
Patch Set: Address comment.s Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/chromeos/arc/arc_auth_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_auth_service.h" 5 #include "chrome/browser/chromeos/arc/arc_auth_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/shelf/shelf_delegate.h" 9 #include "ash/common/shelf/shelf_delegate.h"
10 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 return account_info_notifier_ != nullptr; 393 return account_info_notifier_ != nullptr;
394 } 394 }
395 395
396 void ArcAuthService::PrepareContextForAuthCodeRequest() { 396 void ArcAuthService::PrepareContextForAuthCodeRequest() {
397 // Requesting auth code on demand happens in following cases: 397 // Requesting auth code on demand happens in following cases:
398 // 1. To handle account password revoke. 398 // 1. To handle account password revoke.
399 // 2. In case Arc is activated in OOBE flow. 399 // 2. In case Arc is activated in OOBE flow.
400 // 3. For any other state on Android side that leads device appears in 400 // 3. For any other state on Android side that leads device appears in
401 // non-signed state. 401 // non-signed state.
402 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 402 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
403 DCHECK(IsAuthCodeRequest()); 403 DCHECK(state_ != State::ACTIVE || IsAuthCodeRequest());
404 DCHECK_EQ(state_, State::ACTIVE);
405 initial_opt_in_ = false;
406 context_->PrepareContext(); 404 context_->PrepareContext();
407 } 405 }
408 406
409 void ArcAuthService::OnSignInComplete() { 407 void ArcAuthService::OnSignInComplete() {
410 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 408 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
411 DCHECK_EQ(state_, State::ACTIVE); 409 DCHECK_EQ(state_, State::ACTIVE);
412 410
413 if (!sign_in_time_.is_null()) { 411 if (!sign_in_time_.is_null()) {
414 arc_sign_in_timer_.Stop(); 412 arc_sign_in_timer_.Stop();
415 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, true, 413 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, true,
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 CHECK(extension && extensions::util::IsAppLaunchable( 624 CHECK(extension && extensions::util::IsAppLaunchable(
627 ArcSupportHost::kHostAppId, profile_)); 625 ArcSupportHost::kHostAppId, profile_));
628 OpenApplication(CreateAppLaunchParamsUserContainer( 626 OpenApplication(CreateAppLaunchParamsUserContainer(
629 profile_, extension, WindowOpenDisposition::NEW_WINDOW, 627 profile_, extension, WindowOpenDisposition::NEW_WINDOW,
630 extensions::SOURCE_CHROME_INTERNAL)); 628 extensions::SOURCE_CHROME_INTERNAL));
631 } 629 }
632 630
633 void ArcAuthService::OnContextReady() { 631 void ArcAuthService::OnContextReady() {
634 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 632 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
635 633
636 DCHECK(!initial_opt_in_);
637
638 // TODO(hidehiko): The check is not necessary if this is a part of re-auth 634 // TODO(hidehiko): The check is not necessary if this is a part of re-auth
639 // flow. Remove this. 635 // flow. Remove this.
640 android_management_checker_.reset(new ArcAndroidManagementChecker( 636 android_management_checker_.reset(new ArcAndroidManagementChecker(
641 profile_, context_->token_service(), context_->account_id(), 637 profile_, context_->token_service(), context_->account_id(),
642 false /* retry_on_error */)); 638 false /* retry_on_error */));
643 android_management_checker_->StartCheck( 639 android_management_checker_->StartCheck(
644 base::Bind(&ArcAuthService::OnAndroidManagementChecked, 640 base::Bind(&ArcAuthService::OnAndroidManagementChecked,
645 weak_ptr_factory_.GetWeakPtr())); 641 weak_ptr_factory_.GetWeakPtr()));
646 } 642 }
647 643
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 return; 685 return;
690 } 686 }
691 687
692 if (state_ == State::ACTIVE) 688 if (state_ == State::ACTIVE)
693 return; 689 return;
694 CloseUI(); 690 CloseUI();
695 auth_code_.clear(); 691 auth_code_.clear();
696 692
697 if (!profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) { 693 if (!profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) {
698 // Need pre-fetch auth code and show OptIn UI if needed. 694 // Need pre-fetch auth code and show OptIn UI if needed.
699 initial_opt_in_ = true;
700 StartUI(); 695 StartUI();
701 } else { 696 } else {
702 // Ready to start Arc, but check Android management in parallel. 697 // Ready to start Arc, but check Android management in parallel.
703 StartArc(); 698 StartArc();
704 // Note: Because the callback may be called in synchronous way (i.e. called 699 // Note: Because the callback may be called in synchronous way (i.e. called
705 // on the same stack), StartCheck() needs to be called *after* StartArc(). 700 // on the same stack), StartCheck() needs to be called *after* StartArc().
706 // Otherwise, DisableArc() which may be called in 701 // Otherwise, DisableArc() which may be called in
707 // OnBackgroundAndroidManagementChecked() could be ignored. 702 // OnBackgroundAndroidManagementChecked() could be ignored.
708 if (!g_disable_ui_for_testing || 703 if (!g_disable_ui_for_testing ||
709 g_enable_check_android_management_for_testing) { 704 g_enable_check_android_management_for_testing) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 819 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
825 820
826 // Update UMA only if error (with or without feedback) is currently shown. 821 // Update UMA only if error (with or without feedback) is currently shown.
827 if (ui_page_ == UIPage::ERROR) { 822 if (ui_page_ == UIPage::ERROR) {
828 UpdateOptInActionUMA(OptInActionType::RETRY); 823 UpdateOptInActionUMA(OptInActionType::RETRY);
829 } else if (ui_page_ == UIPage::ERROR_WITH_FEEDBACK) { 824 } else if (ui_page_ == UIPage::ERROR_WITH_FEEDBACK) {
830 UpdateOptInActionUMA(OptInActionType::RETRY); 825 UpdateOptInActionUMA(OptInActionType::RETRY);
831 ShutdownBridge(); 826 ShutdownBridge();
832 } 827 }
833 828
834 // TODO(khmel): Use PrepareContextForAuthCodeRequest for this case. 829 DCHECK(arc_bridge_service()->stopped());
835 initial_opt_in_ = false; 830 SetState(State::FETCHING_CODE);
836 StartUI(); 831 PrepareContextForAuthCodeRequest();
837 } 832 }
838 833
839 void ArcAuthService::CancelAuthCode() { 834 void ArcAuthService::CancelAuthCode() {
840 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 835 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
841 836
842 if (state_ == State::NOT_INITIALIZED) { 837 if (state_ == State::NOT_INITIALIZED) {
843 NOTREACHED(); 838 NOTREACHED();
844 return; 839 return;
845 } 840 }
846 841
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 900
906 if (!arc_bridge_service()->stopped()) { 901 if (!arc_bridge_service()->stopped()) {
907 // If the user attempts to re-enable ARC while the bridge is still running 902 // If the user attempts to re-enable ARC while the bridge is still running
908 // the user should not be able to continue until the bridge has stopped. 903 // the user should not be able to continue until the bridge has stopped.
909 ShowUI(UIPage::ERROR, l10n_util::GetStringUTF16( 904 ShowUI(UIPage::ERROR, l10n_util::GetStringUTF16(
910 IDS_ARC_SIGN_IN_SERVICE_UNAVAILABLE_ERROR)); 905 IDS_ARC_SIGN_IN_SERVICE_UNAVAILABLE_ERROR));
911 return; 906 return;
912 } 907 }
913 908
914 SetState(State::FETCHING_CODE); 909 SetState(State::FETCHING_CODE);
915 910 ShowUI(UIPage::TERMS, base::string16());
916 if (initial_opt_in_) {
917 initial_opt_in_ = false;
918 ShowUI(UIPage::TERMS, base::string16());
919 } else {
920 context_->PrepareContext();
921 }
922 } 911 }
923 912
924 void ArcAuthService::OnPrepareContextFailed() { 913 void ArcAuthService::OnPrepareContextFailed() {
925 DCHECK_EQ(state_, State::FETCHING_CODE); 914 DCHECK_EQ(state_, State::FETCHING_CODE);
926 915
927 ShutdownBridgeAndShowUI( 916 ShutdownBridgeAndShowUI(
928 UIPage::ERROR, 917 UIPage::ERROR,
929 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); 918 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR));
930 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); 919 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR);
931 } 920 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 return os << "FETCHING_CODE"; 1017 return os << "FETCHING_CODE";
1029 case ArcAuthService::State::ACTIVE: 1018 case ArcAuthService::State::ACTIVE:
1030 return os << "ACTIVE"; 1019 return os << "ACTIVE";
1031 default: 1020 default:
1032 NOTREACHED(); 1021 NOTREACHED();
1033 return os; 1022 return os;
1034 } 1023 }
1035 } 1024 }
1036 1025
1037 } // namespace arc 1026 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_auth_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698