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

Unified Diff: chrome/browser/sessions/session_restore.cc

Issue 2927853002: Force guest profiles to return default startup prefs. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sessions/session_restore.cc
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc
index 49b446873dcf51153daf3469ba46dd8e84370b6c..be9816dea967feb064c9769c1cb79ed777741728 100644
--- a/chrome/browser/sessions/session_restore.cc
+++ b/chrome/browser/sessions/session_restore.cc
@@ -86,6 +86,12 @@ bool HasSingleNewTabPage(Browser* browser) {
search::IsInstantNTP(active_tab);
}
+Profile* SafeProfileForNewWindows(Profile* profile) {
+ // Guest sessions must always be OffTheRecord when opening windows.
+ return profile->IsGuestSession() ? profile->GetOffTheRecordProfile()
sky 2017/06/07 19:21:40 I'm a little confused by this, and forgive me beca
shrike 2017/06/07 20:19:05 Gosh, I wish could even start to comment. I know n
+ : profile;
+}
+
class SessionRestoreImpl;
// Pointers to SessionRestoreImpls which are currently restoring the session.
@@ -214,7 +220,8 @@ class SessionRestoreImpl : public content::NotificationObserver {
bool use_new_window = disposition == WindowOpenDisposition::NEW_WINDOW;
Browser* browser = use_new_window
- ? new Browser(Browser::CreateParams(profile_, true))
+ ? new Browser(Browser::CreateParams(
+ SafeProfileForNewWindows(profile_), true))
: browser_;
RecordAppLaunchForTab(browser, tab, selected_index);
@@ -292,7 +299,8 @@ class SessionRestoreImpl : public content::NotificationObserver {
std::vector<RestoredTab>* contents_created) {
Browser* browser = nullptr;
if (!created_tabbed_browser && always_create_tabbed_browser_) {
- browser = new Browser(Browser::CreateParams(profile_, false));
+ browser = new Browser(
+ Browser::CreateParams(SafeProfileForNewWindows(profile_), false));
if (urls_to_open_.empty()) {
// No tab browsers were created and no URLs were supplied on the command
// line. Open the new tab page.
@@ -629,11 +637,12 @@ class SessionRestoreImpl : public content::NotificationObserver {
const std::string& workspace,
ui::WindowShowState show_state,
const std::string& app_name) {
- Browser::CreateParams params(type, profile_, false);
+ Profile* profile = SafeProfileForNewWindows(profile_);
+ Browser::CreateParams params(type, profile, false);
if (!app_name.empty()) {
const bool trusted_source = true; // We only store trusted app windows.
params = Browser::CreateParams::CreateForApp(app_name, trusted_source,
- bounds, profile_, false);
+ bounds, profile, false);
} else {
params.initial_bounds = bounds;
}
« 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