| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 if (ash::WmShell::HasInstance()) { | 74 if (ash::WmShell::HasInstance()) { |
| 75 DCHECK(ash::WmShell::Get()->shelf_delegate()); | 75 DCHECK(ash::WmShell::Get()->shelf_delegate()); |
| 76 return ash::WmShell::Get()->shelf_delegate(); | 76 return ash::WmShell::Get()->shelf_delegate(); |
| 77 } | 77 } |
| 78 return nullptr; | 78 return nullptr; |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace | 81 } // namespace |
| 82 | 82 |
| 83 ArcSessionManager::ArcSessionManager(ArcBridgeService* bridge_service) | 83 ArcSessionManager::ArcSessionManager(ArcBridgeService* bridge_service) |
| 84 : ArcService(bridge_service), weak_ptr_factory_(this) { | 84 : ArcService(bridge_service), |
| 85 attempt_user_exit_callback_(base::Bind(chrome::AttemptUserExit)), |
| 86 weak_ptr_factory_(this) { |
| 85 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 87 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 86 DCHECK(!g_arc_session_manager); | 88 DCHECK(!g_arc_session_manager); |
| 87 g_arc_session_manager = this; | 89 g_arc_session_manager = this; |
| 88 | 90 |
| 89 arc_bridge_service()->AddObserver(this); | 91 arc_bridge_service()->AddObserver(this); |
| 90 } | 92 } |
| 91 | 93 |
| 92 ArcSessionManager::~ArcSessionManager() { | 94 ArcSessionManager::~ArcSessionManager() { |
| 93 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 95 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 94 | 96 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 << " additional result " << static_cast<int>(result) << "."; | 286 << " additional result " << static_cast<int>(result) << "."; |
| 285 return; | 287 return; |
| 286 } | 288 } |
| 287 provisioning_reported_ = true; | 289 provisioning_reported_ = true; |
| 288 | 290 |
| 289 if (result == ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR) { | 291 if (result == ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR) { |
| 290 if (IsArcKioskMode()) { | 292 if (IsArcKioskMode()) { |
| 291 VLOG(1) << "Robot account auth code fetching error"; | 293 VLOG(1) << "Robot account auth code fetching error"; |
| 292 // Log out the user. All the cleanup will be done in Shutdown() method. | 294 // Log out the user. All the cleanup will be done in Shutdown() method. |
| 293 // The callback is not called because auth code is empty. | 295 // The callback is not called because auth code is empty. |
| 294 chrome::AttemptUserExit(); | 296 attempt_user_exit_callback_.Run(); |
| 295 return; | 297 return; |
| 296 } | 298 } |
| 297 | 299 |
| 298 // For backwards compatibility, use NETWORK_ERROR for | 300 // For backwards compatibility, use NETWORK_ERROR for |
| 299 // CHROME_SERVER_COMMUNICATION_ERROR case. | 301 // CHROME_SERVER_COMMUNICATION_ERROR case. |
| 300 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); | 302 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); |
| 301 } else if (!sign_in_time_.is_null()) { | 303 } else if (!sign_in_time_.is_null()) { |
| 302 arc_sign_in_timer_.Stop(); | 304 arc_sign_in_timer_.Stop(); |
| 303 | 305 |
| 304 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, | 306 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 support_host_->ShowArcLoading(); | 893 support_host_->ShowArcLoading(); |
| 892 StartArcAndroidManagementCheck(); | 894 StartArcAndroidManagementCheck(); |
| 893 } | 895 } |
| 894 } | 896 } |
| 895 | 897 |
| 896 void ArcSessionManager::OnSendFeedbackClicked() { | 898 void ArcSessionManager::OnSendFeedbackClicked() { |
| 897 DCHECK(support_host_); | 899 DCHECK(support_host_); |
| 898 chrome::OpenFeedbackDialog(nullptr); | 900 chrome::OpenFeedbackDialog(nullptr); |
| 899 } | 901 } |
| 900 | 902 |
| 903 void ArcSessionManager::SetAttemptUserExitCallbackForTesting( |
| 904 const base::Closure& callback) { |
| 905 DCHECK(!callback.is_null()); |
| 906 attempt_user_exit_callback_ = callback; |
| 907 } |
| 908 |
| 901 std::ostream& operator<<(std::ostream& os, | 909 std::ostream& operator<<(std::ostream& os, |
| 902 const ArcSessionManager::State& state) { | 910 const ArcSessionManager::State& state) { |
| 903 switch (state) { | 911 switch (state) { |
| 904 case ArcSessionManager::State::NOT_INITIALIZED: | 912 case ArcSessionManager::State::NOT_INITIALIZED: |
| 905 return os << "NOT_INITIALIZED"; | 913 return os << "NOT_INITIALIZED"; |
| 906 case ArcSessionManager::State::STOPPED: | 914 case ArcSessionManager::State::STOPPED: |
| 907 return os << "STOPPED"; | 915 return os << "STOPPED"; |
| 908 case ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE: | 916 case ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE: |
| 909 return os << "SHOWING_TERMS_OF_SERVICE"; | 917 return os << "SHOWING_TERMS_OF_SERVICE"; |
| 910 case ArcSessionManager::State::CHECKING_ANDROID_MANAGEMENT: | 918 case ArcSessionManager::State::CHECKING_ANDROID_MANAGEMENT: |
| 911 return os << "CHECKING_ANDROID_MANAGEMENT"; | 919 return os << "CHECKING_ANDROID_MANAGEMENT"; |
| 912 case ArcSessionManager::State::REMOVING_DATA_DIR: | 920 case ArcSessionManager::State::REMOVING_DATA_DIR: |
| 913 return os << "REMOVING_DATA_DIR"; | 921 return os << "REMOVING_DATA_DIR"; |
| 914 case ArcSessionManager::State::ACTIVE: | 922 case ArcSessionManager::State::ACTIVE: |
| 915 return os << "ACTIVE"; | 923 return os << "ACTIVE"; |
| 916 } | 924 } |
| 917 | 925 |
| 918 // Some compiler reports an error even if all values of an enum-class are | 926 // Some compiler reports an error even if all values of an enum-class are |
| 919 // covered indivisually in a switch statement. | 927 // covered indivisually in a switch statement. |
| 920 NOTREACHED(); | 928 NOTREACHED(); |
| 921 return os; | 929 return os; |
| 922 } | 930 } |
| 923 | 931 |
| 924 } // namespace arc | 932 } // namespace arc |
| OLD | NEW |