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

Unified Diff: chrome/browser/chromeos/arc/arc_auth_service.cc

Issue 2149853004: arc: Implement safe access to ArcAuthService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update browser_Tests Created 4 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/arc/arc_auth_service.h ('k') | chrome/browser/chromeos/arc/arc_support_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/arc/arc_auth_service.cc
diff --git a/chrome/browser/chromeos/arc/arc_auth_service.cc b/chrome/browser/chromeos/arc/arc_auth_service.cc
index b9e6986c54d8648191e565c52f478c4d283041e0..ed8da4a40f936f2653ee87815e2db78e8f01b176 100644
--- a/chrome/browser/chromeos/arc/arc_auth_service.cc
+++ b/chrome/browser/chromeos/arc/arc_auth_service.cc
@@ -57,6 +57,9 @@ ArcAuthService* g_arc_auth_service = nullptr;
// Skip creating UI in unit tests
bool g_disable_ui_for_testing = false;
+// Skip checking for cryptohome data ephemeral users.
+bool g_allow_cryptohome_data_ephemeral_user_for_testing = false;
khmel 2016/07/18 20:23:42 In most browser tests user is logged as Ephemeral
xiyuan 2016/07/18 20:59:12 Sounds like UserManagerBase::IsUserCryptohomeDataE
khmel 2016/07/18 22:15:11 Yes, this helps
+
// Use specified ash::ShelfDelegate for unit tests.
ash::ShelfDelegate* g_shelf_delegate_for_testing = nullptr;
@@ -133,6 +136,11 @@ void ArcAuthService::DisableUIForTesting() {
}
// static
+void ArcAuthService::AllowCryptohomeDataEphemeralUserForTesting() {
+ g_allow_cryptohome_data_ephemeral_user_for_testing = true;
+}
+
+// static
void ArcAuthService::SetShelfDelegateForTesting(
ash::ShelfDelegate* shelf_delegate) {
g_shelf_delegate_for_testing = shelf_delegate;
@@ -178,7 +186,8 @@ bool ArcAuthService::IsAllowedForProfile(const Profile* profile) {
return false;
}
- if (user_manager::UserManager::Get()
+ if (!g_allow_cryptohome_data_ephemeral_user_for_testing &&
+ user_manager::UserManager::Get()
->IsCurrentUserCryptohomeDataEphemeral()) {
VLOG(2) << "Users with ephemeral data are not supported in Arc.";
return false;
@@ -342,9 +351,6 @@ void ArcAuthService::OnPrimaryUserProfilePrepared(Profile* profile) {
Shutdown();
- profile_ = profile;
- SetState(State::STOPPED);
-
if (!IsAllowedForProfile(profile))
return;
@@ -354,6 +360,9 @@ void ArcAuthService::OnPrimaryUserProfilePrepared(Profile* profile) {
return;
}
+ profile_ = profile;
+ SetState(State::STOPPED);
+
PrefServiceSyncableFromProfile(profile_)->AddSyncedPrefObserver(
prefs::kArcEnabled, this);
@@ -637,6 +646,9 @@ bool ArcAuthService::IsArcManaged() const {
bool ArcAuthService::IsArcEnabled() const {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ if (!IsAllowed())
+ return false;
+
DCHECK(profile_);
return profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled);
}
« no previous file with comments | « chrome/browser/chromeos/arc/arc_auth_service.h ('k') | chrome/browser/chromeos/arc/arc_support_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698