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

Side by Side Diff: chrome/browser/prefs/session_startup_pref.cc

Issue 2927853002: Force guest profiles to return default startup prefs. (Closed)
Patch Set: Force guest profiles to return default startup prefs. Created 3 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/prefs/session_startup_pref.h" 5 #include "chrome/browser/prefs/session_startup_pref.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 for (size_t i = 0; i < pref.urls.size(); ++i) { 92 for (size_t i = 0; i < pref.urls.size(); ++i) {
93 url_pref_list->Set(static_cast<int>(i), 93 url_pref_list->Set(static_cast<int>(i),
94 base::MakeUnique<base::Value>(pref.urls[i].spec())); 94 base::MakeUnique<base::Value>(pref.urls[i].spec()));
95 } 95 }
96 } 96 }
97 } 97 }
98 98
99 // static 99 // static
100 SessionStartupPref SessionStartupPref::GetStartupPref(Profile* profile) { 100 SessionStartupPref SessionStartupPref::GetStartupPref(Profile* profile) {
101 DCHECK(profile); 101 DCHECK(profile);
102 return GetStartupPref(profile->GetPrefs()); 102
103 PrefService* prefs = profile->GetPrefs();
104
105 // If a guest profile, force a return of the DEFAULT startup prefs. See
sky 2017/06/20 16:45:27 When writing comments strive for comments that cla
shrike 2017/06/20 18:01:17 Acknowledged.
106 // https://crbug.com/723414 .
107 if (profile->IsGuestSession()) {
108 DCHECK(prefs);
109 prefs->SetInteger(prefs::kRestoreOnStartup,
sky 2017/06/20 16:45:27 Is it really necessary to modify the prefs here? I
shrike 2017/06/20 18:01:17 I was concerned about not changing the original co
110 TypeToPrefValue(SessionStartupPref::DEFAULT));
111 }
112
113 return GetStartupPref(prefs);
103 } 114 }
104 115
105 // static 116 // static
106 SessionStartupPref SessionStartupPref::GetStartupPref(PrefService* prefs) { 117 SessionStartupPref SessionStartupPref::GetStartupPref(PrefService* prefs) {
107 DCHECK(prefs); 118 DCHECK(prefs);
108 119
109 SessionStartupPref pref( 120 SessionStartupPref pref(
110 PrefValueToType(prefs->GetInteger(prefs::kRestoreOnStartup))); 121 PrefValueToType(prefs->GetInteger(prefs::kRestoreOnStartup)));
111 122
112 // Always load the urls, even if the pref type isn't URLS. This way the 123 // Always load the urls, even if the pref type isn't URLS. This way the
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 default: return SessionStartupPref::DEFAULT; 164 default: return SessionStartupPref::DEFAULT;
154 } 165 }
155 } 166 }
156 167
157 SessionStartupPref::SessionStartupPref(Type type) : type(type) {} 168 SessionStartupPref::SessionStartupPref(Type type) : type(type) {}
158 169
159 SessionStartupPref::SessionStartupPref(const SessionStartupPref& other) = 170 SessionStartupPref::SessionStartupPref(const SessionStartupPref& other) =
160 default; 171 default;
161 172
162 SessionStartupPref::~SessionStartupPref() {} 173 SessionStartupPref::~SessionStartupPref() {}
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698