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

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

Issue 2927853002: Force guest profiles to return default startup prefs. (Closed)
Patch Set: Fix error. 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 // Guest sessions should not store any state, therefore they should never
104 // trigger a restore during startup.
105 return profile->IsGuestSession()
106 ? SessionStartupPref(SessionStartupPref::DEFAULT)
107 : GetStartupPref(profile->GetPrefs());
103 } 108 }
104 109
105 // static 110 // static
106 SessionStartupPref SessionStartupPref::GetStartupPref(PrefService* prefs) { 111 SessionStartupPref SessionStartupPref::GetStartupPref(PrefService* prefs) {
107 DCHECK(prefs); 112 DCHECK(prefs);
108 113
109 SessionStartupPref pref( 114 SessionStartupPref pref(
110 PrefValueToType(prefs->GetInteger(prefs::kRestoreOnStartup))); 115 PrefValueToType(prefs->GetInteger(prefs::kRestoreOnStartup)));
111 116
112 // Always load the urls, even if the pref type isn't URLS. This way the 117 // 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; 158 default: return SessionStartupPref::DEFAULT;
154 } 159 }
155 } 160 }
156 161
157 SessionStartupPref::SessionStartupPref(Type type) : type(type) {} 162 SessionStartupPref::SessionStartupPref(Type type) : type(type) {}
158 163
159 SessionStartupPref::SessionStartupPref(const SessionStartupPref& other) = 164 SessionStartupPref::SessionStartupPref(const SessionStartupPref& other) =
160 default; 165 default;
161 166
162 SessionStartupPref::~SessionStartupPref() {} 167 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