OLD | NEW |
---|---|
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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 void ArcAuthService::GetAuthCodeDeprecated( | 297 void ArcAuthService::GetAuthCodeDeprecated( |
298 const GetAuthCodeDeprecatedCallback& callback) { | 298 const GetAuthCodeDeprecatedCallback& callback) { |
299 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 299 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
300 DCHECK(!IsOptInVerificationDisabled()); | 300 DCHECK(!IsOptInVerificationDisabled()); |
301 callback.Run(GetAndResetAuthCode()); | 301 callback.Run(GetAndResetAuthCode()); |
302 } | 302 } |
303 | 303 |
304 void ArcAuthService::GetAuthCode(const GetAuthCodeCallback& callback) { | 304 void ArcAuthService::GetAuthCode(const GetAuthCodeCallback& callback) { |
305 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 305 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
306 // GetAuthCodeAndAccountType operation must not be in progress. | 306 // GetAuthCodeAndAccountType operation must not be in progress. |
307 DCHECK(!auth_account_callback_.is_null()); | 307 DCHECK(auth_account_callback_.is_null()); |
308 | 308 |
309 const std::string auth_code = GetAndResetAuthCode(); | 309 const std::string auth_code = GetAndResetAuthCode(); |
310 const bool verification_disabled = IsOptInVerificationDisabled(); | 310 const bool verification_disabled = IsOptInVerificationDisabled(); |
311 if (!auth_code.empty() || verification_disabled) { | 311 if (!auth_code.empty() || verification_disabled) { |
312 callback.Run(auth_code, !verification_disabled); | 312 callback.Run(auth_code, !verification_disabled); |
313 return; | 313 return; |
314 } | 314 } |
315 | 315 |
316 initial_opt_in_ = false; | 316 initial_opt_in_ = false; |
317 auth_callback_ = callback; | 317 auth_callback_ = callback; |
318 StartUI(); | 318 StartUI(); |
319 } | 319 } |
320 | 320 |
321 void ArcAuthService::GetAuthCodeAndAccountType( | 321 void ArcAuthService::GetAuthCodeAndAccountType( |
322 const GetAuthCodeAndAccountTypeCallback& callback) { | 322 const GetAuthCodeAndAccountTypeCallback& callback) { |
323 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 323 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
324 // GetAuthCode operation must not be in progress. | 324 // GetAuthCode operation must not be in progress. |
325 DCHECK(!auth_callback_.is_null()); | 325 DCHECK(auth_callback_.is_null()); |
326 | 326 |
327 const std::string auth_code = GetAndResetAuthCode(); | 327 const std::string auth_code = GetAndResetAuthCode(); |
328 const bool verification_disabled = IsOptInVerificationDisabled(); | 328 const bool verification_disabled = IsOptInVerificationDisabled(); |
329 if (!auth_code.empty() || verification_disabled) { | 329 if (!auth_code.empty() || verification_disabled) { |
330 callback.Run(auth_code, !verification_disabled, | 330 callback.Run(auth_code, !verification_disabled, |
331 mojom::ChromeAccountType::USER_ACCOUNT); | 331 mojom::ChromeAccountType::USER_ACCOUNT); |
332 return; | 332 return; |
333 } | 333 } |
334 | 334 |
335 initial_opt_in_ = false; | 335 initial_opt_in_ = false; |
336 auth_account_callback_ = callback; | 336 auth_account_callback_ = callback; |
337 StartUI(); | 337 StartUI(); |
338 } | 338 } |
339 | 339 |
340 bool ArcAuthService::IsAuthCodeRequest() { | |
341 return !auth_callback_.is_null() || !auth_account_callback_.is_null(); | |
342 } | |
343 | |
340 void ArcAuthService::OnSignInComplete() { | 344 void ArcAuthService::OnSignInComplete() { |
341 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 345 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
342 DCHECK_EQ(state_, State::ACTIVE); | 346 DCHECK_EQ(state_, State::ACTIVE); |
343 DCHECK(!sign_in_time_.is_null()); | 347 DCHECK(!sign_in_time_.is_null()); |
344 | 348 |
345 arc_sign_in_timer_.Stop(); | 349 arc_sign_in_timer_.Stop(); |
346 | 350 |
347 if (!IsOptInVerificationDisabled() && | 351 if (!IsOptInVerificationDisabled() && |
348 !profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) { | 352 !profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) { |
349 playstore_launcher_.reset( | 353 playstore_launcher_.reset( |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
804 if (!IsArcManaged()) | 808 if (!IsArcManaged()) |
805 profile_->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); | 809 profile_->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); |
806 } | 810 } |
807 | 811 |
808 void ArcAuthService::DisableArc() { | 812 void ArcAuthService::DisableArc() { |
809 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 813 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
810 DCHECK(profile_); | 814 DCHECK(profile_); |
811 profile_->GetPrefs()->SetBoolean(prefs::kArcEnabled, false); | 815 profile_->GetPrefs()->SetBoolean(prefs::kArcEnabled, false); |
812 } | 816 } |
813 | 817 |
814 void ArcAuthService::StartUI() { | 818 void ArcAuthService::StartUI() { |
hidehiko
2016/10/13 15:22:00
StartUI is called only from four places.
- GetAuth
khmel
2016/10/13 15:30:19
Checks I added is real condition that prevents And
hidehiko
2016/10/13 15:44:32
I meant;
- StartLso() should not use StartUI() con
khmel
2016/10/13 15:53:21
This is real case that blocks working re-auth proc
Yusuke Sato
2016/10/15 01:16:32
I'm wondering what's your request now based on the
hidehiko
2016/10/17 09:23:31
Or, maybe introducing two functions.
void StartSu
| |
815 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 819 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
816 | 820 |
817 if (!arc_bridge_service()->stopped()) { | 821 if (!IsAuthCodeRequest() && !arc_bridge_service()->stopped()) { |
818 // If the user attempts to re-enable ARC while the bridge is still running | 822 // If the user attempts to re-enable ARC while the bridge is still running |
819 // the user should not be able to continue until the bridge has stopped. | 823 // the user should not be able to continue until the bridge has stopped. |
820 ShowUI(UIPage::ERROR, l10n_util::GetStringUTF16( | 824 ShowUI(UIPage::ERROR, |
821 IDS_ARC_SIGN_IN_SERVICE_UNAVAILABLE_ERROR)); | 825 l10n_util::GetStringUTF16(IDS_ARC_SIGN_IN_UNKNOWN_ERROR)); |
khmel
2016/10/12 23:46:28
This error has nothing with "Couldn't reach Google
| |
822 return; | 826 return; |
823 } | 827 } |
824 | 828 |
825 SetState(State::FETCHING_CODE); | 829 SetState(State::FETCHING_CODE); |
826 | 830 |
827 if (initial_opt_in_) { | 831 if (initial_opt_in_) { |
828 initial_opt_in_ = false; | 832 initial_opt_in_ = false; |
829 ShowUI(UIPage::TERMS_PROGRESS, base::string16()); | 833 ShowUI(UIPage::TERMS_PROGRESS, base::string16()); |
830 } else { | 834 } else { |
831 context_->PrepareContext(); | 835 context_->PrepareContext(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
897 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); | 901 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); |
898 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); | 902 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); |
899 break; | 903 break; |
900 default: | 904 default: |
901 NOTREACHED(); | 905 NOTREACHED(); |
902 } | 906 } |
903 } | 907 } |
904 | 908 |
905 void ArcAuthService::StartArcIfSignedIn() { | 909 void ArcAuthService::StartArcIfSignedIn() { |
906 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 910 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
907 if (state_ == State::ACTIVE) | 911 if (state_ == State::ACTIVE && !IsAuthCodeRequest()) |
hidehiko
2016/10/13 15:22:00
My understanding is that; ArcAuthService shows an
khmel
2016/10/13 15:30:19
It can be requested when Arc is running on second
hidehiko
2016/10/13 15:44:31
I understand |state_| can be ACTIVE in re-auth cas
khmel
2016/10/13 15:53:21
I don't see such case. I only see case with re-aut
Yusuke Sato
2016/10/15 01:16:32
Then we can revert line 911 to the original one?
hidehiko
2016/10/17 09:23:31
Reverting will cause a problem, because the new co
| |
908 return; | 912 return; |
909 | 913 |
910 if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn) || | 914 if (!IsAuthCodeRequest() && |
hidehiko
2016/10/13 15:22:00
In this case, kArcSignedIn should be set to false
khmel
2016/10/13 15:30:19
If AuthCodeRequest is set then kArcSignedIn may be
hidehiko
2016/10/13 15:44:32
Isn't kArcSignedIn represents the ARC container si
khmel
2016/10/13 15:53:21
Re-auth may occur at any moment, with or without S
Yusuke Sato
2016/10/15 01:16:32
Ok, so we don't have to fix kArcSignedIn behavior
hidehiko
2016/10/17 09:23:31
https://cs.chromium.org/chromium/src/chrome/common
| |
911 IsOptInVerificationDisabled()) { | 915 (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn) || |
916 IsOptInVerificationDisabled())) { | |
912 StartArc(); | 917 StartArc(); |
913 } else { | 918 } else { |
914 const base::CommandLine* command_line = | 919 const base::CommandLine* command_line = |
915 base::CommandLine::ForCurrentProcess(); | 920 base::CommandLine::ForCurrentProcess(); |
916 std::string auth_endpoint; | 921 std::string auth_endpoint; |
917 if (command_line->HasSwitch(chromeos::switches::kArcUseAuthEndpoint)) { | 922 if (command_line->HasSwitch(chromeos::switches::kArcUseAuthEndpoint)) { |
918 auth_endpoint = command_line->GetSwitchValueASCII( | 923 auth_endpoint = command_line->GetSwitchValueASCII( |
919 chromeos::switches::kArcUseAuthEndpoint); | 924 chromeos::switches::kArcUseAuthEndpoint); |
920 } | 925 } |
921 | 926 |
(...skipping 16 matching lines...) Expand all Loading... | |
938 return os << kStateFetchingCode; | 943 return os << kStateFetchingCode; |
939 case ArcAuthService::State::ACTIVE: | 944 case ArcAuthService::State::ACTIVE: |
940 return os << kStateActive; | 945 return os << kStateActive; |
941 default: | 946 default: |
942 NOTREACHED(); | 947 NOTREACHED(); |
943 return os; | 948 return os; |
944 } | 949 } |
945 } | 950 } |
946 | 951 |
947 } // namespace arc | 952 } // namespace arc |
OLD | NEW |