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

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

Issue 2476973003: Remove initial_opt_in_ field. (Closed)
Patch Set: 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 if (state_ == State::ACTIVE) {
404 DCHECK_EQ(state_, State::ACTIVE); 404 DCHECK(IsAuthCodeRequest());
Luis Héctor Chávez 2016/11/04 22:37:54 How about DCHECK(state_ != State::ACTIVE || IsAuth
hidehiko 2016/11/04 22:42:42 Done.
405 initial_opt_in_ = false; 405 }
406 context_->PrepareContext(); 406 context_->PrepareContext();
407 } 407 }
408 408
409 void ArcAuthService::OnSignInComplete() { 409 void ArcAuthService::OnSignInComplete() {
410 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 410 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
411 DCHECK_EQ(state_, State::ACTIVE); 411 DCHECK_EQ(state_, State::ACTIVE);
412 412
413 if (!sign_in_time_.is_null()) { 413 if (!sign_in_time_.is_null()) {
414 arc_sign_in_timer_.Stop(); 414 arc_sign_in_timer_.Stop();
415 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, true, 415 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( 626 CHECK(extension && extensions::util::IsAppLaunchable(
627 ArcSupportHost::kHostAppId, profile_)); 627 ArcSupportHost::kHostAppId, profile_));
628 OpenApplication(CreateAppLaunchParamsUserContainer( 628 OpenApplication(CreateAppLaunchParamsUserContainer(
629 profile_, extension, WindowOpenDisposition::NEW_WINDOW, 629 profile_, extension, WindowOpenDisposition::NEW_WINDOW,
630 extensions::SOURCE_CHROME_INTERNAL)); 630 extensions::SOURCE_CHROME_INTERNAL));
631 } 631 }
632 632
633 void ArcAuthService::OnContextReady() { 633 void ArcAuthService::OnContextReady() {
634 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 634 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
635 635
636 DCHECK(!initial_opt_in_);
637
638 // TODO(hidehiko): The check is not necessary if this is a part of re-auth 636 // TODO(hidehiko): The check is not necessary if this is a part of re-auth
639 // flow. Remove this. 637 // flow. Remove this.
640 android_management_checker_.reset(new ArcAndroidManagementChecker( 638 android_management_checker_.reset(new ArcAndroidManagementChecker(
641 profile_, context_->token_service(), context_->account_id(), 639 profile_, context_->token_service(), context_->account_id(),
642 false /* retry_on_error */)); 640 false /* retry_on_error */));
643 android_management_checker_->StartCheck( 641 android_management_checker_->StartCheck(
644 base::Bind(&ArcAuthService::OnAndroidManagementChecked, 642 base::Bind(&ArcAuthService::OnAndroidManagementChecked,
645 weak_ptr_factory_.GetWeakPtr())); 643 weak_ptr_factory_.GetWeakPtr()));
646 } 644 }
647 645
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 return; 687 return;
690 } 688 }
691 689
692 if (state_ == State::ACTIVE) 690 if (state_ == State::ACTIVE)
693 return; 691 return;
694 CloseUI(); 692 CloseUI();
695 auth_code_.clear(); 693 auth_code_.clear();
696 694
697 if (!profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) { 695 if (!profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) {
698 // Need pre-fetch auth code and show OptIn UI if needed. 696 // Need pre-fetch auth code and show OptIn UI if needed.
699 initial_opt_in_ = true;
700 StartUI(); 697 StartUI();
701 } else { 698 } else {
702 // Ready to start Arc, but check Android management in parallel. 699 // Ready to start Arc, but check Android management in parallel.
703 StartArc(); 700 StartArc();
704 // Note: Because the callback may be called in synchronous way (i.e. called 701 // 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(). 702 // on the same stack), StartCheck() needs to be called *after* StartArc().
706 // Otherwise, DisableArc() which may be called in 703 // Otherwise, DisableArc() which may be called in
707 // OnBackgroundAndroidManagementChecked() could be ignored. 704 // OnBackgroundAndroidManagementChecked() could be ignored.
708 if (!g_disable_ui_for_testing || 705 if (!g_disable_ui_for_testing ||
709 g_enable_check_android_management_for_testing) { 706 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); 821 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
825 822
826 // Update UMA only if error (with or without feedback) is currently shown. 823 // Update UMA only if error (with or without feedback) is currently shown.
827 if (ui_page_ == UIPage::ERROR) { 824 if (ui_page_ == UIPage::ERROR) {
828 UpdateOptInActionUMA(OptInActionType::RETRY); 825 UpdateOptInActionUMA(OptInActionType::RETRY);
829 } else if (ui_page_ == UIPage::ERROR_WITH_FEEDBACK) { 826 } else if (ui_page_ == UIPage::ERROR_WITH_FEEDBACK) {
830 UpdateOptInActionUMA(OptInActionType::RETRY); 827 UpdateOptInActionUMA(OptInActionType::RETRY);
831 ShutdownBridge(); 828 ShutdownBridge();
832 } 829 }
833 830
834 // TODO(khmel): Use PrepareContextForAuthCodeRequest for this case. 831 DCHECK(!arc_bridge_service()->stopped());
Luis Héctor Chávez 2016/11/04 22:37:54 DCHECK(arc_bridge_service()->stopped());
hidehiko 2016/11/04 22:42:42 Ugrrr... Good catch. Fixed.
835 initial_opt_in_ = false; 832 SetState(State::FETCHING_CODE);
836 StartUI(); 833 PrepareContextForAuthCodeRequest();
837 } 834 }
838 835
839 void ArcAuthService::CancelAuthCode() { 836 void ArcAuthService::CancelAuthCode() {
840 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 837 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
841 838
842 if (state_ == State::NOT_INITIALIZED) { 839 if (state_ == State::NOT_INITIALIZED) {
843 NOTREACHED(); 840 NOTREACHED();
844 return; 841 return;
845 } 842 }
846 843
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 902
906 if (!arc_bridge_service()->stopped()) { 903 if (!arc_bridge_service()->stopped()) {
907 // If the user attempts to re-enable ARC while the bridge is still running 904 // 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. 905 // the user should not be able to continue until the bridge has stopped.
909 ShowUI(UIPage::ERROR, l10n_util::GetStringUTF16( 906 ShowUI(UIPage::ERROR, l10n_util::GetStringUTF16(
910 IDS_ARC_SIGN_IN_SERVICE_UNAVAILABLE_ERROR)); 907 IDS_ARC_SIGN_IN_SERVICE_UNAVAILABLE_ERROR));
911 return; 908 return;
912 } 909 }
913 910
914 SetState(State::FETCHING_CODE); 911 SetState(State::FETCHING_CODE);
915 912 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 } 913 }
923 914
924 void ArcAuthService::OnPrepareContextFailed() { 915 void ArcAuthService::OnPrepareContextFailed() {
925 DCHECK_EQ(state_, State::FETCHING_CODE); 916 DCHECK_EQ(state_, State::FETCHING_CODE);
926 917
927 ShutdownBridgeAndShowUI( 918 ShutdownBridgeAndShowUI(
928 UIPage::ERROR, 919 UIPage::ERROR,
929 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); 920 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR));
930 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); 921 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR);
931 } 922 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 return os << "FETCHING_CODE"; 1019 return os << "FETCHING_CODE";
1029 case ArcAuthService::State::ACTIVE: 1020 case ArcAuthService::State::ACTIVE:
1030 return os << "ACTIVE"; 1021 return os << "ACTIVE";
1031 default: 1022 default:
1032 NOTREACHED(); 1023 NOTREACHED();
1033 return os; 1024 return os;
1034 } 1025 }
1035 } 1026 }
1036 1027
1037 } // namespace arc 1028 } // 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