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

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

Issue 2553193002: Remove explicit singletonness of ArcBridgeService part 4. (Closed)
Patch Set: Created 4 years 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
OLDNEW
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
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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 248
247 void ArcSessionManager::OnProvisioningFinished(ProvisioningResult result) { 249 void ArcSessionManager::OnProvisioningFinished(ProvisioningResult result) {
248 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 250 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
249 DCHECK_EQ(state_, State::ACTIVE); 251 DCHECK_EQ(state_, State::ACTIVE);
250 252
251 if (result == ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR) { 253 if (result == ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR) {
252 if (IsArcKioskMode()) { 254 if (IsArcKioskMode()) {
253 VLOG(1) << "Robot account auth code fetching error"; 255 VLOG(1) << "Robot account auth code fetching error";
254 // Log out the user. All the cleanup will be done in Shutdown() method. 256 // Log out the user. All the cleanup will be done in Shutdown() method.
255 // The callback is not called because auth code is empty. 257 // The callback is not called because auth code is empty.
256 chrome::AttemptUserExit(); 258 attempt_user_exit_callback_.Run();
257 return; 259 return;
258 } 260 }
259 261
260 // For backwards compatibility, use NETWORK_ERROR for 262 // For backwards compatibility, use NETWORK_ERROR for
261 // CHROME_SERVER_COMMUNICATION_ERROR case. 263 // CHROME_SERVER_COMMUNICATION_ERROR case.
262 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); 264 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR);
263 } else if (!sign_in_time_.is_null()) { 265 } else if (!sign_in_time_.is_null()) {
264 arc_sign_in_timer_.Stop(); 266 arc_sign_in_timer_.Stop();
265 267
266 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, 268 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_,
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 support_host_->ShowArcLoading(); 833 support_host_->ShowArcLoading();
832 StartArcAndroidManagementCheck(); 834 StartArcAndroidManagementCheck();
833 } 835 }
834 } 836 }
835 837
836 void ArcSessionManager::OnSendFeedbackClicked() { 838 void ArcSessionManager::OnSendFeedbackClicked() {
837 DCHECK(support_host_); 839 DCHECK(support_host_);
838 chrome::OpenFeedbackDialog(nullptr); 840 chrome::OpenFeedbackDialog(nullptr);
839 } 841 }
840 842
843 void ArcSessionManager::SetAttemptUserExitCallbackForTesting(
844 const base::Closure& callback) {
845 DCHECK(!callback.is_null());
846 attempt_user_exit_callback_ = callback;
847 }
848
841 std::ostream& operator<<(std::ostream& os, 849 std::ostream& operator<<(std::ostream& os,
842 const ArcSessionManager::State& state) { 850 const ArcSessionManager::State& state) {
843 switch (state) { 851 switch (state) {
844 case ArcSessionManager::State::NOT_INITIALIZED: 852 case ArcSessionManager::State::NOT_INITIALIZED:
845 return os << "NOT_INITIALIZED"; 853 return os << "NOT_INITIALIZED";
846 case ArcSessionManager::State::STOPPED: 854 case ArcSessionManager::State::STOPPED:
847 return os << "STOPPED"; 855 return os << "STOPPED";
848 case ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE: 856 case ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE:
849 return os << "SHOWING_TERMS_OF_SERVICE"; 857 return os << "SHOWING_TERMS_OF_SERVICE";
850 case ArcSessionManager::State::CHECKING_ANDROID_MANAGEMENT: 858 case ArcSessionManager::State::CHECKING_ANDROID_MANAGEMENT:
851 return os << "CHECKING_ANDROID_MANAGEMENT"; 859 return os << "CHECKING_ANDROID_MANAGEMENT";
852 case ArcSessionManager::State::ACTIVE: 860 case ArcSessionManager::State::ACTIVE:
853 return os << "ACTIVE"; 861 return os << "ACTIVE";
854 } 862 }
855 863
856 // Some compiler reports an error even if all values of an enum-class are 864 // Some compiler reports an error even if all values of an enum-class are
857 // covered indivisually in a switch statement. 865 // covered indivisually in a switch statement.
858 NOTREACHED(); 866 NOTREACHED();
859 return os; 867 return os;
860 } 868 }
861 869
862 } // namespace arc 870 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698