Commit 3254af5e authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Set guest mode correctly for incognito profiles.

A service factory may check the guest/incognito bits to determine which
context to use.  If these bits aren't set correctly before the various
context-keyed services are created, the result could be the wrong
service, no service, etc.

Without this, apps::LaunchServiceFactory cannot be registered properly
on startup.  (Fixing that will happen separately.)

Bug: none
Change-Id: I75d545066e382a10ff3b5f7aff2db59fa7a6e4c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135204
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756310}
parent b91ac240
......@@ -40,7 +40,6 @@
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/prefs/pref_service_syncable_util.h"
#include "chrome/browser/profiles/profile_key.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ssl/stateful_ssl_host_state_delegate_factory.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/transition_manager/full_browser_transition_manager.h"
......@@ -146,12 +145,13 @@ OffTheRecordProfileImpl::OffTheRecordProfileImpl(
void OffTheRecordProfileImpl::Init() {
FullBrowserTransitionManager::Get()->OnProfileCreated(this);
// Must be done before CreateBrowserContextServices(), since some of them
// change behavior based on whether the provided context is a guest session.
set_is_guest_profile(profile_->IsGuestSession());
BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices(
this);
set_is_guest_profile(
profile_->GetPath() == ProfileManager::GetGuestProfilePath());
// Always crash when incognito is not available.
// Guest profiles may always be OTR. Check IncognitoModePrefs otherwise.
CHECK(profile_->IsGuestSession() || profile_->IsSystemProfile() ||
......
......@@ -778,8 +778,12 @@ Profile* TestingProfile::GetOffTheRecordProfile(
DCHECK(otr_profile_id == OTRProfileID::PrimaryID());
if (IsOffTheRecord())
return this;
if (!incognito_profile_)
TestingProfile::Builder().BuildIncognito(this);
if (!incognito_profile_) {
TestingProfile::Builder builder;
if (IsGuestSession())
builder.SetGuestSession();
builder.BuildIncognito(this);
}
return incognito_profile_.get();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment