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

Side by Side Diff: chrome/browser/chromeos/login/users/affiliation.cc

Issue 2545523003: As YAPS server does not handle affiliation_ids correctly yet, we need to have a flag that would al… (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | components/policy/core/common/policy_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/login/users/affiliation.h" 5 #include "chrome/browser/chromeos/login/users/affiliation.h"
6 6
7 #include "base/command_line.h"
7 #include "chrome/browser/chromeos/policy/device_local_account.h" 8 #include "chrome/browser/chromeos/policy/device_local_account.h"
9 #include "components/policy/core/common/policy_switches.h"
8 #include "google_apis/gaia/gaia_auth_util.h" 10 #include "google_apis/gaia/gaia_auth_util.h"
9 11
10 namespace chromeos { 12 namespace chromeos {
11 13
12 bool HaveCommonElement(const std::set<std::string>& set1, 14 bool HaveCommonElement(const std::set<std::string>& set1,
13 const std::set<std::string>& set2) { 15 const std::set<std::string>& set2) {
14 std::set<std::string>::const_iterator it1 = set1.begin(); 16 std::set<std::string>::const_iterator it1 = set1.begin();
15 std::set<std::string>::const_iterator it2 = set2.begin(); 17 std::set<std::string>::const_iterator it2 = set2.begin();
16 18
17 while (it1 != set1.end() && it2 != set2.end()) { 19 while (it1 != set1.end() && it2 != set2.end()) {
18 if (*it1 == *it2) 20 if (*it1 == *it2)
19 return true; 21 return true;
20 if (*it1 < *it2) { 22 if (*it1 < *it2) {
21 ++it1; 23 ++it1;
22 } else { 24 } else {
23 ++it2; 25 ++it2;
24 } 26 }
25 } 27 }
26 return false; 28 return false;
27 } 29 }
28 30
29 bool IsUserAffiliated(const AffiliationIDSet& user_affiliation_ids, 31 bool IsUserAffiliated(const AffiliationIDSet& user_affiliation_ids,
30 const AffiliationIDSet& device_affiliation_ids, 32 const AffiliationIDSet& device_affiliation_ids,
31 const std::string& email) { 33 const std::string& email) {
32 // An empty username means incognito user in case of Chrome OS and no 34 // An empty username means incognito user in case of Chrome OS and no
33 // logged-in user in case of Chrome (SigninService). Many tests use nonsense 35 // logged-in user in case of Chrome (SigninService). Many tests use nonsense
34 // email addresses (e.g. 'test') so treat those as non-enterprise users. 36 // email addresses (e.g. 'test') so treat those as non-enterprise users.
35 if (email.empty() || email.find('@') == std::string::npos) { 37 if (email.empty() || email.find('@') == std::string::npos) {
Andrew T Wilson (Slow) 2016/12/01 09:35:39 Note that guests will not appear to be affiliated
36 return false; 38 return false;
37 } 39 }
38 40
39 if (policy::IsDeviceLocalAccountUser(email, NULL)) { 41 if (policy::IsDeviceLocalAccountUser(email, NULL)) {
40 return true; 42 return true;
41 } 43 }
42 44
45 // Not all test servers correctly support affiliation ids so far, so
Andrew T Wilson (Slow) 2016/12/01 09:35:39 complete comment.
46 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
47 if (command_line->HasSwitch(policy::switches::kUserAlwaysAffiliated)) {
48 return true;
49 }
50
43 if (!device_affiliation_ids.empty() && !user_affiliation_ids.empty()) { 51 if (!device_affiliation_ids.empty() && !user_affiliation_ids.empty()) {
44 return HaveCommonElement(user_affiliation_ids, device_affiliation_ids); 52 return HaveCommonElement(user_affiliation_ids, device_affiliation_ids);
45 } 53 }
46 54
47 return false; 55 return false;
48 } 56 }
49 57
50 } // namespace chromeos 58 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | components/policy/core/common/policy_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698