Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 // static | 187 // static |
| 188 bool ArcSessionManager::IsArcKioskMode() { | 188 bool ArcSessionManager::IsArcKioskMode() { |
| 189 return user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp(); | 189 return user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 void ArcSessionManager::OnBridgeStopped(ArcBridgeService::StopReason reason) { | 192 void ArcSessionManager::OnBridgeStopped(ArcBridgeService::StopReason reason) { |
| 193 // TODO(crbug.com/625923): Use |reason| to report more detailed errors. | 193 // TODO(crbug.com/625923): Use |reason| to report more detailed errors. |
| 194 if (arc_sign_in_timer_.IsRunning()) { | 194 if (arc_sign_in_timer_.IsRunning()) { |
| 195 OnProvisioningFinished(ProvisioningResult::ARC_STOPPED); | 195 OnProvisioningFinished(ProvisioningResult::ARC_STOPPED); |
| 196 } | 196 } |
| 197 provisioning_error_reported_ = false; | |
|
Luis Héctor Chávez
2016/12/06 17:35:20
Is this one needed? Shouldn't we just use the one
khmel
2016/12/06 17:46:55
Actually not, more paranoiac...
| |
| 197 | 198 |
| 198 if (clear_required_) { | 199 if (clear_required_) { |
| 199 // This should be always true, but just in case as this is looked at | 200 // This should be always true, but just in case as this is looked at |
| 200 // inside RemoveArcData() at first. | 201 // inside RemoveArcData() at first. |
| 201 DCHECK(arc_bridge_service()->stopped()); | 202 DCHECK(arc_bridge_service()->stopped()); |
| 202 RemoveArcData(); | 203 RemoveArcData(); |
| 203 } else { | 204 } else { |
| 204 // To support special "Stop and enable ARC" procedure for enterprise, | 205 // To support special "Stop and enable ARC" procedure for enterprise, |
| 205 // here call OnArcDataRemoved(true) as if the data removal is successfully | 206 // here call OnArcDataRemoved(true) as if the data removal is successfully |
| 206 // done. | 207 // done. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 // the ARC user data wipe is still required or not. | 242 // the ARC user data wipe is still required or not. |
| 242 reenable_arc_ = false; | 243 reenable_arc_ = false; |
| 243 VLOG(1) << "Reenable ARC"; | 244 VLOG(1) << "Reenable ARC"; |
| 244 EnableArc(); | 245 EnableArc(); |
| 245 } | 246 } |
| 246 | 247 |
| 247 void ArcSessionManager::OnProvisioningFinished(ProvisioningResult result) { | 248 void ArcSessionManager::OnProvisioningFinished(ProvisioningResult result) { |
| 248 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 249 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 249 DCHECK_EQ(state_, State::ACTIVE); | 250 DCHECK_EQ(state_, State::ACTIVE); |
| 250 | 251 |
| 252 if (result != ProvisioningResult::SUCCESS) { | |
|
hidehiko
2016/12/06 18:10:53
Per offline discussion, we want to guarantee OnPro
khmel
2016/12/06 18:13:35
Per our discussion I thought that we want to have
hidehiko
2016/12/06 18:15:54
I meant, it is not needed to check if result is SU
khmel
2016/12/06 18:41:13
Got you! However LOG(WARNING) sounds better becaus
| |
| 253 if (provisioning_error_reported_) { | |
| 254 LOG(WARNING) << " Provisioning error was already reported. Ignoring " | |
| 255 << " additional error " << static_cast<int>(result) << "."; | |
| 256 return; | |
| 257 } | |
| 258 provisioning_error_reported_ = true; | |
| 259 } | |
| 260 | |
| 251 if (result == ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR) { | 261 if (result == ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR) { |
| 252 if (IsArcKioskMode()) { | 262 if (IsArcKioskMode()) { |
| 253 VLOG(1) << "Robot account auth code fetching error"; | 263 VLOG(1) << "Robot account auth code fetching error"; |
| 254 // Log out the user. All the cleanup will be done in Shutdown() method. | 264 // Log out the user. All the cleanup will be done in Shutdown() method. |
| 255 // The callback is not called because auth code is empty. | 265 // The callback is not called because auth code is empty. |
| 256 chrome::AttemptUserExit(); | 266 chrome::AttemptUserExit(); |
| 257 return; | 267 return; |
| 258 } | 268 } |
| 259 | 269 |
| 260 // For backwards compatibility, use NETWORK_ERROR for | 270 // For backwards compatibility, use NETWORK_ERROR for |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 584 // TODO(hidehiko): Remove this. | 594 // TODO(hidehiko): Remove this. |
| 585 void ArcSessionManager::StopAndEnableArc() { | 595 void ArcSessionManager::StopAndEnableArc() { |
| 586 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 596 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 587 DCHECK(!arc_bridge_service()->stopped()); | 597 DCHECK(!arc_bridge_service()->stopped()); |
| 588 reenable_arc_ = true; | 598 reenable_arc_ = true; |
| 589 StopArc(); | 599 StopArc(); |
| 590 } | 600 } |
| 591 | 601 |
| 592 void ArcSessionManager::StartArc() { | 602 void ArcSessionManager::StartArc() { |
| 593 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 603 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 604 provisioning_error_reported_ = false; | |
| 594 arc_bridge_service()->RequestStart(); | 605 arc_bridge_service()->RequestStart(); |
| 595 SetState(State::ACTIVE); | 606 SetState(State::ACTIVE); |
| 596 } | 607 } |
| 597 | 608 |
| 598 void ArcSessionManager::OnArcSignInTimeout() { | 609 void ArcSessionManager::OnArcSignInTimeout() { |
| 599 LOG(ERROR) << "Timed out waiting for first sign in."; | 610 LOG(ERROR) << "Timed out waiting for first sign in."; |
| 600 OnProvisioningFinished(ProvisioningResult::OVERALL_SIGN_IN_TIMEOUT); | 611 OnProvisioningFinished(ProvisioningResult::OVERALL_SIGN_IN_TIMEOUT); |
| 601 } | 612 } |
| 602 | 613 |
| 603 void ArcSessionManager::CancelAuthCode() { | 614 void ArcSessionManager::CancelAuthCode() { |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 853 return os << "ACTIVE"; | 864 return os << "ACTIVE"; |
| 854 } | 865 } |
| 855 | 866 |
| 856 // Some compiler reports an error even if all values of an enum-class are | 867 // Some compiler reports an error even if all values of an enum-class are |
| 857 // covered indivisually in a switch statement. | 868 // covered indivisually in a switch statement. |
| 858 NOTREACHED(); | 869 NOTREACHED(); |
| 859 return os; | 870 return os; |
| 860 } | 871 } |
| 861 | 872 |
| 862 } // namespace arc | 873 } // namespace arc |
| OLD | NEW |