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

Side by Side Diff: components/arc/arc_util.cc

Issue 2885933003: arc: Consolidate IsArcAllowedForUser logic (Closed)
Patch Set: rebase & address #4 comments Created 3 years, 7 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 unified diff | Download patch
OLDNEW
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 "components/arc/arc_util.h" 5 #include "components/arc/arc_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "ash/shared/app_types.h" 9 #include "ash/shared/app_types.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) { 85 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) {
86 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability, 86 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability,
87 kAvailabilityOfficiallySupported); 87 kAvailabilityOfficiallySupported);
88 } 88 }
89 89
90 bool IsArcKioskMode() { 90 bool IsArcKioskMode() {
91 return user_manager::UserManager::IsInitialized() && 91 return user_manager::UserManager::IsInitialized() &&
92 user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp(); 92 user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp();
93 } 93 }
94 94
95 bool IsArcAllowedForUser(const user_manager::User* user) {
96 if (!user) {
97 VLOG(1) << "No ARC for nullptr user.";
98 return false;
99 }
100
101 if (!user->HasGaiaAccount() && !user->IsActiveDirectoryUser() &&
102 user->GetType() != user_manager::USER_TYPE_ARC_KIOSK_APP) {
hidehiko 2017/05/23 07:23:26 Could you comment that this check is compatible wi
xiyuan 2017/05/24 19:22:56 Done.
103 VLOG(1) << "Users without GAIA or AD accounts, or not ARC kiosk apps are "
104 "not supported in ARC.";
105 return false;
106 }
107
108 // Do not allow for ephemeral data user. cf) b/26402681
109 if (user_manager::UserManager::Get()->IsUserCryptohomeDataEphemeral(
110 user->GetAccountId())) {
111 VLOG(1) << "Users with ephemeral data are not supported in ARC.";
112 return false;
113 }
114
115 return true;
116 }
117
95 bool IsArcOptInVerificationDisabled() { 118 bool IsArcOptInVerificationDisabled() {
96 const auto* command_line = base::CommandLine::ForCurrentProcess(); 119 const auto* command_line = base::CommandLine::ForCurrentProcess();
97 return command_line->HasSwitch( 120 return command_line->HasSwitch(
98 chromeos::switches::kDisableArcOptInVerification); 121 chromeos::switches::kDisableArcOptInVerification);
99 } 122 }
100 123
101 bool IsArcAppWindow(aura::Window* window) { 124 bool IsArcAppWindow(aura::Window* window) {
102 if (!window) 125 if (!window)
103 return false; 126 return false;
104 return window->GetProperty(aura::client::kAppType) == 127 return window->GetProperty(aura::client::kAppType) ==
105 static_cast<int>(ash::AppType::ARC_APP); 128 static_cast<int>(ash::AppType::ARC_APP);
106 } 129 }
107 130
108 } // namespace arc 131 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698