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/shelf/shelf_delegate.h" | 9 #include "ash/shelf/shelf_delegate.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 | 188 |
189 return true; | 189 return true; |
190 } | 190 } |
191 | 191 |
192 void ArcAuthService::OnAuthInstanceReady() { | 192 void ArcAuthService::OnAuthInstanceReady() { |
193 arc_bridge_service()->auth_instance()->Init( | 193 arc_bridge_service()->auth_instance()->Init( |
194 binding_.CreateInterfacePtrAndBind()); | 194 binding_.CreateInterfacePtrAndBind()); |
195 } | 195 } |
196 | 196 |
197 void ArcAuthService::OnBridgeStopped() { | 197 void ArcAuthService::OnBridgeStopped() { |
198 if (waiting_for_reply_) { | |
199 // Using SERVICE_UNAVAILABLE instead of UNKNOWN_ERROR, since the latter | |
200 // causes this code to not try to stop ARC, so it would retry without the | |
201 // user noticing. | |
202 OnSignInFailed(arc::mojom::ArcSignInFailureReason::SERVICE_UNAVAILABLE); | |
203 } | |
198 if (!clear_required_) | 204 if (!clear_required_) |
199 return; | 205 return; |
200 clear_required_ = false; | 206 clear_required_ = false; |
201 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->RemoveArcData( | 207 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->RemoveArcData( |
202 cryptohome::Identification( | 208 cryptohome::Identification( |
203 multi_user_util::GetAccountIdFromProfile(profile_))); | 209 multi_user_util::GetAccountIdFromProfile(profile_))); |
204 } | 210 } |
205 | 211 |
206 std::string ArcAuthService::GetAndResetAuthCode() { | 212 std::string ArcAuthService::GetAndResetAuthCode() { |
207 DCHECK(thread_checker.Get().CalledOnValidThread()); | 213 DCHECK(thread_checker.Get().CalledOnValidThread()); |
(...skipping 22 matching lines...) Expand all Loading... | |
230 initial_opt_in_ = false; | 236 initial_opt_in_ = false; |
231 auth_callback_ = callback; | 237 auth_callback_ = callback; |
232 StartUI(); | 238 StartUI(); |
233 } | 239 } |
234 | 240 |
235 void ArcAuthService::OnSignInComplete() { | 241 void ArcAuthService::OnSignInComplete() { |
236 DCHECK(thread_checker.Get().CalledOnValidThread()); | 242 DCHECK(thread_checker.Get().CalledOnValidThread()); |
237 DCHECK_EQ(state_, State::ACTIVE); | 243 DCHECK_EQ(state_, State::ACTIVE); |
238 DCHECK(!sign_in_time_.is_null()); | 244 DCHECK(!sign_in_time_.is_null()); |
239 | 245 |
246 waiting_for_reply_ = false; | |
Luis Héctor Chávez
2016/06/29 23:37:50
If adding this flag is undesirable, all the places
| |
247 | |
240 if (!IsOptInVerificationDisabled() && | 248 if (!IsOptInVerificationDisabled() && |
241 !profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) { | 249 !profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) { |
242 playstore_launcher_.reset( | 250 playstore_launcher_.reset( |
243 new ArcAppLauncher(profile_, kPlayStoreAppId, true)); | 251 new ArcAppLauncher(profile_, kPlayStoreAppId, true)); |
244 } | 252 } |
245 | 253 |
246 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); | 254 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); |
247 CloseUI(); | 255 CloseUI(); |
248 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, true, | 256 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, true, |
249 IsAccountManaged(profile_)); | 257 IsAccountManaged(profile_)); |
250 UpdateProvisioningResultUMA(ProvisioningResult::SUCCESS); | 258 UpdateProvisioningResultUMA(ProvisioningResult::SUCCESS); |
251 } | 259 } |
252 | 260 |
253 void ArcAuthService::OnSignInFailed(arc::mojom::ArcSignInFailureReason reason) { | 261 void ArcAuthService::OnSignInFailed(arc::mojom::ArcSignInFailureReason reason) { |
254 DCHECK(thread_checker.Get().CalledOnValidThread()); | 262 DCHECK(thread_checker.Get().CalledOnValidThread()); |
255 DCHECK_EQ(state_, State::ACTIVE); | 263 DCHECK_EQ(state_, State::ACTIVE); |
256 DCHECK(!sign_in_time_.is_null()); | 264 DCHECK(!sign_in_time_.is_null()); |
257 | 265 |
266 waiting_for_reply_ = false; | |
267 | |
258 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, false, | 268 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, false, |
259 IsAccountManaged(profile_)); | 269 IsAccountManaged(profile_)); |
260 int error_message_id; | 270 int error_message_id; |
261 switch (reason) { | 271 switch (reason) { |
262 case arc::mojom::ArcSignInFailureReason::NETWORK_ERROR: | 272 case arc::mojom::ArcSignInFailureReason::NETWORK_ERROR: |
263 error_message_id = IDS_ARC_SIGN_IN_NETWORK_ERROR; | 273 error_message_id = IDS_ARC_SIGN_IN_NETWORK_ERROR; |
264 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); | 274 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); |
265 UpdateProvisioningResultUMA(ProvisioningResult::NETWORK_ERROR); | 275 UpdateProvisioningResultUMA(ProvisioningResult::NETWORK_ERROR); |
266 break; | 276 break; |
267 case arc::mojom::ArcSignInFailureReason::SERVICE_UNAVAILABLE: | 277 case arc::mojom::ArcSignInFailureReason::SERVICE_UNAVAILABLE: |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 if (state != State::FETCHING_CODE) { | 567 if (state != State::FETCHING_CODE) { |
558 ShutdownBridgeAndCloseUI(); | 568 ShutdownBridgeAndCloseUI(); |
559 return; | 569 return; |
560 } | 570 } |
561 | 571 |
562 sign_in_time_ = base::Time::Now(); | 572 sign_in_time_ = base::Time::Now(); |
563 | 573 |
564 SetUIPage(UIPage::START_PROGRESS, base::string16()); | 574 SetUIPage(UIPage::START_PROGRESS, base::string16()); |
565 ShutdownBridge(); | 575 ShutdownBridge(); |
566 auth_code_ = auth_code; | 576 auth_code_ = auth_code; |
577 waiting_for_reply_ = true; | |
567 StartArc(); | 578 StartArc(); |
568 } | 579 } |
569 | 580 |
570 void ArcAuthService::StartLso() { | 581 void ArcAuthService::StartLso() { |
571 DCHECK(thread_checker.Get().CalledOnValidThread()); | 582 DCHECK(thread_checker.Get().CalledOnValidThread()); |
572 | 583 |
573 // Update UMA only if error (with or without feedback) is currently shown. | 584 // Update UMA only if error (with or without feedback) is currently shown. |
574 if (ui_page_ == UIPage::ERROR) { | 585 if (ui_page_ == UIPage::ERROR) { |
575 UpdateOptInActionUMA(OptInActionType::RETRY); | 586 UpdateOptInActionUMA(OptInActionType::RETRY); |
576 } else if (ui_page_ == UIPage::ERROR_WITH_FEEDBACK) { | 587 } else if (ui_page_ == UIPage::ERROR_WITH_FEEDBACK) { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
718 return os << kStateFetchingCode; | 729 return os << kStateFetchingCode; |
719 case ArcAuthService::State::ACTIVE: | 730 case ArcAuthService::State::ACTIVE: |
720 return os << kStateActive; | 731 return os << kStateActive; |
721 default: | 732 default: |
722 NOTREACHED(); | 733 NOTREACHED(); |
723 return os; | 734 return os; |
724 } | 735 } |
725 } | 736 } |
726 | 737 |
727 } // namespace arc | 738 } // namespace arc |
OLD | NEW |