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

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

Issue 2642783003: Move more utility functions to arc_util. (Closed)
Patch Set: address review 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
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..8efffac90575c795a138492f3e64721fea880375
--- /dev/null
+++ b/chrome/browser/chromeos/arc/arc_util.cc
@@ -0,0 +1,89 @@
+// 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;
+ }
+
+ // TODO(hidehiko): Comment what situation this condition wants to support.
Yusuke Sato 2017/01/24 20:36:59 Then, probably TODO(hidehiko|xxx) would be better.
hidehiko 2017/01/31 13:07:51 Finding original author means I need to go deeper
+ 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;
+ }
+
+ // TODO(hidehiko): Comment what situation this condition wants to support.
Yusuke Sato 2017/01/24 20:36:59 same
hidehiko 2017/01/31 13:07:51 Done.
+ 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

Powered by Google App Engine
This is Rietveld 408576698