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> | |
8 #include <sys/statfs.h> | |
9 | |
10 #include "base/files/file_path.h" | |
11 #include "base/files/file_util.h" | |
xiyuan
2017/04/04 15:32:21
nit: not used?
kinaba
2017/04/05 02:35:27
Done.
| |
7 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/strings/string_split.h" | |
xiyuan
2017/04/04 15:32:21
nit: not used?
kinaba
2017/04/05 02:35:27
Done.
| |
14 #include "base/sys_info.h" | |
15 #include "base/threading/thread_restrictions.h" | |
8 #include "chrome/browser/chromeos/arc/arc_session_manager.h" | 16 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
9 #include "chrome/browser/chromeos/login/user_flow.h" | 17 #include "chrome/browser/chromeos/login/user_flow.h" |
10 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 18 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
11 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 19 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
12 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
14 #include "components/arc/arc_util.h" | 22 #include "components/arc/arc_util.h" |
15 #include "components/prefs/pref_service.h" | 23 #include "components/prefs/pref_service.h" |
16 #include "components/user_manager/user.h" | 24 #include "components/user_manager/user.h" |
17 #include "components/user_manager/user_manager.h" | 25 #include "components/user_manager/user_manager.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 return false; | 93 return false; |
86 } | 94 } |
87 | 95 |
88 // Do not allow for Ephemeral data user. cf) b/26402681 | 96 // Do not allow for Ephemeral data user. cf) b/26402681 |
89 if (user_manager::UserManager::Get() | 97 if (user_manager::UserManager::Get() |
90 ->IsCurrentUserCryptohomeDataEphemeral()) { | 98 ->IsCurrentUserCryptohomeDataEphemeral()) { |
91 VLOG(1) << "Users with ephemeral data are not supported in ARC."; | 99 VLOG(1) << "Users with ephemeral data are not supported in ARC."; |
92 return false; | 100 return false; |
93 } | 101 } |
94 | 102 |
103 // Do not allow newer version of ARC on old filesystem | |
104 if (base::SysInfo::IsRunningOnChromeOS()) { | |
hidehiko
2017/04/04 18:35:12
Could you add a bit more comment about IsRunningOn
kinaba
2017/04/05 02:35:28
Done.
| |
105 std::string arc_sdk_version; | |
106 if (!profile->GetPrefs()->GetBoolean( | |
hidehiko
2017/04/04 18:35:12
Could you comment the strategy here? We're making
kinaba
2017/04/05 02:35:26
Done.
| |
107 prefs::kArcCompatibleFilesystemChosen) && | |
108 (!base::SysInfo::GetLsbReleaseValue("CHROMEOS_ARC_ANDROID_SDK_VERSION", | |
109 &arc_sdk_version) || | |
Junichi Uekawa
2017/04/04 23:48:12
If CHROMEOS_ARC_ANDROID_SDK_VERSION is not there,
kinaba
2017/04/05 02:35:27
If Android isn't on the board at all, a check abov
| |
110 arc_sdk_version != "23")) { | |
Junichi Uekawa
2017/04/04 23:48:13
can you name this constant, like:
constexpr std::
kinaba
2017/04/05 02:35:27
Done.
| |
111 VLOG(1) << "Users postponed to migrate to dircrypto are not supported."; | |
hidehiko
2017/04/04 18:35:12
nit/optional: how about output arc_sdk_version her
kinaba
2017/04/05 02:35:28
Done.
| |
112 return false; | |
113 } | |
114 } | |
115 | |
95 return true; | 116 return true; |
96 } | 117 } |
97 | 118 |
98 void DisallowArcForTesting() { | 119 void DisallowArcForTesting() { |
99 g_disallow_for_testing = true; | 120 g_disallow_for_testing = true; |
100 } | 121 } |
101 | 122 |
102 bool IsArcPlayStoreEnabledForProfile(const Profile* profile) { | 123 bool IsArcPlayStoreEnabledForProfile(const Profile* profile) { |
103 return IsArcAllowedForProfile(profile) && | 124 return IsArcAllowedForProfile(profile) && |
104 profile->GetPrefs()->GetBoolean(prefs::kArcEnabled); | 125 profile->GetPrefs()->GetBoolean(prefs::kArcEnabled); |
(...skipping 29 matching lines...) Expand all Loading... | |
134 profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, enabled); | 155 profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, enabled); |
135 } | 156 } |
136 | 157 |
137 bool AreArcAllOptInPreferencesManagedForProfile(const Profile* profile) { | 158 bool AreArcAllOptInPreferencesManagedForProfile(const Profile* profile) { |
138 return profile->GetPrefs()->IsManagedPreference( | 159 return profile->GetPrefs()->IsManagedPreference( |
139 prefs::kArcBackupRestoreEnabled) && | 160 prefs::kArcBackupRestoreEnabled) && |
140 profile->GetPrefs()->IsManagedPreference( | 161 profile->GetPrefs()->IsManagedPreference( |
141 prefs::kArcLocationServiceEnabled); | 162 prefs::kArcLocationServiceEnabled); |
142 } | 163 } |
143 | 164 |
165 bool IsArcCompatibleFilesystem(const base::FilePath& path) { | |
166 base::ThreadRestrictions::AssertIOAllowed(); | |
167 | |
168 // If it can be verified it is not on ecryptfs, then it is ok. | |
169 struct statfs statfs_buf; | |
170 if (statfs(path.value().c_str(), &statfs_buf) < 0) | |
171 return false; | |
172 return statfs_buf.f_type != ECRYPTFS_SUPER_MAGIC; | |
173 } | |
174 | |
144 } // namespace arc | 175 } // namespace arc |
OLD | NEW |