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

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

Issue 2885933003: arc: Consolidate IsArcAllowedForUser logic (Closed)
Patch Set: rebase 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) { 90 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) {
91 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability, 91 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability,
92 kAvailabilityOfficiallySupported); 92 kAvailabilityOfficiallySupported);
93 } 93 }
94 94
95 bool IsArcKioskMode() { 95 bool IsArcKioskMode() {
96 return user_manager::UserManager::IsInitialized() && 96 return user_manager::UserManager::IsInitialized() &&
97 user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp(); 97 user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp();
98 } 98 }
99 99
100 bool IsArcAllowedForUser(const user_manager::User* user) {
101 if (!user) {
102 VLOG(1) << "No ARC for nullptr user.";
103 return false;
104 }
105
106 if (!user->HasGaiaAccount() && !(user->IsActiveDirectoryUser() &&
107 IsArcAllowedForActiveDirectoryUsers())) {
108 VLOG(1) << "Users without GAIA or active directory users without support"
109 " are not supported in ARC.";
110 return false;
111 }
112
113 // Do not allow for ephemeral data user. cf) b/26402681
114 if (user_manager::UserManager::Get()->IsUserCryptohomeDataEphemeral(
115 user->GetAccountId())) {
116 VLOG(1) << "Users with ephemeral data are not supported in ARC.";
117 return false;
118 }
119
120 return true;
121 }
122
100 bool IsArcAllowedForActiveDirectoryUsers() { 123 bool IsArcAllowedForActiveDirectoryUsers() {
101 const auto* command_line = base::CommandLine::ForCurrentProcess(); 124 const auto* command_line = base::CommandLine::ForCurrentProcess();
102 125
103 if (!command_line->HasSwitch(chromeos::switches::kArcAvailability)) 126 if (!command_line->HasSwitch(chromeos::switches::kArcAvailability))
104 return false; 127 return false;
105 128
106 return command_line->GetSwitchValueASCII( 129 return command_line->GetSwitchValueASCII(
107 chromeos::switches::kArcAvailability) == 130 chromeos::switches::kArcAvailability) ==
108 kAvailabilityOfficiallySupportedWithActiveDirectory; 131 kAvailabilityOfficiallySupportedWithActiveDirectory;
109 } 132 }
110 133
111 bool IsArcOptInVerificationDisabled() { 134 bool IsArcOptInVerificationDisabled() {
112 const auto* command_line = base::CommandLine::ForCurrentProcess(); 135 const auto* command_line = base::CommandLine::ForCurrentProcess();
113 return command_line->HasSwitch( 136 return command_line->HasSwitch(
114 chromeos::switches::kDisableArcOptInVerification); 137 chromeos::switches::kDisableArcOptInVerification);
115 } 138 }
116 139
117 bool IsArcAppWindow(aura::Window* window) { 140 bool IsArcAppWindow(aura::Window* window) {
118 if (!window) 141 if (!window)
119 return false; 142 return false;
120 return window->GetProperty(aura::client::kAppType) == 143 return window->GetProperty(aura::client::kAppType) ==
121 static_cast<int>(ash::AppType::ARC_APP); 144 static_cast<int>(ash::AppType::ARC_APP);
122 } 145 }
123 146
124 } // namespace arc 147 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698