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

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

Issue 2642783003: Move more utility functions to arc_util. (Closed)
Patch Set: address comments Created 3 years, 11 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_util.h ('k') | chrome/browser/chromeos/arc/arc_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/arc/arc_util.cc
diff --git a/chrome/browser/chromeos/arc/arc_util.cc b/chrome/browser/chromeos/arc/arc_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5a0eef24cd9d1bef5d8c7d1f3405ba2a1ddfe4b8
--- /dev/null
+++ b/chrome/browser/chromeos/arc/arc_util.cc
@@ -0,0 +1,91 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/arc/arc_util.h"
+
+#include "base/logging.h"
+#include "chrome/browser/chromeos/login/user_flow.h"
+#include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/profiles/profile.h"
+#include "components/arc/arc_util.h"
+#include "components/user_manager/user.h"
+#include "components/user_manager/user_manager.h"
+
+namespace arc {
+
+namespace {
+
+// Let IsAllowedForProfile() return "false" for any profile.
+bool g_disallow_for_testing = false;
+
+} // namespace
+
+bool IsArcAllowedForProfile(const Profile* profile) {
+ if (g_disallow_for_testing) {
+ VLOG(1) << "ARC is disallowed for testing.";
+ return false;
+ }
+
+ if (!IsArcAvailable()) {
+ VLOG(1) << "ARC is not available.";
+ return false;
+ }
+
+ if (!profile) {
+ VLOG(1) << "ARC is not supported for systems without profile.";
+ return false;
+ }
+
+ if (!chromeos::ProfileHelper::IsPrimaryProfile(profile)) {
+ VLOG(1) << "Non-primary users are not supported in ARC.";
+ return false;
+ }
+
+ // IsPrimaryProfile can return true for an incognito profile corresponding
+ // to the primary profile, but ARC does not support it.
+ if (profile->IsOffTheRecord()) {
+ VLOG(1) << "Incognito profile is not supported in ARC.";
+ return false;
+ }
+
+ if (profile->IsLegacySupervised()) {
+ VLOG(1) << "Supervised users are not supported in ARC.";
+ return false;
+ }
+
+ // Do not allow for public session. Communicating with Play Store requires
+ // GAIA account. An exception is Kiosk mode, which uses different application
+ // install mechanism. cf) crbug.com/605545
+ const user_manager::User* user =
+ chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
+ if ((!user || !user->HasGaiaAccount()) && !IsArcKioskMode()) {
+ VLOG(1) << "Users without GAIA accounts are not supported in ARC.";
+ return false;
+ }
+
+ // Do not run ARC instance when supervised user is being created.
+ // Otherwise noisy notification may be displayed.
+ chromeos::UserFlow* user_flow =
+ chromeos::ChromeUserManager::Get()->GetUserFlow(user->GetAccountId());
+ if (!user_flow || !user_flow->CanStartArc()) {
+ VLOG(1) << "ARC is not allowed in the current user flow.";
+ return false;
+ }
+
+ // Do not allow for Ephemeral data user. cf) b/26402681
+ if (user_manager::UserManager::Get()
+ ->IsCurrentUserCryptohomeDataEphemeral()) {
+ VLOG(1) << "Users with ephemeral data are not supported in ARC.";
+ return false;
+ }
+
+ return true;
+}
+
+void DisallowArcForTesting() {
+ g_disallow_for_testing = true;
+}
+
+} // namespace arc
« no previous file with comments | « chrome/browser/chromeos/arc/arc_util.h ('k') | chrome/browser/chromeos/arc/arc_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698