Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_util.h" | 5 #include "chrome/browser/chromeos/arc/arc_util.h" |
| 6 | 6 |
| 7 #include <linux/magic.h> | 7 #include <linux/magic.h> |
| 8 #include <sys/statfs.h> | 8 #include <sys/statfs.h> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/sys_info.h" | 12 #include "base/sys_info.h" |
| 13 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
| 14 #include "chrome/browser/chromeos/arc/arc_session_manager.h" | 14 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
| 15 #include "chrome/browser/chromeos/login/user_flow.h" | 15 #include "chrome/browser/chromeos/login/user_flow.h" |
| 16 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 16 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
| 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 20 #include "components/arc/arc_util.h" | 20 #include "components/arc/arc_util.h" |
| 21 #include "components/prefs/pref_service.h" | 21 #include "components/prefs/pref_service.h" |
| 22 #include "components/user_manager/known_user.h" | |
| 22 #include "components/user_manager/user.h" | 23 #include "components/user_manager/user.h" |
| 23 #include "components/user_manager/user_manager.h" | 24 #include "components/user_manager/user_manager.h" |
| 24 | 25 |
| 25 namespace arc { | 26 namespace arc { |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 constexpr char kLsbReleaseArcVersionKey[] = "CHROMEOS_ARC_ANDROID_SDK_VERSION"; | 30 constexpr char kLsbReleaseArcVersionKey[] = "CHROMEOS_ARC_ANDROID_SDK_VERSION"; |
| 30 constexpr char kAndroidMSdkVersion[] = "23"; | 31 constexpr char kAndroidMSdkVersion[] = "23"; |
| 31 | 32 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 if (user_manager::UserManager::Get() | 115 if (user_manager::UserManager::Get() |
| 115 ->IsCurrentUserCryptohomeDataEphemeral()) { | 116 ->IsCurrentUserCryptohomeDataEphemeral()) { |
| 116 VLOG(1) << "Users with ephemeral data are not supported in ARC."; | 117 VLOG(1) << "Users with ephemeral data are not supported in ARC."; |
| 117 return false; | 118 return false; |
| 118 } | 119 } |
| 119 | 120 |
| 120 return true; | 121 return true; |
| 121 } | 122 } |
| 122 | 123 |
| 123 bool IsArcCompatibleFileSystemUsedForProfile(const Profile* profile) { | 124 bool IsArcCompatibleFileSystemUsedForProfile(const Profile* profile) { |
| 124 // chromeos::UserSessionManager::PrepareProfile does the actual file system | 125 const user_manager::User* user = |
| 125 // check and stores the result to prefs, so that it survives crash-restart. | 126 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); |
| 127 if (!user) | |
| 128 return false; | |
|
hidehiko
2017/04/13 12:38:27
IIUC, this case is not expected even for testing?
xiyuan
2017/04/13 16:35:59
Think this should only happen in tests. GetUserByP
kinaba
2017/04/14 04:33:55
For instance, the sign-in profile does not have an
| |
| 129 | |
| 130 // chromeos::UserSessionManager does the actual file system check and stores | |
| 131 // the result to prefs, so that it survives crash-restart. | |
| 132 int filesystem_compatibility = kFileSystemIncompatible; | |
| 133 user_manager::known_user::GetIntegerPref( | |
| 134 user->GetAccountId(), prefs::kArcCompatibleFilesystemChosen, | |
| 135 &filesystem_compatibility); | |
| 136 | |
| 126 const bool is_filesystem_compatible = | 137 const bool is_filesystem_compatible = |
| 127 profile->GetPrefs()->GetBoolean(prefs::kArcCompatibleFilesystemChosen); | 138 filesystem_compatibility >= kFileSystemCompatible; |
|
hidehiko
2017/04/13 12:38:27
Could you use "==" instead, just in case that a ne
kinaba
2017/04/14 04:33:55
changed to "!= Incompatible" (to align with the us
| |
| 128 std::string arc_sdk_version; | 139 std::string arc_sdk_version; |
| 129 const bool is_M = base::SysInfo::GetLsbReleaseValue(kLsbReleaseArcVersionKey, | 140 const bool is_M = base::SysInfo::GetLsbReleaseValue(kLsbReleaseArcVersionKey, |
| 130 &arc_sdk_version) && | 141 &arc_sdk_version) && |
| 131 arc_sdk_version == kAndroidMSdkVersion; | 142 arc_sdk_version == kAndroidMSdkVersion; |
| 132 | 143 |
| 133 // To run ARC we want to make sure either | 144 // To run ARC we want to make sure either |
| 134 // - Underlying file system is compatible with ARC, or | 145 // - Underlying file system is compatible with ARC, or |
| 135 // - SDK version is M. | 146 // - SDK version is M. |
| 136 if (!is_filesystem_compatible && !is_M) { | 147 if (!is_filesystem_compatible && !is_M) { |
| 137 VLOG(1) | 148 VLOG(1) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 base::ThreadRestrictions::AssertIOAllowed(); | 204 base::ThreadRestrictions::AssertIOAllowed(); |
| 194 | 205 |
| 195 // If it can be verified it is not on ecryptfs, then it is ok. | 206 // If it can be verified it is not on ecryptfs, then it is ok. |
| 196 struct statfs statfs_buf; | 207 struct statfs statfs_buf; |
| 197 if (statfs(path.value().c_str(), &statfs_buf) < 0) | 208 if (statfs(path.value().c_str(), &statfs_buf) < 0) |
| 198 return false; | 209 return false; |
| 199 return statfs_buf.f_type != ECRYPTFS_SUPER_MAGIC; | 210 return statfs_buf.f_type != ECRYPTFS_SUPER_MAGIC; |
| 200 } | 211 } |
| 201 | 212 |
| 202 } // namespace arc | 213 } // namespace arc |
| OLD | NEW |