Commit f52c0981 authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Update IsIncognitoProfile to return false for non-primary OTRs.

Profile::IsIncognitoProfile() currently returns true for incognito
profiles and also other non-Guest OTR profiles.

This behavior is updated so that it only returns true for incognito
profiles.

Bug: 1033903, 1074201
Change-Id: Ic2ce57b85a92534f0f6582c5c718b2947a899ff6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2124249Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772112}
parent 575f4bf7
...@@ -355,8 +355,7 @@ bool Profile::IsRegularProfile() const { ...@@ -355,8 +355,7 @@ bool Profile::IsRegularProfile() const {
} }
bool Profile::IsIncognitoProfile() const { bool Profile::IsIncognitoProfile() const {
// TODO(https://crbug.com/1033903): Update to exclude non-primary OTRs. return IsPrimaryOTRProfile() && !IsGuestSession();
return IsOffTheRecord() && !IsGuestSession();
} }
bool Profile::IsGuestSession() const { bool Profile::IsGuestSession() const {
...@@ -374,7 +373,7 @@ bool Profile::IsSystemProfile() const { ...@@ -374,7 +373,7 @@ bool Profile::IsSystemProfile() const {
return is_system_profile_; return is_system_profile_;
} }
bool Profile::IsPrimaryOTRProfile() { bool Profile::IsPrimaryOTRProfile() const {
return IsOffTheRecord() && GetOTRProfileID() == OTRProfileID::PrimaryID(); return IsOffTheRecord() && GetOTRProfileID() == OTRProfileID::PrimaryID();
} }
......
...@@ -401,21 +401,18 @@ class Profile : public content::BrowserContext { ...@@ -401,21 +401,18 @@ class Profile : public content::BrowserContext {
// IsRegularProfile() and IsIncognitoProfile() are mutually exclusive. // IsRegularProfile() and IsIncognitoProfile() are mutually exclusive.
// IsSystemProfile() implies that IsRegularProfile() is true. // IsSystemProfile() implies that IsRegularProfile() is true.
// IsOffTheRecord() is true for the off the record profile of incognito mode // IsOffTheRecord() is true for the off the record profile of incognito mode
// and guest sessions. // and guest sessions, and also non-primary OffTheRecord profiles.
// Returns whether it's a regular profile. // Returns whether it's a regular profile.
bool IsRegularProfile() const; bool IsRegularProfile() const;
// Returns whether it is an Incognito profile. An Incognito profile is an // Returns whether it is an Incognito profile. An Incognito profile is an
// off-the-record profile that is not a guest profile. // off-the-record profile that is used for incognito mode.
//
// TODO(https://crbug.com/1033903): Update to return false for non-primary
// OTRs and update documentation above.
bool IsIncognitoProfile() const; bool IsIncognitoProfile() const;
// Returns true if this is a primary OffTheRecord profile, which covers the // Returns true if this is a primary OffTheRecord profile, which covers the
// OffTheRecord profile used for incognito mode and guest sessions. // OffTheRecord profile used for incognito mode and guest sessions.
virtual bool IsPrimaryOTRProfile(); bool IsPrimaryOTRProfile() const;
// Returns whether it is a guest session. This covers both the guest profile // Returns whether it is a guest session. This covers both the guest profile
// and its parent. // and its parent.
......
...@@ -185,13 +185,11 @@ profile_metrics::BrowserProfileType ProfileMetrics::GetBrowserProfileType( ...@@ -185,13 +185,11 @@ profile_metrics::BrowserProfileType ProfileMetrics::GetBrowserProfileType(
if (profile->IsRegularProfile()) if (profile->IsRegularProfile())
return profile_metrics::BrowserProfileType::kRegular; return profile_metrics::BrowserProfileType::kRegular;
// TODO(https://crrev.com/1033903): To be updated after updating if (profile->IsIncognitoProfile())
// |IsIncognitoProfile| to return false for non-primary OTR profiles. return profile_metrics::BrowserProfileType::kIncognito;
if (profile->IsIncognitoProfile()) {
return profile->IsPrimaryOTRProfile() if (profile->IsOffTheRecord() && !profile->IsPrimaryOTRProfile())
? profile_metrics::BrowserProfileType::kIncognito return profile_metrics::BrowserProfileType::kOtherOffTheRecordProfile;
: profile_metrics::BrowserProfileType::kOtherOffTheRecordProfile;
}
NOTREACHED(); NOTREACHED();
return profile_metrics::BrowserProfileType::kMaxValue; return profile_metrics::BrowserProfileType::kMaxValue;
......
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