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

Side by Side Diff: chrome/browser/profiles/profiles_state.cc

Issue 2325643003: Disables user manager actions only if there is at least one regular profile and they're all locked. (Closed)
Patch Set: Addressed comment Created 4 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/profiles/profiles_state.h" 5 #include "chrome/browser/profiles/profiles_state.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // We should never be saving the System Profile as the last one used since it 249 // We should never be saving the System Profile as the last one used since it
250 // shouldn't have a browser. 250 // shouldn't have a browser.
251 if (profile_dir == base::FilePath(chrome::kSystemProfileDir).AsUTF8Unsafe()) 251 if (profile_dir == base::FilePath(chrome::kSystemProfileDir).AsUTF8Unsafe())
252 return; 252 return;
253 253
254 PrefService* local_state = g_browser_process->local_state(); 254 PrefService* local_state = g_browser_process->local_state();
255 DCHECK(local_state); 255 DCHECK(local_state);
256 local_state->SetString(prefs::kProfileLastUsed, profile_dir); 256 local_state->SetString(prefs::kProfileLastUsed, profile_dir);
257 } 257 }
258 258
259 bool AreAllProfilesLocked() { 259 bool AreAllNonChildNonSupervisedProfilesLocked() {
260 bool all_profiles_locked = true; 260 bool at_least_one_regular_profile_present = false;
261 261
262 std::vector<ProfileAttributesEntry*> entries = 262 std::vector<ProfileAttributesEntry*> entries =
263 g_browser_process->profile_manager()->GetProfileAttributesStorage(). 263 g_browser_process->profile_manager()->GetProfileAttributesStorage().
264 GetAllProfilesAttributes(); 264 GetAllProfilesAttributes();
265 for (const ProfileAttributesEntry* entry : entries) { 265 for (const ProfileAttributesEntry* entry : entries) {
266 if (entry->IsOmitted()) 266 if (entry->IsOmitted())
267 continue; 267 continue;
268 268
269 // Supervised and Child profiles cannot be locked. 269 // Only consider non-child and non-supervised profiles.
270 if (!entry->IsSigninRequired() && 270 if (!entry->IsChild() && !entry->IsLegacySupervised()) {
271 !entry->IsChild() && 271 at_least_one_regular_profile_present = true;
272 !entry->IsLegacySupervised()) { 272
273 return false; 273 if (!entry->IsSigninRequired())
274 return false;
274 } 275 }
275 } 276 }
276 return all_profiles_locked; 277 return at_least_one_regular_profile_present;
277 } 278 }
278 279
279 } // namespace profiles 280 } // namespace profiles
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profiles_state.h ('k') | chrome/browser/ui/webui/signin/user_manager_screen_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698