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

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

Issue 2541173002: arc: Make request to remove Android's data folder persistent. (Closed)
Patch Set: rename pref flag / update comments 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
« no previous file with comments | « chrome/browser/chromeos/arc/arc_session_manager.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 ArcSessionManager* ArcSessionManager::Get() { 103 ArcSessionManager* ArcSessionManager::Get() {
104 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 104 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
105 return g_arc_session_manager; 105 return g_arc_session_manager;
106 } 106 }
107 107
108 // static 108 // static
109 void ArcSessionManager::RegisterProfilePrefs( 109 void ArcSessionManager::RegisterProfilePrefs(
110 user_prefs::PrefRegistrySyncable* registry) { 110 user_prefs::PrefRegistrySyncable* registry) {
111 // TODO(dspaid): Implement a mechanism to allow this to sync on first boot 111 // TODO(dspaid): Implement a mechanism to allow this to sync on first boot
112 // only. 112 // only.
113 registry->RegisterBooleanPref(prefs::kArcDataRemoveRequested, false);
113 registry->RegisterBooleanPref(prefs::kArcEnabled, false); 114 registry->RegisterBooleanPref(prefs::kArcEnabled, false);
114 registry->RegisterBooleanPref(prefs::kArcSignedIn, false); 115 registry->RegisterBooleanPref(prefs::kArcSignedIn, false);
115 registry->RegisterBooleanPref(prefs::kArcTermsAccepted, false); 116 registry->RegisterBooleanPref(prefs::kArcTermsAccepted, false);
116 registry->RegisterBooleanPref(prefs::kArcBackupRestoreEnabled, true); 117 registry->RegisterBooleanPref(prefs::kArcBackupRestoreEnabled, true);
117 registry->RegisterBooleanPref(prefs::kArcLocationServiceEnabled, true); 118 registry->RegisterBooleanPref(prefs::kArcLocationServiceEnabled, true);
118 } 119 }
119 120
120 // static 121 // static
121 void ArcSessionManager::DisableUIForTesting() { 122 void ArcSessionManager::DisableUIForTesting() {
122 g_disable_ui_for_testing = true; 123 g_disable_ui_for_testing = true;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 bool ArcSessionManager::IsArcKioskMode() { 182 bool ArcSessionManager::IsArcKioskMode() {
182 return user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp(); 183 return user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp();
183 } 184 }
184 185
185 void ArcSessionManager::OnBridgeStopped(ArcBridgeService::StopReason reason) { 186 void ArcSessionManager::OnBridgeStopped(ArcBridgeService::StopReason reason) {
186 // TODO(crbug.com/625923): Use |reason| to report more detailed errors. 187 // TODO(crbug.com/625923): Use |reason| to report more detailed errors.
187 if (arc_sign_in_timer_.IsRunning()) { 188 if (arc_sign_in_timer_.IsRunning()) {
188 OnProvisioningFinished(ProvisioningResult::ARC_STOPPED); 189 OnProvisioningFinished(ProvisioningResult::ARC_STOPPED);
189 } 190 }
190 191
191 if (clear_required_) { 192 if (profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)) {
192 // This should be always true, but just in case as this is looked at 193 // This should be always true, but just in case as this is looked at
193 // inside RemoveArcData() at first. 194 // inside RemoveArcData() at first.
194 DCHECK(arc_bridge_service()->stopped()); 195 DCHECK(arc_bridge_service()->stopped());
195 RemoveArcData(); 196 RemoveArcData();
196 } else { 197 } else {
197 // To support special "Stop and enable ARC" procedure for enterprise, 198 // To support special "Stop and enable ARC" procedure for enterprise,
198 // here call OnArcDataRemoved(true) as if the data removal is successfully 199 // here call OnArcDataRemoved(true) as if the data removal is successfully
199 // done. 200 // done.
200 // TODO(hidehiko): Restructure the code. crbug.com/665316 201 // TODO(hidehiko): Restructure the code. crbug.com/665316
201 base::ThreadTaskRunnerHandle::Get()->PostTask( 202 base::ThreadTaskRunnerHandle::Get()->PostTask(
202 FROM_HERE, base::Bind(&ArcSessionManager::OnArcDataRemoved, 203 FROM_HERE, base::Bind(&ArcSessionManager::OnArcDataRemoved,
203 weak_ptr_factory_.GetWeakPtr(), true)); 204 weak_ptr_factory_.GetWeakPtr(), true));
204 } 205 }
205 } 206 }
206 207
207 void ArcSessionManager::RemoveArcData() { 208 void ArcSessionManager::RemoveArcData() {
209 // OnArcDataRemoved resets this flag.
210 profile_->GetPrefs()->SetBoolean(prefs::kArcDataRemoveRequested, true);
211
208 if (!arc_bridge_service()->stopped()) { 212 if (!arc_bridge_service()->stopped()) {
209 // Just set a flag. On bridge stopped, this will be re-called, 213 // Just set a flag. On bridge stopped, this will be re-called,
210 // then session manager should remove the data. 214 // then session manager should remove the data.
211 clear_required_ = true;
212 return; 215 return;
213 } 216 }
214 clear_required_ = false; 217
215 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->RemoveArcData( 218 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->RemoveArcData(
216 cryptohome::Identification( 219 cryptohome::Identification(
217 multi_user_util::GetAccountIdFromProfile(profile_)), 220 multi_user_util::GetAccountIdFromProfile(profile_)),
218 base::Bind(&ArcSessionManager::OnArcDataRemoved, 221 base::Bind(&ArcSessionManager::OnArcDataRemoved,
219 weak_ptr_factory_.GetWeakPtr())); 222 weak_ptr_factory_.GetWeakPtr()));
220 } 223 }
221 224
222 void ArcSessionManager::OnArcDataRemoved(bool success) { 225 void ArcSessionManager::OnArcDataRemoved(bool success) {
223 LOG_IF(ERROR, !success) << "Required ARC user data wipe failed."; 226 LOG_IF(ERROR, !success) << "Required ARC user data wipe failed.";
224 227
228 profile_->GetPrefs()->SetBoolean(prefs::kArcDataRemoveRequested, false);
229
225 // Here check if |reenable_arc_| is marked or not. 230 // Here check if |reenable_arc_| is marked or not.
226 // The only case this happens should be in the special case for enterprise 231 // The only case this happens should be in the special case for enterprise
227 // "on managed lost" case. In that case, OnBridgeStopped() should trigger 232 // "on managed lost" case. In that case, OnBridgeStopped() should trigger
228 // the RemoveArcData(), then this. 233 // the RemoveArcData(), then this.
229 // TODO(hidehiko): Restructure the code. 234 // TODO(hidehiko): Restructure the code.
230 if (!reenable_arc_) 235 if (!reenable_arc_)
231 return; 236 return;
232 237
233 // Restart ARC anyway. Let the enterprise reporting instance decide whether 238 // Restart ARC anyway. Let the enterprise reporting instance decide whether
234 // the ARC user data wipe is still required or not. 239 // the ARC user data wipe is still required or not.
(...skipping 19 matching lines...) Expand all
254 UpdateProvisioningResultUMA(result, 259 UpdateProvisioningResultUMA(result,
255 policy_util::IsAccountManaged(profile_)); 260 policy_util::IsAccountManaged(profile_));
256 if (result != ProvisioningResult::SUCCESS) 261 if (result != ProvisioningResult::SUCCESS)
257 UpdateOptInCancelUMA(OptInCancelReason::CLOUD_PROVISION_FLOW_FAIL); 262 UpdateOptInCancelUMA(OptInCancelReason::CLOUD_PROVISION_FLOW_FAIL);
258 } 263 }
259 264
260 if (result == ProvisioningResult::SUCCESS) { 265 if (result == ProvisioningResult::SUCCESS) {
261 if (support_host_) 266 if (support_host_)
262 support_host_->Close(); 267 support_host_->Close();
263 268
269 // Make sure request to remove data folder is off.
hidehiko 2016/12/01 00:58:02 Better to comment an example case that this actual
khmel 2016/12/01 03:12:20 I don't see any use case. Probably we can change i
hidehiko 2016/12/01 16:15:03 After some more investigation I found a case that
khmel 2016/12/01 17:18:59 Replaced by DCHECK
270 profile_->GetPrefs()->SetBoolean(prefs::kArcDataRemoveRequested, false);
271
264 if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) 272 if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn))
265 return; 273 return;
266 274
267 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); 275 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true);
268 // Don't show Play Store app for ARC Kiosk because the only one UI in kiosk 276 // Don't show Play Store app for ARC Kiosk because the only one UI in kiosk
269 // mode must be the kiosk app and device is not needed for opt-in. 277 // mode must be the kiosk app and device is not needed for opt-in.
270 if (!IsOptInVerificationDisabled() && !IsArcKioskMode()) { 278 if (!IsOptInVerificationDisabled() && !IsArcKioskMode()) {
271 playstore_launcher_.reset( 279 playstore_launcher_.reset(
272 new ArcAppLauncher(profile_, kPlayStoreAppId, true)); 280 new ArcAppLauncher(profile_, kPlayStoreAppId, true));
273 } 281 }
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 // TODO(hidehiko): Remove this. 566 // TODO(hidehiko): Remove this.
559 void ArcSessionManager::StopAndEnableArc() { 567 void ArcSessionManager::StopAndEnableArc() {
560 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 568 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
561 DCHECK(!arc_bridge_service()->stopped()); 569 DCHECK(!arc_bridge_service()->stopped());
562 reenable_arc_ = true; 570 reenable_arc_ = true;
563 StopArc(); 571 StopArc();
564 } 572 }
565 573
566 void ArcSessionManager::StartArc() { 574 void ArcSessionManager::StartArc() {
567 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 575 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
576
577 // Don't start ARC if there is a pending request to remove the data. Restart
578 // ARC once data removal finishes.
579 if (profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)) {
hidehiko 2016/12/01 00:58:02 Should this be in OnPrimaryUserProfilePrepared() ?
khmel 2016/12/01 03:12:21 I think this is more reliable point to handle this
hidehiko 2016/12/01 16:15:03 Good example scenario. I think, in that case, we s
khmel 2016/12/01 17:18:59 I moved this check to upper level OnOptInPreferenc
580 reenable_arc_ = true;
hidehiko 2016/12/01 00:58:02 This has an edge case: Remove request is set in p
khmel 2016/12/01 03:12:20 Good catch. I think in this case we can reset reen
hidehiko 2016/12/01 16:15:03 IsAllowed() check looks not the one we need here?
khmel 2016/12/01 17:18:59 IsAllowed is required to safely reset request. It
581 RemoveArcData();
582 return;
583 }
584
568 arc_bridge_service()->RequestStart(); 585 arc_bridge_service()->RequestStart();
569 SetState(State::ACTIVE); 586 SetState(State::ACTIVE);
570 } 587 }
571 588
572 void ArcSessionManager::OnArcSignInTimeout() { 589 void ArcSessionManager::OnArcSignInTimeout() {
573 LOG(ERROR) << "Timed out waiting for first sign in."; 590 LOG(ERROR) << "Timed out waiting for first sign in.";
574 OnProvisioningFinished(ProvisioningResult::OVERALL_SIGN_IN_TIMEOUT); 591 OnProvisioningFinished(ProvisioningResult::OVERALL_SIGN_IN_TIMEOUT);
575 } 592 }
576 593
577 void ArcSessionManager::CancelAuthCode() { 594 void ArcSessionManager::CancelAuthCode() {
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 return os << "ACTIVE"; 843 return os << "ACTIVE";
827 } 844 }
828 845
829 // Some compiler reports an error even if all values of an enum-class are 846 // Some compiler reports an error even if all values of an enum-class are
830 // covered indivisually in a switch statement. 847 // covered indivisually in a switch statement.
831 NOTREACHED(); 848 NOTREACHED();
832 return os; 849 return os;
833 } 850 }
834 851
835 } // namespace arc 852 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_session_manager.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698