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

Unified Diff: chrome/browser/profiles/profile_manager.cc

Issue 1129293002: Fix the System Profile with extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: msw comments Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profiles/profile_manager.cc
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index e8771db996830e14e3f794af7adc9c9872afe918..3fed01653e66ab8d63b72125c372f5e53f61c022 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -304,6 +304,7 @@ Profile* ProfileManager::GetLastUsedProfile() {
Profile* ProfileManager::GetLastUsedProfileAllowedByPolicy() {
Profile* profile = GetLastUsedProfile();
if (profile->IsGuestSession() ||
+ profile->IsSystemProfile() ||
IncognitoModePrefs::GetAvailability(profile->GetPrefs()) ==
IncognitoModePrefs::FORCED) {
return profile->GetOffTheRecordProfile();
@@ -437,8 +438,10 @@ void ProfileManager::CreateProfileAsync(
if (iter != profiles_info_.end() && info->created) {
Profile* profile = info->profile.get();
// If this was the guest profile, apply settings and go OffTheRecord.
- if (profile->GetPath() == ProfileManager::GetGuestProfilePath()) {
- SetGuestProfilePrefs(profile);
+ // System Profile also needs characteristics of being off the record, such
msw 2015/05/21 17:48:12 nit: I think this should be "The system profile",
Mike Lerman 2015/05/21 19:24:33 Done.
+ // as having no extensions, not writing to disk, etc.
+ if (profile->IsGuestSession() || profile->IsSystemProfile()) {
+ SetNonPersonalProfilePrefs(profile);
profile = profile->GetOffTheRecordProfile();
}
// Profile has already been created. Run callback immediately.
@@ -1002,9 +1005,10 @@ void ProfileManager::OnProfileCreated(Profile* profile,
}
if (profile) {
- // If this was the guest profile, finish setting its special status.
- if (profile->GetPath() == ProfileManager::GetGuestProfilePath())
- SetGuestProfilePrefs(profile);
+ // If this was the guest or system profile, finish setting its special
+ // status.
+ if (profile->IsGuestSession() || profile->IsSystemProfile())
+ SetNonPersonalProfilePrefs(profile);
// Invoke CREATED callback for incognito profiles.
if (go_off_the_record)
@@ -1323,16 +1327,12 @@ void ProfileManager::AddProfileToCache(Profile* profile) {
}
}
-void ProfileManager::SetGuestProfilePrefs(Profile* profile) {
+void ProfileManager::SetNonPersonalProfilePrefs(Profile* profile) {
PrefService* prefs = profile->GetPrefs();
prefs->SetBoolean(prefs::kSigninAllowed, false);
prefs->SetBoolean(bookmarks::prefs::kEditBookmarksEnabled, false);
prefs->SetBoolean(bookmarks::prefs::kShowBookmarkBar, false);
prefs->ClearPref(DefaultSearchManager::kDefaultSearchProviderDataPrefName);
- // This can be removed in the future but needs to be present through
- // a release (or two) so that any existing installs get switched to
- // the new state and away from the previous "forced" state.
- IncognitoModePrefs::SetAvailability(prefs, IncognitoModePrefs::ENABLED);
}
bool ProfileManager::ShouldGoOffTheRecord(Profile* profile) {
@@ -1341,7 +1341,7 @@ bool ProfileManager::ShouldGoOffTheRecord(Profile* profile) {
return true;
}
#endif
- return profile->IsGuestSession();
+ return profile->IsGuestSession() || profile->IsSystemProfile();
}
void ProfileManager::RunCallbacks(const std::vector<CreateCallback>& callbacks,
@@ -1367,7 +1367,9 @@ void ProfileManager::UpdateLastUser(Profile* last_active) {
PrefService* local_state = g_browser_process->local_state();
DCHECK(local_state);
// Only keep track of profiles that we are managing; tests may create others.
- if (profiles_info_.find(last_active->GetPath()) != profiles_info_.end()) {
+ // Also never consider the SystemProfile as "active".
+ if (profiles_info_.find(last_active->GetPath()) != profiles_info_.end() &&
+ !last_active->IsSystemProfile()) {
std::string profile_path_base =
last_active->GetPath().BaseName().MaybeAsASCII();
if (profile_path_base != GetLastUsedProfileName())

Powered by Google App Engine
This is Rietveld 408576698